Merge lp:~tlnd/financisto/bug-fixes into lp:~financisto-dev/financisto/trunk

Proposed by tlnd
Status: Merged
Merged at revision: 198
Proposed branch: lp:~tlnd/financisto/bug-fixes
Merge into: lp:~financisto-dev/financisto/trunk
Diff against target: 63 lines (+10/-7)
2 files modified
src/ru/orangesoftware/financisto/activity/AccountActivity.java (+7/-4)
src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java (+3/-3)
To merge this branch: bzr merge lp:~tlnd/financisto/bug-fixes
Reviewer Review Type Date Requested Status
Denis Solonenko Pending
Review via email: mp+63743@code.launchpad.net

Description of the change

Induced by the redesign of the income/expense amount input fields, the handling of the credit card limit is kind of corrupted. While previously the limit had been stored as a positive value, it is stored as a negative one (expense) when creating new accounts -- which is reasonable. However, negative amounts have not been considered, e.g. to visualize the balance in the account list with a colorful bar.

For legacy support, the absolute value is considered now.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ru/orangesoftware/financisto/activity/AccountActivity.java'
--- src/ru/orangesoftware/financisto/activity/AccountActivity.java 2011-02-20 19:39:08 +0000
+++ src/ru/orangesoftware/financisto/activity/AccountActivity.java 2011-06-07 17:47:24 +0000
@@ -130,6 +130,8 @@
130 x.addEditNode(layout, R.string.title, accountTitle); 130 x.addEditNode(layout, R.string.title, accountTitle);
131 currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency, R.string.select_currency);131 currencyText = x.addListNodePlus(layout, R.id.currency, R.id.currency_add, R.string.currency, R.string.select_currency);
132 132
133 limitInput.setExpense();
134 limitInput.disableIncomeExpenseButton();
133 limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput);135 limitAmountView = x.addEditNode(layout, R.string.limit_amount, limitInput);
134 setVisibility(limitAmountView, View.GONE);136 setVisibility(limitAmountView, View.GONE);
135137
@@ -207,7 +209,7 @@
207 String sortOrder = Utils.text(sortOrderText);209 String sortOrder = Utils.text(sortOrderText);
208 account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder);210 account.sortOrder = sortOrder == null ? 0 : Integer.parseInt(sortOrder);
209 account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked();211 account.isIncludeIntoTotals = isIncludedIntoTotals.isChecked();
210 account.limitAmount = limitInput.getAmount();212 account.limitAmount = -Math.abs(limitInput.getAmount());
211 213
212 long accountId = em.saveAccount(account);214 long accountId = em.saveAccount(account);
213 long amount = amountInput.getAmount();215 long amount = amountInput.getAmount();
@@ -329,8 +331,9 @@
329 }331 }
330 332
331 private void selectCurrency(Currency c) {333 private void selectCurrency(Currency c) {
332 currencyText.setText(c.name); 334 currencyText.setText(c.name);
333 amountInput.setCurrency(c);335 amountInput.setCurrency(c);
336 limitInput.setCurrency(c);
334 account.currency = c; 337 account.currency = c;
335 }338 }
336339
@@ -355,8 +358,8 @@
355 /********************************/ 358 /********************************/
356 359
357 isIncludedIntoTotals.setChecked(account.isIncludeIntoTotals);360 isIncludedIntoTotals.setChecked(account.isIncludeIntoTotals);
358 if (account.limitAmount > 0) {361 if (account.limitAmount != 0) {
359 limitInput.setAmount(account.limitAmount);362 limitInput.setAmount(-Math.abs(account.limitAmount));
360 }363 }
361 }364 }
362365
363366
=== modified file 'src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java'
--- src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java 2011-02-20 19:39:08 +0000
+++ src/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java 2011-06-07 17:47:24 +0000
@@ -81,12 +81,12 @@
81 v.bottomView.setText(df.format(new Date(date)));81 v.bottomView.setText(df.format(new Date(date)));
82 82
83 long amount = a.totalAmount; 83 long amount = a.totalAmount;
84 if (type == AccountType.CREDIT_CARD && a.limitAmount > 0) {84 if (type == AccountType.CREDIT_CARD && a.limitAmount != 0) {
85 long balance = a.limitAmount + amount;85 long balance = Math.abs(a.limitAmount) + amount;
86 u.setAmountText(v.rightCenterView, a.currency, amount, false);86 u.setAmountText(v.rightCenterView, a.currency, amount, false);
87 u.setAmountText(v.rightView, a.currency, balance, false);87 u.setAmountText(v.rightView, a.currency, balance, false);
88 v.rightCenterView.setVisibility(View.VISIBLE);88 v.rightCenterView.setVisibility(View.VISIBLE);
89 v.progressBar.setMax((int)a.limitAmount);89 v.progressBar.setMax((int) Math.abs(a.limitAmount));
90 v.progressBar.setProgress((int)(balance > 0 ? balance : 0));90 v.progressBar.setProgress((int)(balance > 0 ? balance : 0));
91 v.progressBar.setVisibility(View.VISIBLE);91 v.progressBar.setVisibility(View.VISIBLE);
92 } else {92 } else {