import hd account seed qr code support select language
ADD
bither-android/res/layout/dialog_import_hd_account_seed_qr_code_select_language.xml
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="40dp"
+ android:minWidth="200dp"
+ android:text="@string/hd_account_seed_language_select_title"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:textColor="@color/white"
+ android:textSize="16sp"/>
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_marginTop="5dp"
+ android:background="#66ffffff"/>
+
+ <TextView
+ android:id="@+id/tv_en"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:paddingLeft="15dp"
+ android:paddingRight="15dp"
+ android:gravity="center"
+ android:text="@string/hd_account_seed_language_select_en"
+ android:background="@drawable/ui_touchable_bg"
+ android:layout_gravity="center_horizontal"
+ android:textColor="@color/white"
+ android:textSize="14sp"/>
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_marginLeft="15dp"
+ android:layout_marginRight="15dp"
+ android:background="#66ffffff"/>
+
+ <TextView
+ android:id="@+id/tv_zh_cn"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:paddingLeft="15dp"
+ android:paddingRight="15dp"
+ android:gravity="center"
+ android:text="@string/hd_account_seed_language_select_zh_cn"
+ android:background="@drawable/ui_touchable_bg"
+ android:layout_gravity="center_horizontal"
+ android:textColor="@color/white"
+ android:textSize="14sp"/>
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_marginLeft="15dp"
+ android:layout_marginRight="15dp"
+ android:background="#66ffffff"/>
+
+ <TextView
+ android:id="@+id/tv_zh_tw"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:paddingLeft="15dp"
+ android:paddingRight="15dp"
+ android:gravity="center"
+ android:text="@string/hd_account_seed_language_select_zh_tw"
+ android:background="@drawable/ui_touchable_bg"
+ android:layout_gravity="center_horizontal"
+ android:textColor="@color/white"
+ android:textSize="14sp"/>
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_marginLeft="15dp"
+ android:layout_marginRight="15dp"
+ android:background="#66ffffff"/>
+
+ <TextView
+ android:id="@+id/tv_cancel"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
+ android:paddingLeft="15dp"
+ android:paddingRight="15dp"
+ android:gravity="center"
+ android:text="@string/cancel"
+ android:background="@drawable/ui_touchable_bg"
+ android:layout_gravity="center_horizontal"
+ android:textColor="@color/white"
+ android:textSize="14sp"/>
+
+
+</LinearLayout>
\ No newline at end of file

MODIFY
bither-android/res/values/strings.xml
bither-android/res/values/strings.xml
<string name="address_add_mode_clone_des">Added by cloning</string>
<string name="address_add_mode_other_des">Imported, cloned or not created in xrandom mode from an old version</string>
+ <string name="hd_account_seed_language_select_title">Select HD account seed language</string>
+ <string name="hd_account_seed_language_select_en">English</string>
+ <string name="hd_account_seed_language_select_zh_cn">Simplified Chinese</string>
+ <string name="hd_account_seed_language_select_zh_tw">Traditional Chinese</string>
+
</resources>

