add import private key recommend
MODIFY
bither-android/res/layout/dialog_import_private_key_address_validation.xml
bither-android/res/layout/dialog_import_private_key_address_validation.xml
android:textSize="16sp" />
<TextView
+ android:id="@+id/tv_private_key_recommend_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="10dp" >
<TextView
- android:id="@+id/tv_compress_address"
+ android:id="@+id/tv_recommend_address"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14sp" />
<Button
- android:id="@+id/btn_import_compress"
+ android:id="@+id/btn_import_recommend"
android:layout_width="62dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
</RelativeLayout>
<TextView
+ android:id="@+id/tv_private_key_not_recommend_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="10dp" >
<TextView
- android:id="@+id/tv_uncompressed_address"
+ android:id="@+id/tv_not_recommend_address"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14sp" />
<Button
- android:id="@+id/btn_import_uncompressed"
+ android:id="@+id/btn_import_not_recommend"
android:layout_width="62dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"

MODIFY
bither-android/res/values/strings.xml
bither-android/res/values/strings.xml
<string name="private_key_import_title">Please select the address corresponding to the import private key</string>
<string name="private_key_compressed_address">Compress private key address</string>
<string name="private_key_uncompressed_address">Uncompressed private key address</string>
+ <string name="private_key_recommend">(Recommend)</string>
</resources>

