modify scan qr result invalid tip
MODIFY
bither-android/res/values/strings.xml
bither-android/res/values/strings.xml
<string name="bitpie_signed_send_tx">Sign Transaction</string>
<string name="bitpie_signed_message_change_to_coin_title">Bitpie coin switch</string>
<string name="bitpie_signed_message_change_coin_confirm">Confirm to switch</string>
+ <string name="bitpie_signed_change_coin_qr_code_title">Use Bitpie scan to switch</string>
+ <string name="bitpie_no_support_coin">This coin hasn`t been supported yet, please update to the newest version</string>
<string name="permissions_no_grant">Please go to Phone Setting->Apps->Bither->Permission to switch on relevant permissions, otherwise the function cannot be used.</string>

MODIFY
bither-android/src/net/bither/activity/cold/BitpieColdSignChangeCoinActivity.java
bither-android/src/net/bither/activity/cold/BitpieColdSignChangeCoinActivity.java
@@ -12,6 +12,7 @@ import net.bither.BitherSetting;
import net.bither.R;
import net.bither.bitherj.core.AddressManager;
import net.bither.bitherj.crypto.SecureCharSequence;
+import net.bither.bitherj.exception.BitpieColdNoSupportCoinException;
import net.bither.bitherj.qrcode.QRCodeBitpieColdSignMessage;
import net.bither.bitherj.utils.Utils;
import net.bither.qrcode.BitherQRCodeActivity;
@@ -44,6 +45,7 @@ public class BitpieColdSignChangeCoinActivity extends SwipeRightActivity impleme
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == BitherSetting.INTENT_REF.SCAN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
String str = data.getExtras().getString(ScanActivity.INTENT_EXTRA_RESULT);
+ try {
QRCodeBitpieColdSignMessage signMessage = QRCodeBitpieColdSignMessage.formatQRCode(str);
if (signMessage == null) {
super.finish();
@@ -57,6 +59,14 @@ public class BitpieColdSignChangeCoinActivity extends SwipeRightActivity impleme
}
}, 400);
}
+ } catch (BitpieColdNoSupportCoinException ex) {
+ ex.printStackTrace();
+ showScanResultInvalid(getString(R.string.bitpie_no_support_coin));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ super.finish();
+ return;
+ }
} else {
super.finish();
return;
@@ -126,7 +136,7 @@ public class BitpieColdSignChangeCoinActivity extends SwipeRightActivity impleme
dp.dismiss();
Intent intent = new Intent(BitpieColdSignChangeCoinActivity.this, BitherQRCodeActivity.class);
intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING, result);
- intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING, getString(R.string.signed_transaction_qr_code_title));
+ intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING, getString(R.string.bitpie_signed_change_coin_qr_code_title));
intent.putExtra(BitherSetting.INTENT_REF.BITPIE_COLD_SIGN_MESSAGE_TYPE_STRING, qrCodeBitpieColdSignMessage.getSignMessageType().getType());
intent.putExtra(BitherSetting.INTENT_REF.BITPIE_COLD_CHANGE_COIN_IS_ONLY_GET_XPUB_STRING, qrCodeBitpieColdSignMessage.isOnlyGetXpub());
startActivity(intent);

MODIFY
bither-android/src/net/bither/activity/cold/SignTxActivity.java
bither-android/src/net/bither/activity/cold/SignTxActivity.java
@@ -19,6 +19,7 @@ package net.bither.activity.cold;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -33,11 +34,13 @@ import net.bither.R;
import net.bither.bitherj.core.Address;
import net.bither.bitherj.core.AddressManager;
import net.bither.bitherj.core.BitpieHDAccountCold;
+import net.bither.bitherj.core.Coin;
import net.bither.bitherj.core.EnterpriseHDMSeed;
import net.bither.bitherj.core.HDAccountCold;
import net.bither.bitherj.crypto.ECKey;
import net.bither.bitherj.crypto.SecureCharSequence;
import net.bither.bitherj.crypto.hd.DeterministicKey;
+import net.bither.bitherj.exception.BitpieColdNoSupportCoinException;
import net.bither.bitherj.qrcode.QRCodeTxTransport;
import net.bither.bitherj.qrcode.QRCodeUtil;
import net.bither.bitherj.utils.Utils;
@@ -116,6 +119,7 @@ public class SignTxActivity extends SwipeRightActivity implements
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == BitherSetting.INTENT_REF.SCAN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
String str = data.getExtras().getString(ScanActivity.INTENT_EXTRA_RESULT);
+ try {
qrCodeTransport = QRCodeTxTransport.formatQRCodeTransport(str);
if (qrCodeTransport != null) {
showTransaction();
@@ -123,6 +127,14 @@ public class SignTxActivity extends SwipeRightActivity implements
super.finish();
return;
}
+ } catch (BitpieColdNoSupportCoinException ex) {
+ ex.printStackTrace();
+ showScanResultInvalid(getString(R.string.bitpie_no_support_coin));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ super.finish();
+ return;
+ }
} else {
super.finish();
return;
@@ -131,8 +143,16 @@ public class SignTxActivity extends SwipeRightActivity implements
}
private void showTransaction() {
- String symbol = qrCodeTransport.getCoinDetail().displayCode;
- int unitDecimal = qrCodeTransport.getCoinDetail().unitDecimal;
+ String symbol;
+ int unitDecimal;
+ if (qrCodeTransport.getCoinDetail() == null) {
+ Coin coin = Utils.getCoinByAddressHeader(qrCodeTransport.getToAddress());
+ symbol = coin.getName();
+ unitDecimal = coin.getUnitDecimal();
+ } else {
+ symbol = qrCodeTransport.getCoinDetail().displayCode;
+ unitDecimal = qrCodeTransport.getCoinDetail().unitDecimal;
+ }
if (qrCodeTransport.isUseOwnFee() && qrCodeTransport.getFeeCoinDetail() != null) {
llFee.setVisibility(View.GONE);
} else {
@@ -169,14 +189,17 @@ public class SignTxActivity extends SwipeRightActivity implements
tvAddressChange.setText(WalletUtils.formatHash(qrCodeTransport.getChangeAddress(), 4, qrCodeTransport.getChangeAddress().length()));
tvAmountChange.setText(UnitUtilWrapper.formatValueWithBoldByUnit(BigInteger.valueOf(qrCodeTransport.getChangeAmt()), unitDecimal));
}
- if (qrCodeTransport.getTxTransportType().isBitpieCold()
- && AddressManager.getInstance().hasBitpieHDAccountCold()
- && AddressManager.getInstance().getBitpieHDAccountCold().getFirstAddressFromDb().equals(qrCodeTransport.getMyAddress())) {
+ if (qrCodeTransport.getTxTransportType().isBitpieCold()) {
+ if (AddressManager.getInstance().hasBitpieHDAccountCold() && AddressManager.getInstance().getBitpieHDAccountCold().getFirstAddressFromDb().equals(qrCodeTransport.getMyAddress())) {
btnSign.setEnabled(true);
if (qrCodeTransport.isFeeTx()) {
btnSign.setText(R.string.bitpie_signed_miner_fee_tx);
}
tvCannotFindPrivateKey.setVisibility(View.GONE);
+ } else {
+ btnSign.setEnabled(false);
+ tvCannotFindPrivateKey.setVisibility(View.VISIBLE);
+ }
} else {
Address address = WalletUtils.findPrivateKey(qrCodeTransport.getMyAddress());
if ((qrCodeTransport.getHdmIndex() < 0 && address == null && qrCodeTransport.getTxTransportType() != QRCodeTxTransport.TxTransportType.ColdHD && !qrCodeTransport.getTxTransportType().isBitpieCold()) ||

MODIFY
bither-android/src/net/bither/ui/base/SwipeRightActivity.java
bither-android/src/net/bither/ui/base/SwipeRightActivity.java
package net.bither.ui.base;
+import android.os.Handler;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import net.bither.R;
+import net.bither.activity.cold.BitpieColdSignChangeCoinActivity;
public class SwipeRightActivity extends BaseActivity {
protected SwipeRightTouchView mTouchView;
@@ -73,4 +75,19 @@ public class SwipeRightActivity extends BaseActivity {
getWindow().getAttributes().height = WindowManager.LayoutParams.MATCH_PARENT;
super.onResume();
}
+
+ protected void showScanResultInvalid(final String msg) {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ DropdownMessage.showDropdownMessage(SwipeRightActivity.this, msg, new Runnable() {
+ @Override
+ public void run() {
+ finish();
+ return;
+ }
+ });
+ }
+ }, 400);
+ }
}

MODIFY
bitherj
bitherj
-Subproject commit c17daf60645ae51e21d82454cffbdb47adb164a1
+Subproject commit 3f12462b8ff1ea8efb0178f9df224fdcaddf4109

modify scan qr result invalid tip