abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
diff options
context:
space:
mode:
authorMatej Drobnič2025-05-22 23:54:13 +0200
committerGitHub2025-05-22 23:54:13 +0200
commit97355881a855c5d2503f7e518c1e30fc03f88d4e (patch)
treef9abbdb522c1d4dfc478b6716430ef5afdceee0d /srcs/juloo.keyboard2/Keyboard2.java
parenta7312054b56ad3bdbc62d03c774b5942db9852e9 (diff)
downloadunexpected-keyboard-97355881a855c5d2503f7e518c1e30fc03f88d4e.tar.gz
unexpected-keyboard-97355881a855c5d2503f7e518c1e30fc03f88d4e.zip
Better support for foldable devices (#982)
* Add AndroidX WindowManager unfortunately, this seems to be the only way to get fold state, native Android APIs are internal. To add this, we need to update some dependencies, raise java version and raise compile SDK. * adds separate layouts and separate layout settings for folded and unfolded state of the device. The affected settings are: + the margin bottom settings + the horizontal margin settings + the keyboard height settings * Update shell.nix
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 9e54aaf..9ce78f1 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -43,6 +43,8 @@ public class Keyboard2 extends InputMethodService
private Config _config;
+ private FoldStateTracker _foldStateTracker;
+
/** Layout currently visible before it has been modified. */
KeyboardData current_layout_unmodified()
{
@@ -111,13 +113,22 @@ public class Keyboard2 extends InputMethodService
SharedPreferences prefs = DirectBootAwarePreferences.get_shared_preferences(this);
_handler = new Handler(getMainLooper());
_keyeventhandler = new KeyEventHandler(this.new Receiver());
- Config.initGlobalConfig(prefs, getResources(), _keyeventhandler);
+ _foldStateTracker = new FoldStateTracker(this);
+ Config.initGlobalConfig(prefs, getResources(), _keyeventhandler, _foldStateTracker.isUnfolded());
prefs.registerOnSharedPreferenceChangeListener(this);
_config = Config.globalConfig();
_keyboardView = (Keyboard2View)inflate_view(R.layout.keyboard);
_keyboardView.reset();
Logs.set_debug_logs(getResources().getBoolean(R.bool.debug_logs));
ClipboardHistoryService.on_startup(this, _keyeventhandler);
+ _foldStateTracker.setChangedCallback(() -> { refresh_config(); });
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ _foldStateTracker.close();
}
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
@@ -234,7 +245,7 @@ public class Keyboard2 extends InputMethodService
private void refresh_config()
{
int prev_theme = _config.theme;
- _config.refresh(getResources());
+ _config.refresh(getResources(), _foldStateTracker.isUnfolded());
refreshSubtypeImm();
// Refreshing the theme config requires re-creating the views
if (prev_theme != _config.theme)