From d488a5c4f593938de317054d2c6702972e7d2228 Mon Sep 17 00:00:00 2001 From: Alberto Boldrini Date: Tue, 11 Oct 2022 17:07:19 +0200 Subject: [PATCH] Add on-chain balance to wallet fragment --- .../zap/fragments/WalletFragment.java | 15 +++- app/src/main/res/layout/fragment_wallet.xml | 71 +++++++++++++++++- docs/screenshot.png | Bin 26193 -> 38522 bytes 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/zapsolutions/zap/fragments/WalletFragment.java b/app/src/main/java/zapsolutions/zap/fragments/WalletFragment.java index a70d9f3b..829a5ff3 100644 --- a/app/src/main/java/zapsolutions/zap/fragments/WalletFragment.java +++ b/app/src/main/java/zapsolutions/zap/fragments/WalletFragment.java @@ -59,6 +59,10 @@ public class WalletFragment extends Fragment implements SharedPreferences.OnShar private TextView mTvPrimaryBalanceUnit; private TextView mTvSecondaryBalance; private TextView mTvSecondaryBalanceUnit; + private TextView mTvOnChainPrimaryBalance; + private TextView mTvOnChainPrimaryBalanceUnit; + private TextView mTvOnChainSecondaryBalance; + private TextView mTvOnChainSecondaryBalanceUnit; private TextView mTvMode; private ConstraintLayout mClBalanceLayout; private ImageView mIvLogo; @@ -102,6 +106,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mTvPrimaryBalanceUnit = view.findViewById(R.id.BalancePrimaryUnit); mTvSecondaryBalance = view.findViewById(R.id.BalanceSecondary); mTvSecondaryBalanceUnit = view.findViewById(R.id.BalanceSecondaryUnit); + mTvOnChainPrimaryBalance = view.findViewById(R.id.OnChainBalancePrimary); + mTvOnChainPrimaryBalanceUnit = view.findViewById(R.id.OnChainBalancePrimaryUnit); + mTvOnChainSecondaryBalance = view.findViewById(R.id.OnChainBalanceSecondary); + mTvOnChainSecondaryBalanceUnit = view.findViewById(R.id.OnChainBalanceSecondaryUnit ); mTvMode = view.findViewById(R.id.mode); mBalanceFadeOutAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.balance_fade_out); mLogoFadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.logo_fade_in); @@ -367,11 +375,16 @@ public void run() { balances = Wallet.getInstance().getDemoBalances(); } - mTvPrimaryBalance.setText(MonetaryUtil.getInstance().getPrimaryDisplayAmount(balances.total())); + mTvPrimaryBalance.setText("⚡ " + MonetaryUtil.getInstance().getPrimaryDisplayAmount(balances.total())); mTvPrimaryBalanceUnit.setText(MonetaryUtil.getInstance().getPrimaryDisplayUnit()); mTvSecondaryBalance.setText(MonetaryUtil.getInstance().getSecondaryDisplayAmount(balances.total())); mTvSecondaryBalanceUnit.setText(MonetaryUtil.getInstance().getSecondaryDisplayUnit()); + mTvOnChainPrimaryBalance.setText("❄ " + MonetaryUtil.getInstance().getPrimaryDisplayAmount(balances.onChainTotal())); + mTvOnChainPrimaryBalanceUnit.setText(MonetaryUtil.getInstance().getPrimaryDisplayUnit()); + mTvOnChainSecondaryBalance.setText(MonetaryUtil.getInstance().getSecondaryDisplayAmount(balances.onChainTotal())); + mTvOnChainSecondaryBalanceUnit.setText(MonetaryUtil.getInstance().getSecondaryDisplayUnit()); + ZapLog.v(LOG_TAG, "Total balance display updated"); } }); diff --git a/app/src/main/res/layout/fragment_wallet.xml b/app/src/main/res/layout/fragment_wallet.xml index a3fe1bcd..afea9d05 100644 --- a/app/src/main/res/layout/fragment_wallet.xml +++ b/app/src/main/res/layout/fragment_wallet.xml @@ -211,6 +211,75 @@ tools:text="sat" /> + + + + + + + + + + + + + + @@ -282,7 +351,7 @@ app:layout_constraintBottom_toBottomOf="@+id/BalanceLayout" app:layout_constraintStart_toEndOf="@+id/BalanceLayout" app:layout_constraintTop_toTopOf="@+id/BalanceLayout" - app:layout_constraintVertical_bias="0.6" + app:layout_constraintVertical_bias="0.5" app:tint="@color/lightningOrange" />