mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-19 08:20:15 +00:00
Made keyboard layout aware of one-handed mode (e.g. hides one-handed key when one-handed mode is enabled)
This commit is contained in:
parent
d27659de4f
commit
1b1dc96a3d
10 changed files with 81 additions and 22 deletions
|
@ -85,6 +85,7 @@ public final class KeyboardId {
|
|||
public final String mCustomActionLabel;
|
||||
public final boolean mHasShortcutKey;
|
||||
public final boolean mIsSplitLayout;
|
||||
public final boolean mOneHandedModeEnabled;
|
||||
|
||||
private final int mHashCode;
|
||||
|
||||
|
@ -103,6 +104,7 @@ public final class KeyboardId {
|
|||
? mEditorInfo.actionLabel.toString() : null;
|
||||
mHasShortcutKey = params.mVoiceInputKeyEnabled;
|
||||
mIsSplitLayout = params.mIsSplitLayoutEnabled;
|
||||
mOneHandedModeEnabled = params.mOneHandedModeEnabled;
|
||||
|
||||
mHashCode = computeHashCode(this);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ public final class KeyboardLayoutSet {
|
|||
boolean mNumberRowEnabled;
|
||||
boolean mLanguageSwitchKeyEnabled;
|
||||
boolean mEmojiKeyEnabled;
|
||||
boolean mOneHandedModeEnabled;
|
||||
RichInputMethodSubtype mSubtype;
|
||||
boolean mIsSpellChecker;
|
||||
int mKeyboardWidth;
|
||||
|
@ -351,6 +352,11 @@ public final class KeyboardLayoutSet {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setOneHandedModeEnabled(boolean enabled) {
|
||||
mParams.mOneHandedModeEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Super redux version of reading the script ID for some subtype from Xml.
|
||||
static int readScriptId(final Resources resources, final InputMethodSubtype subtype) {
|
||||
final String layoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
|
||||
|
|
|
@ -129,10 +129,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
|||
builder.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey);
|
||||
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
|
||||
&& settingsValues.mIsSplitKeyboardEnabled);
|
||||
final boolean oneHandedModeEnabled = settingsValues.mOneHandedModeEnabled;
|
||||
builder.setOneHandedModeEnabled(oneHandedModeEnabled);
|
||||
mKeyboardLayoutSet = builder.build();
|
||||
try {
|
||||
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState,
|
||||
settingsValues.mOneHandedModeEnabled);
|
||||
oneHandedModeEnabled);
|
||||
mKeyboardTextsSet.setLocale(mRichImm.getCurrentSubtypeLocale(), mThemeContext);
|
||||
} catch (KeyboardLayoutSetException e) {
|
||||
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
|
||||
|
|
|
@ -700,13 +700,16 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
final boolean countryCodeMatched = matchCountryCodes(caseAttr, locale);
|
||||
final boolean splitLayoutMatched = matchBoolean(caseAttr,
|
||||
R.styleable.Keyboard_Case_isSplitLayout, id.mIsSplitLayout);
|
||||
final boolean oneHandedModeEnabledMatched = matchBoolean(caseAttr,
|
||||
R.styleable.Keyboard_Case_oneHandedModeEnabled,
|
||||
id.mOneHandedModeEnabled);
|
||||
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
|
||||
&& keyboardThemeMacthed && modeMatched && navigateNextMatched
|
||||
&& navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
|
||||
&& hasShortcutKeyMatched && numberRowEnabledMatched && languageSwitchKeyEnabledMatched
|
||||
&& emojiKeyEnabledMatched && isMultiLineMatched && imeActionMatched && isIconDefinedMatched
|
||||
&& localeCodeMatched && languageCodeMatched && countryCodeMatched
|
||||
&& splitLayoutMatched;
|
||||
&& splitLayoutMatched && oneHandedModeEnabledMatched;
|
||||
|
||||
if (DEBUG) {
|
||||
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
|
||||
|
@ -748,6 +751,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
|
|||
"languageCode"),
|
||||
textAttr(caseAttr.getString(R.styleable.Keyboard_Case_countryCode),
|
||||
"countryCode"),
|
||||
booleanAttr(caseAttr, R.styleable.Keyboard_Case_oneHandedModeEnabled,
|
||||
"oneHandedModeEnabled"),
|
||||
selected ? "" : " skipped");
|
||||
}
|
||||
|
||||
|
|
|
@ -261,6 +261,7 @@ public final class KeyboardTextsTable {
|
|||
/* 177: 0 */ "keyspec_clipboard_action_key",
|
||||
/* 178: 0 */ "keyspec_clipboard_normal_key",
|
||||
/* 179: 0 */ "keyspec_start_onehanded_mode",
|
||||
/* 180: 0 */ "keyspec_language_switch",
|
||||
};
|
||||
|
||||
private static final String EMPTY = "";
|
||||
|
@ -489,6 +490,7 @@ public final class KeyboardTextsTable {
|
|||
/* keyspec_clipboard_action_key */ "!icon/clipboard_action_key|!code/key_clipboard",
|
||||
/* keyspec_clipboard_normal_key */ "!icon/clipboard_normal_key|!code/key_clipboard",
|
||||
/* keyspec_start_onehanded_mode */ "!icon/start_onehanded_mode_key|!code/key_start_onehanded",
|
||||
/* keyspec_language_switch */ "!icon/language_switch_key|!code/key_language_switch",
|
||||
};
|
||||
|
||||
/* Locale af: Afrikaans */
|
||||
|
@ -4251,7 +4253,7 @@ public final class KeyboardTextsTable {
|
|||
|
||||
private static final Object[] LOCALES_AND_TEXTS = {
|
||||
// "locale", TEXT_ARRAY, /* numberOfNonNullText/lengthOf_TEXT_ARRAY localeName */
|
||||
"DEFAULT", TEXTS_DEFAULT, /* 180/180 DEFAULT */
|
||||
"DEFAULT", TEXTS_DEFAULT, /* 181/181 DEFAULT */
|
||||
"af" , TEXTS_af, /* 7/ 13 Afrikaans */
|
||||
"ar" , TEXTS_ar, /* 55/110 Arabic */
|
||||
"az" , TEXTS_az, /* 11/ 18 Azerbaijani */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue