X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionItemHolder.java;h=f283aee53e124f609bd4084b46ada0920743f5fd;hb=ff27cd8c41424676ec046c58448d23cd4313d1dc;hp=9af8baca40346ed0d2021d825d030665ea4824d9;hpb=217da55a224e2ae899d0b50604e2e54f882ec04f;p=mobile-ledger-staging.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java index 9af8baca..f283aee5 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java @@ -30,6 +30,7 @@ import android.widget.EditText; 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; @@ -45,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; @@ -69,6 +69,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder private NewTransactionModel.Item item; private TextView tvDate; private AutoCompleteTextView tvDescription; + private TextView tvDummy; private AutoCompleteTextView tvAccount; private TextView tvComment; private EditText tvAmount; @@ -107,6 +108,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); + 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); @@ -166,10 +168,10 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder } if (id == R.id.comment) { - commentFocusChanged(commentLayout, tvComment, hasFocus); + commentFocusChanged(tvComment, hasFocus); } else if (id == R.id.transaction_comment) { - commentFocusChanged(transactionCommentLayout, tvTransactionComment, hasFocus); + commentFocusChanged(tvTransactionComment, hasFocus); } }; @@ -292,6 +294,8 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder } }; editableObserver = this::setEditable; + commentFocusChanged(tvTransactionComment, false); + commentFocusChanged(tvComment, false); focusedAccountObserver = index -> { if ((index == null) || !index.equals(getAdapterPosition()) || itemView.hasFocus()) return; @@ -430,15 +434,18 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder 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) { - textColor = Colors.defaultTextColor; 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())) { @@ -494,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) {