diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java index 1a35e8ee3..49db5520b 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/KeyboardView.java @@ -124,6 +124,8 @@ public class KeyboardView extends View { private Bitmap mOffscreenBuffer; /** Flag for whether the key hints should be displayed */ private boolean mShowsHints; + /** Scale for downscaling icons and fixed size backgrounds if keyboard height is set below 80% */ + private float mIconScaleFactor; /** The canvas for the above mutable keyboard bitmap */ @NonNull private final Canvas mOffscreenCanvas = new Canvas(); @@ -301,6 +303,8 @@ public class KeyboardView extends View { } mShowsHints = Settings.getInstance().getCurrent().mShowsHints; + final float scale = Settings.getInstance().getCurrent().mKeyboardHeightScale; + mIconScaleFactor = scale < 0.8f ? scale + 0.2f : scale; final Paint paint = mPaint; final Drawable background = getBackground(); // Calculate clip region and set. @@ -370,8 +374,8 @@ public class KeyboardView extends View { if (key.needsToKeepBackgroundAspectRatio(mDefaultKeyLabelFlags) // HACK: To disable expanding normal/functional key background. && !key.hasCustomActionLabel()) { - bgWidth = background.getIntrinsicWidth(); - bgHeight = background.getIntrinsicHeight(); + bgWidth = (int) (background.getIntrinsicWidth() * mIconScaleFactor); + bgHeight = (int) (background.getIntrinsicHeight() * mIconScaleFactor); bgX = (keyWidth - bgWidth) / 2; bgY = (keyHeight - bgHeight) / 2; } else { @@ -497,11 +501,11 @@ public class KeyboardView extends View { if (label == null && icon != null) { final int iconWidth; if (key.getCode() == Constants.CODE_SPACE && icon instanceof NinePatchDrawable) { - iconWidth = (int)(keyWidth * mSpacebarIconWidthRatio); + iconWidth = (int) (keyWidth * mSpacebarIconWidthRatio * mIconScaleFactor); } else { - iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth); + iconWidth = (int) (Math.min(icon.getIntrinsicWidth(), keyWidth) * mIconScaleFactor); } - final int iconHeight = icon.getIntrinsicHeight(); + final int iconHeight = (int) (icon.getIntrinsicHeight() * mIconScaleFactor); final int iconY; if (key.isAlignIconToBottom()) { iconY = keyHeight - iconHeight; diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt index e0d6e257d..74cab47cb 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/KeyboardWrapperView.kt @@ -110,18 +110,22 @@ class KeyboardWrapperView @JvmOverloads constructor( keyboardView.measuredHeight ) + val scale = Settings.getInstance().current.mKeyboardHeightScale + // scale one-handed mode button height if keyboard height scale is < 80% + // more relevant: also change the distance, so the buttons are actually visible + val heightScale = scale + 0.2f val buttonsLeft = if (isLeftGravity) keyboardView.measuredWidth else 0 stopOneHandedModeBtn.layout( buttonsLeft + (spareWidth - stopOneHandedModeBtn.measuredWidth) / 2, - stopOneHandedModeBtn.measuredHeight / 2, + (heightScale * stopOneHandedModeBtn.measuredHeight / 2).toInt(), buttonsLeft + (spareWidth + stopOneHandedModeBtn.measuredWidth) / 2, - 3 * stopOneHandedModeBtn.measuredHeight / 2 + (heightScale * 3 * stopOneHandedModeBtn.measuredHeight / 2).toInt() ) switchOneHandedModeBtn.layout( buttonsLeft + (spareWidth - switchOneHandedModeBtn.measuredWidth) / 2, - 2 * stopOneHandedModeBtn.measuredHeight, + (heightScale * 2 * stopOneHandedModeBtn.measuredHeight).toInt(), buttonsLeft + (spareWidth + switchOneHandedModeBtn.measuredWidth) / 2, - 2 * stopOneHandedModeBtn.measuredHeight + switchOneHandedModeBtn.measuredHeight + (heightScale * (2 * stopOneHandedModeBtn.measuredHeight + switchOneHandedModeBtn.measuredHeight)).toInt() ) }