Skip to content

Commit aead32d

Browse files
committed
LatinIME: Support enabling number row for only password inputs
Change-Id: Ie6aeb23ea396bd6342c6a4c12fda917cbc3f1b52
1 parent 20a85f2 commit aead32d

8 files changed

Lines changed: 26 additions & 1 deletion

File tree

java/res/values/cm_strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ disposition rather than other common dispositions for Latin languages. [CHAR LIM
3636
<string name="number_row">Number row</string>
3737
<string name="number_row_summary">Always show a number row for all layouts that feature 4 rows of keys</string>
3838

39+
<!-- Preference item for enabling the number row on password inputs -->
40+
<string name="number_row_password">Number row for passwords</string>
41+
<string name="number_row_password_summary">Always show a number row for all layouts that feature 4 rows of keys for password input</string>
42+
3943
<!-- Preference item for the space bar track pad -->
4044
<string name="space_trackpad">Space bar trackpad</string>
4145
<string name="space_trackpad_summary">Swipe on the spacebar to move the cursor</string>

java/res/xml/prefs_screen_preferences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
android:summary="@string/number_row_summary"
3131
android:defaultValue="false"
3232
android:persistent="true" />
33+
<CheckBoxPreference
34+
android:key="pref_show_number_row_password"
35+
android:title="@string/number_row_password"
36+
android:summary="@string/number_row_password_summary"
37+
android:defaultValue="false"
38+
android:persistent="true" />
3339
<CheckBoxPreference
3440
android:key="pref_show_emoji_key"
3541
android:title="@string/show_emoji_key"

java/src/com/android/inputmethod/keyboard/KeyboardId.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
9595
mElementId = elementId;
9696
mEditorInfo = params.mEditorInfo;
9797
mClobberSettingsKey = params.mNoSettingsKey;
98-
mNumberRowEnabled = params.mNumberRowEnabled;
98+
mNumberRowEnabled = params.mNumberRowEnabled ||
99+
(params.mNumberRowPasswordEnabled && params.mIsPasswordField);
99100
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
100101
mEmojiKeyEnabled = params.mEmojiKeyEnabled;
101102
mCustomActionLabel = (mEditorInfo.actionLabel != null)

java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public static final class Params {
119119
boolean mVoiceInputKeyEnabled;
120120
boolean mNoSettingsKey;
121121
boolean mNumberRowEnabled;
122+
boolean mNumberRowPasswordEnabled; // implied if mNumberRowEnabled
122123
boolean mLanguageSwitchKeyEnabled;
123124
boolean mEmojiKeyEnabled;
124125
RichInputMethodSubtype mSubtype;
@@ -329,6 +330,11 @@ public Builder setNumberRowEnabled(final boolean enabled) {
329330
return this;
330331
}
331332

333+
public Builder setNumberRowPasswordEnabled(final boolean enabled) {
334+
mParams.mNumberRowPasswordEnabled = enabled;
335+
return this;
336+
}
337+
332338
public Builder setLanguageSwitchKeyEnabled(final boolean enabled) {
333339
mParams.mLanguageSwitchKeyEnabled = enabled;
334340
return this;

java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues setti
128128
builder.setSubtype(mRichImm.getCurrentSubtype());
129129
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
130130
builder.setNumberRowEnabled(settingsValues.mShowNumberRow);
131+
builder.setNumberRowPasswordEnabled(settingsValues.mShowNumberRowPassword);
131132
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
132133
builder.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey);
133134
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED

java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public void onSharedPreferenceChanged(final SharedPreferences prefs, final Strin
9595
setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
9696
Settings.readKeyPreviewPopupEnabled(prefs, res));
9797
}
98+
if (key.equals(Settings.PREF_SHOW_NUMBER_ROW)) {
99+
setPreferenceEnabled(Settings.PREF_SHOW_NUMBER_ROW_PASSWORD,
100+
!Settings.readShowNumberRow(prefs));
101+
}
98102
refreshEnablingsOfKeypressSoundAndVibrationSettings();
99103
}
100104

java/src/com/android/inputmethod/latin/settings/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
104104

105105
public static final String PREF_ENABLE_METRICS_LOGGING = "pref_enable_metrics_logging";
106106
public static final String PREF_SHOW_NUMBER_ROW = "pref_show_number_row";
107+
public static final String PREF_SHOW_NUMBER_ROW_PASSWORD = "pref_show_number_row_password";
107108

108109
public static final String PREF_SHOW_LONGPRESS_HINTS = "pref_show_longpress_hints";
109110
// This preference key is deprecated. Use {@link #PREF_SHOW_LANGUAGE_SWITCH_KEY} instead.

java/src/com/android/inputmethod/latin/settings/SettingsValues.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class SettingsValues {
6868
public final boolean mKeyPreviewPopupOn;
6969
public final boolean mShowsVoiceInputKey;
7070
public final boolean mShowNumberRow;
71+
public final boolean mShowNumberRowPassword;
7172
public final boolean mShowLongpressHints;
7273
public final boolean mIncludesOtherImesInLanguageSwitchList;
7374
public final boolean mShowsLanguageSwitchKey;
@@ -145,6 +146,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
145146
&& mInputAttributes.mShouldShowVoiceInputKey
146147
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
147148
mShowNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false);
149+
mShowNumberRowPassword = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW_PASSWORD, false);
148150
mShowLongpressHints = prefs.getBoolean(Settings.PREF_SHOW_LONGPRESS_HINTS, true);
149151
mIncludesOtherImesInLanguageSwitchList = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
150152
? prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false)

0 commit comments

Comments
 (0)