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 3049bac..f283aee 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 f8b8707..96de4b6 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 be68ccc..829d162 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 765b818..5e058d0 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"