Browse Source

fix some UI and navigation issue (#24)

V1.2.0-btc-release
JunZhang 5 years ago
committed by GitHub
parent
commit
31d77d475d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/src/main/java/com/cobo/cold/ui/fragment/BaseFragment.java
  2. 23
      app/src/main/java/com/cobo/cold/ui/fragment/SyncFragment.java
  3. 19
      app/src/main/java/com/cobo/cold/ui/fragment/main/AssetFragment.java
  4. 5
      app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ExportXpubGuideFragment.java
  5. 27
      app/src/main/java/com/cobo/cold/ui/fragment/setting/ChooseWatchWalletFragment.java
  6. 2
      app/src/main/java/com/cobo/cold/ui/fragment/setting/MainPreferenceFragment.java
  7. 38
      app/src/main/java/com/cobo/cold/ui/fragment/setup/SelectAddressFormatFragment.java
  8. 2
      app/src/main/res/layout/common_modal.xml
  9. 5
      app/src/main/res/layout/export_xpub.xml
  10. 4
      app/src/main/res/layout/setup_watch_wallet.xml
  11. 29
      app/src/main/res/layout/sync.xml
  12. 1
      app/src/main/res/layout/sync_fragment.xml
  13. 45
      app/src/main/res/navigation/nav_graph_main.xml
  14. 8
      app/src/main/res/values-zh-rCN/strings.xml
  15. 8
      app/src/main/res/values/strings.xml

4
app/src/main/java/com/cobo/cold/ui/fragment/BaseFragment.java

@ -139,6 +139,10 @@ public abstract class BaseFragment<T extends ViewDataBinding> extends Fragment {
NavHostFragment.findNavController(this).navigate(id);
}
public void popBackStack(@IdRes int id, boolean inclusive) {
NavHostFragment.findNavController(this).popBackStack(id, inclusive);
}
public void navigate(@IdRes int id, Bundle data) {
NavHostFragment.findNavController(this).navigate(id, data);
}

23
app/src/main/java/com/cobo/cold/ui/fragment/SyncFragment.java

@ -19,15 +19,20 @@ package com.cobo.cold.ui.fragment;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModelProviders;
import com.cobo.cold.R;
import com.cobo.cold.databinding.CommonModalBinding;
import com.cobo.cold.databinding.SyncFragmentBinding;
import com.cobo.cold.db.entity.CoinEntity;
import com.cobo.cold.ui.MainActivity;
import com.cobo.cold.ui.modal.ModalDialog;
import com.cobo.cold.viewmodel.CoinListViewModel;
import java.util.List;
@ -48,10 +53,11 @@ public class SyncFragment extends BaseFragment<SyncFragmentBinding> {
viewModel = ViewModelProviders.of(mActivity).get(CoinListViewModel.class);
subscribe(viewModel.getCoins());
if (mActivity instanceof MainActivity) {
mBinding.complete.setVisibility(View.GONE);
mBinding.complete.setOnClickListener(v -> popBackStack(R.id.assetFragment, false));
} else {
mBinding.complete.setOnClickListener(v -> navigate(R.id.action_to_setupCompleteFragment));
}
mBinding.sync.info.setOnClickListener(v -> showCoboInfo());
}
private void subscribe(LiveData<List<CoinEntity>> coins) {
@ -72,4 +78,19 @@ public class SyncFragment extends BaseFragment<SyncFragmentBinding> {
protected void initData(Bundle savedInstanceState) {
}
private void showCoboInfo() {
ModalDialog modalDialog = ModalDialog.newInstance();
CommonModalBinding binding = DataBindingUtil.inflate(
LayoutInflater.from(mActivity), R.layout.common_modal,
null, false);
binding.title.setText(R.string.export_xpub_guide_text1_cobo);
binding.subTitle.setText(R.string.export_xpub_guide_text2_cobo);
binding.subTitle.setGravity(Gravity.START);
binding.close.setVisibility(View.GONE);
binding.confirm.setText(R.string.know);
binding.confirm.setOnClickListener(vv -> modalDialog.dismiss());
modalDialog.setBinding(binding);
modalDialog.show(mActivity.getSupportFragmentManager(), "");
}
}

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

@ -220,10 +220,21 @@ public class AssetFragment extends BaseFragment<AssetFragmentBinding>
DialogBottomSheetBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity),
R.layout.dialog_bottom_sheet,null,false);
binding.exportXpub.setOnClickListener(v-> {
if (watchWallet == SupportedWatchWallet.GENERIC) {
navigate(R.id.action_to_export_xpub_generic);
} else {
navigate(R.id.action_to_export_xpub_guide);
switch (watchWallet) {
case ELECTRUM:
navigate(R.id.export_electrum_ypub);
break;
case COBO:
navigate(R.id.export_xpub_cobo);
break;
case WASABI:
navigate(R.id.action_to_export_xpub_guide);
break;
case GENERIC:
navigate(R.id.action_to_export_xpub_generic);
break;
case BLUE:
break;
}
dialog.dismiss();

5
app/src/main/java/com/cobo/cold/ui/fragment/main/electrum/ExportXpubGuideFragment.java

@ -22,6 +22,8 @@ import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
import com.cobo.cold.R;
import com.cobo.cold.databinding.ExportSdcardModalBinding;
@ -57,7 +59,8 @@ public class ExportXpubGuideFragment extends BaseFragment<ExportXpubGuideBinding
mBinding.toolbarTitle.setText(getTitle());
mBinding.export.setOnClickListener(v -> export());
if (mActivity instanceof MainActivity) {
mBinding.skip.setVisibility(View.GONE);
mBinding.skip.setOnClickListener( v -> popBackStack(R.id.assetFragment,false));
} else {
mBinding.skip.setOnClickListener(v -> navigate(R.id.action_to_setupCompleteFragment));
}

27
app/src/main/java/com/cobo/cold/ui/fragment/setting/ChooseWatchWalletFragment.java

@ -23,6 +23,7 @@ import android.view.View;
import com.cobo.coinlib.utils.Coins;
import com.cobo.cold.R;
import com.cobo.cold.Utilities;
import com.cobo.cold.ui.MainActivity;
import com.cobo.cold.ui.SetupVaultActivity;
import com.cobo.cold.viewmodel.SupportedWatchWallet;
@ -31,6 +32,7 @@ import java.util.Arrays;
import static com.cobo.cold.ui.fragment.Constants.KEY_TITLE;
import static com.cobo.cold.ui.fragment.setting.MainPreferenceFragment.SETTING_ADDRESS_FORMAT;
import static com.cobo.cold.ui.fragment.setting.MainPreferenceFragment.SETTING_CHOOSE_WATCH_WALLET;
import static com.cobo.cold.viewmodel.SupportedWatchWallet.getSupportedWatchWallet;
public class ChooseWatchWalletFragment extends ListPreferenceFragment {
@ -54,6 +56,31 @@ public class ChooseWatchWalletFragment extends ListPreferenceFragment {
adapter.setItems(Arrays.asList(entries));
}
mBinding.list.setAdapter(adapter);
mBinding.confirm.setText(R.string.next);
mBinding.confirm.setOnClickListener(v -> next());
if (mActivity instanceof MainActivity) {
mBinding.confirm.setVisibility(View.VISIBLE);
}
}
private void next() {
int navId = 0;
Bundle data = new Bundle();
SupportedWatchWallet selectWatchOnlyWallet = getSupportedWatchWallet(mActivity);
switch (selectWatchOnlyWallet) {
case ELECTRUM:
case GENERIC:
data.putInt(KEY_TITLE, R.string.select_address_format);
navId = R.id.action_to_selectAddressFormatFragment;
break;
case COBO:
case WASABI:
case BLUE:
navId = R.id.action_to_export_xpub_guide;
break;
}
navigate(navId, data);
}
@Override

2
app/src/main/java/com/cobo/cold/ui/fragment/setting/MainPreferenceFragment.java

@ -274,7 +274,7 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
break;
case SETTING_CHOOSE_WATCH_WALLET:
Bundle data = new Bundle();
data.putInt(Constants.KEY_TITLE, R.string.setting_language);
data.putInt(Constants.KEY_TITLE, R.string.choose_watch_only_wallet);
Navigation.findNavController(Objects.requireNonNull(getView()))
.navigate(R.id.action_to_chooseWatchOnly, data);
break;

38
app/src/main/java/com/cobo/cold/ui/fragment/setup/SelectAddressFormatFragment.java

@ -17,12 +17,17 @@
package com.cobo.cold.ui.fragment.setup;
import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import com.cobo.coinlib.utils.Coins;
import com.cobo.cold.R;
import com.cobo.cold.ui.MainActivity;
import com.cobo.cold.databinding.ModalWithTwoButtonBinding;
import com.cobo.cold.ui.fragment.setting.ListPreferenceFragment;
import com.cobo.cold.ui.modal.ModalDialog;
import com.cobo.cold.viewmodel.SupportedWatchWallet;
import static com.cobo.cold.ui.fragment.setting.MainPreferenceFragment.SETTING_ADDRESS_FORMAT;
@ -35,13 +40,15 @@ public class SelectAddressFormatFragment extends ListPreferenceFragment {
mBinding.confirm.setVisibility(View.VISIBLE);
mBinding.confirm.setText(R.string.next);
mBinding.confirm.setOnClickListener(v -> next());
if (mActivity instanceof MainActivity) {
mBinding.confirm.setVisibility(View.GONE);
}
}
private void next() {
navigate(R.id.action_to_export_xpub_guide);
if (SupportedWatchWallet.getSupportedWatchWallet(mActivity)
== SupportedWatchWallet.GENERIC) {
navigate(R.id.action_to_export_xpub_generic);
} else {
navigate(R.id.action_to_export_xpub_guide);
}
}
@Override
@ -69,8 +76,25 @@ public class SelectAddressFormatFragment extends ListPreferenceFragment {
String old = value;
value = values[position].toString();
if (!old.equals(value)) {
prefs.edit().putString(getKey(), value).apply();
adapter.notifyDataSetChanged();
ModalDialog dialog = new ModalDialog();
ModalWithTwoButtonBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mActivity),
R.layout.modal_with_two_button,
null, false);
binding.title.setText(R.string.confirm_toggle);
binding.subTitle.setText(R.string.toggle_address_hint);
binding.left.setText(R.string.toggle_later);
binding.left.setOnClickListener(v -> {
dialog.dismiss();
value = old;
});
binding.right.setText(R.string.toggle_confirm);
binding.right.setOnClickListener(v -> {
dialog.dismiss();
prefs.edit().putString(getKey(), value).apply();
adapter.notifyDataSetChanged();
});
dialog.setBinding(binding);
dialog.show(mActivity.getSupportFragmentManager(), "");
}
}
}

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

