forked from codinguser/gnucash-android
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codinguser#876 - TransactionTypeSwitch does not change amount signum …
…anymore
- Loading branch information
Showing
1 changed file
with
16 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,14 +33,13 @@ | |
|
||
/** | ||
* A special type of {@link android.widget.ToggleButton} which displays the appropriate DEBIT/CREDIT labels for the | ||
* linked account type | ||
* linked account type and update the color of the amount and currency fields as well | ||
* | ||
* checked means CREDIT | ||
* unchecked means DEBIT | ||
* | ||
* @author Ngewi Fet <[email protected]> | ||
*/ | ||
// TODO TW m 2020-03-03 : Should be named SplitTypeToggleButton (or SplitTypeSwitch) instead of TransactionTypeSwitch | ||
public class TransactionTypeSwitch extends SwitchCompat { | ||
|
||
private AccountType mAccountType = AccountType.EXPENSE; | ||
|
@@ -233,6 +232,21 @@ private void setSwitchTextAndColor(final boolean isCredit) { | |
: getTextOff() // DEBIT | ||
); | ||
|
||
// | ||
// Change signum if needed | ||
// | ||
|
||
// BigDecimal amount = mAmountEditText.getValue(); | ||
// | ||
// if (amount != null) { | ||
// if ((isCredit && amount.signum() > 0) //we switched to debit but the amount is +ve | ||
// || (!isCredit && amount.signum() < 0)) { //credit but amount is -ve | ||
// | ||
// mAmountEditText.setValue(amount.negate()); | ||
// } | ||
// | ||
// } | ||
|
||
// | ||
// Set text color of views | ||
// | ||
|
@@ -274,21 +288,6 @@ public void onCheckedChanged(CompoundButton compoundButton, | |
|
||
setSwitchTextAndColor(isCredit); | ||
|
||
// | ||
// Change signum if needed | ||
// | ||
|
||
BigDecimal amount = mAmountEditText.getValue(); | ||
|
||
if (amount != null) { | ||
if ((isCredit && amount.signum() > 0) //we switched to debit but the amount is +ve | ||
|| (!isCredit && amount.signum() < 0)) { //credit but amount is -ve | ||
|
||
mAmountEditText.setValue(amount.negate()); | ||
} | ||
|
||
} | ||
|
||
// | ||
// Call other listeners | ||
// | ||
|