Search in sources :

Example 1 with OKEX_MAIN

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;
    }
}
Also used : ClipboardManager(android.content.ClipboardManager) Context(android.content.Context) ImageButton(android.widget.ImageButton) LinearLayout(android.widget.LinearLayout) Arrays(java.util.Arrays) Bundle(android.os.Bundle) Dialog_ChoiceNet(wannabit.io.cosmostaion.dialog.Dialog_ChoiceNet) NonNull(androidx.annotation.NonNull) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) Filter(android.widget.Filter) Intent(android.content.Intent) WDp(wannabit.io.cosmostaion.utils.WDp) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) WUtil(wannabit.io.cosmostaion.utils.WUtil) MnemonicCode(org.bitcoinj.crypto.MnemonicCode) Toast(android.widget.Toast) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Button(android.widget.Button) KAVA_MAIN(wannabit.io.cosmostaion.base.BaseChain.KAVA_MAIN) RecyclerView(androidx.recyclerview.widget.RecyclerView) OKEX_MAIN(wannabit.io.cosmostaion.base.BaseChain.OKEX_MAIN) BaseConstant(wannabit.io.cosmostaion.base.BaseConstant) FilledVerticalButtonAlertDialog(wannabit.io.cosmostaion.dialog.FilledVerticalButtonAlertDialog) SECRET_MAIN(wannabit.io.cosmostaion.base.BaseChain.SECRET_MAIN) WKey(wannabit.io.cosmostaion.utils.WKey) LUM_MAIN(wannabit.io.cosmostaion.base.BaseChain.LUM_MAIN) TextUtils(android.text.TextUtils) R(wannabit.io.cosmostaion.R) BaseChain(wannabit.io.cosmostaion.base.BaseChain) ViewGroup(android.view.ViewGroup) FETCHAI_MAIN(wannabit.io.cosmostaion.base.BaseChain.FETCHAI_MAIN) TextView(android.widget.TextView) Html(android.text.Html) RelativeLayout(android.widget.RelativeLayout) Toolbar(androidx.appcompat.widget.Toolbar) BaseActivity(wannabit.io.cosmostaion.base.BaseActivity) Filterable(android.widget.Filterable) CryptoHelper(wannabit.io.cosmostaion.crypto.CryptoHelper) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Activity(android.app.Activity) EditText(android.widget.EditText) ImageButton(android.widget.ImageButton) Button(android.widget.Button) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 ClipboardManager (android.content.ClipboardManager)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Html (android.text.Html)1 TextUtils (android.text.TextUtils)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 WindowManager (android.view.WindowManager)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 Filter (android.widget.Filter)1 Filterable (android.widget.Filterable)1 ImageButton (android.widget.ImageButton)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 RelativeLayout (android.widget.RelativeLayout)1