@ -51,7 +51,7 @@
android:textSize="15sp"
android:textStyle="bold" />
<TextView
<com.cobo.cold.ui.views.SpanedTextView
android:id="@+id/sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

5
app/src/main/res/layout/export_xpub.xml

@ -45,7 +45,7 @@
android:layout_marginEnd="20dp"
android:ellipsize="middle"
android:singleLine="true"
android:text="@string/electrum_compatibility"
android:text="@string/export_wallet"
android:textColor="@android:color/white"
android:textSize="15sp" />
</androidx.appcompat.widget.Toolbar>
@ -72,7 +72,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/scan_xpub"
android:layout_marginHorizontal="16dp"
android:text="@string/scan_qrcode_with_generic_wallet"
android:textColor="@color/white"
android:textSize="15sp"
android:textStyle="bold" />

4
app/src/main/res/layout/setup_watch_wallet.xml

@ -45,14 +45,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="17sp"
android:textSize="15sp"
android:textStyle="bold"
android:layout_marginTop="32dp"
android:text="@string/choose_watch_only_wallet"
/>
<fragment
android:id="@+id/list"
android:id="@+id/choose_watch_wallet"
android:name="com.cobo.cold.ui.fragment.setting.ChooseWatchWalletFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

29
app/src/main/res/layout/sync.xml

