Allow always images / original text for sender domain

pull/193/head
M66B 4 years ago
parent 8e946e9863
commit de37b168fb

@ -1899,11 +1899,17 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message.from != null)
for (Address sender : message.from) {
String from = ((InternetAddress) sender).getAddress();
if (prefs.getBoolean(from + ".show_full", false)) {
if (TextUtils.isEmpty(from))
continue;
int at = from.indexOf('@');
String domain = (at < 0 ? from : from.substring(at));
if (prefs.getBoolean(from + ".show_full", false) ||
prefs.getBoolean(domain + ".show_full", false)) {
properties.setValue("full", message.id, true);
properties.setValue("full_asked", message.id, true);
}
if (prefs.getBoolean(from + ".show_images", false)) {
if (prefs.getBoolean(from + ".show_images", false) ||
prefs.getBoolean(domain + ".show_images", false)) {
properties.setValue("images", message.id, true);
properties.setValue("images_asked", message.id, true);
}
@ -3651,7 +3657,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences.Editor editor = prefs.edit();
for (Address sender : message.from) {
String from = ((InternetAddress) sender).getAddress();
if (TextUtils.isEmpty(from))
continue;
int at = from.indexOf('@');
String domain = (at < 0 ? from : from.substring(at));
editor.remove(from + (full ? ".show_full" : ".show_images"));
editor.remove(domain + (full ? ".show_full" : ".show_images"));
}
editor.apply();
}
@ -3667,6 +3678,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
View dview = LayoutInflater.from(context).inflate(
full ? R.layout.dialog_show_full : R.layout.dialog_show_images, null);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
CheckBox cbNotAgainDomain = dview.findViewById(R.id.cbNotAgainDomain);
CheckBox cbAlwaysImages = dview.findViewById(R.id.cbAlwaysImages);
if (full) {
@ -3680,25 +3692,30 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
});
}
if (message.from == null || message.from.length == 0)
if (message.from == null || message.from.length == 0) {
cbNotAgain.setVisibility(View.GONE);
else {
cbNotAgainDomain.setVisibility(View.GONE);
} else {
List<String> froms = new ArrayList<>();
for (Address address : message.from)
froms.add(((InternetAddress) address).getAddress());
List<String> 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<AdapterMessage.ViewHold
public void onClick(DialogInterface dialog, int which) {
properties.setValue(full ? "full" : "images", message.id, true);
properties.setValue(full ? "full_asked" : "images_asked", message.id, true);
SharedPreferences.Editor editor = prefs.edit();
for (Address sender : message.from) {
String from = ((InternetAddress) sender).getAddress();
if (TextUtils.isEmpty(from))
continue;
int at = from.indexOf('@');
String domain = (at < 0 ? from : from.substring(at));
editor.putBoolean(from + (full ? ".show_full" : ".show_images"),
cbNotAgain.isChecked());
editor.putBoolean(domain + (full ? ".show_full" : ".show_images"),
cbNotAgain.isChecked() && cbNotAgainDomain.isChecked());
}
editor.apply();
if (full)
onShowFullConfirmed(message);
else

@ -36,11 +36,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/tvDark" />
<CheckBox
android:id="@+id/cbNotAgainDomain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="false"
android:text="@string/title_no_ask_for_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
<CheckBox
android:id="@+id/cbAlwaysImages"
android:layout_width="wrap_content"
@ -49,6 +60,6 @@
android:text="@string/title_ask_show_html_images"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
app:layout_constraintTop_toBottomOf="@id/cbNotAgainDomain" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

@ -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" />
<CheckBox
android:id="@+id/cbNotAgainDomain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:enabled="false"
android:text="@string/title_no_ask_for_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotAgain" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpTracking"
android:layout_width="0dp"

Loading…
Cancel
Save