]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix focused comment text color on re-configuration; stop using Colors.defaultTextColor*
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Jun 2020 13:23:56 +0000 (16:23 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 28 Jun 2020 13:23:56 +0000 (16:23 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java
app/src/main/res/layout/new_transaction_row.xml

index 9af8baca40346ed0d2021d825d030665ea4824d9..3049bac4ebf34ef02e9723bd5e4bc7b0f515a174 100644 (file)
@@ -30,6 +30,7 @@ import android.widget.EditText;
 import android.widget.FrameLayout;
 import android.widget.TextView;
 
 import android.widget.FrameLayout;
 import android.widget.TextView;
 
+import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.constraintlayout.widget.ConstraintLayout;
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.constraintlayout.widget.ConstraintLayout;
@@ -69,6 +70,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
     private NewTransactionModel.Item item;
     private TextView tvDate;
     private AutoCompleteTextView tvDescription;
     private NewTransactionModel.Item item;
     private TextView tvDate;
     private AutoCompleteTextView tvDescription;
+    private TextView tvDummy;
     private AutoCompleteTextView tvAccount;
     private TextView tvComment;
     private EditText tvAmount;
     private AutoCompleteTextView tvAccount;
     private TextView tvComment;
     private EditText tvAmount;
@@ -107,6 +109,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
         tvCurrency = itemView.findViewById(R.id.currency);
         tvDate = itemView.findViewById(R.id.new_transaction_date);
         tvDescription = itemView.findViewById(R.id.new_transaction_description);
         tvCurrency = itemView.findViewById(R.id.currency);
         tvDate = itemView.findViewById(R.id.new_transaction_date);
         tvDescription = itemView.findViewById(R.id.new_transaction_description);
+        tvDummy = itemView.findViewById(R.id.dummy_text);
         lHead = itemView.findViewById(R.id.ntr_data);
         lPadding = itemView.findViewById(R.id.ntr_padding);
         final View commentLayout = itemView.findViewById(R.id.comment_layout);
         lHead = itemView.findViewById(R.id.ntr_data);
         lPadding = itemView.findViewById(R.id.ntr_padding);
         final View commentLayout = itemView.findViewById(R.id.comment_layout);
@@ -166,10 +169,10 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
             }
 
             if (id == R.id.comment) {
             }
 
             if (id == R.id.comment) {
-                commentFocusChanged(commentLayout, tvComment, hasFocus);
+                commentFocusChanged(tvComment, hasFocus);
             }
             else if (id == R.id.transaction_comment) {
             }
             else if (id == R.id.transaction_comment) {
-                commentFocusChanged(transactionCommentLayout, tvTransactionComment, hasFocus);
+                commentFocusChanged(tvTransactionComment, hasFocus);
             }
         };
 
             }
         };
 
@@ -292,6 +295,8 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
             }
         };
         editableObserver = this::setEditable;
             }
         };
         editableObserver = this::setEditable;
+        commentFocusChanged(tvTransactionComment, false);
+        commentFocusChanged(tvComment, false);
         focusedAccountObserver = index -> {
             if ((index == null) || !index.equals(getAdapterPosition()) || itemView.hasFocus())
                 return;
         focusedAccountObserver = index -> {
             if ((index == null) || !index.equals(getAdapterPosition()) || itemView.hasFocus())
                 return;
@@ -430,15 +435,18 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
             tvAmount.setMinEms(valid ? 4 : 5);
         };
     }
             tvAmount.setMinEms(valid ? 4 : 5);
         };
     }
-    private void commentFocusChanged(View layout, TextView textView, boolean hasFocus) {
-        int textColor;
+    private void commentFocusChanged(TextView textView, boolean hasFocus) {
+        @ColorInt int textColor;
+        textColor = tvDummy.getTextColors()
+                           .getDefaultColor();
         if (hasFocus) {
         if (hasFocus) {
-            textColor = Colors.defaultTextColor;
             textView.setTypeface(null, Typeface.NORMAL);
             textView.setHint(R.string.transaction_account_comment_hint);
         }
         else {
             textView.setTypeface(null, Typeface.NORMAL);
             textView.setHint(R.string.transaction_account_comment_hint);
         }
         else {
-            textColor = Colors.defaultTextColorDisabled;
+            int alpha = (textColor >> 24 & 0xff);
+            alpha = 3 * alpha / 4;
+            textColor = (alpha << 24) | (0x00ffffff & textColor);
             textView.setTypeface(null, Typeface.ITALIC);
             textView.setHint("");
             if (Misc.isEmptyOrNull(textView.getText())) {
             textView.setTypeface(null, Typeface.ITALIC);
             textView.setHint("");
             if (Misc.isEmptyOrNull(textView.getText())) {
index af8281e2b065f461aecb1ed3d2d5371a91ef7ca8..e85b3c6620a327d8964db911bb830230e83594b7 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?><!--
 <?xml version="1.0" encoding="utf-8"?><!--
-  ~ Copyright © 2019 Damyan Ivanov.
+  ~ Copyright © 2020 Damyan Ivanov.
   ~ This file is part of MoLe.
   ~ MoLe is free software: you can distribute it and/or modify it
   ~ under the term of the GNU General Public License as published by
   ~ This file is part of MoLe.
   ~ MoLe is free software: you can distribute it and/or modify it
   ~ under the term of the GNU General Public License as published by
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:animateLayoutChanges="true"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:animateLayoutChanges="true"
-        android:orientation="horizontal">
+        android:orientation="horizontal"
+        >
 
 
+        <TextView
+            android:id="@+id/dummy_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:visibility="gone"
+            tools:ignore="MissingConstraints"
+            />
         <EditText
             android:id="@+id/new_transaction_date"
             android:layout_width="94dp"
         <EditText
             android:id="@+id/new_transaction_date"
             android:layout_width="94dp"