Skip to content

Commit

Permalink
Assign colors to accounts when "Account color in reports" is checked.
Browse files Browse the repository at this point in the history
  • Loading branch information
rivaldi8 committed Apr 27, 2016
1 parent df9a06e commit 36accb0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ private BarData getData() {
if (!accountToColorMap.containsKey(account.getUID())) {
Integer color;
if (mUseAccountColor) {
color = account.getColor();
color = (account.getColor() != Account.DEFAULT_COLOR)
? account.getColor()
: COLORS[accountToColorMap.size() % COLORS.length];
} else {
color = COLORS[accountToColorMap.size() % COLORS.length];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.gnucash.android.R;
import org.gnucash.android.app.GnuCashApplication;
import org.gnucash.android.db.AccountsDbAdapter;
import org.gnucash.android.db.TransactionsDbAdapter;
import org.gnucash.android.model.Account;
import org.gnucash.android.model.AccountType;

Expand Down Expand Up @@ -197,9 +196,15 @@ private PieData getData() {
mReportStartTime, mReportEndTime).asDouble();
if (balance > 0) {
dataSet.addEntry(new Entry((float) balance, dataSet.getEntryCount()));
colors.add(mUseAccountColor
? account.getColor()
: ReportsActivity.COLORS[(dataSet.getEntryCount() - 1) % ReportsActivity.COLORS.length]);
int color;
if (mUseAccountColor) {
color = (account.getColor() != Account.DEFAULT_COLOR)
? account.getColor()
: ReportsActivity.COLORS[(dataSet.getEntryCount() - 1) % ReportsActivity.COLORS.length];
} else {
color = ReportsActivity.COLORS[(dataSet.getEntryCount() - 1) % ReportsActivity.COLORS.length];
}
colors.add(color);
labels.add(account.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ private PieData getData() {
Collections.singletonList(account.getUID()), start, end).asDouble();
if (balance > 0) {
dataSet.addEntry(new Entry((float) balance, dataSet.getEntryCount()));
colors.add(account.getColor());
colors.add(account.getColor() != Account.DEFAULT_COLOR
? account.getColor()
: ReportsActivity.COLORS[(dataSet.getEntryCount() - 1) % ReportsActivity.COLORS.length]);
labels.add(account.getName());
}
}
Expand Down

0 comments on commit 36accb0

Please sign in to comment.