Added option to disable PDF preview

This commit is contained in:
M66B 2023-10-14 14:10:35 +02:00
parent f913347455
commit 9630097160
5 changed files with 28 additions and 4 deletions

View File

@ -312,6 +312,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean authentication_indicator;
private boolean infra;
private boolean tld_flags;
private boolean pdf_preview;
private boolean autoclose_unseen;
private boolean collapse_marked;
@ -3650,7 +3651,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
List<EntityAttachment> images = new ArrayList<>();
if (thumbnails && bind_extras) {
for (EntityAttachment attachment : attachments)
if (attachment.isPDF() ||
if ((pdf_preview && attachment.isPDF()) ||
(attachment.isAttachment() && attachment.isImage())) {
images.add(attachment);
if (attachment.available && !attachment.isPDF())
@ -7982,6 +7983,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.authentication_indicator = prefs.getBoolean("authentication_indicator", false);
this.infra = prefs.getBoolean("infra", false);
this.tld_flags = prefs.getBoolean("tld_flags", false);
this.pdf_preview = prefs.getBoolean("pdf_preview", true);
this.language_detection = prefs.getBoolean("language_detection", false);
this.autoclose_unseen = prefs.getBoolean("autoclose_unseen", false);
this.collapse_marked = prefs.getBoolean("collapse_marked", true);

View File

@ -165,7 +165,7 @@ public class FragmentOptions extends FragmentBase {
"biometrics",
"default_light",
"vt_enabled", "vt_apikey",
"webp"
"pdf_preview", "webp"
};
@Override

View File

@ -240,6 +240,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swNativeDkim;
private SwitchCompat swNativeArc;
private EditText etNativeArcWhitelist;
private SwitchCompat swPdfPreview;
private SwitchCompat swWebp;
private SwitchCompat swEasyCorrect;
private SwitchCompat swInfra;
@ -312,7 +313,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"max_backoff_power", "logarithmic_backoff",
"exact_alarms",
"native_dkim", "native_arc", "native_arc_whitelist",
"webp", "easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn",
"pdf_preview", "webp", "easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn",
"app_chooser", "delete_confirmation", "global_keywords", "test_iab"
};
@ -502,6 +503,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swNativeDkim = view.findViewById(R.id.swNativeDkim);
swNativeArc = view.findViewById(R.id.swNativeArc);
etNativeArcWhitelist = view.findViewById(R.id.etNativeArcWhitelist);
swPdfPreview = view.findViewById(R.id.swPdfPreview);
swWebp = view.findViewById(R.id.swWebp);
swEasyCorrect = view.findViewById(R.id.swEasyCorrect);
swInfra = view.findViewById(R.id.swInfra);
@ -1886,6 +1888,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
}
});
swPdfPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("pdf_preview", checked).apply();
}
});
swWebp.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2716,6 +2725,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swNativeArc.setChecked(prefs.getBoolean("native_arc", true));
etNativeArcWhitelist.setEnabled(swNativeDkim.isEnabled() && swNativeDkim.isChecked());
etNativeArcWhitelist.setText(prefs.getString("native_arc_whitelist", null));
swPdfPreview.setChecked(prefs.getBoolean("pdf_preview", true));
swWebp.setChecked(prefs.getBoolean("webp", true));
swEasyCorrect.setChecked(prefs.getBoolean("easy_correct", false));
swInfra.setChecked(prefs.getBoolean("infra", false));

View File

@ -2066,6 +2066,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNativeArc" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPdfPreview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_pdf_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etNativeArcWhitelist"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWebp"
android:layout_width="0dp"
@ -2074,7 +2085,7 @@
android:text="@string/title_advanced_webp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etNativeArcWhitelist"
app:layout_constraintTop_toBottomOf="@id/swPdfPreview"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -908,6 +908,7 @@
<string name="title_advanced_exact_alarms" translatable="false">Use exact timers</string>
<string name="title_advanced_native_dkim" translatable="false">Native DKIM verification</string>
<string name="title_advanced_native_arc" translatable="false">Native ARC verification</string>
<string name="title_advanced_pdf_preview" translatable="false">PDF preview</string>
<string name="title_advanced_webp" translatable="false">Webp</string>
<string name="title_advanced_easy_correct" translatable="false">Easy correct</string>
<string name="title_advanced_infra" translatable="false">Show infrastructure</string>