Added option to always show images on showing original messages

This commit is contained in:
M66B 2019-11-04 09:38:01 +01:00
parent 1e9ef96d5f
commit d7a104b8f9
4 changed files with 33 additions and 6 deletions

View File

@ -2508,11 +2508,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onShow(final TupleMessageEx message, boolean full) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean current = properties.getValue(full ? "full" : "images", message.id);
boolean asked = properties.getValue(full ? "full_asked" : "images_asked", message.id);
if (current || asked) {
if (current) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
for (Address address : message.from) {
String from = ((InternetAddress) address).getAddress();
@ -2529,6 +2530,17 @@ 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 cbAlwaysImages = dview.findViewById(R.id.cbAlwaysImages);
if (full)
cbAlwaysImages.setChecked(prefs.getBoolean("html_always_images", false));
cbAlwaysImages.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("html_always_images", isChecked).apply();
}
});
if (message.from == null || message.from.length == 0)
cbNotAgain.setVisibility(View.GONE);
@ -2543,7 +2555,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
for (Address address : message.from) {
String from = ((InternetAddress) address).getAddress();
@ -2557,7 +2568,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
TextView tvDark = dview.findViewById(R.id.tvDark);
tvDark.setVisibility(Helper.isDarkTheme(context) ? View.VISIBLE : View.GONE);
} else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
ImageView ivInfo = dview.findViewById(R.id.ivInfo);
@ -2581,9 +2591,15 @@ 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);
if (full)
if (full) {
boolean images = prefs.getBoolean("html_always_images", false);
if (images) {
properties.setValue("images", message.id, true);
onShowImagesConfirmed(message);
}
onShowFullConfirmed(message);
onShowImagesConfirmed(message);
} else
onShowImagesConfirmed(message);
}
})
.setNegativeButton(android.R.string.cancel, null)

View File

@ -68,7 +68,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private final static String[] RESET_QUESTIONS = new String[]{
"welcome", "crash_reports_asked",
"print_html_confirmed",
"html_always_images", "print_html_confirmed",
"identities_asked", "delete_ref_confirmed", "send_dialog"
};

View File

@ -40,5 +40,15 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDark" />
<CheckBox
android:id="@+id/cbAlwaysImages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
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" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

View File

@ -606,6 +606,7 @@
<string name="title_ask_discard">Discard draft?</string>
<string name="title_ask_show_html">Showing the original message can leak privacy sensitive information</string>
<string name="title_ask_show_html_remark">Displaying the original message with a dark background is not possible because it can cause invisible dark texts and images</string>
<string name="title_ask_show_html_images">Always show images on showing original messages</string>
<string name="title_ask_show_image">Showing images can leak privacy sensitive information</string>
<string name="title_ask_show_image_hint">Images recognized as tracking images will not be shown</string>
<string name="title_ask_delete_ref">Delete replied/forwarded message text? This cannot be undone.</string>