From 9a8b9bb8f2c1e2ade1c0da70bc1c98d49245ef8c Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 12 Jan 2019 08:07:06 +0000 Subject: [PATCH] Added option for automatically resizing of images --- FAQ.md | 6 ++++-- .../java/eu/faircode/email/FragmentCompose.java | 5 ++++- .../java/eu/faircode/email/FragmentOptions.java | 10 ++++++++++ app/src/main/res/layout/fragment_options.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/FAQ.md b/FAQ.md index e92fad16a7..450ac19d41 100644 --- a/FAQ.md +++ b/FAQ.md @@ -985,9 +985,11 @@ If your provider requires an unsupported authentication method, you'll likely ge **(63) How are images resized for displaying on screens?** -After adding an inline image or an image attachment you might be asked if you want to reduce the image size for displaying on a screens. -If you answer "yes", the image will be resized to a maximum width and height of about 1920 pixels and saved with a compression ratio of 90 out of 100. +Large inline or attached images will automatically be resized for displaying on screens. +This is because email messages are limited in size, depending on the provider mostly between 10 and 50 MB. +Image will be resized to a maximum width and height of about 1280 pixels and saved with a compression ratio of 90 out of 100. Images are scaled down using whole number factors to reduce memory usage and to retain image quality. +There is an advanced option to disable automatically resizing of image attachments.
diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 15aca0ed90..d5400e8539 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1312,7 +1312,10 @@ public class FragmentCompose extends FragmentEx { } } - if (image && + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean autoresize = prefs.getBoolean("autoresize", true); + + if ((image || autoresize) && ("image/jpeg".equals(attachment.type) || "image/png".equals(attachment.type))) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index e69e8aa537..c5ae9ad54c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -76,6 +76,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS private SwitchCompat swAutoMove; private SwitchCompat swConfirm; private SwitchCompat swSender; + private SwitchCompat swAutoResize; private SwitchCompat swAutoSend; private SwitchCompat swLight; @@ -118,6 +119,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS swAutoMove = view.findViewById(R.id.swAutoMove); swConfirm = view.findViewById(R.id.swConfirm); swSender = view.findViewById(R.id.swSender); + swAutoResize = view.findViewById(R.id.swAutoResize); swAutoSend = view.findViewById(R.id.swAutoSend); swLight = view.findViewById(R.id.swLight); @@ -348,6 +350,14 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS } }); + swAutoResize.setChecked(prefs.getBoolean("autoresize", true)); + swAutoResize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("autoresize", checked).apply(); + } + }); + swAutoSend.setChecked(!prefs.getBoolean("autosend", false)); swAutoSend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override diff --git a/app/src/main/res/layout/fragment_options.xml b/app/src/main/res/layout/fragment_options.xml index 8f1db9fd3d..8d0b3a80e5 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -444,6 +444,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swSender" /> + + Confirm moving messages Confirm actions that might leak privacy sensitive information Allow editing sender address + Automatically resize images for displaying on screens Confirm sending messages Check for updates @@ -319,7 +320,6 @@ Send View Send after … - Reduce size of %1$s for displaying on screens? Nothing selected Bold