From 62bff1e68ace1a3fb66231f4f84ab2f30b3b04cf Mon Sep 17 00:00:00 2001 From: Helium314 Date: Tue, 19 Dec 2023 00:27:19 +0100 Subject: [PATCH] allow fullscreen mode again, but limit to cases where the keyboard blocks more than 60% of the screen --- .../dslul/openboard/inputmethod/latin/LatinIME.java | 11 +++++++++-- .../inputmethod/latin/settings/Settings.java | 4 ++-- app/src/main/res/values-land/config.xml | 2 +- .../res/values-sw430dp/config-per-form-factor.xml | 2 +- .../res/values-sw600dp/config-per-form-factor.xml | 2 +- .../res/values-sw768dp/config-per-form-factor.xml | 2 +- app/src/main/res/values/config.xml | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java index 43d367d6a..1b5d2eec7 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/LatinIME.java @@ -1320,14 +1320,21 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return false; } // Reread resource value here, because this method is called by the framework as needed. - final boolean isFullscreenModeAllowed = Settings.readUseFullscreenMode(getResources()); + final boolean isFullscreenModeAllowed = Settings.readFullscreenModeAllowed(getResources()); if (super.onEvaluateFullscreenMode() && isFullscreenModeAllowed) { // TODO: Remove this hack. Actually we should not really assume NO_EXTRACT_UI // implies NO_FULLSCREEN. However, the framework mistakenly does. i.e. NO_EXTRACT_UI // without NO_FULLSCREEN doesn't work as expected. Because of this we need this // hack for now. Let's get rid of this once the framework gets fixed. final EditorInfo ei = getCurrentInputEditorInfo(); - return !(ei != null && ((ei.imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0)); + if (ei == null) return false; + final boolean noExtractUi = (ei.imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0; + final boolean noFullscreen = (ei.imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0; + if (noExtractUi || noFullscreen) return false; + if (mKeyboardSwitcher.getVisibleKeyboardView() == null || mSuggestionStripView == null) return false; + final int usedHeight = mKeyboardSwitcher.getVisibleKeyboardView().getHeight() + mSuggestionStripView.getHeight(); + final int availableHeight = getResources().getDisplayMetrics().heightPixels; + return usedHeight > availableHeight * 0.6; // if we have less than 40% available, use fullscreen mode } return false; } diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java index 6f379fa04..f80815c85 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/settings/Settings.java @@ -378,8 +378,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang return prefs.getBoolean(PREF_AUTOSPACE_AFTER_PUNCTUATION, false); } - public static boolean readUseFullscreenMode(final Resources res) { - return res.getBoolean(R.bool.config_use_fullscreen_mode); + public static boolean readFullscreenModeAllowed(final Resources res) { + return res.getBoolean(R.bool.config_fullscreen_mode_allowed); } public static boolean readShowSetupWizardIcon(final SharedPreferences prefs, diff --git a/app/src/main/res/values-land/config.xml b/app/src/main/res/values-land/config.xml index 6366e2ca5..ae6a92f4a 100644 --- a/app/src/main/res/values-land/config.xml +++ b/app/src/main/res/values-land/config.xml @@ -7,7 +7,7 @@ - false + true diff --git a/app/src/main/res/values-sw430dp/config-per-form-factor.xml b/app/src/main/res/values-sw430dp/config-per-form-factor.xml index f9c94fcc7..f14687b19 100644 --- a/app/src/main/res/values-sw430dp/config-per-form-factor.xml +++ b/app/src/main/res/values-sw430dp/config-per-form-factor.xml @@ -15,5 +15,5 @@ false - false + false diff --git a/app/src/main/res/values-sw600dp/config-per-form-factor.xml b/app/src/main/res/values-sw600dp/config-per-form-factor.xml index cf13f6b3f..8b5d49d53 100644 --- a/app/src/main/res/values-sw600dp/config-per-form-factor.xml +++ b/app/src/main/res/values-sw600dp/config-per-form-factor.xml @@ -15,5 +15,5 @@ false - false + false diff --git a/app/src/main/res/values-sw768dp/config-per-form-factor.xml b/app/src/main/res/values-sw768dp/config-per-form-factor.xml index 12e56efe8..898dc94d9 100644 --- a/app/src/main/res/values-sw768dp/config-per-form-factor.xml +++ b/app/src/main/res/values-sw768dp/config-per-form-factor.xml @@ -15,5 +15,5 @@ true - false + false diff --git a/app/src/main/res/values/config.xml b/app/src/main/res/values/config.xml index 7169ab526..012fffc37 100644 --- a/app/src/main/res/values/config.xml +++ b/app/src/main/res/values/config.xml @@ -7,7 +7,7 @@ - false + false 8.0dp