Skip to content

Commit

Permalink
add setting from bottom padding scale
Browse files Browse the repository at this point in the history
  • Loading branch information
Helium314 committed Nov 3, 2023
1 parent fec5bc9 commit c2a48b2
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Might end up on F-Droid...
* Number pad
* Show all available extra characters on long pressing a key
* Backup your learned word / history data
* Adjustable bottom padding

## Hidden functionality
Features that may go unnoticed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class ClipboardLayoutParams(res: Resources) {
keyHorizontalGap = res.getFraction(R.fraction.config_key_horizontal_gap_holo,
defaultKeyboardWidth, defaultKeyboardWidth).toInt()
}
bottomPadding = res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight).toInt()
bottomPadding = (res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight) * Settings.getInstance().current.mBottomPaddingScale).toInt()
topPadding = res.getFraction(R.fraction.config_keyboard_top_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight).toInt()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,14 @@ public EmojiLayoutParams(final Resources res) {
mKeyHorizontalGap = (int) (res.getFraction(R.fraction.config_key_horizontal_gap_holo,
defaultKeyboardWidth, defaultKeyboardWidth));
}
mBottomPadding = (int) res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight);
mBottomPadding = (int) (res.getFraction(R.fraction.config_keyboard_bottom_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight) * Settings.getInstance().getCurrent().mBottomPaddingScale);
mTopPadding = (int) res.getFraction(R.fraction.config_keyboard_top_padding_holo,
defaultKeyboardHeight, defaultKeyboardHeight);
mEmojiCategoryPageIdViewHeight =
(int) (res.getDimension(R.dimen.config_emoji_category_page_id_height));
final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding
+ mKeyVerticalGap;
mEmojiActionBarHeight = baseheight / DEFAULT_KEYBOARD_ROWS
- (mKeyVerticalGap - mBottomPadding) / 2;
mEmojiListHeight = defaultKeyboardHeight - mEmojiActionBarHeight
- mEmojiCategoryPageIdViewHeight;
mEmojiCategoryPageIdViewHeight = (int) (res.getDimension(R.dimen.config_emoji_category_page_id_height));
final int baseheight = defaultKeyboardHeight - mBottomPadding - mTopPadding + mKeyVerticalGap;
mEmojiActionBarHeight = baseheight / DEFAULT_KEYBOARD_ROWS - (mKeyVerticalGap - mBottomPadding) / 2;
mEmojiListHeight = defaultKeyboardHeight - mEmojiActionBarHeight - mEmojiCategoryPageIdViewHeight;
mEmojiListBottomMargin = 0;
mEmojiKeyboardHeight = mEmojiListHeight - mEmojiListBottomMargin - 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ public void readAttributes(final Context context, @Nullable final AttributeSet a
mOccupiedWidth = width;
mTopPadding = (int) keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
mBottomPadding = (int) keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
mBottomPadding = (int) (keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardBottomPadding, height, height, 0)
* Settings.getInstance().getCurrent().mBottomPaddingScale);
mLeftPadding = (int) keyboardAttr.getFraction(
R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
mRightPadding = (int) keyboardAttr.getFraction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AppearanceSettingsFragment : SubScreenFragment() {
setColorPrefs(sharedPreferences.getString(Settings.PREF_THEME_STYLE, KeyboardTheme.STYLE_MATERIAL)!!)

setupScalePrefs(Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
setupScalePrefs(Settings.PREF_BOTTOM_PADDING_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
if (splitScalePref != null) {
setupScalePrefs(Settings.PREF_SPLIT_SPACER_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
splitScalePref?.isVisible = splitPref?.isChecked == true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard";
public static final String PREF_SPLIT_SPACER_SCALE = "pref_split_spacer_scale";
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
public static final String PREF_BOTTOM_PADDING_SCALE = "pref_bottom_padding_scale";
public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad";
public static final String PREF_DELETE_SWIPE = "pref_delete_swipe";
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "pref_autospace_after_punctuation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class SettingsValues {
public final float mKeyboardHeightScale;
public final boolean mUrlDetectionEnabled;
public final List<String> mPinnedKeys;
public final float mBottomPaddingScale;

// From the input box
@NonNull
Expand Down Expand Up @@ -228,6 +229,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
mUrlDetectionEnabled = prefs.getBoolean(Settings.PREF_URL_DETECTION, false);
mPinnedKeys = Settings.readPinnedKeys(prefs);
mSpacingAndPunctuations = new SpacingAndPunctuations(res, mUrlDetectionEnabled);
mBottomPaddingScale = prefs.getFloat(Settings.PREF_BOTTOM_PADDING_SCALE, DEFAULT_SIZE_SCALE);
}

public boolean isApplicationSpecifiedCompletionsOn() {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@
<string name="prefs_narrow_key_gaps">Narrow key gaps</string>
<!-- Title of the settings for setting keyboard height -->
<string name="prefs_keyboard_height_scale">Keyboard height scale</string>
<!-- Title of the settings for setting bottom padding height -->
<string name="prefs_bottom_padding_scale">Bottom padding scale</string>
<!-- Description of prefs_bottom_padding_scale -->
<string name="prefs_bottom_padding_scale_summary">Set size of the empty space below the keyboard</string>
<!-- Description for English (UK) keyboard subtype [CHAR LIMIT=25]
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT. -->
<string name="subtype_en_GB">English (UK)</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/prefs_screen_appearance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@
latin:minValue="50"
latin:maxValue="150" /> <!-- percentage -->

<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
android:key="pref_bottom_padding_scale"
android:title="@string/prefs_bottom_padding_scale"
android:summary="@string/prefs_bottom_padding_scale_summary"
latin:minValue="0"
latin:maxValue="500" /> <!-- percentage -->

</PreferenceCategory>

</PreferenceScreen>

0 comments on commit c2a48b2

Please sign in to comment.