]> git.ktnx.net Git - mobile-ledger-staging.git/commitdiff
drop a couple of global colour values
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Jun 2020 16:28:29 +0000 (19:28 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Jun 2020 16:28:29 +0000 (19:28 +0300)
replaced with inspecting the textColor of a dummy TextView

app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListAdapter.java
app/src/main/java/net/ktnx/mobileledger/utils/Colors.java
app/src/main/res/layout/transaction_list_row_accounts_table_row.xml

index 3049bac4ebf34ef02e9723bd5e4bc7b0f515a174..f283aee53e124f609bd4084b46ada0920743f5fd 100644 (file)
@@ -46,7 +46,6 @@ import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.ui.CurrencySelectorFragment;
 import net.ktnx.mobileledger.ui.DatePickerFragment;
 import net.ktnx.mobileledger.ui.TextViewClearHelper;
-import net.ktnx.mobileledger.utils.Colors;
 import net.ktnx.mobileledger.utils.DimensionUtils;
 import net.ktnx.mobileledger.utils.Logger;
 import net.ktnx.mobileledger.utils.MLDB;
@@ -502,13 +501,17 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
         }
     }
     private void setCurrencyString(String currency) {
+        @ColorInt int textColor = tvDummy.getTextColors()
+                                         .getDefaultColor();
         if ((currency == null) || currency.isEmpty()) {
             tvCurrency.setText(R.string.currency_symbol);
-            tvCurrency.setTextColor(0x7f000000 + (0x00ffffff & Colors.defaultTextColor));
+            int alpha = (textColor >> 24) & 0xff;
+            alpha = alpha * 3 / 4;
+            tvCurrency.setTextColor((alpha << 24) | (0x00ffffff & textColor));
         }
         else {
             tvCurrency.setText(currency);
-            tvCurrency.setTextColor(Colors.defaultTextColor);
+            tvCurrency.setTextColor(textColor);
         }
     }
     private void setCurrency(Currency currency) {
index f8b870723ac629c7478a165b75f4f778d3d58845..96de4b64a017501b4e7a842717e41def70768119 100644 (file)
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.RecyclerView;
 
@@ -185,6 +186,7 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionRowH
                         // the accounts remain with their default text (set in the layout resource)
                         holder.tableAccounts.addView(row);
                     }
+                    TextView dummyText = row.findViewById(R.id.dummy_text);
                     TextView accName = row.findViewById(R.id.transaction_list_acc_row_acc_name);
                     TextView accComment =
                             row.findViewById(R.id.transaction_list_acc_row_acc_comment);
@@ -208,8 +210,10 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionRowH
                         accName.setText(ss);
                     }
                     else {
-                        accName.setTextColor(Colors.defaultTextColor);
-                        accAmount.setTextColor(Colors.defaultTextColor);
+                        @ColorInt int textColor = dummyText.getTextColors()
+                                                           .getDefaultColor();
+                        accName.setTextColor(textColor);
+                        accAmount.setTextColor(textColor);
                         accName.setText(acc.getAccountName());
                     }
 
index be68ccc70f261e16821cd3ef4c7e7fa92fa1550b..829d1622d93a1c16562a485168451659a2324705 100644 (file)
@@ -54,7 +54,7 @@ public class Colors {
     @ColorInt
     public static int tableRowDarkBG;
     @ColorInt
-    public static int primary, defaultTextColor, defaultTextColorDisabled;
+    public static int primary;
     public static int profileThemeId = -1;
     public static MutableLiveData<Integer> themeWatch = new MutableLiveData<>(0);
     public static int errorTextColor;
@@ -105,9 +105,6 @@ public class Colors {
         tableRowLightBG = tv.data;
         theme.resolveAttribute(R.attr.colorPrimary, tv, true);
         primary = tv.data;
-        theme.resolveAttribute(R.attr.textColor, tv, true);
-        defaultTextColor = tv.data;
-        defaultTextColorDisabled = 0x7f000000 | 0x00ffffff & defaultTextColor;
         theme.resolveAttribute(R.attr.colorAccent, tv, true);
         accent = tv.data;
         theme.resolveAttribute(R.attr.errorTextColor, tv, true);
index 765b818946fd2f18ce07a2ac9e5d0f01cbb2a764..5e058d07a15e5627cef42b9ca208c47a64033ce0 100644 (file)
         android:layout_width="0dp"
         android:layout_height="wrap_content"
         android:layout_weight="5"
-        android:orientation="vertical">
+        android:orientation="vertical"
+        >
+        <TextView
+            android:id="@+id/dummy_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:visibility="gone"
+            />
 
         <TextView
             android:id="@+id/transaction_list_acc_row_acc_name"