@ -27,17 +27,28 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<com.cobo.cold.ui.views.SpanedTextView
android:id="@+id/hin1"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="@color/white"
android:textStyle="bold"
android:layout_gravity="center"
android:text="@string/sync_hint1" />
android:layout_marginTop="10dp"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/sync_hint1"
android:textColor="@color/white"
android:textSize="15sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/info"
android:layout_width="30dp"
android:layout_height="30dp"
android:padding="5dp"
android:src="@drawable/info" />
</LinearLayout>
<include
android:id="@+id/qrcode_layout"
layout="@layout/dynamic_qrcode" />

1
app/src/main/res/layout/sync_fragment.xml

@ -64,5 +64,6 @@
android:text="@string/complete"/>
</LinearLayout>
</layout>

45
app/src/main/res/navigation/nav_graph_main.xml

@ -163,7 +163,23 @@
<fragment
android:id="@+id/chooseWatchOnly"
android:name="com.cobo.cold.ui.fragment.setting.ChooseWatchWalletFragment"
android:label="ChooseWatchOnlyFragment" />
android:label="ChooseWatchOnlyFragment" >
<action
android:id="@id/action_to_selectAddressFormatFragment"
app:destination="@id/selectAddressFormatFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right"/>
<action
android:id="@id/action_to_export_xpub_guide"
app:destination="@id/exportXpubGuideFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right"/>
</fragment>
<fragment
android:id="@+id/syncFragment"
android:name="com.cobo.cold.ui.fragment.SyncFragment"
@ -268,6 +284,19 @@
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right" />
<action android:id="@id/export_electrum_ypub"
app:destination="@id/electrumExportFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right" />
<action android:id="@id/export_xpub_cobo"
app:destination="@id/syncFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right" />
</fragment>
<fragment
@ -311,6 +340,20 @@
android:id="@id/selectAddressFormatFragment"
android:name="com.cobo.cold.ui.fragment.setup.SelectAddressFormatFragment"
android:label="SelectAddressFormatFragment">
<action
android:id="@id/action_to_export_xpub_guide"
app:destination="@id/exportXpubGuideFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right"/>
<action
android:id="@id/action_to_export_xpub_generic"
app:destination="@id/exportGenericXpubFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@android:anim/slide_in_left"
app:popExitAnim="@android:anim/slide_out_right"/>
</fragment>
<fragment
android:id="@+id/txListFragment"

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