MODIFY
bither-android/src/net/bither/activity/cold/ColdAdvanceActivity.java
bither-android/src/net/bither/activity/cold/ColdAdvanceActivity.java
@@ -67,6 +67,7 @@ import net.bither.ui.base.dialog.DialogConfirmTask;
import net.bither.ui.base.dialog.DialogEditPassword;
import net.bither.ui.base.dialog.DialogEnterpriseHDMEnable;
import net.bither.ui.base.dialog.DialogImportBip38KeyText;
+import net.bither.ui.base.dialog.DialogImportHdAccountSeedQrCodeSelectLanguage;
import net.bither.ui.base.dialog.DialogImportPrivateKeyText;
import net.bither.ui.base.dialog.DialogPassword;
import net.bither.ui.base.dialog.DialogPasswordWithOther;
@@ -755,11 +756,38 @@ public class ColdAdvanceActivity extends SwipeRightFragmentActivity {
final String hdAccountSeed = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
final MnemonicWordList mnemonicWordList = MnemonicWordList.getMnemonicWordListForHdSeed(hdAccountSeed);
if (mnemonicWordList != null) {
+ if (mnemonicWordList == MnemonicWordList.English) {
+ new DialogImportHdAccountSeedQrCodeSelectLanguage(this, new DialogImportHdAccountSeedQrCodeSelectLanguage.Listener() {
+ @Override
+ public void onClicked(MnemonicWordList wordList) {
+ importHdAccountSeedQrCode(mnemonicWordList, wordList, hdAccountSeed);
+ }
+
+ @Override
+ public void cancel() {
+
+ }
+ }).show();
+ } else {
+ importHdAccountSeedQrCode(mnemonicWordList, mnemonicWordList, hdAccountSeed);
+ }
+ } else {
+ DropdownMessage.showDropdownMessage(ColdAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
+ }
+ break;
+ case BitherSetting.INTENT_REF.IMPORT_ACCOUNT_SEED_FROM_PHRASE_REQUEST_CODE:
+ ssvImportPrivateKey.loadData();
+ }
+ }
+
+ private void importHdAccountSeedQrCode(final MnemonicWordList mnemonicWordList, final MnemonicWordList selectMnemonicWordList, final String hdAccountSeed) {
try {
MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
mnemonicCode.setMnemonicWordList(mnemonicWordList);
- dialogPassword = new DialogPassword(this,
- new ImportHDAccountPasswordListener(hdAccountSeed, mnemonicCode));
+ MnemonicCode selectMnemonicCode = new MnemonicCodeAndroid();
+ selectMnemonicCode.setMnemonicWordList(selectMnemonicWordList);
+ DialogPassword dialogPassword = new DialogPassword(this,
+ new ImportHDAccountPasswordListener(hdAccountSeed, mnemonicCode, selectMnemonicCode));
dialogPassword.setCheckPre(false);
dialogPassword.setCheckPasswordListener(new ICheckPasswordListener() {
@Override
@@ -783,22 +811,17 @@ public class ColdAdvanceActivity extends SwipeRightFragmentActivity {
e.printStackTrace();
DropdownMessage.showDropdownMessage(ColdAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
}
- } else {
- DropdownMessage.showDropdownMessage(ColdAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
- }
- break;
- case BitherSetting.INTENT_REF.IMPORT_ACCOUNT_SEED_FROM_PHRASE_REQUEST_CODE:
- ssvImportPrivateKey.loadData();
- }
}
private class ImportHDAccountPasswordListener implements IDialogPasswordListener {
private String content;
private MnemonicCode mnemonicCode;
+ private MnemonicCode qrSelectMnemonicCode;
- public ImportHDAccountPasswordListener(String content, MnemonicCode mnemonicCode) {
+ public ImportHDAccountPasswordListener(String content, MnemonicCode mnemonicCode, MnemonicCode qrSelectMnemonicCode) {
this.content = content;
this.mnemonicCode = mnemonicCode;
+ this.qrSelectMnemonicCode = qrSelectMnemonicCode;
}
@Override
@@ -807,7 +830,7 @@ public class ColdAdvanceActivity extends SwipeRightFragmentActivity {
dp.setMessage(R.string.import_private_key_qr_code_importing);
LogUtil.d("importhdseed", "onPasswordEntered");
ImportHDSeedAndroid importHDSeedAndroid = new ImportHDSeedAndroid
- (ColdAdvanceActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedQRCode, dp, content, null, password, mnemonicCode);
+ (ColdAdvanceActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedQRCode, dp, content, null, password, mnemonicCode, qrSelectMnemonicCode);
importHDSeedAndroid.importHDSeed();
}
}

MODIFY
bither-android/src/net/bither/activity/cold/HdmImportWordListActivity.java
bither-android/src/net/bither/activity/cold/HdmImportWordListActivity.java
@@ -174,7 +174,7 @@ public class HdmImportWordListActivity extends SwipeRightFragmentActivity implem
if (importHDSeedType == ImportHDSeed.ImportHDSeedType.HDSeedPhrase) {
isZhTw();
ImportHDSeedAndroid importHDSeedAndroid = new ImportHDSeedAndroid
- (HdmImportWordListActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedPhrase, dp, null, words, password, mnemonic);
+ (HdmImportWordListActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedPhrase, dp, null, words, password, mnemonic, mnemonic);
importHDSeedAndroid.importHDSeed();
} else {
ImportHDSeedAndroid importHDSeedAndroid = new ImportHDSeedAndroid

MODIFY
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
@@ -84,6 +84,7 @@ import net.bither.ui.base.dialog.DialogConfirmTask;
import net.bither.ui.base.dialog.DialogEditPassword;
import net.bither.ui.base.dialog.DialogEnterpriseHDMEnable;
import net.bither.ui.base.dialog.DialogImportBip38KeyText;
+import net.bither.ui.base.dialog.DialogImportHdAccountSeedQrCodeSelectLanguage;
import net.bither.ui.base.dialog.DialogImportPrivateKeyText;
import net.bither.ui.base.dialog.DialogPassword;
import net.bither.ui.base.dialog.DialogPasswordWithOther;
@@ -1357,33 +1358,20 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
final String hdAccountSeed = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
final MnemonicWordList mnemonicWordList = MnemonicWordList.getMnemonicWordListForHdSeed(hdAccountSeed);
if (mnemonicWordList != null) {
- try {
- MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
- mnemonicCode.setMnemonicWordList(mnemonicWordList);
- dialogPassword = new DialogPassword(this,
- new ImportHDAccountPasswordListener(hdAccountSeed, mnemonicCode));
- dialogPassword.setCheckPre(false);
- dialogPassword.setCheckPasswordListener(new ICheckPasswordListener() {
+ if (mnemonicWordList == MnemonicWordList.English) {
+ new DialogImportHdAccountSeedQrCodeSelectLanguage(this, new DialogImportHdAccountSeedQrCodeSelectLanguage.Listener() {
@Override
- public boolean checkPassword(SecureCharSequence password) {
- String keyString = hdAccountSeed.substring(mnemonicWordList.getHdQrCodeFlag().length());
- String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keyString);
- String encreyptString = Utils.joinString(new String[]{passwordSeeds[0], passwordSeeds[1], passwordSeeds[2]}, QRCodeUtil.QR_CODE_SPLIT);
- EncryptedData encryptedData = new EncryptedData(encreyptString);
- byte[] result = null;
- try {
- result = encryptedData.decrypt(password);
- } catch (Exception e) {
- e.printStackTrace();
+ public void onClicked(MnemonicWordList wordList) {
+ importHdAccountSeedQrCode(mnemonicWordList, wordList, hdAccountSeed);
}
- return result != null;
+
+ @Override
+ public void cancel() {
+
}
- });
- dialogPassword.setTitle(R.string.import_private_key_qr_code_password);
- dialogPassword.show();
- } catch (IOException e) {
- e.printStackTrace();
- DropdownMessage.showDropdownMessage(HotAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
+ }).show();
+ } else {
+ importHdAccountSeedQrCode(mnemonicWordList, mnemonicWordList, hdAccountSeed);
}
} else {
DropdownMessage.showDropdownMessage(HotAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
@@ -1433,14 +1421,48 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
}
}
+ private void importHdAccountSeedQrCode(final MnemonicWordList mnemonicWordList, final MnemonicWordList selectMnemonicWordList, final String hdAccountSeed) {
+ try {
+ MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
+ mnemonicCode.setMnemonicWordList(mnemonicWordList);
+ MnemonicCode selectMnemonicCode = new MnemonicCodeAndroid();
+ selectMnemonicCode.setMnemonicWordList(selectMnemonicWordList);
+ DialogPassword dialogPassword = new DialogPassword(this,
+ new ImportHDAccountPasswordListener(hdAccountSeed, mnemonicCode, selectMnemonicCode));
+ dialogPassword.setCheckPre(false);
+ dialogPassword.setCheckPasswordListener(new ICheckPasswordListener() {
+ @Override
+ public boolean checkPassword(SecureCharSequence password) {
+ String keyString = hdAccountSeed.substring(mnemonicWordList.getHdQrCodeFlag().length());
+ String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keyString);
+ String encreyptString = Utils.joinString(new String[]{passwordSeeds[0], passwordSeeds[1], passwordSeeds[2]}, QRCodeUtil.QR_CODE_SPLIT);
+ EncryptedData encryptedData = new EncryptedData(encreyptString);
+ byte[] result = null;
+ try {
+ result = encryptedData.decrypt(password);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result != null;
+ }
+ });
+ dialogPassword.setTitle(R.string.import_private_key_qr_code_password);
+ dialogPassword.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ DropdownMessage.showDropdownMessage(HotAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
+ }
+ }
+
private class ImportHDAccountPasswordListener implements IDialogPasswordListener {
private String content;
private MnemonicCode mnemonicCode;
+ private MnemonicCode qrSelectMnemonicCode;
-
- public ImportHDAccountPasswordListener(String content, MnemonicCode mnemonicCode) {
+ public ImportHDAccountPasswordListener(String content, MnemonicCode mnemonicCode, MnemonicCode qrSelectMnemonicCode) {
this.content = content;
this.mnemonicCode = mnemonicCode;
+ this.qrSelectMnemonicCode = qrSelectMnemonicCode;
}
@Override
@@ -1449,9 +1471,8 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
dp.setMessage(R.string.import_private_key_qr_code_importing);
LogUtil.d("importhdseed", "onPasswordEntered");
ImportHDSeedAndroid importHDSeedAndroid = new ImportHDSeedAndroid
- (HotAdvanceActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedQRCode, dp, content, null, password, mnemonicCode);
+ (HotAdvanceActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedQRCode, dp, content, null, password, mnemonicCode, qrSelectMnemonicCode);
importHDSeedAndroid.importHDSeed();
-
}
}

MODIFY
bither-android/src/net/bither/factory/ImportHDSeedAndroid.java
bither-android/src/net/bither/factory/ImportHDSeedAndroid.java
@@ -56,10 +56,9 @@ public class ImportHDSeedAndroid extends ImportHDSeed {
this.dp = dp;
}
-
public ImportHDSeedAndroid(Activity activity, ImportHDSeedType importHDSeedType,
- DialogProgress dp, String content, List<String> worlds, SecureCharSequence password, MnemonicCode mnemonicCode) {
- super(importHDSeedType, content, worlds, password, mnemonicCode);
+ DialogProgress dp, String content, List<String> worlds, SecureCharSequence password, MnemonicCode mnemonicCode, MnemonicCode qrSelectMnemonicCode) {
+ super(importHDSeedType, content, worlds, password, mnemonicCode, qrSelectMnemonicCode);
this.activity = activity;
this.dp = dp;
}
@@ -134,8 +133,8 @@ public class ImportHDSeedAndroid extends ImportHDSeed {
}
}
if (success) {
- AppSharedPreference.getInstance().setMnemonicWordList(mnemonicCode.getMnemonicWordList());
- MnemonicCode.setInstance(mnemonicCode);
+ AppSharedPreference.getInstance().setMnemonicWordList(qrSelectMnemonicCode.getMnemonicWordList());
+ MnemonicCode.setInstance(qrSelectMnemonicCode);
ThreadUtil.runOnMainThread(new Runnable() {
@Override
public void run() {

MODIFY
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
package net.bither.factory;
import android.app.Activity;
+import android.os.Handler;
import net.bither.R;
import net.bither.activity.cold.ColdAdvanceActivity;
@@ -52,10 +53,6 @@ public class ImportPrivateKeyAndroid extends ImportPrivateKey {
ThreadUtil.runOnMainThread(new Runnable() {
@Override
public void run() {
- if (dp != null && dp.isShowing()) {
- dp.setThread(null);
- dp.dismiss();
- }
switch (errorCode) {
case PASSWORD_WRONG:
DropdownMessage.showDropdownMessage(activity, R.string.password_wrong);
@@ -87,7 +84,14 @@ public class ImportPrivateKeyAndroid extends ImportPrivateKey {
DropdownMessage.showDropdownMessage(activity, R.string.import_private_key_qr_code_failed);
break;
}
-
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (dp != null && dp.isShowing()) {
+ dp.dismiss();
+ }
+ }
+ }, 400);
}
});

ADD
bither-android/src/net/bither/ui/base/dialog/DialogImportHdAccountSeedQrCodeSelectLanguage.java
+package net.bither.ui.base.dialog;
+
+import static net.bither.bitherj.crypto.mnemonic.MnemonicWordList.English;
+import static net.bither.bitherj.crypto.mnemonic.MnemonicWordList.ZhCN;
+import static net.bither.bitherj.crypto.mnemonic.MnemonicWordList.ZhTw;
+
+import android.content.Context;
+import android.view.View;
+import android.widget.TextView;
+
+import net.bither.R;
+import net.bither.bitherj.crypto.mnemonic.MnemonicWordList;
+
+public class DialogImportHdAccountSeedQrCodeSelectLanguage extends CenterDialog {
+
+ public interface Listener {
+ void onClicked(MnemonicWordList mnemonicWordList);
+ void cancel();
+ }
+
+ private TextView tvEn, tvZhCn, tvZhTw, tvCancel;
+ private Listener listener;
+
+ public DialogImportHdAccountSeedQrCodeSelectLanguage(Context context, final Listener listener) {
+ super(context);
+ this.listener = listener;
+ setContentView(R.layout.dialog_import_hd_account_seed_qr_code_select_language);
+ tvEn = (TextView) findViewById(R.id.tv_en);
+ tvZhCn = (TextView) findViewById(R.id.tv_zh_cn);
+ tvZhTw = (TextView) findViewById(R.id.tv_zh_tw);
+ tvCancel = (TextView) findViewById(R.id.tv_cancel);
+ tvEn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ listener.onClicked(English);
+ dismiss();
+ }
+ });
+ tvZhCn.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ listener.onClicked(ZhCN);
+ dismiss();
+ }
+ });
+ tvZhTw.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ listener.onClicked(ZhTw);
+ dismiss();
+ }
+ });
+ tvCancel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ listener.cancel();
+ dismiss();
+ }
+ });
+ }
+
+}

MODIFY
bitherj
bitherj
-Subproject commit b3827686c527594eb5c1539df9076dfa9efd01fb
+Subproject commit b7986bd486408ada9480dc5a8342af87c2390f47

import hd account seed qr code support select language