Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New alternate row colors option and UI for Blotter and Account list. #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ResourceCursorAdapter;
import android.widget.TextView;

Expand Down Expand Up @@ -110,6 +112,19 @@ public void bindView(View view, Context context, Cursor cursor) {
v.rightView.setVisibility(View.GONE);
v.progressBar.setVisibility(View.GONE);
}
alternateColorIfNeeded(v, context, cursor);
}

protected void alternateColorIfNeeded(AccountListItemHolder v, Context context, Cursor cursor) {
if(MyPreferences.isAccountAlternateColors(context)) {
if(cursor.getPosition() %2 == 1) {
v.layout.setBackgroundColor(Color.argb(255, 31, 31, 31));
} else {
v.layout.setBackgroundColor(Color.TRANSPARENT);
}
} else {
v.layout.setBackgroundColor(Color.TRANSPARENT);
}
}

private static class AccountListItemHolder {
Expand All @@ -121,6 +136,7 @@ private static class AccountListItemHolder {
TextView rightCenterView;
TextView rightView;
ProgressBar progressBar;
RelativeLayout layout;

public static View create(View view) {
AccountListItemHolder v = new AccountListItemHolder();
Expand All @@ -134,6 +150,7 @@ public static View create(View view) {
v.rightView.setVisibility(View.GONE);
v.progressBar = view.findViewById(R.id.progress);
v.progressBar.setVisibility(View.GONE);
v.layout = view.findViewById(R.id.account_list_item_layout);
view.setTag(v);
return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ public void onClick(View arg0) {
boolean isChecked = getCheckedState(id);
v.checkBox.setChecked(isChecked);
}
alternateColorIfNeeded(v, context, cursor);
}

protected void alternateColorIfNeeded(BlotterViewHolder v, Context context, Cursor cursor) {
if(MyPreferences.isBlotterAlternateColors(context)) {
if(cursor.getPosition() %2 == 1) {
v.layout.setBackgroundColor(Color.argb(255, 31, 31, 31));
} else {
v.layout.setBackgroundColor(Color.TRANSPARENT);
}
} else {
v.layout.setBackgroundColor(Color.TRANSPARENT);
}
}

private void setTransactionTitleText(Cursor cursor, TextView noteView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ru.orangesoftware.financisto.db.DatabaseHelper.BlotterColumns;
import ru.orangesoftware.financisto.model.Currency;
import ru.orangesoftware.financisto.utils.CurrencyCache;
import ru.orangesoftware.financisto.utils.MyPreferences;
import ru.orangesoftware.financisto.utils.StringUtil;
import ru.orangesoftware.financisto.utils.Utils;

Expand Down Expand Up @@ -63,7 +64,6 @@ protected void bindView(BlotterViewHolder v, Context context, Cursor cursor) {
String text = generateTransactionTitle(sb, payee, note, location, categoryId, category);
v.centerView.setText(text);
sb.setLength(0);

long currencyId = cursor.getLong(BlotterColumns.from_account_currency_id.ordinal());
Currency c = CurrencyCache.getCurrency(db, currencyId);
long originalCurrencyId = cursor.getLong(BlotterColumns.original_currency_id.ordinal());
Expand Down Expand Up @@ -95,6 +95,6 @@ protected void bindView(BlotterViewHolder v, Context context, Cursor cursor) {
v.rightView.setText(Utils.amountToString(c, balance, false));
removeRightViewIfNeeded(v);
setIndicatorColor(v, cursor);
alternateColorIfNeeded(v, context, cursor);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,16 @@ public static boolean isShowRunningBalance(Context context) {
return sharedPreferences.getBoolean("show_running_balance", true);
}

public static boolean isBlotterAlternateColors(Context context) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
return sharedPreferences.getBoolean("alternate_blotter_rows", true);
}

public static boolean isAccountAlternateColors(Context context) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
return sharedPreferences.getBoolean("alternate_account_rows", true);
}

private static final String DEFAULT = "default";

public static Context switchLocale(Context context) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/account_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/account_list_item_layout"
android:paddingBottom="2dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@
<string name="day_of_month">День месяца</string>
<string name="show_running_balance">Показывать текущий баланс</string>
<string name="show_running_balance_summary">Показывать текущий баланс в Журнале (требует перезапуска)</string>
<string name="alternate_blotter_row_colors">Чередовать цвет в чётных и нечётных строках Журнала</string>
<string name="alternate_blotter_row_colors_summary">Чередовать цвет строк</string>
<string name="alternate_account_row_colors">Чередовать цвет в чётных и нечётных строках счетов</string>
<string name="alternate_account_row_colors_summary">Чередовать цвет строк</string>
<string name="new_currency">Новая валюта…</string>
<string name="lock_time">Блокировка</string>
<string name="lock_time_summary">Время после истечения которого приложение блокируется ПИНом</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@
<string name="show_running_balance">Show running balance</string>
<string name="show_running_balance_summary">Show account running balance in the blotter (requires restart)</string>

<string name="alternate_blotter_row_colors">Alternate blotter rows color in even and uneven rows</string>
<string name="alternate_blotter_row_colors_summary">Alternate blotter rows color</string>

<string name="alternate_account_row_colors">Alternate account rows color in even and uneven rows</string>
<string name="alternate_account_row_colors_summary">Alternate account rows color</string>

<string name="new_currency">New currency…</string>
<string name="lock_time">Lock time</string>
<string name="lock_time_summary">Time to keep main screen active before locking it off</string>
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
android:key="show_menu_button_on_accounts_screen"
android:summary="@string/show_menu_button_on_accounts_screen_summary"
android:title="@string/show_menu_button_on_accounts_screen" />
<CheckBoxPreference
android:defaultValue="false"
android:key="alternate_account_rows"
android:summary="@string/alternate_account_row_colors"
android:title="@string/alternate_account_row_colors_summary" />
</PreferenceScreen>
<PreferenceScreen
android:summary="@string/blotter_screen_summary"
Expand All @@ -73,6 +78,11 @@
android:key="show_running_balance"
android:summary="@string/show_running_balance_summary"
android:title="@string/show_running_balance" />
<CheckBoxPreference
android:defaultValue="false"
android:key="alternate_blotter_rows"
android:summary="@string/alternate_blotter_row_colors"
android:title="@string/alternate_blotter_row_colors_summary" />
</PreferenceScreen>
<PreferenceScreen
android:summary="@string/transaction_screen_summary"
Expand Down