use of wannabit.io.cosmostaion.base.BaseChain.OKEX_MAIN in project cosmostation-android by cosmostation.
the class RestoreActivity method onClick.
@Override
public void onClick(View v) {
if (v.equals(mClearAll)) {
onClearAll();
return;
} else if (v.equals(mPaste)) {
onClearAll();
if (getBaseDao().mCopySalt != null && getBaseDao().mCopyEncResult != null) {
String words = CryptoHelper.doDecryptData(getBaseDao().mCopySalt, getBaseDao().mCopyEncResult.getEncDataString(), getBaseDao().mCopyEncResult.getIvDataString());
if (TextUtils.isEmpty(words)) {
return;
}
ArrayList<String> newinsert = new ArrayList<>(Arrays.asList(words.split("\\s+")));
for (int i = 0; i < mEtMnemonics.length; i++) {
if (newinsert.size() > i) {
String toinsert = newinsert.get(i).replace(" ", "");
mEtMnemonics[i].setText(toinsert);
}
}
if (newinsert.size() < 23) {
mEtMnemonics[newinsert.size()].requestFocus();
} else {
mEtMnemonics[23].requestFocus();
}
mEtMnemonics[mMnemonicPosition].setSelection(mEtMnemonics[mMnemonicPosition].getText().length());
mMnemonicAdapter.getFilter().filter(mEtMnemonics[mMnemonicPosition].getText().toString().trim());
onCheckMnemonicCnt();
} else {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard.getPrimaryClip() != null && clipboard.getPrimaryClip().getItemCount() > 0) {
String userPaste = clipboard.getPrimaryClip().getItemAt(0).coerceToText(getBaseContext()).toString().trim();
if (TextUtils.isEmpty(userPaste)) {
Toast.makeText(this, R.string.error_clipboard_no_data, Toast.LENGTH_SHORT).show();
return;
}
ArrayList<String> newinsert = new ArrayList<>(Arrays.asList(userPaste.split("\\s+")));
for (int i = 0; i < mEtMnemonics.length; i++) {
if (newinsert.size() > i) {
String toinsert = newinsert.get(i).replace(" ", "");
mEtMnemonics[i].setText(toinsert);
}
}
if (newinsert.size() < 23) {
mEtMnemonics[newinsert.size()].requestFocus();
} else {
mEtMnemonics[23].requestFocus();
}
mEtMnemonics[mMnemonicPosition].setSelection(mEtMnemonics[mMnemonicPosition].getText().length());
mMnemonicAdapter.getFilter().filter(mEtMnemonics[mMnemonicPosition].getText().toString().trim());
onCheckMnemonicCnt();
} else {
Toast.makeText(this, R.string.error_clipboard_no_data, Toast.LENGTH_SHORT).show();
}
}
return;
} else if (v.equals(mBtnConfirm)) {
mWords.clear();
for (int i = 0; i < mEtMnemonics.length; i++) {
if (!TextUtils.isEmpty(mEtMnemonics[i].getText().toString().trim())) {
mWords.add(mEtMnemonics[i].getText().toString().trim());
} else {
break;
}
}
if (isValidWords()) {
if (mChain.equals(KAVA_MAIN)) {
FilledVerticalButtonAlertDialog.showDoubleButton(this, getString(R.string.str_kava_newpath_title), getString(R.string.str_kava_newpath_msg), getString(R.string.str_kava_old_path), view -> onUsingCustomPath(0), null, getString(R.string.str_kava_new_path), view -> onUsingCustomPath(1), null, false);
return;
} else if (mChain.equals(SECRET_MAIN)) {
FilledVerticalButtonAlertDialog.showDoubleButton(this, getString(R.string.str_secret_newpath_title), getString(R.string.str_secret_newpath_msg), getString(R.string.str_secret_old_path), view -> onUsingCustomPath(0), null, getString(R.string.str_secret_new_path), view -> onUsingCustomPath(1), null, false);
return;
} else if (mChain.equals(OKEX_MAIN)) {
FilledVerticalButtonAlertDialog.showTripleButton(this, getString(R.string.str_okex_newpath_title), getString(R.string.str_okex_newpath_msg), getString(R.string.str_okex_old_type), view -> onUsingCustomPath(0), null, getString(R.string.str_okex_new_type), view -> onUsingCustomPath(1), null, Html.fromHtml("<b>" + getString(R.string.str_okex_eth_type) + "</b>"), view -> onUsingCustomPath(2), null, false);
return;
} else if (mChain.equals(FETCHAI_MAIN)) {
FilledVerticalButtonAlertDialog.showQuadrupleButton(this, getString(R.string.str_secret_newpath_title), getString(R.string.str_fetch_eth_path_msg), getString(R.string.str_fetch_cosmos_path), view -> onUsingCustomPath(0), null, getString(R.string.str_fetch_eth_path), view -> onUsingCustomPath(1), null, getString(R.string.str_fetch_eth_ledger_path), view -> onUsingCustomPath(2), null, getString(R.string.str_fetch_eth_ledger_live), view -> onUsingCustomPath(3), null, false);
return;
} else if (mChain.equals(LUM_MAIN)) {
FilledVerticalButtonAlertDialog.showDoubleButton(this, getString(R.string.str_lum_newpath_title), getString(R.string.str_lum_newpath_msg), getString(R.string.str_lum_basic_type), view -> onUsingCustomPath(0), null, getString(R.string.str_lum_airdrop_type), view -> onUsingCustomPath(1), null, false);
return;
} else {
onConfirmedWords();
}
} else {
Toast.makeText(this, R.string.error_invalid_mnemonic_count, Toast.LENGTH_SHORT).show();
}
return;
} else if (v.equals(mBtnDelete)) {
String existed = mEtMnemonics[mMnemonicPosition].getText().toString().trim();
if (TextUtils.isEmpty(existed)) {
onBeforeWord();
} else {
mEtMnemonics[mMnemonicPosition].setText(existed.substring(0, existed.length() - 1));
mEtMnemonics[mMnemonicPosition].setSelection(mEtMnemonics[mMnemonicPosition].getText().length());
}
mMnemonicAdapter.getFilter().filter(mEtMnemonics[mMnemonicPosition].getText().toString().trim());
onCheckMnemonicCnt();
return;
} else if (v.equals(mBtnSpace)) {
onNextWord();
return;
}
if (v instanceof Button) {
String input = ((Button) v).getText().toString();
mEtMnemonics[mMnemonicPosition].setText(mEtMnemonics[mMnemonicPosition].getText().toString() + input);
mEtMnemonics[mMnemonicPosition].setSelection(mEtMnemonics[mMnemonicPosition].getText().length());
mMnemonicAdapter.getFilter().filter(mEtMnemonics[mMnemonicPosition].getText().toString().trim());
return;
}
}
Aggregations