From db1bf7652d2b871db7f52bbd1d910310009152ca Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 4 Jul 2021 10:24:36 +0200 Subject: [PATCH] Added keyword title edit --- .../eu/faircode/email/AdapterKeyword.java | 130 +++++++++++++----- .../eu/faircode/email/AdapterMessage.java | 34 +++-- .../java/eu/faircode/email/EntityMessage.java | 17 --- .../java/eu/faircode/email/TupleKeyword.java | 27 +++- .../eu/faircode/email/TupleMessageEx.java | 19 ++- app/src/main/res/layout/item_keyword.xml | 61 +++++++- 6 files changed, 220 insertions(+), 68 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterKeyword.java b/app/src/main/java/eu/faircode/email/AdapterKeyword.java index aba7bd7f67..7db177d94d 100644 --- a/app/src/main/java/eu/faircode/email/AdapterKeyword.java +++ b/app/src/main/java/eu/faircode/email/AdapterKeyword.java @@ -24,13 +24,18 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.inputmethod.InputMethodManager; import android.widget.CheckBox; import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.ImageButton; import androidx.annotation.NonNull; +import androidx.constraintlayout.widget.Group; import androidx.lifecycle.LifecycleOwner; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; @@ -49,6 +54,7 @@ public class AdapterKeyword extends RecyclerView.Adapter 0) - keywords.append(" "); + if (ssb.length() > 0) + ssb.append(' '); - // Thunderbird - String keyword = EntityMessage.getKeywordAlias(context, message.keywords[i]); - keywords.append(keyword); + String keyword = message.keyword_titles[i]; + ssb.append(keyword); - if (message.keyword_colors != null && - message.keyword_colors[i] != null) { - int len = keywords.length(); - keywords.setSpan( + if (message.keyword_colors[i] != null) { + int len = ssb.length(); + ssb.setSpan( new ForegroundColorSpan(message.keyword_colors[i]), len - keyword.length(), len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } } - return keywords; + return ssb; } ItemDetailsLookup.ItemDetails getItemDetails(@NonNull MotionEvent motionEvent) { @@ -6796,6 +6800,14 @@ public class AdapterMessage extends RecyclerView.Adapter color = new ArrayList<>(); + List titles = new ArrayList<>(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); for (int i = 0; i < this.keywords.length; i++) { - String key = "keyword." + this.keywords[i]; - if (prefs.contains(key)) - color.add(prefs.getInt(key, Color.GRAY)); + String keyword = this.keywords[i]; + + String keyColor1 = "kwcolor." + keyword; + String keyColor2 = "keyword." + keyword; // legacy + if (prefs.contains(keyColor1)) + color.add(prefs.getInt(keyColor1, Color.GRAY)); + else if (prefs.contains(keyColor2)) + color.add(prefs.getInt(keyColor2, Color.GRAY)); else color.add(null); + + String keyTitle = "kwtitle." + keyword; + String def = TupleKeyword.getDefaultKeywordAlias(context, keyword); + titles.add(prefs.getString(keyTitle, def)); } this.keyword_colors = color.toArray(new Integer[0]); + this.keyword_titles = titles.toArray(new String[0]); } String getRemark() { diff --git a/app/src/main/res/layout/item_keyword.xml b/app/src/main/res/layout/item_keyword.xml index 93987ada0e..c97680e57b 100644 --- a/app/src/main/res/layout/item_keyword.xml +++ b/app/src/main/res/layout/item_keyword.xml @@ -18,19 +18,76 @@ android:text="Keyword" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintBottom_toBottomOf="@+id/btnColor" - app:layout_constraintEnd_toStartOf="@+id/btnColor" + app:layout_constraintEnd_toStartOf="@+id/ibEdit" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/btnColor" /> + + + + + + + + + +