From 0114f0528775c2ee80b4111426c8544ceb23b20e Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 14 Feb 2025 14:25:46 +0100 Subject: [PATCH] Added option for keyboard margin --- .../main/java/eu/faircode/email/ActivityBase.java | 5 ++++- .../java/eu/faircode/email/FragmentOptions.java | 2 +- .../eu/faircode/email/FragmentOptionsSend.java | 12 +++++++++++- app/src/main/res/layout/fragment_options_send.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index dbedd63db2..06a1ce8ccb 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -108,6 +108,9 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean hide_toolbar = prefs.getBoolean("hide_toolbar", !BuildConfig.PLAY_STORE_RELEASE); boolean edge_to_edge = prefs.getBoolean("edge_to_edge", false); + boolean keyboard_margin = prefs.getBoolean("keyboard_margin", false); + + int bnv_height = Helper.dp2pixels(this, 24 + 2 * 8); // icon size + 2 x margin int colorPrimary = Helper.resolveColor(this, androidx.appcompat.R.attr.colorPrimary); double lum = ColorUtils.calculateLuminance(colorPrimary); @@ -223,7 +226,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc int b = v.getPaddingBottom(); if (Helper.isKeyboardVisible(v)) { int bottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom; - int pad = Math.max(0, bottom - insets.bottom); + int pad = Math.max(0, bottom - insets.bottom + (keyboard_margin ? bnv_height : 0)); if (b != pad) v.setPaddingRelative(0, 0, 0, pad); } else { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index abc905b48c..9bd213da17 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -165,7 +165,7 @@ public class FragmentOptions extends FragmentBase { "collapse_quotes", "image_placeholders", "inline_images", "seekbar", "actionbar", "actionbar_swap", "actionbar_color", "group_category", "autoscroll", "swipenav", "updown", "reversed", "swipe_close", "swipe_move", "autoexpand", "autoclose", "onclose", - "auto_hide_answer", "swipe_reply", + "keyboard_margin", "auto_hide_answer", "swipe_reply", "move_thread_all", "move_thread_sent", "language_detection", "quick_filter", "quick_scroll", "quick_actions", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index f92da68ddb..737ed638a2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -73,6 +73,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private View view; private ImageButton ibHelp; private SwitchCompat swKeyboard; + private SwitchCompat swKeyboardMargin; private SwitchCompat swKeyboardNoFullscreen; private SwitchCompat swSuggestNames; private SwitchCompat swSuggestSent; @@ -140,7 +141,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swSendPartial; final static List RESET_OPTIONS = Collections.unmodifiableList(Arrays.asList( - "keyboard", "keyboard_no_fullscreen", + "keyboard", "keyboard_margin", "keyboard_no_fullscreen", "suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "suggest_account", "auto_identity", "purge_contact_age", "purge_contact_freq", "send_reminders", "send_chips", "send_nav_color", "send_pending", @@ -173,6 +174,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc ibHelp = view.findViewById(R.id.ibHelp); swKeyboard = view.findViewById(R.id.swKeyboard); + swKeyboardMargin = view.findViewById(R.id.swKeyboardMargin); swKeyboardNoFullscreen = view.findViewById(R.id.swKeyboardNoFullscreen); swSuggestNames = view.findViewById(R.id.swSuggestNames); swSuggestSent = view.findViewById(R.id.swSuggestSent); @@ -297,6 +299,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + swKeyboardMargin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("keyboard_margin", checked).apply(); + } + }); + swKeyboardNoFullscreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -988,6 +997,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc int purge_contact_freq = prefs.getInt("purge_contact_freq", 0); swKeyboard.setChecked(prefs.getBoolean("keyboard", true)); + swKeyboardMargin.setChecked(prefs.getBoolean("keyboard_margin", false)); swKeyboardNoFullscreen.setChecked(prefs.getBoolean("keyboard_no_fullscreen", false)); swSuggestNames.setChecked(prefs.getBoolean("suggest_names", true)); swSuggestSent.setChecked(prefs.getBoolean("suggest_sent", true)); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 0e16eb6734..fe5df0f1eb 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -87,6 +87,18 @@ app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral" app:switchPadding="12dp" /> + + Block lists aren\'t perfect and may block more than just spam! Show keyboard by default + Add a margin above the keyboard Prevent fullscreen keyboard Use names and email addresses Suggest locally stored contacts