Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add on-chain balance to wallet fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoBoldrini committed Oct 11, 2022
1 parent acffc0e commit d488a5c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/src/main/java/zapsolutions/zap/fragments/WalletFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
});
Expand Down
71 changes: 70 additions & 1 deletion app/src/main/res/layout/fragment_wallet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,75 @@
tools:text="sat" />
</LinearLayout>

<LinearLayout
android:id="@+id/OnChainBalancePrimaryLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20pt"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/BalanceSecondaryLayout">

<TextView
android:id="@+id/OnChainBalancePrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="38sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Primary" />

<zapsolutions.zap.customView.NonClippingTextView
android:id="@+id/OnChainBalancePrimaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="italic"
tools:text="BTC" />

</LinearLayout>

<LinearLayout
android:id="@+id/OnChainBalanceSecondaryLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/OnChainBalancePrimaryLayout">

<TextView
android:id="@+id/OnChainBalanceSecondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/gray"
android:textSize="15sp"
app:layout_constraintTop_toBottomOf="@id/OnChainBalancePrimary"
tools:text="Secondary" />

<zapsolutions.zap.customView.NonClippingTextView
android:id="@+id/OnChainBalanceSecondaryUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:textAlignment="center"
android:textColor="@color/gray"
android:textSize="15sp"
android:textStyle="italic"
tools:text="sat" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down Expand Up @@ -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" />

<Button
Expand Down
Binary file modified docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d488a5c

Please sign in to comment.