Browse Source

fix some UI issue (#5)

V1.1.0-release
JunZhang 5 years ago
committed by GitHub
parent
commit
fb75fce746
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      app/src/main/java/com/cobo/cold/ui/fragment/main/QRCodeScanFragment.java
  2. 2
      app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ElectrumExportFragment.java
  3. 2
      app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ElectrumTxConfirmFragment.java
  4. 2
      app/src/main/java/com/cobo/cold/viewmodel/ElectrumViewModel.java
  5. 11
      app/src/main/res/layout/electrum_export.xml
  6. 2
      app/src/main/res/layout/electrum_export_guide.xml
  7. 2
      app/src/main/res/layout/electrum_tx_detail.xml
  8. 4
      app/src/main/res/values-zh-rCN/strings.xml
  9. 6
      app/src/main/res/values/strings.xml

19
app/src/main/java/com/cobo/cold/ui/fragment/main/QRCodeScanFragment.java

@ -189,7 +189,8 @@ public class QRCodeScanFragment extends BaseFragment<QrcodeScanFragmentBinding>
alert(getString(R.string.unsupported_qrcode));
}
} catch (XpubNotMatchException e) {
alert(getString(R.string.master_pubkey_not_match));
alert(getString(R.string.identification_failed),
getString(R.string.master_pubkey_not_match));
}
}
}
@ -234,7 +235,7 @@ public class QRCodeScanFragment extends BaseFragment<QrcodeScanFragmentBinding>
alert(getString(R.string.incorrect_qrcode));
} catch (CoinNotFindException e) {
e.printStackTrace();
alert(getString(R.string.version_not_match), () -> {
alert(null,getString(R.string.version_not_match), () -> {
navigateUp();
((MainActivity) mActivity).getNavController().navigateUp();
((MainActivity) mActivity).getNavController().navigate(R.id.action_to_settingFragment);
@ -264,14 +265,22 @@ public class QRCodeScanFragment extends BaseFragment<QrcodeScanFragmentBinding>
}
private void alert(String message) {
alert(message, null);
alert(null, message);
}
private void alert(String message, Runnable run) {
private void alert(String title, String message) {
alert(title, message, null);
}
private void alert(String title, String message, Runnable run) {
dialog = ModalDialog.newInstance();
CommonModalBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity),
R.layout.common_modal, null, false);
binding.title.setText(R.string.scan_failed);
if (title != null) {
binding.title.setText(title);
} else {
binding.title.setText(R.string.scan_failed);
}
binding.subTitle.setText(message);
binding.close.setVisibility(View.GONE);
binding.confirm.setText(R.string.know);

2
app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ElectrumExportFragment.java

@ -42,7 +42,7 @@ import static com.cobo.cold.viewmodel.ElectrumViewModel.writeToSdcard;
public class ElectrumExportFragment extends BaseFragment<ElectrumExportBinding> {
private static final String EXTEND_PUB_FILE_NAME = "CV-P2SH-P2WPKH-pubkey.txt";
private static final String EXTEND_PUB_FILE_NAME = "p2wpkh-p2sh-pubkey.txt";
private String exPub;
@Override

2
app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ElectrumTxConfirmFragment.java

@ -90,7 +90,7 @@ public class ElectrumTxConfirmFragment extends BaseFragment<ElectrumTxConfirmFra
ModalDialog modalDialog = ModalDialog.newInstance();
ExportSdcardModalBinding binding = DataBindingUtil.inflate(LayoutInflater.from(activity),
R.layout.export_sdcard_modal, null, false);
String fileName = txId.substring(0, 5) + "-signed.txn";
String fileName = "signed_" + txId.substring(0, 8) + ".txn";
binding.title.setText(R.string.export_signed_txn);
binding.fileName.setText(fileName);
binding.actionHint.setText(R.string.electrum_import_signed_txn);

2
app/src/main/java/com/cobo/cold/viewmodel/ElectrumViewModel.java

@ -68,7 +68,7 @@ public class ElectrumViewModel extends AndroidViewModel {
public static final String ELECTRUM_SIGN_ID = "electrum_sign_id";
private static final int DEFAULT_CHANGE_ADDRESS_NUM = 100;
private static Pattern signedTxnPattern = Pattern.compile("[0-9a-f]{5}-signed.txn$");
private static Pattern signedTxnPattern = Pattern.compile("^signed_[0-9a-fA-F]{8}.txn$");
private final DataRepository mRepo;
private MutableLiveData<String> exPub = new MutableLiveData<>();
private Storage storage;

11
app/src/main/res/layout/electrum_export.xml

@ -58,14 +58,14 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:gravity="center">
<TextView
@ -90,7 +90,7 @@
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_marginHorizontal="34dp"
android:layout_marginTop="20dp"
android:layout_marginTop="16dp"
android:background="@color/white"
android:keepScreenOn="true"
android:padding="5dp">
@ -115,7 +115,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:paddingVertical="10dp"
android:gravity="center"
android:text="@string/electrum_qrcode_hint"
android:textColor="@color/white"
@ -130,7 +131,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="@string/master_xpub"
android:textColor="@color/white"

2
app/src/main/res/layout/electrum_export_guide.xml

@ -43,7 +43,7 @@
android:layout_marginEnd="20dp"
android:ellipsize="middle"
android:singleLine="true"
android:text="@string/export_to_electrum"
android:text="@string/electrum_compatibility"
android:textColor="@android:color/white"
android:textSize="15sp" />
</androidx.appcompat.widget.Toolbar>

2
app/src/main/res/layout/electrum_tx_detail.xml

@ -87,6 +87,7 @@
android:textColor="@color/white"
android:textSize="14sp"
android:textStyle="bold"
android:visibility="gone"
tools:text="2.62407806" />
<TextView
@ -102,6 +103,7 @@
android:textSize="12sp"
android:textStyle="bold"
app:time="@{tx.timeStamp}"
android:visibility="gone"
tools:text="2018/06/01 15:40" />
<include

4
app/src/main/res/values-zh-rCN/strings.xml

@ -302,6 +302,8 @@
<string name="electrum_qrcode_hint"><![CDATA[扫码困难?点击二维码进行放大<br>或<u>\点击此处导出文件\</u>]]></string>
<string name="scan_electrum_hint">若扫描 Electrum 困难,可将待签交易导出成文件,前往【菜单--读取TF卡】对文件签名。</string>
<string name="sign_txn_in_sdcard">对文件签名</string>
<string name="master_pubkey_not_match">主公钥不匹配</string>
<string name="master_pubkey_not_match">该交易无法识别,您的 Cobo 金库与此观察钱包不匹配。</string>
<string name="change">找零</string>
<string name="electrum_compatibility">适配 Electrum</string>
<string name="identification_failed">交易识别失败</string>
</resources>

6
app/src/main/res/values/strings.xml

@ -304,7 +304,7 @@
<string name="no_unsigned_txn_hint">Please make sure the file you wish to sign was successfully saved to your microSD card.</string>
<string name="electrum_broadcast_guide">How to Broadcast</string>
<string name="electrum_broadcast_action_guide">In Electrum, go to Tools > Load Transaction > From QR Code\n\nDifficulty scanning? You can export the signed transaction data as a file using a microSD card and broadcast the transaction from a file with Electrum.</string>
<string name="electrum_decode_txn_fail">Notice</string>
<string name="electrum_decode_txn_fail">Parsing Failed</string>
<string name="electrum_import_xpub_guide_title">How to scan QR code</string>
<string name="electrum_import_xpub_action_guide">1. Open Electrumand and create a new wallet.\n2. Choose “Standard wallet”.\n3. Choose “Use a master key”. \n4. Click the camera icon in the “Create keystore from a master key” window in Electrum to scan the QR code that displays on Cobo Vault.\n\nDifficulty scanning? You can also export the master public key file using a microSD card.</string>
<string name="error_txn_file">Unable to parse file, please try exporting again.</string>
@ -326,6 +326,8 @@
<string name="electrum_qrcode_hint"><![CDATA[Difficulty scanning?Tap the QR code to enlarge<br>or <u>\"touch here to export via microSD.\"</u>]]></string>
<string name="scan_electrum_hint">Difficulty scanning Electrum? You can export the pending transactions as a file using a microSD card (Menu > MicroSD Card)</string>
<string name="sign_txn_in_sdcard">Files Awaiting Signature</string>
<string name="master_pubkey_not_match">Master Public Key not match</string>
<string name="master_pubkey_not_match">This transaction can\'t be recognized, your Cobo Vault doesn’t match the watch-only wallet. </string>
<string name="change">Change</string>
<string name="electrum_compatibility">Electrum Compatibility</string>
<string name="identification_failed">Identification Failed</string>
</resources>

Loading…
Cancel
Save