diff --git a/res/values/values.xml b/res/values/values.xml
index d506011..169fe1a 100644
--- a/res/values/values.xml
+++ b/res/values/values.xml
@@ -6,9 +6,6 @@
28dp
300dp
28dp
-
- 48dp
false
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index b2b01da..eafb236 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -81,7 +81,6 @@ public final class Config
int current_layout_landscape;
int current_layout_unfolded_portrait;
int current_layout_unfolded_landscape;
- public int bottomInsetMin;
private Config(SharedPreferences prefs, Resources res, IKeyEventHandler h, Boolean foldableUnfolded)
{
@@ -176,8 +175,6 @@ public final class Config
current_layout_unfolded_landscape = _prefs.getInt("current_layout_unfolded_landscape", 0);
circle_sensitivity = Integer.valueOf(_prefs.getString("circle_sensitivity", "2"));
clipboard_history_enabled = _prefs.getBoolean("clipboard_history_enabled", false);
- bottomInsetMin = Utils.is_navigation_bar_gestural(res) ?
- (int)res.getDimension(R.dimen.bottom_inset_min) : 0;
}
public int get_current_layout()
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index 64fbea1..5c4e32d 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -47,6 +47,9 @@ public class Keyboard2View extends View
private float _marginRight;
private float _marginLeft;
private float _marginBottom;
+ private int _insets_left = 0;
+ private int _insets_right = 0;
+ private int _insets_bottom = 0;
private Theme _theme;
private Theme.Computed _tc;
@@ -264,35 +267,11 @@ public class Keyboard2View extends View
public void onMeasure(int wSpec, int hSpec)
{
int width;
- int insets_left = 0;
- int insets_right = 0;
- int insets_bottom = 0;
- // LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS is set in [Keyboard2#updateSoftInputWindowLayoutParams].
- // and keyboard is allowed do draw behind status/navigation bars
- if (VERSION.SDK_INT >= 35)
- {
- WindowMetrics metrics =
- ((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE))
- .getCurrentWindowMetrics();
- width = metrics.getBounds().width();
- WindowInsets wi = metrics.getWindowInsets();
- int insets_types =
- WindowInsets.Type.systemBars()
- | WindowInsets.Type.displayCutout()
- | WindowInsets.Type.mandatorySystemGestures();
- Insets insets = wi.getInsets(insets_types);
- insets_left = insets.left;
- insets_right = insets.right;
- insets_bottom = Math.max(insets.bottom, _config.bottomInsetMin);
- }
- else
- {
- DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
- width = dm.widthPixels;
- }
- _marginLeft = Math.max(_config.horizontal_margin, insets_left);
- _marginRight = Math.max(_config.horizontal_margin, insets_right);
- _marginBottom = _config.margin_bottom + insets_bottom;
+ DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
+ width = dm.widthPixels;
+ _marginLeft = Math.max(_config.horizontal_margin, _insets_left);
+ _marginRight = Math.max(_config.horizontal_margin, _insets_right);
+ _marginBottom = _config.margin_bottom + _insets_bottom;
_keyWidth = (width - _marginLeft - _marginRight) / _keyboard.keysWidth;
_tc = new Theme.Computed(_theme, _config, _keyWidth, _keyboard);
// Compute the size of labels based on the width or the height of keys. The
@@ -328,6 +307,22 @@ public class Keyboard2View extends View
}
}
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets wi)
+ {
+ // LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS is set in [Keyboard2#updateSoftInputWindowLayoutParams] for SDK_INT >= 35.
+ if (VERSION.SDK_INT < 35)
+ return wi;
+ int insets_types =
+ WindowInsets.Type.systemBars()
+ | WindowInsets.Type.displayCutout();
+ Insets insets = wi.getInsets(insets_types);
+ _insets_left = insets.left;
+ _insets_right = insets.right;
+ _insets_bottom = insets.bottom;
+ return WindowInsets.CONSUMED;
+ }
+
/** Horizontal and vertical position of the 9 indexes. */
static final Paint.Align[] LABEL_POSITION_H = new Paint.Align[]{
Paint.Align.CENTER, Paint.Align.LEFT, Paint.Align.RIGHT, Paint.Align.LEFT,
diff --git a/srcs/juloo.keyboard2/Utils.java b/srcs/juloo.keyboard2/Utils.java
index 88c865c..5cc1664 100644
--- a/srcs/juloo.keyboard2/Utils.java
+++ b/srcs/juloo.keyboard2/Utils.java
@@ -49,14 +49,4 @@ public final class Utils
out.append(buff, 0, l);
return out.toString();
}
-
- /** Whether the thin gesture-navigation bar is used.
- https://stackoverflow.com/questions/36514167/how-to-really-get-the-navigation-bar-height-in-android
- */
- public static boolean is_navigation_bar_gestural(Resources res)
- {
- // core/java/android/view/WindowManagerPolicyConstants.java
- int res_id = res.getIdentifier("config_navBarInteractionMode", "integer", "android");
- return (res_id > 0 && res.getInteger(res_id) == 2);
- }
}