@ -310,6 +310,7 @@
<string name="master_pubkey_not_match">该交易无法识别,您的 Cobo 金库与此观察钱包不匹配。</string>
<string name="change">找零</string>
<string name="electrum_compatibility">适配 Electrum</string>
<string name="generic_compatibility">适配通用钱包</string>
<string name="identification_failed">交易识别失败</string>
<string name="from_electrum">来自Electrum</string>
<string name="update_failed">升级失败</string>
@ -374,7 +375,7 @@
<string name="p2pkh">支付给公钥哈希</string>
<string name="nested_segwit">隔离见证兼容</string>
<string name="txid">交易ID</string>
<string name="skip_export">暂不导出</string>
<string name="skip_export">已导出 / 暂不导出</string>
<string name="choose_watch_only_wallet">选择观察钱包</string>
<string name="switch_watch_only_wallet_guide">切换观察钱包可前往【菜单--设置--选择观察钱包】</string>
<string name="wallet_info">钱包信息</string>
@ -387,6 +388,11 @@
<string name="wallet_info_hint">*请不要随意泄露该信息(可通过 Public Key 获取钱包地址及知道地址上存有的资产)</string>
<string name="confirm_add_address">确认创建</string>
<string name="watch_wallet_not_match">请使用%s生成待签交易</string>
<string name="scan_qrcode_with_generic_wallet">请用已适配 Cobo 金库的钱包扫描二维码</string>
<string name="confirm_toggle">确认是否切换</string>
<string name="toggle_address_hint">切换地址格式后,您的收款地址、导出钱包、钱包信息都将切换,您需导出该地址格式的观察钱包</string>
<string name="toggle_later">暂不切换</string>
<string name="toggle_confirm">确认切换</string>
<string-array name="watch_wallet_list">
<item>Cobo 金库 App</item>
<item>Electrum</item>

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

@ -366,6 +366,7 @@
<string name="master_pubkey_not_match">Transaction not recognized. Your Cobo Vault has not been successfully paired with the watch-only wallet.</string>
<string name="change">Change</string>
<string name="electrum_compatibility">Electrum Watch-Only Wallet</string>
<string name="generic_compatibility">Generic Wallet</string>
<string name="identification_failed">Identification Failed</string>
<string name="from_electrum">From Electrum</string>
<string name="update_failed">Update failed</string>
@ -430,7 +431,7 @@
<string name="p2pkh">Pay To Public Key Hash</string>
<string name="nested_segwit">Nested SegWit</string>
<string name="txid">TxID</string>
<string name="skip_export">Export Later</string>
<string name="skip_export">Exported / Export Later</string>
<string name="choose_watch_only_wallet">Choose Watch Wallet</string>
<string name="switch_watch_only_wallet_guide">Go to Menu > Setting > Watch-only wallet to switch</string>
<string name="wallet_info">Wallet Info</string>
@ -443,4 +444,9 @@
<string name="wallet_info_hint">*Do not share Public Key with others, Account Extended Public Key can get your addresses and find out how may coins you have</string>
<string name="confirm_add_address">Confirm</string>
<string name="watch_wallet_not_match">Please use %s generate unsigned transaction</string>
<string name="scan_qrcode_with_generic_wallet">Please scan the QR code with the wallet that has been adapted to the Cobo vault</string>
<string name="confirm_toggle">确认是否切换</string>
<string name="toggle_address_hint">切换地址格式后,您的收款地址、导出钱包、钱包信息都将切换,您需导出该地址格式的观察钱包</string>
<string name="toggle_later">暂不切换</string>
<string name="toggle_confirm">确认切换</string>
</resources>

Loading…
Cancel
Save