Modify HDAccountHot QrCode Support For Importing Chinese
MODIFY
bither-android/src/net/bither/BitherApplication.java
bither-android/src/net/bither/BitherApplication.java
@@ -175,9 +175,7 @@ public class BitherApplication extends Application {
@Override
public void run() {
try {
- MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
- mnemonicCode.setMnemonicWordList(AppSharedPreference.getInstance().getMnemonicWordList());
- MnemonicCode.setInstance(mnemonicCode);
+ MnemonicCodeAndroid.setMnemonicCode(AppSharedPreference.getInstance().getMnemonicWordList());
} catch (IOException e) {
e.printStackTrace();
}

MODIFY
bither-android/src/net/bither/activity/cold/ColdActivity.java
bither-android/src/net/bither/activity/cold/ColdActivity.java
@@ -42,6 +42,7 @@ import net.bither.bitherj.crypto.EncryptedData;
import net.bither.bitherj.crypto.PasswordSeed;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.crypto.mnemonic.MnemonicCode;
+import net.bither.bitherj.crypto.mnemonic.MnemonicWordList;
import net.bither.bitherj.qrcode.QRCodeUtil;
import net.bither.bitherj.utils.PrivateKeyUtil;
import net.bither.bitherj.utils.Utils;
@@ -383,7 +384,7 @@ public class ColdActivity extends BaseFragmentActivity {
String[] strings = BackupUtil.getBackupKeyStrList(file);
HDMKeychain hdmKeychain = null;
boolean check = false;
- int hdQrCodeFlagLength = hdQrCodeFlagLength(strings);
+ int hdQrCodeFlagLength = MnemonicWordList.getHdQrCodeFlagLength(strings[0], MnemonicCode.instance().getMnemonicWordList());
if (strings != null && strings.length > 0) {
if (strings[0].indexOf(QRCodeUtil.HDM_QR_CODE_FLAG) == 0 || hdQrCodeFlagLength != 0) {
String keychainString = strings[0].substring(hdQrCodeFlagLength);
@@ -454,13 +455,6 @@ public class ColdActivity extends BaseFragmentActivity {
}
- private int hdQrCodeFlagLength(String[] strings) {
- String hdQrCodeFlag = MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag();
- if (strings.length < hdQrCodeFlag.length()) { return 0; }
- String prefixStr = strings[0].substring(0, hdQrCodeFlag.length());
- return hdQrCodeFlag.equals(prefixStr) ? hdQrCodeFlag.length() : 0;
- }
-
private void checkPasswordWrong() {
ThreadUtil.runOnMainThread(new Runnable() {
@Override

MODIFY
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
bither-android/src/net/bither/activity/hot/HotAdvanceActivity.java
@@ -48,6 +48,7 @@ import net.bither.bitherj.crypto.PasswordSeed;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.crypto.bip38.Bip38;
import net.bither.bitherj.crypto.mnemonic.MnemonicCode;
+import net.bither.bitherj.crypto.mnemonic.MnemonicWordList;
import net.bither.bitherj.db.AbstractDb;
import net.bither.bitherj.factory.ImportHDSeed;
import net.bither.bitherj.factory.ImportPrivateKey;
@@ -59,6 +60,7 @@ import net.bither.enums.TotalBalanceHide;
import net.bither.factory.ImportHDSeedAndroid;
import net.bither.factory.ImportPrivateKeyAndroid;
import net.bither.fragment.Refreshable;
+import net.bither.mnemonic.MnemonicCodeAndroid;
import net.bither.pin.PinCodeChangeActivity;
import net.bither.pin.PinCodeDisableActivity;
import net.bither.pin.PinCodeEnableActivity;
@@ -1268,14 +1270,18 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
break;
case BitherSetting.INTENT_REF.IMPORT_HD_ACCOUNT_SEED_REQUEST_CODE:
final String hdAccountSeed = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
- if (hdAccountSeed.indexOf(MnemonicCode.instance().getMnemonicWordList().getHdQrCodeFlag()) == 0) {
+ final MnemonicWordList mnemonicWordList = MnemonicWordList.getMnemonicWordList(hdAccountSeed);
+ if (mnemonicWordList != null) {
+ try {
+ MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
+ mnemonicCode.setMnemonicWordList(mnemonicWordList);
dialogPassword = new DialogPassword(this,
- new ImportHDAccountPasswordListener(hdAccountSeed));
+ new ImportHDAccountPasswordListener(hdAccountSeed, mnemonicCode));
dialogPassword.setCheckPre(false);
dialogPassword.setCheckPasswordListener(new ICheckPasswordListener() {
@Override
public boolean checkPassword(SecureCharSequence password) {
- String keyString = hdAccountSeed.substring(1);
+ 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);
@@ -1290,9 +1296,12 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
});
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);
+ }
} else {
- DropdownMessage.showDropdownMessage(HotAdvanceActivity.this
- , R.string.import_hd_account_seed_format_error);
+ DropdownMessage.showDropdownMessage(HotAdvanceActivity.this, R.string.import_hd_account_seed_format_error);
}
break;
case BitherSetting.INTENT_REF.IMPORT_BIP38PRIVATE_KEY_REQUEST_CODE:
@@ -1339,11 +1348,12 @@ public class HotAdvanceActivity extends SwipeRightFragmentActivity {
private class ImportHDAccountPasswordListener implements IDialogPasswordListener {
private String content;
+ private MnemonicCode mnemonicCode;
- public ImportHDAccountPasswordListener(String content) {
+ public ImportHDAccountPasswordListener(String content, MnemonicCode mnemonicCode) {
this.content = content;
-
+ this.mnemonicCode = mnemonicCode;
}
@Override
@@ -1352,7 +1362,7 @@ 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, null);
+ (HotAdvanceActivity.this, ImportHDSeed.ImportHDSeedType.HDSeedQRCode, dp, content, null, password, mnemonicCode);
importHDSeedAndroid.importHDSeed();
}

MODIFY
bither-android/src/net/bither/mnemonic/MnemonicCodeAndroid.java
bither-android/src/net/bither/mnemonic/MnemonicCodeAndroid.java
@@ -38,6 +38,12 @@ public class MnemonicCodeAndroid extends MnemonicCode {
super();
}
+ static public void setMnemonicCode(MnemonicWordList mnemonicWordList) throws IOException {
+ MnemonicCode mnemonicCode = new MnemonicCodeAndroid();
+ mnemonicCode.setMnemonicWordList(mnemonicWordList);
+ MnemonicCode.setInstance(mnemonicCode);
+ }
+
@Override
protected HashMap<MnemonicWordList, InputStream> openWordList() throws IOException, IllegalArgumentException {
return getAllMnemonicWordListRawResources();

MODIFY
bitherj
bitherj
-Subproject commit 7daddc49fde02cc75c1f0d60645d0fe75603b509
+Subproject commit cb5a50e55b8b0ae41a957b6ea3e4d2b42a0bbeaa

Modify HDAccountHot QrCode Support For Importing Chinese