From de37b168fb4f51a1acfcead99053dd22cd6e5626 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 19 Jan 2021 14:06:22 +0100 Subject: [PATCH] Allow always images / original text for sender domain --- .../eu/faircode/email/AdapterMessage.java | 56 +++++++++++++++---- app/src/main/res/layout/dialog_show_full.xml | 15 ++++- .../main/res/layout/dialog_show_images.xml | 13 ++++- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 9163afa6ae..23dd5dfc55 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1899,11 +1899,17 @@ public class AdapterMessage extends RecyclerView.Adapter froms = new ArrayList<>(); - for (Address address : message.from) - froms.add(((InternetAddress) address).getAddress()); + List domains = new ArrayList<>(); + for (Address address : message.from) { + String from = ((InternetAddress) address).getAddress(); + froms.add(from); + int at = from.indexOf('@'); + String domain = (at < 0 ? from : from.substring(at)); + domains.add(domain); + } cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, TextUtils.join(", ", froms))); + cbNotAgainDomain.setText(context.getString(R.string.title_no_ask_for_again, + TextUtils.join(", ", domains))); } + cbNotAgainDomain.setEnabled(false); cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - SharedPreferences.Editor editor = prefs.edit(); - for (Address sender : message.from) { - String from = ((InternetAddress) sender).getAddress(); - editor.putBoolean(from + (full ? ".show_full" : ".show_images"), isChecked); - } - editor.apply(); + cbNotAgainDomain.setEnabled(isChecked); } }); @@ -3729,6 +3746,21 @@ public class AdapterMessage extends RecyclerView.Adapter + + + app:layout_constraintTop_toBottomOf="@id/cbNotAgainDomain" /> \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_show_images.xml b/app/src/main/res/layout/dialog_show_images.xml index fe865725fc..242c139148 100644 --- a/app/src/main/res/layout/dialog_show_images.xml +++ b/app/src/main/res/layout/dialog_show_images.xml @@ -60,11 +60,22 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="12dp" - android:text="@string/title_no_ask_again" + android:text="@string/title_no_ask_for_again" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvTracking" /> + +