aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/res/values/attrs.xml6
-rw-r--r--java/res/values/config.xml9
-rw-r--r--java/res/values/strings.xml2
-rw-r--r--java/res/values/styles.xml3
-rw-r--r--java/res/xml/prefs.xml7
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java26
-rw-r--r--java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java7
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java11
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsFragment.java31
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java43
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java3
-rw-r--r--native/jni/src/proximity_info_state.cpp23
-rw-r--r--native/jni/src/proximity_info_state.h14
-rw-r--r--native/jni/src/proximity_info_state_utils.cpp66
-rw-r--r--native/jni/src/proximity_info_state_utils.h19
-rw-r--r--tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java31
-rw-r--r--tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java130
18 files changed, 236 insertions, 197 deletions
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index c41263515..850b1b8dc 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -87,10 +87,8 @@
<attr name="keyRepeatStartTimeout" format="integer" />
<!-- Key repeat interval in millisecond. -->
<attr name="keyRepeatInterval" format="integer" />
- <!-- Long press timeout of letter key in millisecond. -->
- <attr name="longPressKeyTimeout" format="integer" />
- <!-- Long press timeout of shift key in millisecond. -->
- <attr name="longPressShiftKeyTimeout" format="integer" />
+ <!-- Long press timeout of shift key to shift lock in millisecond. -->
+ <attr name="longPressShiftLockTimeout" format="integer" />
<!-- Ignore special key timeout while typing in millisecond. -->
<attr name="ignoreAltCodeKeyTimeout" format="integer" />
<!-- Layout resource for key press feedback.-->
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index 503e92322..6b3c891c7 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -64,10 +64,13 @@
<bool name="config_sliding_key_input_enabled">true</bool>
<integer name="config_key_repeat_start_timeout">400</integer>
<integer name="config_key_repeat_interval">50</integer>
- <integer name="config_long_press_key_timeout">400</integer>
+ <integer name="config_default_longpress_key_timeout">300</integer> <!-- milliseconds -->
+ <integer name="config_longpress_timeout_step">10</integer> <!-- milliseconds -->
+ <integer name="config_min_longpress_timeout">100</integer> <!-- milliseconds -->
+ <integer name="config_max_longpress_timeout">700</integer> <!-- milliseconds -->
<!-- Long pressing shift will invoke caps-lock if > 0, never invoke caps-lock if == 0 -->
- <integer name="config_long_press_shift_key_timeout">1200</integer>
- <integer name="config_ignore_alt_code_key_timeout">350</integer>
+ <integer name="config_longpress_shift_lock_timeout">1200</integer> <!-- milliseconds -->
+ <integer name="config_ignore_alt_code_key_timeout">350</integer> <!-- milliseconds -->
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
false -->
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index fdae3020a..e39cafc7f 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -374,6 +374,8 @@
<!-- Title of an option for usability study mode -->
<string name="prefs_usability_study_mode">Usability study mode</string>
+ <!-- Title of the settings for key long press delay -->
+ <string name="prefs_key_longpress_timeout_settings">Key long press delay settings</string>
<!-- Title of the settings for keypress vibration duration -->
<string name="prefs_keypress_vibration_duration_settings">Keypress vibration duration settings</string>
<!-- Title of the settings for keypress sound volume -->
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index c398b5924..f71963ad1 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -80,8 +80,7 @@
<item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item>
<item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item>
<item name="keyRepeatInterval">@integer/config_key_repeat_interval</item>
- <item name="longPressKeyTimeout">@integer/config_long_press_key_timeout</item>
- <item name="longPressShiftKeyTimeout">@integer/config_long_press_shift_key_timeout</item>
+ <item name="longPressShiftLockTimeout">@integer/config_longpress_shift_lock_timeout</item>
<item name="ignoreAltCodeKeyTimeout">@integer/config_ignore_alt_code_key_timeout</item>
<item name="keyPreviewLayout">@layout/key_preview</item>
<item name="keyPreviewOffset">@dimen/key_preview_offset</item>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index cc1b52ba6..84e7f54ab 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -146,6 +146,13 @@
android:key="pref_key_preview_popup_dismiss_delay"
android:title="@string/key_preview_popup_dismiss_delay" />
<com.android.inputmethod.latin.SeekBarDialogPreference
+ android:key="pref_key_longpress_timeout"
+ android:title="@string/prefs_key_longpress_timeout_settings"
+ latin:valueFormatText="@string/abbreviation_unit_milliseconds"
+ latin:minValue="@integer/config_min_longpress_timeout"
+ latin:maxValue="@integer/config_max_longpress_timeout"
+ latin:stepValue="@integer/config_longpress_timeout_step" />
+ <com.android.inputmethod.latin.SeekBarDialogPreference
android:key="pref_vibration_duration_settings"
android:title="@string/prefs_keypress_vibration_duration_settings"
latin:valueFormatText="@string/abbreviation_unit_milliseconds"
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 28a22f35c..cf89ef210 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -65,6 +65,7 @@ import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResourceUtils;
+import com.android.inputmethod.latin.Settings;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeLocale;
@@ -205,8 +206,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final int mKeyRepeatStartTimeout;
private final int mKeyRepeatInterval;
- private final int mLongPressKeyTimeout;
- private final int mLongPressShiftKeyTimeout;
+ private final int mLongPressShiftLockTimeout;
private final int mIgnoreAltCodeKeyTimeout;
private final int mGestureRecognitionUpdateTime;
@@ -218,10 +218,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
- mLongPressKeyTimeout = mainKeyboardViewAttr.getInt(
- R.styleable.MainKeyboardView_longPressKeyTimeout, 0);
- mLongPressShiftKeyTimeout = mainKeyboardViewAttr.getInt(
- R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
+ mLongPressShiftLockTimeout = mainKeyboardViewAttr.getInt(
+ R.styleable.MainKeyboardView_longPressShiftLockTimeout, 0);
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
mGestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
@@ -285,7 +283,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int delay;
switch (code) {
case Constants.CODE_SHIFT:
- delay = mLongPressShiftKeyTimeout;
+ delay = mLongPressShiftLockTimeout;
break;
default:
delay = 0;
@@ -306,15 +304,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
final int delay;
switch (key.mCode) {
case Constants.CODE_SHIFT:
- delay = mLongPressShiftKeyTimeout;
+ delay = mLongPressShiftLockTimeout;
break;
default:
+ final int longpressTimeout =
+ Settings.getInstance().getCurrent().mKeyLongpressTimeout;
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
// We use longer timeout for sliding finger input started from the symbols
// mode key.
- delay = mLongPressKeyTimeout * 3;
+ delay = longpressTimeout * 3;
} else {
- delay = mLongPressKeyTimeout;
+ delay = longpressTimeout;
}
break;
}
@@ -1371,7 +1371,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private String layoutLanguageOnSpacebar(final Paint paint, final InputMethodSubtype subtype,
final int width) {
// Choose appropriate language name to fit into the width.
- final String fullText = getFullDisplayName(subtype, getResources());
+ final String fullText = getFullDisplayName(subtype);
if (fitsTextIntoWidth(width, fullText, paint)) {
return fullText;
}
@@ -1445,12 +1445,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// zz azerty T AZERTY AZERTY
// Get InputMethodSubtype's full display name in its locale.
- static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) {
+ static String getFullDisplayName(final InputMethodSubtype subtype) {
if (SubtypeLocale.isNoLanguage(subtype)) {
return SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype);
}
- return SubtypeLocale.getSubtypeDisplayName(subtype, res);
+ return SubtypeLocale.getSubtypeDisplayName(subtype);
}
// Get InputMethodSubtype's short display name in its locale.
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
index 9e5e18353..a56c78bcd 100644
--- a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
@@ -103,7 +103,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
if (DEBUG_SUBTYPE_ID) {
android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
- SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources())));
+ SubtypeLocale.getSubtypeDisplayName(subtype)));
}
if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
items.add(createItem(context, subtype.getLocale()));
@@ -205,8 +205,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
setDialogTitle(R.string.add_style);
setKey(KEY_NEW_SUBTYPE);
} else {
- final String displayName = SubtypeLocale.getSubtypeDisplayName(
- subtype, getContext().getResources());
+ final String displayName = SubtypeLocale.getSubtypeDisplayName(subtype);
setTitle(displayName);
setDialogTitle(displayName);
setKey(KEY_PREFIX + subtype.getLocale() + "_"
@@ -498,7 +497,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
final Context context = getActivity();
final Resources res = context.getResources();
final String message = res.getString(R.string.custom_input_style_already_exists,
- SubtypeLocale.getSubtypeDisplayName(subtype, res));
+ SubtypeLocale.getSubtypeDisplayName(subtype));
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index aa705da56..408ea4a49 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -55,6 +55,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
public static final String PREF_GESTURE_SETTINGS = "gesture_typing_settings";
public static final String PREF_GESTURE_INPUT = "gesture_input";
+ public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
public static final String PREF_VIBRATION_DURATION_SETTINGS =
"pref_vibration_duration_settings";
public static final String PREF_KEYPRESS_SOUND_VOLUME =
@@ -175,6 +176,16 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
ResourceUtils.getDeviceOverrideValue(res, R.array.keypress_volumes));
}
+ public static int readKeyLongpressTimeout(final SharedPreferences prefs,
+ final Resources res) {
+ final int ms = prefs.getInt(PREF_KEY_LONGPRESS_TIMEOUT, -1);
+ return (ms >= 0) ? ms : readDefaultKeyLongpressTimeout(res);
+ }
+
+ public static int readDefaultKeyLongpressTimeout(final Resources res) {
+ return res.getInteger(R.integer.config_default_longpress_key_timeout);
+ }
+
public static int readKeypressVibrationDuration(final SharedPreferences prefs,
final Resources res) {
final int ms = prefs.getInt(PREF_VIBRATION_DURATION_SETTINGS, -1);
diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java
index afe6f3594..3ba24fb65 100644
--- a/java/src/com/android/inputmethod/latin/SettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java
@@ -164,6 +164,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
getPreferenceScreen().removePreference(gestureTypingSettings);
}
+ setupKeyLongpressTimeoutSettings(prefs, res);
setupKeypressVibrationDurationSettings(prefs, res);
setupKeypressSoundVolumeSettings(prefs, res);
refreshEnablingsOfKeypressSoundAndVibrationSettings(prefs, res);
@@ -236,7 +237,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final StringBuilder styles = new StringBuilder();
for (final InputMethodSubtype subtype : subtypes) {
if (styles.length() > 0) styles.append(", ");
- styles.append(SubtypeLocale.getSubtypeDisplayName(subtype, res));
+ styles.append(SubtypeLocale.getSubtypeDisplayName(subtype));
}
customInputStyles.setSummary(styles);
}
@@ -298,6 +299,34 @@ public final class SettingsFragment extends InputMethodSettingsFragment
});
}
+ private void setupKeyLongpressTimeoutSettings(final SharedPreferences sp,
+ final Resources res) {
+ final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
+ Settings.PREF_KEY_LONGPRESS_TIMEOUT);
+ if (pref == null) {
+ return;
+ }
+ pref.setInterface(new SeekBarDialogPreference.ValueProxy() {
+ @Override
+ public void writeValue(final int value, final String key) {
+ sp.edit().putInt(key, value).apply();
+ }
+
+ @Override
+ public int readValue(final String key) {
+ return Settings.readKeyLongpressTimeout(sp, res);
+ }
+
+ @Override
+ public int readDefaultValue(final String key) {
+ return Settings.readDefaultKeyLongpressTimeout(res);
+ }
+
+ @Override
+ public void feedbackValue(final int value) {}
+ });
+ }
+
private void setupKeypressSoundVolumeSettings(final SharedPreferences sp, final Resources res) {
final SeekBarDialogPreference pref = (SeekBarDialogPreference)findPreference(
Settings.PREF_KEYPRESS_SOUND_VOLUME);
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index d6556d617..29e79e4cc 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -59,6 +59,7 @@ public final class SettingsValues {
public final boolean mGestureInputEnabled;
public final boolean mGesturePreviewTrailEnabled;
public final boolean mGestureFloatingPreviewTextEnabled;
+ public final int mKeyLongpressTimeout;
// From the input box
public final InputAttributes mInputAttributes;
@@ -121,6 +122,7 @@ public final class SettingsValues {
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
// Compute other readable settings
+ mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index 370a6594b..068c34ed6 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -42,6 +42,7 @@ public final class SubtypeLocale {
public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic;
private static boolean sInitialized = false;
+ private static Resources sResources;
private static String[] sPredefinedKeyboardLayoutSet;
// Keyboard layout to its display name map.
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap =
@@ -71,10 +72,11 @@ public final class SubtypeLocale {
}
// Note that this initialization method can be called multiple times.
- public static synchronized void init(Context context) {
+ public static synchronized void init(final Context context) {
if (sInitialized) return;
final Resources res = context.getResources();
+ sResources = res;
final String[] predefinedLayoutSet = res.getStringArray(R.array.predefined_layouts);
sPredefinedKeyboardLayoutSet = predefinedLayoutSet;
@@ -121,15 +123,15 @@ public final class SubtypeLocale {
return sPredefinedKeyboardLayoutSet;
}
- public static boolean isExceptionalLocale(String localeString) {
+ public static boolean isExceptionalLocale(final String localeString) {
return sExceptionalLocaleToWithLayoutNameIdsMap.containsKey(localeString);
}
- private static final String getNoLanguageLayoutKey(String keyboardLayoutName) {
+ private static final String getNoLanguageLayoutKey(final String keyboardLayoutName) {
return NO_LANGUAGE + "_" + keyboardLayoutName;
}
- public static int getSubtypeNameId(String localeString, String keyboardLayoutName) {
+ public static int getSubtypeNameId(final String localeString, final String keyboardLayoutName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& isExceptionalLocale(localeString)) {
return sExceptionalLocaleToWithLayoutNameIdsMap.get(localeString);
@@ -141,7 +143,7 @@ public final class SubtypeLocale {
return nameId == null ? UNKNOWN_KEYBOARD_LAYOUT : nameId;
}
- public static String getSubtypeLocaleDisplayName(String localeString) {
+ public static String getSubtypeLocaleDisplayName(final String localeString) {
final String exceptionalValue = sExceptionalDisplayNamesMap.get(localeString);
if (exceptionalValue != null) {
return exceptionalValue;
@@ -166,12 +168,17 @@ public final class SubtypeLocale {
// en_US azerty T English (US) (AZERTY)
// zz azerty T No language (AZERTY) in system locale
- public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) {
- final String replacementString =
- (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
- && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME))
- ? subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)
- : getSubtypeLocaleDisplayName(subtype.getLocale());
+ private static String getReplacementString(final InputMethodSubtype subtype) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
+ && subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
+ return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
+ } else {
+ return getSubtypeLocaleDisplayName(subtype.getLocale());
+ }
+ }
+
+ public static String getSubtypeDisplayName(final InputMethodSubtype subtype) {
+ final String replacementString = getReplacementString(subtype);
final int nameResId = subtype.getNameResId();
final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
@Override
@@ -190,30 +197,30 @@ public final class SubtypeLocale {
}
};
final Locale locale = isNoLanguage(subtype)
- ? res.getConfiguration().locale : getSubtypeLocale(subtype);
- return getSubtypeName.runInLocale(res, locale);
+ ? sResources.getConfiguration().locale : getSubtypeLocale(subtype);
+ return getSubtypeName.runInLocale(sResources, locale);
}
- public static boolean isNoLanguage(InputMethodSubtype subtype) {
+ public static boolean isNoLanguage(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
return localeString.equals(NO_LANGUAGE);
}
- public static Locale getSubtypeLocale(InputMethodSubtype subtype) {
+ public static Locale getSubtypeLocale(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
return LocaleUtils.constructLocaleFromString(localeString);
}
- public static String getKeyboardLayoutSetDisplayName(InputMethodSubtype subtype) {
+ public static String getKeyboardLayoutSetDisplayName(final InputMethodSubtype subtype) {
final String layoutName = getKeyboardLayoutSetName(subtype);
return getKeyboardLayoutSetDisplayName(layoutName);
}
- public static String getKeyboardLayoutSetDisplayName(String layoutName) {
+ public static String getKeyboardLayoutSetDisplayName(final String layoutName) {
return sKeyboardLayoutToDisplayNameMap.get(layoutName);
}
- public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) {
+ public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
if (keyboardLayoutSet == null) {
// This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index eb0ec3990..2f9e34ff1 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -151,8 +151,7 @@ public final class SubtypeSwitcher {
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
if (DBG) {
- Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(
- newSubtype, mResources));
+ Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeDisplayName(newSubtype));
}
final Locale newLocale = SubtypeLocale.getSubtypeLocale(newSubtype);
diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp
index e720275d0..8c6a525a7 100644
--- a/native/jni/src/proximity_info_state.cpp
+++ b/native/jni/src/proximity_info_state.cpp
@@ -71,9 +71,9 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
mSampledTimes.clear();
mSampledInputIndice.clear();
mSampledLengthCache.clear();
- mDistanceCache_G.clear();
- mNearKeysVector.clear();
- mSearchKeysVector.clear();
+ mSampledDistanceCache_G.clear();
+ mSampledNearKeysVector.clear();
+ mSampledSearchKeysVector.clear();
mSpeedRates.clear();
mBeelineSpeedPercentiles.clear();
mCharProbabilities.clear();
@@ -108,16 +108,17 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi
ProximityInfoStateUtils::initGeometricDistanceInfos(
mProximityInfo, mProximityInfo->getKeyCount(),
mSampledInputSize, lastSavedInputSize, &mSampledInputXs, &mSampledInputYs,
- &mNearKeysVector, &mSearchKeysVector, &mDistanceCache_G);
+ &mSampledNearKeysVector, &mSampledDistanceCache_G);
if (isGeometric) {
// updates probabilities of skipping or mapping each key for all points.
ProximityInfoStateUtils::updateAlignPointProbabilities(
mMaxPointToKeyLength, mProximityInfo->getMostCommonKeyWidth(),
mProximityInfo->getKeyCount(), lastSavedInputSize, mSampledInputSize,
&mSampledInputXs, &mSampledInputYs, &mSpeedRates, &mSampledLengthCache,
- &mDistanceCache_G, &mNearKeysVector, &mCharProbabilities);
- ProximityInfoStateUtils::updateSearchKeysVector(mProximityInfo, mSampledInputSize,
- lastSavedInputSize, &mSampledLengthCache, &mNearKeysVector, &mSearchKeysVector);
+ &mSampledDistanceCache_G, &mSampledNearKeysVector, &mCharProbabilities);
+ ProximityInfoStateUtils::updateSampledSearchKeysVector(mProximityInfo,
+ mSampledInputSize, lastSavedInputSize, &mSampledLengthCache,
+ &mSampledNearKeysVector, &mSampledSearchKeysVector);
}
}
@@ -189,7 +190,7 @@ float ProximityInfoState::getPointToKeyLength(
const int keyId = mProximityInfo->getKeyIndexOf(codePoint);
if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * mProximityInfo->getKeyCount() + keyId;
- return min(mDistanceCache_G[index] * scale, mMaxPointToKeyLength);
+ return min(mSampledDistanceCache_G[index] * scale, mMaxPointToKeyLength);
}
if (isSkippableCodePoint(codePoint)) {
return 0.0f;
@@ -206,7 +207,7 @@ float ProximityInfoState::getPointToKeyLength_G(const int inputIndex, const int
float ProximityInfoState::getPointToKeyByIdLength(
const int inputIndex, const int keyId, const float scale) const {
return ProximityInfoStateUtils::getPointToKeyByIdLength(mMaxPointToKeyLength,
- &mDistanceCache_G, mProximityInfo->getKeyCount(), inputIndex, keyId, scale);
+ &mSampledDistanceCache_G, mProximityInfo->getKeyCount(), inputIndex, keyId, scale);
}
float ProximityInfoState::getPointToKeyByIdLength(const int inputIndex, const int keyId) const {
@@ -289,7 +290,7 @@ int ProximityInfoState::getAllPossibleChars(
int newFilterSize = filterSize;
const int keyCount = mProximityInfo->getKeyCount();
for (int j = 0; j < keyCount; ++j) {
- if (mSearchKeysVector[index].test(j)) {
+ if (mSampledSearchKeysVector[index].test(j)) {
const int keyCodePoint = mProximityInfo->getCodePointOf(j);
bool insert = true;
// TODO: Avoid linear search
@@ -310,7 +311,7 @@ int ProximityInfoState::getAllPossibleChars(
bool ProximityInfoState::isKeyInSerchKeysAfterIndex(const int index, const int keyId) const {
ASSERT(keyId >= 0);
ASSERT(index >= 0 && index < mSampledInputSize);
- return mSearchKeysVector[index].test(keyId);
+ return mSampledSearchKeysVector[index].test(keyId);
}
void ProximityInfoState::popInputData() {
diff --git a/native/jni/src/proximity_info_state.h b/native/jni/src/proximity_info_state.h
index 8bada277e..642925c1a 100644
--- a/native/jni/src/proximity_info_state.h
+++ b/native/jni/src/proximity_info_state.h
@@ -52,9 +52,9 @@ class ProximityInfoState {
mKeyCount(0), mCellHeight(0), mCellWidth(0), mGridHeight(0), mGridWidth(0),
mIsContinuationPossible(false), mSampledInputXs(), mSampledInputYs(), mSampledTimes(),
mSampledInputIndice(), mSampledLengthCache(), mBeelineSpeedPercentiles(),
- mDistanceCache_G(), mSpeedRates(), mDirections(), mCharProbabilities(),
- mNearKeysVector(), mSearchKeysVector(), mTouchPositionCorrectionEnabled(false),
- mSampledInputSize(0) {
+ mSampledDistanceCache_G(), mSpeedRates(), mDirections(), mCharProbabilities(),
+ mSampledNearKeysVector(), mSampledSearchKeysVector(),
+ mTouchPositionCorrectionEnabled(false), mSampledInputSize(0) {
memset(mInputProximities, 0, sizeof(mInputProximities));
memset(mNormalizedSquaredDistances, 0, sizeof(mNormalizedSquaredDistances));
memset(mPrimaryInputWord, 0, sizeof(mPrimaryInputWord));
@@ -240,20 +240,20 @@ class ProximityInfoState {
std::vector<int> mSampledInputIndice;
std::vector<int> mSampledLengthCache;
std::vector<int> mBeelineSpeedPercentiles;
- std::vector<float> mDistanceCache_G;
+ std::vector<float> mSampledDistanceCache_G;
std::vector<float> mSpeedRates;
std::vector<float> mDirections;
// probabilities of skipping or mapping to a key for each point.
std::vector<hash_map_compat<int, float> > mCharProbabilities;
// The vector for the key code set which holds nearby keys for each sampled input point
// 1. Used to calculate the probability of the key
- // 2. Used to calculate mSearchKeysVector
- std::vector<ProximityInfoStateUtils::NearKeycodesSet> mNearKeysVector;
+ // 2. Used to calculate mSampledSearchKeysVector
+ std::vector<ProximityInfoStateUtils::NearKeycodesSet> mSampledNearKeysVector;
// The vector for the key code set which holds nearby keys of some trailing sampled input points
// for each sampled input point. These nearby keys contain the next characters which can be in
// the dictionary. Specifically, currently we are looking for keys nearby trailing sampled
// inputs including the current input point.
- std::vector<ProximityInfoStateUtils::NearKeycodesSet> mSearchKeysVector;
+ std::vector<ProximityInfoStateUtils::NearKeycodesSet> mSampledSearchKeysVector;
bool mTouchPositionCorrectionEnabled;
int mInputProximities[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH];
int mNormalizedSquaredDistances[MAX_PROXIMITY_CHARS_SIZE * MAX_WORD_LENGTH];
diff --git a/native/jni/src/proximity_info_state_utils.cpp b/native/jni/src/proximity_info_state_utils.cpp
index 89e9a30e8..cbc191ed5 100644
--- a/native/jni/src/proximity_info_state_utils.cpp
+++ b/native/jni/src/proximity_info_state_utils.cpp
@@ -215,15 +215,12 @@ namespace latinime {
const int sampledInputSize, const int lastSavedInputSize,
const std::vector<int> *const sampledInputXs,
const std::vector<int> *const sampledInputYs,
- std::vector<NearKeycodesSet> *nearKeysVector,
- std::vector<NearKeycodesSet> *searchKeysVector,
- std::vector<float> *distanceCache_G) {
- nearKeysVector->resize(sampledInputSize);
- searchKeysVector->resize(sampledInputSize);
- distanceCache_G->resize(sampledInputSize * keyCount);
+ std::vector<NearKeycodesSet> *SampledNearKeysVector,
+ std::vector<float> *SampledDistanceCache_G) {
+ SampledNearKeysVector->resize(sampledInputSize);
+ SampledDistanceCache_G->resize(sampledInputSize * keyCount);
for (int i = lastSavedInputSize; i < sampledInputSize; ++i) {
- (*nearKeysVector)[i].reset();
- (*searchKeysVector)[i].reset();
+ (*SampledNearKeysVector)[i].reset();
static const float NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD = 4.0f;
for (int k = 0; k < keyCount; ++k) {
const int index = i * keyCount + k;
@@ -231,9 +228,9 @@ namespace latinime {
const int y = (*sampledInputYs)[i];
const float normalizedSquaredDistance =
proximityInfo->getNormalizedSquaredDistanceFromCenterFloatG(k, x, y);
- (*distanceCache_G)[index] = normalizedSquaredDistance;
+ (*SampledDistanceCache_G)[index] = normalizedSquaredDistance;
if (normalizedSquaredDistance < NEAR_KEY_NORMALIZED_SQUARED_THRESHOLD) {
- (*nearKeysVector)[i][k] = true;
+ (*SampledNearKeysVector)[i][k] = true;
}
}
}
@@ -638,21 +635,21 @@ namespace latinime {
// This function basically converts from a length to an edit distance. Accordingly, it's obviously
// wrong to compare with mMaxPointToKeyLength.
/* static */ float ProximityInfoStateUtils::getPointToKeyByIdLength(const float maxPointToKeyLength,
- const std::vector<float> *const distanceCache_G, const int keyCount,
+ const std::vector<float> *const SampledDistanceCache_G, const int keyCount,
const int inputIndex, const int keyId, const float scale) {
if (keyId != NOT_AN_INDEX) {
const int index = inputIndex * keyCount + keyId;
- return min((*distanceCache_G)[index] * scale, maxPointToKeyLength);
+ return min((*SampledDistanceCache_G)[index] * scale, maxPointToKeyLength);
}
// If the char is not a key on the keyboard then return the max length.
return static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
}
/* static */ float ProximityInfoStateUtils::getPointToKeyByIdLength(const float maxPointToKeyLength,
- const std::vector<float> *const distanceCache_G, const int keyCount,
+ const std::vector<float> *const SampledDistanceCache_G, const int keyCount,
const int inputIndex, const int keyId) {
- return getPointToKeyByIdLength(maxPointToKeyLength, distanceCache_G, keyCount, inputIndex,
- keyId, 1.0f);
+ return getPointToKeyByIdLength(
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, inputIndex, keyId, 1.0f);
}
// Updates probabilities of aligning to some keys and skipping.
@@ -663,8 +660,8 @@ namespace latinime {
const std::vector<int> *const sampledInputYs,
const std::vector<float> *const sampledSpeedRates,
const std::vector<int> *const sampledLengthCache,
- const std::vector<float> *const distanceCache_G,
- std::vector<NearKeycodesSet> *nearKeysVector,
+ const std::vector<float> *const SampledDistanceCache_G,
+ std::vector<NearKeycodesSet> *SampledNearKeysVector,
std::vector<hash_map_compat<int, float> > *charProbabilities) {
static const float MIN_PROBABILITY = 0.000001f;
static const float MAX_SKIP_PROBABILITY = 0.95f;
@@ -701,9 +698,9 @@ namespace latinime {
float nearestKeyDistance = static_cast<float>(MAX_POINT_TO_KEY_LENGTH);
for (int j = 0; j < keyCount; ++j) {
- if ((*nearKeysVector)[i].test(j)) {
+ if ((*SampledNearKeysVector)[i].test(j)) {
const float distance = getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i, j);
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i, j);
if (distance < nearestKeyDistance) {
nearestKeyDistance = distance;
}
@@ -786,14 +783,14 @@ namespace latinime {
// Summing up probability densities of all near keys.
float sumOfProbabilityDensities = 0.0f;
for (int j = 0; j < keyCount; ++j) {
- if ((*nearKeysVector)[i].test(j)) {
+ if ((*SampledNearKeysVector)[i].test(j)) {
float distance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i, j));
if (i == 0 && i != sampledInputSize - 1) {
// For the first point, weighted average of distances from first point and the
// next point to the key is used as a point to key distance.
const float nextDistance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i + 1, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i + 1, j));
if (nextDistance < distance) {
// The distance of the first point tends to bigger than continuing
// points because the first touch by the user can be sloppy.
@@ -806,7 +803,7 @@ namespace latinime {
// For the first point, weighted average of distances from last point and
// the previous point to the key is used as a point to key distance.
const float previousDistance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i - 1, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i - 1, j));
if (previousDistance < distance) {
// The distance of the last point tends to bigger than continuing points
// because the last touch by the user can be sloppy. So we promote the
@@ -824,14 +821,14 @@ namespace latinime {
// Split the probability of an input point to keys that are close to the input point.
for (int j = 0; j < keyCount; ++j) {
- if ((*nearKeysVector)[i].test(j)) {
+ if ((*SampledNearKeysVector)[i].test(j)) {
float distance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i, j));
if (i == 0 && i != sampledInputSize - 1) {
// For the first point, weighted average of distances from the first point and
// the next point to the key is used as a point to key distance.
const float prevDistance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i + 1, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i + 1, j));
if (prevDistance < distance) {
distance = (distance + prevDistance * NEXT_DISTANCE_WEIGHT)
/ (1.0f + NEXT_DISTANCE_WEIGHT);
@@ -840,7 +837,7 @@ namespace latinime {
// For the first point, weighted average of distances from last point and
// the previous point to the key is used as a point to key distance.
const float prevDistance = sqrtf(getPointToKeyByIdLength(
- maxPointToKeyLength, distanceCache_G, keyCount, i - 1, j));
+ maxPointToKeyLength, SampledDistanceCache_G, keyCount, i - 1, j));
if (prevDistance < distance) {
distance = (distance + prevDistance * PREV_DISTANCE_WEIGHT)
/ (1.0f + PREV_DISTANCE_WEIGHT);
@@ -906,10 +903,10 @@ namespace latinime {
for (int j = 0; j < keyCount; ++j) {
hash_map_compat<int, float>::iterator it = (*charProbabilities)[i].find(j);
if (it == (*charProbabilities)[i].end()){
- (*nearKeysVector)[i].reset(j);
+ (*SampledNearKeysVector)[i].reset(j);
} else if(it->second < MIN_PROBABILITY) {
// Erases from near keys vector because it has very low probability.
- (*nearKeysVector)[i].reset(j);
+ (*SampledNearKeysVector)[i].reset(j);
(*charProbabilities)[i].erase(j);
} else {
it->second = -logf(it->second);
@@ -919,25 +916,26 @@ namespace latinime {
}
}
-/* static */ void ProximityInfoStateUtils::updateSearchKeysVector(
+/* static */ void ProximityInfoStateUtils::updateSampledSearchKeysVector(
const ProximityInfo *const proximityInfo, const int sampledInputSize,
const int lastSavedInputSize,
const std::vector<int> *const sampledLengthCache,
- const std::vector<NearKeycodesSet> *const nearKeysVector,
- std::vector<NearKeycodesSet> *searchKeysVector) {
+ const std::vector<NearKeycodesSet> *const SampledNearKeysVector,
+ std::vector<NearKeycodesSet> *sampledSearchKeysVector) {
+ sampledSearchKeysVector->resize(sampledInputSize);
const int readForwordLength = static_cast<int>(
hypotf(proximityInfo->getKeyboardWidth(), proximityInfo->getKeyboardHeight())
* ProximityInfoParams::SEARCH_KEY_RADIUS_RATIO);
for (int i = 0; i < sampledInputSize; ++i) {
if (i >= lastSavedInputSize) {
- (*searchKeysVector)[i].reset();
+ (*sampledSearchKeysVector)[i].reset();
}
for (int j = max(i, lastSavedInputSize); j < sampledInputSize; ++j) {
// TODO: Investigate if this is required. This may not fail.
if ((*sampledLengthCache)[j] - (*sampledLengthCache)[i] >= readForwordLength) {
break;
}
- (*searchKeysVector)[i] |= (*nearKeysVector)[j];
+ (*sampledSearchKeysVector)[i] |= (*SampledNearKeysVector)[j];
}
}
}
diff --git a/native/jni/src/proximity_info_state_utils.h b/native/jni/src/proximity_info_state_utils.h
index b70121ad2..17ef1c3d7 100644
--- a/native/jni/src/proximity_info_state_utils.h
+++ b/native/jni/src/proximity_info_state_utils.h
@@ -69,29 +69,28 @@ class ProximityInfoStateUtils {
const std::vector<int> *const sampledInputYs,
const std::vector<float> *const sampledSpeedRates,
const std::vector<int> *const sampledLengthCache,
- const std::vector<float> *const distanceCache_G,
- std::vector<NearKeycodesSet> *nearKeysVector,
+ const std::vector<float> *const SampledDistanceCache_G,
+ std::vector<NearKeycodesSet> *SampledNearKeysVector,
std::vector<hash_map_compat<int, float> > *charProbabilities);
- static void updateSearchKeysVector(
+ static void updateSampledSearchKeysVector(
const ProximityInfo *const proximityInfo, const int sampledInputSize,
const int lastSavedInputSize,
const std::vector<int> *const sampledLengthCache,
- const std::vector<NearKeycodesSet> *const nearKeysVector,
- std::vector<NearKeycodesSet> *searchKeysVector);
+ const std::vector<NearKeycodesSet> *const SampledNearKeysVector,
+ std::vector<NearKeycodesSet> *sampledSearchKeysVector);
static float getPointToKeyByIdLength(const float maxPointToKeyLength,
- const std::vector<float> *const distanceCache_G, const int keyCount,
+ const std::vector<float> *const SampledDistanceCache_G, const int keyCount,
const int inputIndex, const int keyId, const float scale);
static float getPointToKeyByIdLength(const float maxPointToKeyLength,
- const std::vector<float> *const distanceCache_G, const int keyCount,
+ const std::vector<float> *const SampledDistanceCache_G, const int keyCount,
const int inputIndex, const int keyId);
static void initGeometricDistanceInfos(
const ProximityInfo *const proximityInfo, const int keyCount,
const int sampledInputSize, const int lastSavedInputSize,
const std::vector<int> *const sampledInputXs,
const std::vector<int> *const sampledInputYs,
- std::vector<NearKeycodesSet> *nearKeysVector,
- std::vector<NearKeycodesSet> *searchKeysVector,
- std::vector<float> *distanceCache_G);
+ std::vector<NearKeycodesSet> *SampledNearKeysVector,
+ std::vector<float> *SampledDistanceCache_G);
static void initPrimaryInputWord(
const int inputSize, const int *const inputProximities, int *primaryInputWord);
static void initNormalizedSquaredDistances(
diff --git a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
index 015c2711c..4db54477c 100644
--- a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
@@ -17,7 +17,6 @@
package com.android.inputmethod.keyboard;
import android.content.Context;
-import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.view.inputmethod.InputMethodSubtype;
@@ -35,7 +34,6 @@ public class SpacebarTextTests extends AndroidTestCase {
private final ArrayList<InputMethodSubtype> mSubtypesList = CollectionUtils.newArrayList();
private RichInputMethodManager mRichImm;
- private Resources mRes;
@Override
protected void setUp() throws Exception {
@@ -43,14 +41,13 @@ public class SpacebarTextTests extends AndroidTestCase {
final Context context = getContext();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
- mRes = context.getResources();
SubtypeLocale.init(context);
}
public void testAllFullDisplayName() {
for (final InputMethodSubtype subtype : mSubtypesList) {
- final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes);
- final String spacebarText = MainKeyboardView.getFullDisplayName(subtype, mRes);
+ final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
+ final String spacebarText = MainKeyboardView.getFullDisplayName(subtype);
final String languageName =
SubtypeLocale.getSubtypeLocaleDisplayName(subtype.getLocale());
if (SubtypeLocale.isNoLanguage(subtype)) {
@@ -63,7 +60,7 @@ public class SpacebarTextTests extends AndroidTestCase {
public void testAllMiddleDisplayName() {
for (final InputMethodSubtype subtype : mSubtypesList) {
- final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes);
+ final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
final String spacebarText = MainKeyboardView.getMiddleDisplayName(subtype);
if (SubtypeLocale.isNoLanguage(subtype)) {
assertEquals(subtypeName,
@@ -78,7 +75,7 @@ public class SpacebarTextTests extends AndroidTestCase {
public void testAllShortDisplayName() {
for (final InputMethodSubtype subtype : mSubtypesList) {
- final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes);
+ final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
final String spacebarText = MainKeyboardView.getShortDisplayName(subtype);
final String languageCode = StringUtils.toTitleCase(locale.getLanguage(), locale);
@@ -120,17 +117,17 @@ public class SpacebarTextTests extends AndroidTestCase {
SubtypeLocale.NO_LANGUAGE, "qwerty");
assertEquals("en_US", "English (US)",
- MainKeyboardView.getFullDisplayName(EN_US, mRes));
+ MainKeyboardView.getFullDisplayName(EN_US));
assertEquals("en_GB", "English (UK)",
- MainKeyboardView.getFullDisplayName(EN_GB, mRes));
+ MainKeyboardView.getFullDisplayName(EN_GB));
assertEquals("fr ", "Français",
- MainKeyboardView.getFullDisplayName(FR, mRes));
+ MainKeyboardView.getFullDisplayName(FR));
assertEquals("fr_CA", "Français (Canada)",
- MainKeyboardView.getFullDisplayName(FR_CA, mRes));
+ MainKeyboardView.getFullDisplayName(FR_CA));
assertEquals("de ", "Deutsch",
- MainKeyboardView.getFullDisplayName(DE, mRes));
+ MainKeyboardView.getFullDisplayName(DE));
assertEquals("zz ", "QWERTY",
- MainKeyboardView.getFullDisplayName(ZZ, mRes));
+ MainKeyboardView.getFullDisplayName(ZZ));
assertEquals("en_US", "English", MainKeyboardView.getMiddleDisplayName(EN_US));
assertEquals("en_GB", "English", MainKeyboardView.getMiddleDisplayName(EN_GB));
@@ -158,13 +155,13 @@ public class SpacebarTextTests extends AndroidTestCase {
SubtypeLocale.NO_LANGUAGE, "azerty", null);
assertEquals("fr qwertz", "Français (QWERTZ)",
- MainKeyboardView.getFullDisplayName(FR_QWERTZ, mRes));
+ MainKeyboardView.getFullDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch (QWERTY)",
- MainKeyboardView.getFullDisplayName(DE_QWERTY, mRes));
+ MainKeyboardView.getFullDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "English (US) (AZERTY)",
- MainKeyboardView.getFullDisplayName(US_AZERTY, mRes));
+ MainKeyboardView.getFullDisplayName(US_AZERTY));
assertEquals("zz azerty", "AZERTY",
- MainKeyboardView.getFullDisplayName(ZZ_AZERTY, mRes));
+ MainKeyboardView.getFullDisplayName(ZZ_AZERTY));
assertEquals("fr qwertz", "Français", MainKeyboardView.getMiddleDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch", MainKeyboardView.getMiddleDisplayName(DE_QWERTY));
diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
index 4e81de668..9af6dbc74 100644
--- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
+++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
@@ -33,6 +33,18 @@ public class SubtypeLocaleTests extends AndroidTestCase {
private RichInputMethodManager mRichImm;
private Resources mRes;
+ InputMethodSubtype EN_US;
+ InputMethodSubtype EN_GB;
+ InputMethodSubtype ES_US;
+ InputMethodSubtype FR;
+ InputMethodSubtype FR_CA;
+ InputMethodSubtype DE;
+ InputMethodSubtype ZZ;
+ InputMethodSubtype DE_QWERTY;
+ InputMethodSubtype FR_QWERTZ;
+ InputMethodSubtype US_AZERTY;
+ InputMethodSubtype ZZ_AZERTY;
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -41,11 +53,35 @@ public class SubtypeLocaleTests extends AndroidTestCase {
mRichImm = RichInputMethodManager.getInstance();
mRes = context.getResources();
SubtypeLocale.init(context);
+
+ EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.US.toString(), "qwerty");
+ EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.UK.toString(), "qwerty");
+ ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "es_US", "spanish");
+ FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.FRENCH.toString(), "azerty");
+ FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.CANADA_FRENCH.toString(), "qwerty");
+ DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.GERMAN.toString(), "qwertz");
+ ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ SubtypeLocale.NO_LANGUAGE, "qwerty");
+ DE_QWERTY = AdditionalSubtype.createAdditionalSubtype(
+ Locale.GERMAN.toString(), "qwerty", null);
+ FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype(
+ Locale.FRENCH.toString(), "qwertz", null);
+ US_AZERTY = AdditionalSubtype.createAdditionalSubtype(
+ Locale.US.toString(), "azerty", null);
+ ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype(
+ SubtypeLocale.NO_LANGUAGE, "azerty", null);
+
}
public void testAllFullDisplayName() {
for (final InputMethodSubtype subtype : mSubtypesList) {
- final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes);
+ final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype);
if (SubtypeLocale.isNoLanguage(subtype)) {
final String noLanguage = mRes.getString(R.string.subtype_no_language);
assertTrue(subtypeName, subtypeName.contains(noLanguage));
@@ -74,21 +110,6 @@ public class SubtypeLocaleTests extends AndroidTestCase {
// zz azerty T No language (AZERTY) in system locale
public void testPredefinedSubtypesInEnglish() {
- final InputMethodSubtype EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.US.toString(), "qwerty");
- final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.UK.toString(), "qwerty");
- final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "es_US", "spanish");
- final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.FRENCH.toString(), "azerty");
- final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.CANADA_FRENCH.toString(), "qwerty");
- final InputMethodSubtype DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.GERMAN.toString(), "qwertz");
- final InputMethodSubtype ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocale.NO_LANGUAGE, "qwerty");
-
assertEquals("en_US", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_US));
assertEquals("en_GB", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_GB));
assertEquals("es_US", "spanish", SubtypeLocale.getKeyboardLayoutSetName(ES_US));
@@ -101,19 +122,19 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override
protected Void job(Resources res) {
assertEquals("en_US", "English (US)",
- SubtypeLocale.getSubtypeDisplayName(EN_US, res));
+ SubtypeLocale.getSubtypeDisplayName(EN_US));
assertEquals("en_GB", "English (UK)",
- SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ SubtypeLocale.getSubtypeDisplayName(EN_GB));
assertEquals("es_US", "Español (EE.UU.)",
- SubtypeLocale.getSubtypeDisplayName(ES_US, res));
+ SubtypeLocale.getSubtypeDisplayName(ES_US));
assertEquals("fr ", "Français",
- SubtypeLocale.getSubtypeDisplayName(FR, res));
+ SubtypeLocale.getSubtypeDisplayName(FR));
assertEquals("fr_CA", "Français (Canada)",
- SubtypeLocale.getSubtypeDisplayName(FR_CA, res));
+ SubtypeLocale.getSubtypeDisplayName(FR_CA));
assertEquals("de ", "Deutsch",
- SubtypeLocale.getSubtypeDisplayName(DE, res));
+ SubtypeLocale.getSubtypeDisplayName(DE));
assertEquals("zz ", "No language (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ, res));
+ SubtypeLocale.getSubtypeDisplayName(ZZ));
return null;
}
};
@@ -121,26 +142,17 @@ public class SubtypeLocaleTests extends AndroidTestCase {
}
public void testAdditionalSubtypesInEnglish() {
- final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype(
- Locale.GERMAN.toString(), "qwerty", null);
- final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype(
- Locale.FRENCH.toString(), "qwertz", null);
- final InputMethodSubtype US_AZERTY = AdditionalSubtype.createAdditionalSubtype(
- Locale.US.toString(), "azerty", null);
- final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype(
- SubtypeLocale.NO_LANGUAGE, "azerty", null);
-
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job(Resources res) {
assertEquals("fr qwertz", "Français (QWERTZ)",
- SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res));
+ SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "English (US) (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(US_AZERTY));
assertEquals("zz azerty", "No language (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY));
return null;
}
};
@@ -148,38 +160,23 @@ public class SubtypeLocaleTests extends AndroidTestCase {
}
public void testPredefinedSubtypesInFrench() {
- final InputMethodSubtype EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.US.toString(), "qwerty");
- final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.UK.toString(), "qwerty");
- final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "es_US", "spanish");
- final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.FRENCH.toString(), "azerty");
- final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.CANADA_FRENCH.toString(), "qwerty");
- final InputMethodSubtype DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.GERMAN.toString(), "qwertz");
- final InputMethodSubtype ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocale.NO_LANGUAGE, "qwerty");
-
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job(Resources res) {
assertEquals("en_US", "English (US)",
- SubtypeLocale.getSubtypeDisplayName(EN_US, res));
+ SubtypeLocale.getSubtypeDisplayName(EN_US));
assertEquals("en_GB", "English (UK)",
- SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ SubtypeLocale.getSubtypeDisplayName(EN_GB));
assertEquals("es_US", "Español (EE.UU.)",
- SubtypeLocale.getSubtypeDisplayName(ES_US, res));
+ SubtypeLocale.getSubtypeDisplayName(ES_US));
assertEquals("fr ", "Français",
- SubtypeLocale.getSubtypeDisplayName(FR, res));
+ SubtypeLocale.getSubtypeDisplayName(FR));
assertEquals("fr_CA", "Français (Canada)",
- SubtypeLocale.getSubtypeDisplayName(FR_CA, res));
+ SubtypeLocale.getSubtypeDisplayName(FR_CA));
assertEquals("de ", "Deutsch",
- SubtypeLocale.getSubtypeDisplayName(DE, res));
+ SubtypeLocale.getSubtypeDisplayName(DE));
assertEquals("zz ", "Pas de langue (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ, res));
+ SubtypeLocale.getSubtypeDisplayName(ZZ));
return null;
}
};
@@ -187,26 +184,17 @@ public class SubtypeLocaleTests extends AndroidTestCase {
}
public void testAdditionalSubtypesInFrench() {
- final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype(
- Locale.GERMAN.toString(), "qwerty", null);
- final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype(
- Locale.FRENCH.toString(), "qwertz", null);
- final InputMethodSubtype US_AZERTY = AdditionalSubtype.createAdditionalSubtype(
- Locale.US.toString(), "azerty", null);
- final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype(
- SubtypeLocale.NO_LANGUAGE, "azerty", null);
-
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job(Resources res) {
assertEquals("fr qwertz", "Français (QWERTZ)",
- SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res));
+ SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "English (US) (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(US_AZERTY));
assertEquals("zz azerty", "Aucune langue (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res));
+ SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY));
return null;
}
};