mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-24 08:36:26 +00:00
shrink icons when keyboard scale is below 80%
This commit is contained in:
parent
bca519efe4
commit
9b39101bae
2 changed files with 17 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue