modify import private key text
ADD
bither-android/res/layout/dialog_import_private_key_address_validation.xml
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="240dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/private_key_import_title"
+ android:textAlignment="center"
+ android:textColor="@color/white"
+ android:textSize="16sp" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:gravity="left"
+ android:text="@string/private_key_compressed_address"
+ android:textColor="@color/white"
+ android:textSize="14sp" />
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp" >
+
+ <TextView
+ android:id="@+id/tv_compress_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:layout_width="62dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_alignParentRight="true"
+ android:background="@drawable/dialog_btn_bg_selector"
+ android:text="@string/private_key_import"
+ android:textColor="@color/white"
+ android:textSize="14sp" />
+
+ </RelativeLayout>
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp"
+ android:gravity="left"
+ android:text="@string/private_key_uncompressed_address"
+ android:textColor="@color/white"
+ android:textSize="14sp" />
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dp" >
+
+ <TextView
+ android:id="@+id/tv_uncompressed_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:layout_width="62dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dp"
+ android:layout_alignParentRight="true"
+ android:background="@drawable/dialog_btn_bg_selector"
+ android:text="@string/private_key_import"
+ android:textColor="@color/white"
+ android:textSize="14sp" />
+
+ </RelativeLayout>
+
+</LinearLayout>
\ No newline at end of file

MODIFY
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
bither-android/src/net/bither/factory/ImportPrivateKeyAndroid.java
@@ -27,6 +27,7 @@ import net.bither.bitherj.factory.ImportPrivateKey;
import net.bither.runnable.ThreadNeedService;
import net.bither.service.BlockchainService;
import net.bither.ui.base.DropdownMessage;
+import net.bither.ui.base.dialog.DialogImportPrivateKeyAddressValidation;
import net.bither.ui.base.dialog.DialogProgress;
import net.bither.util.KeyUtil;
import net.bither.util.ThreadUtil;
@@ -93,10 +94,37 @@ public class ImportPrivateKeyAndroid extends ImportPrivateKey {
public void importPrivateKey() {
+ if (importPrivateKeyType != ImportPrivateKeyType.Text) {
+ Address address = initPrivateKey();
+ importPrivateKey(address);
+ return;
+ }
+ final Address compressAddress = initPrivateKey(true);
+ if (compressAddress == null) {
+ return;
+ }
+ final Address uncompressedAddress = initPrivateKey(false);
+ if (uncompressedAddress == null) {
+ return;
+ }
+ DialogImportPrivateKeyAddressValidation dialogImportPrivateKeyAddressValidation = new DialogImportPrivateKeyAddressValidation(activity, compressAddress.getAddress(), uncompressedAddress.getAddress(), new Runnable() {
+ @Override
+ public void run() {
+ importPrivateKey(compressAddress);
+ }
+ }, new Runnable() {
+ @Override
+ public void run() {
+ importPrivateKey(uncompressedAddress);
+ }
+ });
+ dialogImportPrivateKeyAddressValidation.show();
+ }
+
+ private void importPrivateKey(final Address address) {
new ThreadNeedService(dp, activity) {
@Override
public void runWithService(BlockchainService service) {
- Address address = initPrivateKey();
if (address != null) {
List<Address> addressList = new ArrayList<Address>();
addressList.add(address);
@@ -121,5 +149,4 @@ public class ImportPrivateKeyAndroid extends ImportPrivateKey {
}.start();
}
-
}

ADD
bither-android/src/net/bither/ui/base/dialog/DialogImportPrivateKeyAddressValidation.java
+package net.bither.ui.base.dialog;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.View;
+import android.widget.TextView;
+
+import net.bither.R;
+import net.bither.util.WalletUtils;
+
+/**
+ * Created by Hzz on 2017/8/14.
+ */
+
+public class DialogImportPrivateKeyAddressValidation extends CenterDialog implements DialogInterface
+ .OnDismissListener, View.OnClickListener {
+
+ private Runnable importCompressPrivateKeyRunnable;
+ private Runnable importUncompressedPrivateKeyRunnable;
+ private int clickedId;
+ private TextView tvCompressAddress;
+ private TextView tvUncompressedAddress;
+
+ public DialogImportPrivateKeyAddressValidation(Context context, String compressAddress, String uncompressedAddress, Runnable
+ importRunnable, Runnable importUncompressedPrivateKeyRunnable) {
+ super(context);
+ 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);
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ clickedId = 0;
+ }
+
+ @Override
+ public void onClick(View v) {
+ clickedId = v.getId();
+ dismiss();
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ if (clickedId == R.id.btn_import_compress && importCompressPrivateKeyRunnable != null) {
+ importCompressPrivateKeyRunnable.run();
+ } else if (clickedId == R.id.btn_import_uncompressed && importUncompressedPrivateKeyRunnable != null) {
+ importUncompressedPrivateKeyRunnable.run();
+ }
+ }
+
+}

MODIFY
bitherj
bitherj
-Subproject commit 9673392a8bee5b223bf8b441be29162d3681dfee
+Subproject commit d21c9bf558f5971b0f392c5579ea357ffa10dbc1

modify import private key text