MODIFY
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
@@ -22,6 +22,7 @@ import net.bither.R;
import net.bither.activity.cold.ColdAdvanceActivity;
import net.bither.activity.hot.HotAdvanceActivity;
import net.bither.bitherj.core.Address;
+import net.bither.bitherj.crypto.ECKey;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.factory.ImportPrivateKey;
import net.bither.runnable.ThreadNeedService;
@@ -99,24 +100,32 @@ public class ImportPrivateKeyAndroid extends ImportPrivateKey {
importPrivateKey(address);
return;
}
- final Address compressAddress = initPrivateKey(true);
- if (compressAddress == null) {
+
+ boolean isCompressed = getIsCompressed();
+ final ECKey compressKey = initEcKey(true);
+ if (compressKey == null) {
return;
}
- final Address uncompressedAddress = initPrivateKey(false);
- if (uncompressedAddress == null) {
+ final ECKey uncompressedKey = initEcKey(false);
+ if (uncompressedKey == null) {
return;
}
- DialogImportPrivateKeyAddressValidation dialogImportPrivateKeyAddressValidation = new DialogImportPrivateKeyAddressValidation(activity, compressAddress.getAddress(), uncompressedAddress.getAddress(), new Runnable() {
+ DialogImportPrivateKeyAddressValidation dialogImportPrivateKeyAddressValidation = new DialogImportPrivateKeyAddressValidation(activity, compressKey.toAddress(), uncompressedKey.toAddress(), isCompressed, new Runnable() {
@Override
public void run() {
+ Address compressAddress = initPrivateKey(true);
+ if (compressAddress != null) {
importPrivateKey(compressAddress);
}
+ }
}, new Runnable() {
@Override
public void run() {
+ Address uncompressedAddress = initPrivateKey(false);
+ if (uncompressedAddress != null) {
importPrivateKey(uncompressedAddress);
}
+ }
});
dialogImportPrivateKeyAddressValidation.show();
}

MODIFY
bither-android/src/net/bither/ui/base/dialog/DialogImportPrivateKeyAddressValidation.java
bither-android/src/net/bither/ui/base/dialog/DialogImportPrivateKeyAddressValidation.java
@@ -18,22 +18,40 @@ public class DialogImportPrivateKeyAddressValidation extends CenterDialog implem
private Runnable importCompressPrivateKeyRunnable;
private Runnable importUncompressedPrivateKeyRunnable;
private int clickedId;
- private TextView tvCompressAddress;
- private TextView tvUncompressedAddress;
+ private TextView tvRecommendAddressTitle;
+ private TextView tvNotRecommendAddressTitle;
+ private TextView tvRecommendAddress;
+ private TextView tvNotRecommendAddress;
+ private boolean isCompressedKeyRecommend;
- public DialogImportPrivateKeyAddressValidation(Context context, String compressAddress, String uncompressedAddress, Runnable
+ public DialogImportPrivateKeyAddressValidation(Context context, String compressAddress, String uncompressedAddress, boolean isCompressedKeyRecommend, Runnable
importRunnable, Runnable importUncompressedPrivateKeyRunnable) {
super(context);
+ this.isCompressedKeyRecommend = isCompressedKeyRecommend;
this.importCompressPrivateKeyRunnable = importRunnable;
this.importUncompressedPrivateKeyRunnable = importUncompressedPrivateKeyRunnable;
setOnDismissListener(this);
setContentView(R.layout.dialog_import_private_key_address_validation);
- tvCompressAddress = (TextView) findViewById(R.id.tv_compress_address);
- tvUncompressedAddress = (TextView) findViewById(R.id.tv_uncompressed_address);
- tvCompressAddress.setText(WalletUtils.formatHash(compressAddress, 4, 16));
- tvUncompressedAddress.setText(WalletUtils.formatHash(uncompressedAddress, 4, 16));
- findViewById(R.id.btn_import_compress).setOnClickListener(this);
- findViewById(R.id.btn_import_uncompressed).setOnClickListener(this);
+ tvRecommendAddressTitle = (TextView) findViewById(R.id.tv_private_key_recommend_address);
+ tvNotRecommendAddressTitle = (TextView) findViewById(R.id.tv_private_key_not_recommend_address);
+ tvRecommendAddress = (TextView) findViewById(R.id.tv_recommend_address);
+ tvNotRecommendAddress = (TextView) findViewById(R.id.tv_not_recommend_address);
+ if (isCompressedKeyRecommend) {
+ String recommendAddressTitle = context.getString(R.string.private_key_compressed_address) + context.getString(R.string.private_key_recommend);
+ tvRecommendAddressTitle.setText(recommendAddressTitle);
+ tvNotRecommendAddressTitle.setText(R.string.private_key_uncompressed_address);
+ tvRecommendAddress.setText(WalletUtils.formatHash(compressAddress, 4, 16));
+ tvNotRecommendAddress.setText(WalletUtils.formatHash(uncompressedAddress, 4, 16));
+ } else {
+ String recommendAddressTitle = context.getString(R.string.private_key_uncompressed_address) + context.getString(R.string.private_key_recommend);
+ tvRecommendAddressTitle.setText(recommendAddressTitle);
+ tvNotRecommendAddressTitle.setText(R.string.private_key_compressed_address);
+ tvRecommendAddress.setText(WalletUtils.formatHash(uncompressedAddress, 4, 16));
+ tvNotRecommendAddress.setText(WalletUtils.formatHash(compressAddress, 4, 16));
+ }
+ findViewById(R.id.btn_import_recommend).setOnClickListener(this);
+ findViewById(R.id.btn_import_not_recommend).setOnClickListener(this);
+
}
@Override
@@ -50,11 +68,27 @@ public class DialogImportPrivateKeyAddressValidation extends CenterDialog implem
@Override
public void onDismiss(DialogInterface dialog) {
- if (clickedId == R.id.btn_import_compress && importCompressPrivateKeyRunnable != null) {
+ if (clickedId == R.id.btn_import_recommend && importCompressPrivateKeyRunnable != null) {
+ if (isCompressedKeyRecommend) {
+ if (importCompressPrivateKeyRunnable != null) {
importCompressPrivateKeyRunnable.run();
- } else if (clickedId == R.id.btn_import_uncompressed && importUncompressedPrivateKeyRunnable != null) {
+ }
+ } else {
+ if (importUncompressedPrivateKeyRunnable != null) {
+ importUncompressedPrivateKeyRunnable.run();
+ }
+ }
+ } else if (clickedId == R.id.btn_import_not_recommend) {
+ if (isCompressedKeyRecommend) {
+ if (importUncompressedPrivateKeyRunnable != null) {
importUncompressedPrivateKeyRunnable.run();
}
+ } else {
+ if (importCompressPrivateKeyRunnable != null) {
+ importCompressPrivateKeyRunnable.run();
+ }
+ }
+ }
}
}

MODIFY
bitherj
bitherj
-Subproject commit 79e06bd12f0fa390370e5b443242ccf652afdf49
+Subproject commit bcf58a9150c94beedf7c8f3bfb331d364faa2036

add import private key recommend