From 23790c87ba375b0152bbf38c997b074dc7aaa993 Mon Sep 17 00:00:00 2001 From: JeanGarf Date: Sat, 7 Mar 2020 21:54:32 +0100 Subject: [PATCH] #876 - Add shallDisplayAbsValue parameter in displayBalance(...) --- .../gnucash/android/model/AccountType.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/gnucash/android/model/AccountType.java b/app/src/main/java/org/gnucash/android/model/AccountType.java index 245819b1f..130b1d83a 100644 --- a/app/src/main/java/org/gnucash/android/model/AccountType.java +++ b/app/src/main/java/org/gnucash/android/model/AccountType.java @@ -59,23 +59,28 @@ public enum AccountType { } AccountType() { + this(TransactionType.CREDIT); } /** * Display the balance of a transaction in a text view and format the text color to match the sign of the amount + * * @param balanceTextView {@link android.widget.TextView} where balance is to be displayed * @param balance {@link org.gnucash.android.model.Money} balance (>0 or <0) to display */ public void displayBalance(final TextView balanceTextView, - final Money balance) { + final Money balance, + final boolean shallDisplayAbsValue) { // // Display amount // - // TODO TW C 2020-03-06 : Déterminer qui doit dire s'il faut afficher un nombre négatif ou sa valeur absolue - balanceTextView.setText(balance.formattedString()); + balanceTextView.setText(shallDisplayAbsValue + ? balance.abs() + .formattedString() + : balance.formattedString()); // // Define amount color @@ -103,6 +108,21 @@ public void displayBalance(final TextView balanceTextView, balanceTextView.setTextColor(fontColor); } + /** + * Display the balance of a transaction in a text view and format the text color to match the sign of the amount + * + * @param balanceTextView + * {@link android.widget.TextView} where balance is to be displayed + * @param balance + * {@link org.gnucash.android.model.Money} balance (>0 or <0) to display + */ + public void displayBalance(final TextView balanceTextView, + final Money balance) { + + displayBalance(balanceTextView, + balance, + false); + } /** * Compute red/green color according to accountType and isCreditAmount *