diff --git a/app/src/main/java/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java b/app/src/main/java/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java index ef3ed35c..beb2d964 100644 --- a/app/src/main/java/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java +++ b/app/src/main/java/ru/orangesoftware/financisto/adapter/AccountListAdapter2.java @@ -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; @@ -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 { @@ -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(); @@ -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; } diff --git a/app/src/main/java/ru/orangesoftware/financisto/adapter/BlotterListAdapter.java b/app/src/main/java/ru/orangesoftware/financisto/adapter/BlotterListAdapter.java index fe14017c..b2f5e45b 100644 --- a/app/src/main/java/ru/orangesoftware/financisto/adapter/BlotterListAdapter.java +++ b/app/src/main/java/ru/orangesoftware/financisto/adapter/BlotterListAdapter.java @@ -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) { diff --git a/app/src/main/java/ru/orangesoftware/financisto/adapter/TransactionsListAdapter.java b/app/src/main/java/ru/orangesoftware/financisto/adapter/TransactionsListAdapter.java index 139f4257..8cc91009 100644 --- a/app/src/main/java/ru/orangesoftware/financisto/adapter/TransactionsListAdapter.java +++ b/app/src/main/java/ru/orangesoftware/financisto/adapter/TransactionsListAdapter.java @@ -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; @@ -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()); @@ -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); } - } diff --git a/app/src/main/java/ru/orangesoftware/financisto/utils/MyPreferences.java b/app/src/main/java/ru/orangesoftware/financisto/utils/MyPreferences.java index 00918fa7..547e15b0 100644 --- a/app/src/main/java/ru/orangesoftware/financisto/utils/MyPreferences.java +++ b/app/src/main/java/ru/orangesoftware/financisto/utils/MyPreferences.java @@ -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) { diff --git a/app/src/main/res/layout/account_list_item.xml b/app/src/main/res/layout/account_list_item.xml index 13c62ed6..14f49aa1 100644 --- a/app/src/main/res/layout/account_list_item.xml +++ b/app/src/main/res/layout/account_list_item.xml @@ -11,6 +11,7 @@ День месяца Показывать текущий баланс Показывать текущий баланс в Журнале (требует перезапуска) + Чередовать цвет в чётных и нечётных строках Журнала + Чередовать цвет строк + Чередовать цвет в чётных и нечётных строках счетов + Чередовать цвет строк Новая валюта… Блокировка Время после истечения которого приложение блокируется ПИНом diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4332cf13..62f64f8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -632,6 +632,12 @@ Show running balance Show account running balance in the blotter (requires restart) + Alternate blotter rows color in even and uneven rows + Alternate blotter rows color + + Alternate account rows color in even and uneven rows + Alternate account rows color + New currency… Lock time Time to keep main screen active before locking it off diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 315cd783..14cc11c0 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -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" /> + +