Skip to content

Commit 2fde28c

Browse files
committed
allow changing height of bottom row
should fix #1199, unless people really want only the space bar (or have unusual layouts with space bar not in bottom row)
1 parent a0b36d4 commit 2fde28c

6 files changed

Lines changed: 33 additions & 0 deletions

File tree

app/src/main/java/helium314/keyboard/keyboard/internal/keyboard_parser/KeyboardParser.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ class KeyboardParser(private val params: KeyboardParams, private val context: Co
7777
if (heightRescale != 1f) {
7878
keysInRows.forEach { row -> row.forEach { it.mHeight *= heightRescale } }
7979
}
80+
// rescale without changing keyboard height
81+
if (params.mId.isAlphaOrSymbolKeyboard) {
82+
val bottomRowScale = Settings.getValues().mBottomRowScale
83+
val otherRowScale = (keysInRows.size - bottomRowScale) / (keysInRows.size - 1)
84+
keysInRows.forEachIndexed { i, row ->
85+
row.forEach { it.mHeight *= if (i == keysInRows.lastIndex) bottomRowScale else otherRowScale }
86+
}
87+
}
8088

8189
return keysInRows
8290
}

app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ object Defaults {
8585
@JvmField
8686
val PREF_KEYBOARD_HEIGHT_SCALE = Array(2) { DEFAULT_SIZE_SCALE }
8787
@JvmField
88+
val PREF_BOTTOM_ROW_SCALE = Array(2) { DEFAULT_SIZE_SCALE }
89+
@JvmField
8890
val PREF_BOTTOM_PADDING_SCALE = arrayOf(DEFAULT_SIZE_SCALE, 0f)
8991
@JvmField
9092
val PREF_SIDE_PADDING_SCALE = Array(4) { 0f }

app/src/main/java/helium314/keyboard/latin/settings/Settings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
9696
public static final String PREF_ENABLE_SPLIT_KEYBOARD_LANDSCAPE = "split_keyboard_landscape";
9797
public static final String PREF_SPLIT_SPACER_SCALE_PREFIX = "split_spacer_scale";
9898
public static final String PREF_KEYBOARD_HEIGHT_SCALE_PREFIX = "keyboard_height_scale";
99+
public static final String PREF_BOTTOM_ROW_SCALE_PREFIX = "bottom_row_scale";
99100
public static final String PREF_BOTTOM_PADDING_SCALE_PREFIX = "bottom_padding_scale";
100101
public static final String PREF_SIDE_PADDING_SCALE_PREFIX = "side_padding_scale";
101102
public static final String PREF_FONT_SCALE = "font_scale";
@@ -451,6 +452,13 @@ public static float readHeightScale(final SharedPreferences prefs, final boolean
451452
return prefs.getFloat(SettingsKt.createPrefKeyForBooleanSettings(PREF_KEYBOARD_HEIGHT_SCALE_PREFIX, index, 1), defaultValue);
452453
}
453454

455+
public static float readBottomRowScale(final SharedPreferences prefs, final boolean landscape) {
456+
final int index = SettingsKt.findIndexOfDefaultSetting(landscape);
457+
final Float[] defaults = Defaults.PREF_BOTTOM_ROW_SCALE;
458+
final float defaultValue = defaults[index];
459+
return prefs.getFloat(SettingsKt.createPrefKeyForBooleanSettings(PREF_BOTTOM_ROW_SCALE_PREFIX, index, 1), defaultValue);
460+
}
461+
454462
public static boolean readHasHardwareKeyboard(final Configuration conf) {
455463
// The standard way of finding out whether we have a hardware keyboard. This code is taken
456464
// from InputMethodService#onEvaluateInputShown, which canonically determines this.

app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class SettingsValues {
116116
public final boolean mUseAppsDictionary;
117117
public final boolean mCustomNavBarColor;
118118
public final float mKeyboardHeightScale;
119+
public final float mBottomRowScale;
119120
public final boolean mUrlDetectionEnabled;
120121
public final float mBottomPaddingScale;
121122
public final float mSidePaddingScale;
@@ -252,6 +253,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
252253
mIncognitoModeEnabled = prefs.getBoolean(Settings.PREF_ALWAYS_INCOGNITO_MODE, Defaults.PREF_ALWAYS_INCOGNITO_MODE) || mInputAttributes.mNoLearning
253254
|| mInputAttributes.mIsPasswordField;
254255
mKeyboardHeightScale = Settings.readHeightScale(prefs, isLandscape);
256+
mBottomRowScale = Settings.readBottomRowScale(prefs, isLandscape);
255257
mSpaceSwipeHorizontal = Settings.readHorizontalSpaceSwipe(prefs);
256258
mSpaceSwipeVertical = Settings.readVerticalSpaceSwipe(prefs);
257259
mLanguageSwipeDistance = prefs.getInt(Settings.PREF_LANGUAGE_SWIPE_DISTANCE, Defaults.PREF_LANGUAGE_SWIPE_DISTANCE);

app/src/main/java/helium314/keyboard/settings/screens/AppearanceScreen.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ fun AppearanceScreen(
7474
if (prefs.getBoolean(Settings.PREF_THEME_KEY_BORDERS, Defaults.PREF_THEME_KEY_BORDERS))
7575
Settings.PREF_NARROW_KEY_GAPS else null,
7676
Settings.PREF_KEYBOARD_HEIGHT_SCALE_PREFIX,
77+
Settings.PREF_BOTTOM_ROW_SCALE_PREFIX,
7778
Settings.PREF_BOTTOM_PADDING_SCALE_PREFIX,
7879
Settings.PREF_SIDE_PADDING_SCALE_PREFIX,
7980
Settings.PREF_SPACE_BAR_TEXT,
@@ -224,6 +225,16 @@ fun createAppearanceSettings(context: Context) = listOf(
224225
description = { "${(100 * it).toInt()}%" }
225226
) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
226227
},
228+
Setting(context, Settings.PREF_BOTTOM_ROW_SCALE_PREFIX, R.string.prefs_bottom_row_scale) { setting ->
229+
MultiSliderPreference(
230+
name = setting.title,
231+
baseKey = setting.key,
232+
dimensions = listOf(stringResource(R.string.landscape)),
233+
defaults = Defaults.PREF_BOTTOM_ROW_SCALE,
234+
range = 0.5f..2f,
235+
description = { "${(100 * it).toInt()}%" }
236+
) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
237+
},
227238
Setting(context, Settings.PREF_BOTTOM_PADDING_SCALE_PREFIX, R.string.prefs_bottom_padding_scale) { setting ->
228239
MultiSliderPreference(
229240
name = setting.title,

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@
382382
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
383383
<!-- Title of the setting for setting bottom padding height -->
384384
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
385+
<!-- Title of the setting for setting height of the bottom row -->
386+
<string name="prefs_bottom_row_scale">Bottom row scale</string>
385387
<!-- Title of the setting for setting side padding -->
386388
<string name="prefs_side_padding_scale">Side padding scale</string>
387389
<!-- Title of the setting for adjusting font size on the keyboard -->

0 commit comments

Comments
 (0)