mirror of https://github.com/m2049r/xmrwallet.git
create wallet only by button & refactoring (#793)
This commit is contained in:
parent
506e6ce017
commit
27885f2c86
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.m2049r.xmrwallet;
|
package com.m2049r.xmrwallet;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -56,6 +58,7 @@ import com.m2049r.xmrwallet.widget.Toolbar;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
@ -120,134 +123,96 @@ public class GenerateFragment extends Fragment {
|
||||||
etWalletViewKey.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etWalletViewKey.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
etWalletSpendKey.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
etWalletSpendKey.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||||
|
|
||||||
etWalletName.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
etWalletName.getEditText().setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
@Override
|
if (!hasFocus) {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
checkName();
|
||||||
if (!hasFocus) {
|
|
||||||
checkName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clearErrorOnTextEntry(etWalletName);
|
clearErrorOnTextEntry(etWalletName);
|
||||||
|
|
||||||
etWalletMnemonic.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
etWalletMnemonic.getEditText().setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
@Override
|
if (!hasFocus) {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
checkMnemonic();
|
||||||
if (!hasFocus) {
|
|
||||||
checkMnemonic();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clearErrorOnTextEntry(etWalletMnemonic);
|
clearErrorOnTextEntry(etWalletMnemonic);
|
||||||
|
|
||||||
etWalletAddress.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
etWalletAddress.getEditText().setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
@Override
|
if (!hasFocus) {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
checkAddress();
|
||||||
if (!hasFocus) {
|
|
||||||
checkAddress();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clearErrorOnTextEntry(etWalletAddress);
|
clearErrorOnTextEntry(etWalletAddress);
|
||||||
|
|
||||||
etWalletViewKey.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
etWalletViewKey.getEditText().setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
@Override
|
if (!hasFocus) {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
checkViewKey();
|
||||||
if (!hasFocus) {
|
|
||||||
checkViewKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clearErrorOnTextEntry(etWalletViewKey);
|
clearErrorOnTextEntry(etWalletViewKey);
|
||||||
|
|
||||||
etWalletSpendKey.getEditText().setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
etWalletSpendKey.getEditText().setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
@Override
|
if (!hasFocus) {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
checkSpendKey();
|
||||||
if (!hasFocus) {
|
|
||||||
checkSpendKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
clearErrorOnTextEntry(etWalletSpendKey);
|
clearErrorOnTextEntry(etWalletSpendKey);
|
||||||
|
|
||||||
Helper.showKeyboard(getActivity());
|
Helper.showKeyboard(requireActivity());
|
||||||
|
|
||||||
etWalletName.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletName.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if (checkName()) {
|
||||||
if (checkName()) {
|
etWalletPassword.requestFocus();
|
||||||
etWalletPassword.requestFocus();
|
} // otherwise ignore
|
||||||
} // otherwise ignore
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (FingerprintHelper.isDeviceSupported(getContext())) {
|
if (FingerprintHelper.isDeviceSupported(getContext())) {
|
||||||
llFingerprintAuth.setVisibility(View.VISIBLE);
|
llFingerprintAuth.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
final SwitchMaterial swFingerprintAllowed = (SwitchMaterial) llFingerprintAuth.getChildAt(0);
|
final SwitchMaterial swFingerprintAllowed = (SwitchMaterial) llFingerprintAuth.getChildAt(0);
|
||||||
swFingerprintAllowed.setOnClickListener(new View.OnClickListener() {
|
swFingerprintAllowed.setOnClickListener(view1 -> {
|
||||||
@Override
|
if (!swFingerprintAllowed.isChecked()) return;
|
||||||
public void onClick(View view) {
|
|
||||||
if (!swFingerprintAllowed.isChecked()) return;
|
|
||||||
|
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity());
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity());
|
||||||
builder.setMessage(Html.fromHtml(getString(R.string.generate_fingerprint_warn)))
|
builder.setMessage(Html.fromHtml(getString(R.string.generate_fingerprint_warn)))
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton(getString(R.string.label_ok), null)
|
.setPositiveButton(getString(R.string.label_ok), null)
|
||||||
.setNegativeButton(getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
|
.setNegativeButton(getString(R.string.label_cancel), (dialogInterface, i) -> swFingerprintAllowed.setChecked(false))
|
||||||
@Override
|
.show();
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
swFingerprintAllowed.setChecked(false);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals(TYPE_NEW)) {
|
switch (type) {
|
||||||
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
case TYPE_NEW:
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_UNSPECIFIED);
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
break;
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
case TYPE_LEDGER:
|
||||||
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||||
Helper.hideKeyboard(getActivity());
|
etWalletPassword.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
generateWallet();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (type.equals(TYPE_LEDGER)) {
|
|
||||||
etWalletPassword.getEditText().setImeOptions(EditorInfo.IME_ACTION_DONE);
|
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
||||||
etWalletRestoreHeight.requestFocus();
|
etWalletRestoreHeight.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
break;
|
||||||
} else if (type.equals(TYPE_SEED)) {
|
case TYPE_SEED:
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletPassword.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
etWalletMnemonic.requestFocus();
|
etWalletMnemonic.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
etWalletMnemonic.setVisibility(View.VISIBLE);
|
||||||
etWalletMnemonic.setVisibility(View.VISIBLE);
|
etWalletMnemonic.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
etWalletMnemonic.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkMnemonic()) {
|
if (checkMnemonic()) {
|
||||||
|
@ -256,22 +221,20 @@ public class GenerateFragment extends Fragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
break;
|
||||||
} else if (type.equals(TYPE_KEY) || type.equals(TYPE_VIEWONLY)) {
|
case TYPE_KEY:
|
||||||
etWalletPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
case TYPE_VIEWONLY:
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
etWalletPassword.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
etWalletAddress.requestFocus();
|
etWalletAddress.requestFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
etWalletAddress.setVisibility(View.VISIBLE);
|
||||||
etWalletAddress.setVisibility(View.VISIBLE);
|
etWalletAddress.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
etWalletAddress.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkAddress()) {
|
if (checkAddress()) {
|
||||||
|
@ -280,11 +243,9 @@ public class GenerateFragment extends Fragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
etWalletViewKey.setVisibility(View.VISIBLE);
|
||||||
etWalletViewKey.setVisibility(View.VISIBLE);
|
etWalletViewKey.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
etWalletViewKey.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
if (checkViewKey()) {
|
if (checkViewKey()) {
|
||||||
|
@ -297,44 +258,29 @@ public class GenerateFragment extends Fragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
});
|
||||||
});
|
break;
|
||||||
}
|
}
|
||||||
if (type.equals(TYPE_KEY)) {
|
if (type.equals(TYPE_KEY)) {
|
||||||
etWalletSpendKey.setVisibility(View.VISIBLE);
|
etWalletSpendKey.setVisibility(View.VISIBLE);
|
||||||
etWalletSpendKey.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletSpendKey.getEditText().setOnEditorActionListener((v, actionId, event) -> {
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
||||||
|| (actionId == EditorInfo.IME_ACTION_NEXT)) {
|
if (checkSpendKey()) {
|
||||||
if (checkSpendKey()) {
|
etWalletRestoreHeight.requestFocus();
|
||||||
etWalletRestoreHeight.requestFocus();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!type.equals(TYPE_NEW)) {
|
if (!type.equals(TYPE_NEW)) {
|
||||||
etWalletRestoreHeight.setVisibility(View.VISIBLE);
|
etWalletRestoreHeight.setVisibility(View.VISIBLE);
|
||||||
etWalletRestoreHeight.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
etWalletRestoreHeight.getEditText().setImeOptions(EditorInfo.IME_ACTION_UNSPECIFIED);
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|
|
||||||
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
|
|
||||||
Helper.hideKeyboard(getActivity());
|
|
||||||
generateWallet();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
bGenerate.setOnClickListener(new View.OnClickListener() {
|
bGenerate.setOnClickListener(v -> {
|
||||||
@Override
|
Helper.hideKeyboard(getActivity());
|
||||||
public void onClick(View v) {
|
generateWallet();
|
||||||
Helper.hideKeyboard(getActivity());
|
|
||||||
generateWallet();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
etWalletName.requestFocus();
|
etWalletName.requestFocus();
|
||||||
|
@ -387,7 +333,7 @@ public class GenerateFragment extends Fragment {
|
||||||
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
parser.setLenient(false);
|
parser.setLenient(false);
|
||||||
height = RestoreHeight.getInstance().getHeight(parser.parse(restoreHeight));
|
height = RestoreHeight.getInstance().getHeight(parser.parse(restoreHeight));
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ignored) {
|
||||||
}
|
}
|
||||||
if ((height < 0) && (restoreHeight.length() == 8))
|
if ((height < 0) && (restoreHeight.length() == 8))
|
||||||
try {
|
try {
|
||||||
|
@ -395,7 +341,7 @@ public class GenerateFragment extends Fragment {
|
||||||
SimpleDateFormat parser = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat parser = new SimpleDateFormat("yyyyMMdd");
|
||||||
parser.setLenient(false);
|
parser.setLenient(false);
|
||||||
height = RestoreHeight.getInstance().getHeight(parser.parse(restoreHeight));
|
height = RestoreHeight.getInstance().getHeight(parser.parse(restoreHeight));
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ignored) {
|
||||||
}
|
}
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
try {
|
try {
|
||||||
|
@ -466,40 +412,46 @@ public class GenerateFragment extends Fragment {
|
||||||
long height = getHeight();
|
long height = getHeight();
|
||||||
if (height < 0) height = 0;
|
if (height < 0) height = 0;
|
||||||
|
|
||||||
if (type.equals(TYPE_NEW)) {
|
switch (type) {
|
||||||
bGenerate.setEnabled(false);
|
case TYPE_NEW:
|
||||||
if (fingerprintAuthAllowed) {
|
|
||||||
KeyStoreHelper.saveWalletUserPass(getActivity(), name, password);
|
|
||||||
}
|
|
||||||
activityCallback.onGenerate(name, crazyPass);
|
|
||||||
} else if (type.equals(TYPE_SEED)) {
|
|
||||||
if (!checkMnemonic()) return;
|
|
||||||
String seed = etWalletMnemonic.getEditText().getText().toString();
|
|
||||||
bGenerate.setEnabled(false);
|
|
||||||
if (fingerprintAuthAllowed) {
|
|
||||||
KeyStoreHelper.saveWalletUserPass(getActivity(), name, password);
|
|
||||||
}
|
|
||||||
activityCallback.onGenerate(name, crazyPass, seed, height);
|
|
||||||
} else if (type.equals(TYPE_LEDGER)) {
|
|
||||||
bGenerate.setEnabled(false);
|
|
||||||
if (fingerprintAuthAllowed) {
|
|
||||||
KeyStoreHelper.saveWalletUserPass(getActivity(), name, password);
|
|
||||||
}
|
|
||||||
activityCallback.onGenerateLedger(name, crazyPass, height);
|
|
||||||
} else if (type.equals(TYPE_KEY) || type.equals(TYPE_VIEWONLY)) {
|
|
||||||
if (checkAddress() && checkViewKey() && checkSpendKey()) {
|
|
||||||
bGenerate.setEnabled(false);
|
bGenerate.setEnabled(false);
|
||||||
String address = etWalletAddress.getEditText().getText().toString();
|
|
||||||
String viewKey = etWalletViewKey.getEditText().getText().toString();
|
|
||||||
String spendKey = "";
|
|
||||||
if (type.equals(TYPE_KEY)) {
|
|
||||||
spendKey = etWalletSpendKey.getEditText().getText().toString();
|
|
||||||
}
|
|
||||||
if (fingerprintAuthAllowed) {
|
if (fingerprintAuthAllowed) {
|
||||||
KeyStoreHelper.saveWalletUserPass(getActivity(), name, password);
|
KeyStoreHelper.saveWalletUserPass(requireActivity(), name, password);
|
||||||
}
|
}
|
||||||
activityCallback.onGenerate(name, crazyPass, address, viewKey, spendKey, height);
|
activityCallback.onGenerate(name, crazyPass);
|
||||||
}
|
break;
|
||||||
|
case TYPE_SEED:
|
||||||
|
if (!checkMnemonic()) return;
|
||||||
|
String seed = etWalletMnemonic.getEditText().getText().toString();
|
||||||
|
bGenerate.setEnabled(false);
|
||||||
|
if (fingerprintAuthAllowed) {
|
||||||
|
KeyStoreHelper.saveWalletUserPass(requireActivity(), name, password);
|
||||||
|
}
|
||||||
|
activityCallback.onGenerate(name, crazyPass, seed, height);
|
||||||
|
break;
|
||||||
|
case TYPE_LEDGER:
|
||||||
|
bGenerate.setEnabled(false);
|
||||||
|
if (fingerprintAuthAllowed) {
|
||||||
|
KeyStoreHelper.saveWalletUserPass(requireActivity(), name, password);
|
||||||
|
}
|
||||||
|
activityCallback.onGenerateLedger(name, crazyPass, height);
|
||||||
|
break;
|
||||||
|
case TYPE_KEY:
|
||||||
|
case TYPE_VIEWONLY:
|
||||||
|
if (checkAddress() && checkViewKey() && checkSpendKey()) {
|
||||||
|
bGenerate.setEnabled(false);
|
||||||
|
String address = etWalletAddress.getEditText().getText().toString();
|
||||||
|
String viewKey = etWalletViewKey.getEditText().getText().toString();
|
||||||
|
String spendKey = "";
|
||||||
|
if (type.equals(TYPE_KEY)) {
|
||||||
|
spendKey = etWalletSpendKey.getEditText().getText().toString();
|
||||||
|
}
|
||||||
|
if (fingerprintAuthAllowed) {
|
||||||
|
KeyStoreHelper.saveWalletUserPass(requireActivity(), name, password);
|
||||||
|
}
|
||||||
|
activityCallback.onGenerate(name, crazyPass, address, viewKey, spendKey, height);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +504,7 @@ public class GenerateFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
if (context instanceof GenerateFragment.Listener) {
|
if (context instanceof GenerateFragment.Listener) {
|
||||||
this.activityCallback = (GenerateFragment.Listener) context;
|
this.activityCallback = (GenerateFragment.Listener) context;
|
||||||
|
@ -595,7 +547,7 @@ public class GenerateFragment extends Fragment {
|
||||||
|
|
||||||
public void convertLedgerSeed() {
|
public void convertLedgerSeed() {
|
||||||
if (ledgerDialog != null) return;
|
if (ledgerDialog != null) return;
|
||||||
final Activity activity = getActivity();
|
final Activity activity = requireActivity();
|
||||||
View promptsView = getLayoutInflater().inflate(R.layout.prompt_ledger_seed, null);
|
View promptsView = getLayoutInflater().inflate(R.layout.prompt_ledger_seed, null);
|
||||||
MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(activity);
|
MaterialAlertDialogBuilder alertDialogBuilder = new MaterialAlertDialogBuilder(activity);
|
||||||
alertDialogBuilder.setView(promptsView);
|
alertDialogBuilder.setView(promptsView);
|
||||||
|
@ -620,26 +572,20 @@ public class GenerateFragment extends Fragment {
|
||||||
|
|
||||||
ledgerDialog = alertDialogBuilder.create();
|
ledgerDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
ledgerDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
ledgerDialog.setOnShowListener(dialog -> {
|
||||||
@Override
|
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
public void onShow(DialogInterface dialog) {
|
button.setOnClickListener(view -> {
|
||||||
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
|
String ledgerSeed = etSeed.getEditText().getText().toString();
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
String ledgerPassphrase = etPassphrase.getEditText().getText().toString();
|
||||||
@Override
|
String moneroSeed = Monero.convert(ledgerSeed, ledgerPassphrase);
|
||||||
public void onClick(View view) {
|
if (moneroSeed != null) {
|
||||||
String ledgerSeed = etSeed.getEditText().getText().toString();
|
etWalletMnemonic.getEditText().setText(moneroSeed);
|
||||||
String ledgerPassphrase = etPassphrase.getEditText().getText().toString();
|
ledgerDialog.dismiss();
|
||||||
String moneroSeed = Monero.convert(ledgerSeed, ledgerPassphrase);
|
ledgerDialog = null;
|
||||||
if (moneroSeed != null) {
|
} else {
|
||||||
etWalletMnemonic.getEditText().setText(moneroSeed);
|
etSeed.setError(getString(R.string.bad_ledger_seed));
|
||||||
ledgerDialog.dismiss();
|
}
|
||||||
ledgerDialog = null;
|
});
|
||||||
} else {
|
|
||||||
etSeed.setError(getString(R.string.bad_ledger_seed));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Helper.preventScreenshot()) {
|
if (Helper.preventScreenshot()) {
|
||||||
|
|
Loading…
Reference in New Issue