Added option for keyboard margin

pull/217/head
M66B 7 months ago
parent 839665bf2b
commit 0114f05287

@ -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 {

@ -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",

@ -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<String> 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));

@ -87,6 +87,18 @@
app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swKeyboardMargin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_keyboard_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swKeyboard"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swKeyboardNoFullscreen"
android:layout_width="0dp"
@ -95,7 +107,7 @@
android:text="@string/title_advanced_keyboard_no_fullscreen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swKeyboard"
app:layout_constraintTop_toBottomOf="@id/swKeyboardMargin"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -471,6 +471,7 @@
<string name="title_advanced_blocklist_warning">Block lists aren\'t perfect and may block more than just spam!</string>
<string name="title_advanced_keyboard">Show keyboard by default</string>
<string name="title_advanced_keyboard_margin">Add a margin above the keyboard</string>
<string name="title_advanced_keyboard_no_fullscreen">Prevent fullscreen keyboard</string>
<string name="title_advanced_suggest_names">Use names and email addresses</string>
<string name="title_advanced_suggest_local">Suggest locally stored contacts</string>

Loading…
Cancel
Save