aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/layout/additional_subtype_dialog.xml56
-rw-r--r--java/res/values-af/strings.xml4
-rw-r--r--java/res/values-es-rUS/strings.xml2
-rw-r--r--java/res/values-fa/strings.xml2
-rw-r--r--java/res/values/predefined-subtypes.xml23
-rw-r--r--java/res/values/strings.xml17
-rw-r--r--java/res/xml/additional_subtype_settings.xml19
-rw-r--r--java/res/xml/prefs.xml4
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java5
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java29
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java6
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java4
-rw-r--r--java/src/com/android/inputmethod/latin/AdditionalSubtype.java66
-rw-r--r--java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java440
-rw-r--r--java/src/com/android/inputmethod/latin/Constants.java103
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFactory.java15
-rw-r--r--java/src/com/android/inputmethod/latin/ImfUtils.java4
-rw-r--r--java/src/com/android/inputmethod/latin/InputAttributes.java8
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java71
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java18
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsActivity.java12
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsValues.java26
-rw-r--r--java/src/com/android/inputmethod/latin/StringUtils.java50
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java34
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java10
25 files changed, 874 insertions, 154 deletions
diff --git a/java/res/layout/additional_subtype_dialog.xml b/java/res/layout/additional_subtype_dialog.xml
new file mode 100644
index 000000000..f97c006d6
--- /dev/null
+++ b/java/res/layout/additional_subtype_dialog.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:columnCount="2"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="8dip"
+ android:layout_marginRight="8dip"
+ android:padding="8dip">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|center_vertical"
+ style="?android:attr/textAppearanceSmall"
+ android:text="@string/subtype_locale" />
+ <Spinner
+ android:id="@+id/subtype_locale_spinner"
+ android:layout_width="wrap_content"
+ android:layout_marginLeft="8dip"
+ android:layout_marginBottom="8dip"
+ android:layout_marginTop="8dip"
+ android:layout_gravity="fill_horizontal|center_vertical"
+ android:prompt="@string/subtype_locale" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|center_vertical"
+ style="?android:attr/textAppearanceSmall"
+ android:text="@string/keyboard_layout_set" />
+ <Spinner
+ android:id="@+id/keyboard_layout_set_spinner"
+ android:layout_width="wrap_content"
+ android:layout_marginLeft="8dip"
+ android:layout_marginBottom="8dip"
+ android:layout_marginTop="8dip"
+ android:layout_gravity="fill_horizontal|center_vertical"
+ android:prompt="@string/keyboard_layout_set" />
+</GridLayout>
diff --git a/java/res/values-af/strings.xml b/java/res/values-af/strings.xml
index a0bef12f7..ce9d784bf 100644
--- a/java/res/values-af/strings.xml
+++ b/java/res/values-af/strings.xml
@@ -61,9 +61,9 @@
<string name="auto_correction_threshold_mode_modest" msgid="8788366690620799097">"Matig"</string>
<string name="auto_correction_threshold_mode_aggeressive" msgid="3524029103734923819">"Aggressief"</string>
<string name="auto_correction_threshold_mode_very_aggeressive" msgid="3386782235540547678">"Baie aggressief"</string>
- <string name="bigram_suggestion" msgid="8169311444438922902">"Volgende woordvoorstelle"</string>
+ <string name="bigram_suggestion" msgid="8169311444438922902">"Volgendewoordvoorstelle"</string>
<string name="bigram_suggestion_summary" msgid="6635527607242625713">"Gebruik vorige woord om voorstelle te verbeter"</string>
- <string name="bigram_prediction" msgid="3216364899483135294">"Volgende woordvoorspelling"</string>
+ <string name="bigram_prediction" msgid="3216364899483135294">"Volgendewoordvoorspelling"</string>
<string name="bigram_prediction_summary" msgid="1747261921174300098">"Gebruik vorige woord ook vir voorspelling"</string>
<string name="added_word" msgid="8993883354622484372">"<xliff:g id="WORD">%s</xliff:g> : Gestoor"</string>
<string name="label_go_key" msgid="1635148082137219148">"Gaan"</string>
diff --git a/java/res/values-es-rUS/strings.xml b/java/res/values-es-rUS/strings.xml
index 75b1fb47e..c1f9223c6 100644
--- a/java/res/values-es-rUS/strings.xml
+++ b/java/res/values-es-rUS/strings.xml
@@ -62,7 +62,7 @@
<string name="auto_correction_threshold_mode_aggeressive" msgid="3524029103734923819">"Total"</string>
<string name="auto_correction_threshold_mode_very_aggeressive" msgid="3386782235540547678">"Muy agresivo"</string>
<string name="bigram_suggestion" msgid="8169311444438922902">"Sugerencias para la palabra siguiente"</string>
- <string name="bigram_suggestion_summary" msgid="6635527607242625713">"Utiliza la palabra anterior para mejorar las sugerencias."</string>
+ <string name="bigram_suggestion_summary" msgid="6635527607242625713">"Usar la palabra anterior para mejorar las sugerencias"</string>
<string name="bigram_prediction" msgid="3216364899483135294">"Predicción de la palabra siguiente"</string>
<string name="bigram_prediction_summary" msgid="1747261921174300098">"Usar la palabra anterior también para predicción."</string>
<string name="added_word" msgid="8993883354622484372">"<xliff:g id="WORD">%s</xliff:g>: guardada"</string>
diff --git a/java/res/values-fa/strings.xml b/java/res/values-fa/strings.xml
index 5a6302fe3..9f9dde328 100644
--- a/java/res/values-fa/strings.xml
+++ b/java/res/values-fa/strings.xml
@@ -63,7 +63,7 @@
<string name="auto_correction_threshold_mode_very_aggeressive" msgid="3386782235540547678">"بسیار پرخاشگرانه"</string>
<string name="bigram_suggestion" msgid="8169311444438922902">"پیشنهادات کلمه بعدی"</string>
<string name="bigram_suggestion_summary" msgid="6635527607242625713">"برای بهبود پیشنهاد از کلمه قبلی استفاده شود"</string>
- <string name="bigram_prediction" msgid="3216364899483135294">"پیش بینی کلمه بعدی"</string>
+ <string name="bigram_prediction" msgid="3216364899483135294">"پیش‌بینی کلمه بعدی"</string>
<string name="bigram_prediction_summary" msgid="1747261921174300098">"استفاده از کلمه قبلی برای پیش بینی"</string>
<string name="added_word" msgid="8993883354622484372">"<xliff:g id="WORD">%s</xliff:g> : ذخیره شد"</string>
<string name="label_go_key" msgid="1635148082137219148">"برو"</string>
diff --git a/java/res/values/predefined-subtypes.xml b/java/res/values/predefined-subtypes.xml
new file mode 100644
index 000000000..602f53eac
--- /dev/null
+++ b/java/res/values/predefined-subtypes.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Predefined subtypes (language:layout[:extraValue]) in semicolon separated format -->
+ <string name="predefined_subtypes" translatable="false">de:qwerty:AsciiCapable;fr:qwertz:AsciiCapable</string>
+</resources>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 28acd0fcc..93bd26867 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -252,9 +252,26 @@
<string name="subtype_en_GB">English (UK)</string>
<!-- Description for English (United States) keyboard subtype [CHAR LIMIT=22] -->
<string name="subtype_en_US">English (US)</string>
+ <!-- Description for language agnostic keyboard subtype [CHAR LIMIT=22] -->
+ <string name="subtype_no_language">No language</string>
<!-- Description for language agnostic QWERTY keyboard subtype [CHAR LIMIT=22] -->
<string name="subtype_no_language_qwerty">No language (QWERTY)</string>
+ <!-- Title of the preference settings for custom input styles (language and keyboard layout pairs) [CHAR LIMIT=22]-->
+ <string name="custom_input_styles_title">Custom input styles</string>
+ <!-- Title of the option menu to add a new style entry in the preference settings [CHAR_LIMIT=12] -->
+ <string name="add_style">Add style</string>
+ <!-- Title of the button to add custom style entry in the settings dialog [CHAR_LIMIT=12] -->
+ <string name="add">Add</string>
+ <!-- Title of the button to remove a custom style entry in the settings dialog [CHAR_LIMIT=12] -->
+ <string name="remove">Remove</string>
+ <!-- Title of the button to save a custom style entry in the settings dialog [CHAR_LIMIT=12] -->
+ <string name="save">Save</string>
+ <!-- Title of the spinner for choosing a language of custom style in the settings dialog [CHAR_LIMIT=12] -->
+ <string name="subtype_locale">Language</string>
+ <!-- Title of the spinner for choosing a keyboard layout of custom style in the settings dialog [CHAR_LIMIT=12] -->
+ <string name="keyboard_layout_set">Layout</string>
+
<!-- Title of an option for usability study mode -->
<string name="prefs_usability_study_mode">Usability study mode</string>
<!-- Title of the settings for keypress vibration duration -->
diff --git a/java/res/xml/additional_subtype_settings.xml b/java/res/xml/additional_subtype_settings.xml
new file mode 100644
index 000000000..ad280c146
--- /dev/null
+++ b/java/res/xml/additional_subtype_settings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Items will be added at runtime -->
+</PreferenceScreen>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index ab5d44b24..3598a685e 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -100,6 +100,10 @@
android:summary="@string/include_other_imes_in_language_switch_list_summary"
android:persistent="true"
android:defaultValue="false" />
+ <PreferenceScreen
+ android:fragment="com.android.inputmethod.latin.AdditionalSubtypeSettings"
+ android:key="custom_input_styles"
+ android:title="@string/custom_input_styles_title" />
<!-- Values for popup dismiss delay are added programatically -->
<ListPreference
android:key="pref_key_preview_popup_dismiss_delay"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index b7eb8f69c..233716acf 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.keyboard;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
+
import android.text.InputType;
import android.text.TextUtils;
import android.view.inputmethod.EditorInfo;
@@ -23,7 +25,6 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.latin.InputTypeUtils;
-import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.SubtypeLocale;
import java.util.Arrays;
@@ -184,7 +185,7 @@ public class KeyboardId {
return String.format("[%s %s:%s %s%d %s %s %s%s%s%s%s%s%s%s]",
elementIdToName(mElementId),
mLocale,
- mSubtype.getExtraValueOf(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET),
+ mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
(mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode),
imeAction(),
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index 35209e0ad..8c7246855 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -16,6 +16,12 @@
package com.android.inputmethod.keyboard;
+import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
+import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
+import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
+import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
+
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -29,11 +35,10 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.keyboard.KeyboardLayoutSet.Params.ElementParams;
+import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.InputTypeUtils;
-import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.XmlParseUtils;
@@ -229,8 +234,8 @@ public class KeyboardLayoutSet {
params.mMode = getKeyboardMode(editorInfo);
params.mEditorInfo = (editorInfo != null) ? editorInfo : EMPTY_EDITOR_INFO;
- params.mNoSettingsKey = StringUtils.inPrivateImeOptions(
- mPackageName, LatinIME.IME_OPTION_NO_SETTINGS_KEY, mEditorInfo);
+ params.mNoSettingsKey = InputAttributes.inPrivateImeOptions(
+ mPackageName, NO_SETTINGS_KEY, mEditorInfo);
}
public Builder setScreenGeometry(int orientation, int widthPixels) {
@@ -240,10 +245,10 @@ public class KeyboardLayoutSet {
}
public Builder setSubtype(InputMethodSubtype subtype) {
- final boolean asciiCapable = subtype.containsExtraValueKey(
- LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE);
- final boolean deprecatedForceAscii = StringUtils.inPrivateImeOptions(
- mPackageName, LatinIME.IME_OPTION_FORCE_ASCII, mEditorInfo);
+ final boolean asciiCapable = subtype.containsExtraValueKey(ASCII_CAPABLE);
+ @SuppressWarnings("deprecation")
+ final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
+ mPackageName, FORCE_ASCII, mEditorInfo);
final boolean forceAscii = EditorInfoCompatUtils.hasFlagForceAscii(
mParams.mEditorInfo.imeOptions)
|| deprecatedForceAscii;
@@ -259,10 +264,10 @@ public class KeyboardLayoutSet {
public Builder setOptions(boolean voiceKeyEnabled, boolean voiceKeyOnMain,
boolean languageSwitchKeyEnabled) {
@SuppressWarnings("deprecation")
- final boolean deprecatedNoMicrophone = StringUtils.inPrivateImeOptions(
- null, LatinIME.IME_OPTION_NO_MICROPHONE_COMPAT, mEditorInfo);
- final boolean noMicrophone = StringUtils.inPrivateImeOptions(
- mPackageName, LatinIME.IME_OPTION_NO_MICROPHONE, mEditorInfo)
+ final boolean deprecatedNoMicrophone = InputAttributes.inPrivateImeOptions(
+ null, NO_MICROPHONE_COMPAT, mEditorInfo);
+ final boolean noMicrophone = InputAttributes.inPrivateImeOptions(
+ mPackageName, NO_MICROPHONE, mEditorInfo)
|| deprecatedNoMicrophone;
mParams.mVoiceKeyEnabled = voiceKeyEnabled && !noMicrophone;
mParams.mVoiceKeyOnMain = voiceKeyOnMain;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
index 9bbd3a280..8261400b2 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java
@@ -159,7 +159,7 @@ public class KeySpecParser {
return parseEscape(moreKeySpec.substring(end + /* LABEL_END */1));
}
- private static String getOutputText(String moreKeySpec) {
+ static String getOutputText(String moreKeySpec) {
if (hasCode(moreKeySpec)) {
return null;
}
@@ -183,7 +183,7 @@ public class KeySpecParser {
return (StringUtils.codePointCount(label) == 1) ? null : label;
}
- private static int getCode(String moreKeySpec, KeyboardCodesSet codesSet) {
+ static int getCode(String moreKeySpec, KeyboardCodesSet codesSet) {
if (hasCode(moreKeySpec)) {
final int end = indexOfLabelEnd(moreKeySpec, 0);
if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) {
@@ -219,7 +219,7 @@ public class KeySpecParser {
}
}
- private static int getIconId(String moreKeySpec) {
+ static int getIconId(String moreKeySpec) {
if (hasIcon(moreKeySpec)) {
final int end = moreKeySpec.indexOf(LABEL_END, PREFIX_ICON.length());
final String name = moreKeySpec.substring(PREFIX_ICON.length(), end);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java
index a46f3bf1b..3ade2dda7 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardLabelsSet.java
@@ -755,7 +755,7 @@ public final class KeyboardLabelsSet {
// U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX
// U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS
// U+0113: "ē" LATIN SMALL LETTER E WITH MACRON
- /* 1 */ "\u00E8,\u00E9,\u00EA,\u00EB,\u0103",
+ /* 1 */ "\u00E8,\u00E9,\u00EA,\u00EB,\u0113",
// U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX
// U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS
// U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE
@@ -770,7 +770,7 @@ public final class KeyboardLabelsSet {
// U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE
// U+014D: "ō" LATIN SMALL LETTER O WITH MACRON
// U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE
- /* 3 */ "\u00F4,\u00F6,\u00F2,\u00F3,\u0153,\u00F8\u014D,\u00F5",
+ /* 3 */ "\u00F4,\u00F6,\u00F2,\u00F3,\u0153,\u00F8,\u014D,\u00F5",
// U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX
// U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS
// U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtype.java b/java/src/com/android/inputmethod/latin/AdditionalSubtype.java
index 5e42ad6c5..28cec56e6 100644
--- a/java/src/com/android/inputmethod/latin/AdditionalSubtype.java
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtype.java
@@ -16,6 +16,10 @@
package com.android.inputmethod.latin;
+import static com.android.inputmethod.latin.Constants.Subtype.KEYBOARD_MODE;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
+
import android.view.inputmethod.InputMethodSubtype;
import java.util.HashMap;
@@ -24,9 +28,11 @@ public class AdditionalSubtype {
public static final String QWERTY = "qwerty";
public static final String QWERTZ = "qwertz";
public static final String AZERTY = "azerty";
-
- private static final String SUBTYPE_MODE_KEYBOARD = "keyboard";
- private static final String SUBTYPE_EXTRA_VALUE_IS_ADDITIONAL_SUBTYPE = "isAdditionalSubtype";
+ public static final String[] PREDEFINED_KEYBOARD_LAYOUT_SET = {
+ QWERTY,
+ QWERTZ,
+ AZERTY
+ };
// Keyboard layout to subtype name resource id map.
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap =
@@ -38,18 +44,58 @@ public class AdditionalSubtype {
sKeyboardLayoutToNameIdsMap.put(AZERTY, R.string.subtype_generic_azerty);
}
+ private AdditionalSubtype() {
+ // This utility class is not publicly instantiable.
+ }
+
public static boolean isAdditionalSubtype(InputMethodSubtype subtype) {
- return subtype.containsExtraValueKey(SUBTYPE_EXTRA_VALUE_IS_ADDITIONAL_SUBTYPE);
+ return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
}
+ private static final String LOCALE_AND_LAYOUT_SEPARATOR = ":";
+ public static final String PREF_SUBTYPE_SEPARATOR = ";";
+
public static InputMethodSubtype createAdditionalSubtype(
- String localeString, String keyboardLayoutSet) {
- final String extraValue = String.format(
- "%s=%s,%s", LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET, keyboardLayoutSet,
- SUBTYPE_EXTRA_VALUE_IS_ADDITIONAL_SUBTYPE);
- Integer nameId = sKeyboardLayoutToNameIdsMap.get(keyboardLayoutSet);
+ String localeString, String keyboardLayoutSetName, String extraValue) {
+ final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
+ final String filteredExtraValue = StringUtils.appendToCsvIfNotExists(
+ IS_ADDITIONAL_SUBTYPE, extraValue);
+ Integer nameId = sKeyboardLayoutToNameIdsMap.get(keyboardLayoutSetName);
if (nameId == null) nameId = R.string.subtype_generic;
return new InputMethodSubtype(nameId, R.drawable.ic_subtype_keyboard,
- localeString, SUBTYPE_MODE_KEYBOARD, extraValue, false, false);
+ localeString, KEYBOARD_MODE,
+ layoutExtraValue + "," + filteredExtraValue, false, false);
+ }
+
+ public static String getPrefSubtype(InputMethodSubtype subtype) {
+ final String localeString = subtype.getLocale();
+ final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype);
+ final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
+ final String extraValue = StringUtils.removeFromCsvIfExists(layoutExtraValue,
+ StringUtils.removeFromCsvIfExists(IS_ADDITIONAL_SUBTYPE, subtype.getExtraValue()));
+ final String basePrefSubtype = localeString + LOCALE_AND_LAYOUT_SEPARATOR
+ + keyboardLayoutSetName;
+ return extraValue.isEmpty() ? basePrefSubtype
+ : basePrefSubtype + LOCALE_AND_LAYOUT_SEPARATOR + extraValue;
+ }
+
+ public static InputMethodSubtype createAdditionalSubtype(String prefSubtype) {
+ final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
+ if (elems.length < 2 || elems.length > 3) {
+ throw new RuntimeException("Unknown additional subtype specified: " + prefSubtype);
+ }
+ final String localeString = elems[0];
+ final String keyboardLayoutSetName = elems[1];
+ final String extraValue = (elems.length == 3) ? elems[2] : null;
+ return createAdditionalSubtype(localeString, keyboardLayoutSetName, extraValue);
+ }
+
+ public static InputMethodSubtype[] createAdditionalSubtypesArray(String prefSubtypes) {
+ final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
+ final InputMethodSubtype[] subtypesArray = new InputMethodSubtype[prefSubtypeArray.length];
+ for (int i = 0; i < prefSubtypeArray.length; i++) {
+ subtypesArray[i] = createAdditionalSubtype(prefSubtypeArray[i]);
+ }
+ return subtypesArray;
}
}
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
new file mode 100644
index 000000000..7a22c9742
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
@@ -0,0 +1,440 @@
+/**
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.android.inputmethod.latin;
+
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.preference.DialogPreference;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceGroup;
+import android.preference.PreferenceScreen;
+import android.util.Pair;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodSubtype;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+
+import java.util.Locale;
+import java.util.TreeSet;
+
+public class AdditionalSubtypeSettings extends PreferenceFragment {
+ private SharedPreferences mPrefs;
+ private SubtypeLocaleAdapter mSubtypeLocaleAdapter;
+ private KeyboardLayoutSetAdapter mKeyboardLayoutSetAdapter;
+
+ private PreferenceGroup mSubtypePrefGroup;
+
+ private static final int MENU_ADD_SUBTYPE = Menu.FIRST;
+
+ static class SubtypeLocaleItem extends Pair<String, String>
+ implements Comparable<SubtypeLocaleItem> {
+ public SubtypeLocaleItem(String localeString, String displayName) {
+ super(localeString, displayName);
+ }
+
+ public SubtypeLocaleItem(String localeString) {
+ this(localeString, getDisplayName(localeString));
+ }
+
+ @Override
+ public String toString() {
+ return second;
+ }
+
+ @Override
+ public int compareTo(SubtypeLocaleItem o) {
+ return first.compareTo(o.first);
+ }
+
+ private static String getDisplayName(String localeString) {
+ final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
+ return StringUtils.toTitleCase(locale.getDisplayName(locale), locale);
+ }
+ }
+
+ static class SubtypeLocaleAdapter extends ArrayAdapter<SubtypeLocaleItem> {
+ public SubtypeLocaleAdapter(Context context) {
+ super(context, android.R.layout.simple_spinner_item);
+ setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+
+ final TreeSet<SubtypeLocaleItem> items = new TreeSet<SubtypeLocaleItem>();
+ final InputMethodInfo imi = ImfUtils.getInputMethodInfoOfThisIme(context);
+ final int count = imi.getSubtypeCount();
+ for (int i = 0; i < count; i++) {
+ final InputMethodSubtype subtype = imi.getSubtypeAt(i);
+ if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
+ items.add(createItem(context, subtype.getLocale()));
+ }
+ }
+ // TODO: Should filter out already existing combinations of locale and layout.
+ addAll(items);
+ }
+
+ public static SubtypeLocaleItem createItem(Context context, String localeString) {
+ if (localeString.equals(SubtypeLocale.NO_LANGUAGE)) {
+ final String displayName = context.getString(R.string.subtype_no_language);
+ return new SubtypeLocaleItem(localeString, displayName);
+ } else {
+ return new SubtypeLocaleItem(localeString);
+ }
+ }
+ }
+
+ static class KeyboardLayoutSetItem extends Pair<String, String> {
+ public KeyboardLayoutSetItem(String keyboardLayoutSetName) {
+ super(keyboardLayoutSetName, getDisplayName(keyboardLayoutSetName));
+ }
+
+ @Override
+ public String toString() {
+ return second;
+ }
+
+ private static String getDisplayName(String keyboardLayoutSetName) {
+ return keyboardLayoutSetName.toUpperCase();
+ }
+ }
+
+ static class KeyboardLayoutSetAdapter extends ArrayAdapter<KeyboardLayoutSetItem> {
+ public KeyboardLayoutSetAdapter(Context context) {
+ super(context, android.R.layout.simple_spinner_item);
+ setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+
+ // TODO: Should filter out already existing combinations of locale and layout.
+ for (final String layout : AdditionalSubtype.PREDEFINED_KEYBOARD_LAYOUT_SET) {
+ add(new KeyboardLayoutSetItem(layout));
+ }
+ }
+ }
+
+ private interface SubtypeDialogProxy {
+ public void onRemovePressed(SubtypePreference subtypePref);
+ public SubtypeLocaleAdapter getSubtypeLocaleAdapter();
+ public KeyboardLayoutSetAdapter getKeyboardLayoutSetAdapter();
+ }
+
+ static class SubtypePreference extends DialogPreference {
+ private InputMethodSubtype mSubtype;
+
+ private final SubtypeDialogProxy mProxy;
+ private Spinner mSubtypeLocaleSpinner;
+ private Spinner mKeyboardLayoutSetSpinner;
+
+ public SubtypePreference(Context context, InputMethodSubtype subtype,
+ SubtypeDialogProxy proxy) {
+ super(context, null);
+ setPersistent(false);
+ mProxy = proxy;
+ setSubtype(subtype);
+ }
+
+ public void show() {
+ showDialog(null);
+ }
+
+ public InputMethodSubtype getSubtype() {
+ return mSubtype;
+ }
+
+ public void setSubtype(InputMethodSubtype subtype) {
+ mSubtype = subtype;
+ if (subtype == null) {
+ setTitle(null);
+ setDialogTitle(R.string.add_style);
+ } else {
+ final String displayName = SubtypeLocale.getFullDisplayName(subtype);
+ setTitle(displayName);
+ setDialogTitle(displayName);
+ }
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
+ final Context context = builder.getContext();
+ final View v = LayoutInflater.from(context).inflate(
+ R.layout.additional_subtype_dialog, null);
+ builder.setView(v);
+ mSubtypeLocaleSpinner = (Spinner) v.findViewById(R.id.subtype_locale_spinner);
+ mSubtypeLocaleSpinner.setAdapter(mProxy.getSubtypeLocaleAdapter());
+ mKeyboardLayoutSetSpinner = (Spinner) v.findViewById(R.id.keyboard_layout_set_spinner);
+ mKeyboardLayoutSetSpinner.setAdapter(mProxy.getKeyboardLayoutSetAdapter());
+
+ if (mSubtype == null) {
+ builder.setPositiveButton(R.string.add, this)
+ .setNegativeButton(android.R.string.cancel, this);
+ } else {
+ builder.setPositiveButton(R.string.save, this)
+ .setNeutralButton(android.R.string.cancel, this)
+ .setNegativeButton(R.string.remove, this);
+ final SubtypeLocaleItem localeItem = SubtypeLocaleAdapter.createItem(
+ context, mSubtype.getLocale());
+ final KeyboardLayoutSetItem layoutItem = new KeyboardLayoutSetItem(
+ SubtypeLocale.getKeyboardLayoutSetName(mSubtype));
+ setSpinnerPosition(mSubtypeLocaleSpinner, localeItem);
+ setSpinnerPosition(mKeyboardLayoutSetSpinner, layoutItem);
+ }
+ }
+
+ private static void setSpinnerPosition(Spinner spinner, Object itemToSelect) {
+ final SpinnerAdapter adapter = spinner.getAdapter();
+ final int count = adapter.getCount();
+ for (int i = 0; i < count; i++) {
+ final Object item = spinner.getItemAtPosition(i);
+ if (item.equals(itemToSelect)) {
+ spinner.setSelection(i);
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ super.onClick(dialog, which);
+ switch (which) {
+ case DialogInterface.BUTTON_POSITIVE:
+ final SubtypeLocaleItem locale =
+ (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
+ final KeyboardLayoutSetItem layout =
+ (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
+ final InputMethodSubtype subtype = AdditionalSubtype.createAdditionalSubtype(
+ locale.first, layout.first, ASCII_CAPABLE);
+ setSubtype(subtype);
+ notifyChanged();
+ break;
+ case DialogInterface.BUTTON_NEUTRAL:
+ // Nothing to do
+ break;
+ case DialogInterface.BUTTON_NEGATIVE:
+ mProxy.onRemovePressed(this);
+ break;
+ }
+ }
+
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ final SavedState myState = new SavedState(super.onSaveInstanceState());
+ myState.mSubtype = mSubtype;
+ return myState;
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Parcelable state) {
+ if (state instanceof SavedState) {
+ final SavedState myState = (SavedState) state;
+ super.onRestoreInstanceState(state);
+ setSubtype(myState.mSubtype);
+ } else {
+ super.onRestoreInstanceState(state);
+ }
+ }
+
+ static class SavedState extends Preference.BaseSavedState {
+ InputMethodSubtype mSubtype;
+ private static final byte VALID = 1;
+ private static final byte INVALID = 0;
+
+ public SavedState(Parcelable superState) {
+ super(superState);
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ if (mSubtype != null) {
+ dest.writeByte(VALID);
+ mSubtype.writeToParcel(dest, 0);
+ } else {
+ dest.writeByte(INVALID);
+ }
+ }
+
+ public SavedState(Parcel source) {
+ super(source);
+ if (source.readByte() == VALID) {
+ mSubtype = source.readParcelable(null);
+ } else {
+ mSubtype = null;
+ }
+ }
+
+ public static final Parcelable.Creator<SavedState> CREATOR =
+ new Parcelable.Creator<SavedState>() {
+ @Override
+ public SavedState createFromParcel(Parcel source) {
+ return new SavedState(source);
+ }
+
+ @Override
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
+ }
+
+ public AdditionalSubtypeSettings() {
+ // Empty constructor for fragment generation.
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.additional_subtype_settings);
+ setHasOptionsMenu(true);
+ mSubtypePrefGroup = getPreferenceScreen();
+
+ mPrefs = getPreferenceManager().getSharedPreferences();
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final Context context = getActivity();
+ mSubtypeLocaleAdapter = new SubtypeLocaleAdapter(context);
+ mKeyboardLayoutSetAdapter = new KeyboardLayoutSetAdapter(context);
+
+ // TODO: Restore editing dialog if any.
+ }
+
+ private final SubtypeDialogProxy mSubtypeProxy = new SubtypeDialogProxy() {
+ @Override
+ public void onRemovePressed(SubtypePreference subtypePref) {
+ final PreferenceGroup group = mSubtypePrefGroup;
+ if (group != null) {
+ group.removePreference(subtypePref);
+ }
+ }
+
+ @Override
+ public SubtypeLocaleAdapter getSubtypeLocaleAdapter() {
+ return mSubtypeLocaleAdapter;
+ }
+
+ @Override
+ public KeyboardLayoutSetAdapter getKeyboardLayoutSetAdapter() {
+ return mKeyboardLayoutSetAdapter;
+ }
+ };
+
+ private void setPrefSubtypes(String prefSubtypes, Context context) {
+ final PreferenceGroup group = mSubtypePrefGroup;
+ group.removeAll();
+ final String[] prefSubtypeArray = prefSubtypes.split(
+ AdditionalSubtype.PREF_SUBTYPE_SEPARATOR);
+ for (final String prefSubtype : prefSubtypeArray) {
+ final InputMethodSubtype subtype =
+ AdditionalSubtype.createAdditionalSubtype(prefSubtype);
+ final SubtypePreference pref = new SubtypePreference(
+ context, subtype, mSubtypeProxy);
+ group.addPreference(pref);
+ }
+ }
+
+ private String getPrefSubtypes() {
+ final StringBuilder sb = new StringBuilder();
+ final int count = mSubtypePrefGroup.getPreferenceCount();
+ for (int i = 0; i < count; i++) {
+ final Preference pref = mSubtypePrefGroup.getPreference(i);
+ if (pref instanceof SubtypePreference) {
+ final InputMethodSubtype subtype = ((SubtypePreference)pref).getSubtype();
+ if (sb.length() > 0) {
+ sb.append(AdditionalSubtype.PREF_SUBTYPE_SEPARATOR);
+ }
+ sb.append(AdditionalSubtype.getPrefSubtype(subtype));
+ }
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ final String prefSubtypes =
+ SettingsValues.getPrefAdditionalSubtypes(mPrefs, getResources());
+ setPrefSubtypes(prefSubtypes, getActivity());
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ final String oldSubtypes = SettingsValues.getPrefAdditionalSubtypes(mPrefs, getResources());
+ final String prefSubtypes = getPrefSubtypes();
+ if (prefSubtypes.equals(oldSubtypes)) {
+ return;
+ }
+
+ final SharedPreferences.Editor editor = mPrefs.edit();
+ try {
+ editor.putString(Settings.PREF_CUSTOM_INPUT_STYLES, prefSubtypes);
+ } finally {
+ editor.apply();
+ }
+ final InputMethodSubtype[] subtypes =
+ AdditionalSubtype.createAdditionalSubtypesArray(prefSubtypes);
+ ImfUtils.setAdditionalInputMethodSubtypes(getActivity(), subtypes);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ // TODO: save editing dialog state.
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen prefScreen, Preference pref) {
+ if (pref instanceof SubtypePreference) {
+ return true;
+ }
+ return super.onPreferenceTreeClick(prefScreen, pref);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ final MenuItem addSubtypeMenu = menu.add(0, MENU_ADD_SUBTYPE, 0, R.string.add_style);
+ addSubtypeMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ final int itemId = item.getItemId();
+ if (itemId == MENU_ADD_SUBTYPE) {
+ final SubtypePreference subtypePref = new SubtypePreference(
+ getActivity(), null, mSubtypeProxy);
+ mSubtypePrefGroup.addPreference(subtypePref);
+ subtypePref.show();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java
new file mode 100644
index 000000000..b205cc004
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/Constants.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.android.inputmethod.latin;
+
+import android.view.inputmethod.EditorInfo;
+
+public final class Constants {
+ public static final class ImeOption {
+ /**
+ * The private IME option used to indicate that no microphone should be shown for a given
+ * text field. For instance, this is specified by the search dialog when the dialog is
+ * already showing a voice search button.
+ *
+ * @deprecated Use {@link ImeOption#NO_MICROPHONE} with package name prefixed.
+ */
+ @SuppressWarnings("dep-ann")
+ public static final String NO_MICROPHONE_COMPAT = "nm";
+
+ /**
+ * The private IME option used to indicate that no microphone should be shown for a given
+ * text field. For instance, this is specified by the search dialog when the dialog is
+ * already showing a voice search button.
+ */
+ public static final String NO_MICROPHONE = "noMicrophoneKey";
+
+ /**
+ * The private IME option used to indicate that no settings key should be shown for a given
+ * text field.
+ */
+ public static final String NO_SETTINGS_KEY = "noSettingsKey";
+
+ /**
+ * The private IME option used to indicate that the given text field needs ASCII code points
+ * input.
+ *
+ * @deprecated Use {@link EditorInfo#IME_FLAG_FORCE_ASCII}.
+ */
+ @SuppressWarnings("dep-ann")
+ public static final String FORCE_ASCII = "forceAscii";
+
+ private ImeOption() {
+ // This utility class is not publicly instantiable.
+ }
+ }
+
+ public static final class Subtype {
+ /**
+ * The subtype mode used to indicate that the subtype is a keyboard.
+ */
+ public static final String KEYBOARD_MODE = "keyboard";
+
+ public static final class ExtraValue {
+ /**
+ * The subtype extra value used to indicate that the subtype keyboard layout set name.
+ */
+ public static final String KEYBOARD_LAYOUT_SET = "KeyboardLayoutSet";
+
+ /**
+ * The subtype extra value used to indicate that the subtype keyboard layout is capable
+ * for typing ASCII characters.
+ */
+ public static final String ASCII_CAPABLE = "AsciiCapable";
+
+ /**
+ * The subtype extra value used to indicate that the subtype require network connection
+ * to work.
+ */
+ public static final String REQ_NETWORK_CONNECTIVITY = "requireNetworkConnectivity";
+
+ /**
+ * The subtype extra value used to indicate that the subtype is additional subtype
+ * that the user defined. This extra value is private to LatinIME.
+ */
+ public static final String IS_ADDITIONAL_SUBTYPE = "isAdditionalSubtype";
+
+ private ExtraValue() {
+ // This utility class is not publicly instantiable.
+ }
+ }
+
+ private Subtype() {
+ // This utility class is not publicly instantiable.
+ }
+ }
+
+ private Constants() {
+ // This utility class is not publicly instantiable.
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java
index 17d75368e..f5dc7b34a 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java
@@ -30,7 +30,10 @@ import java.util.Locale;
* Factory for dictionary instances.
*/
public class DictionaryFactory {
- private static String TAG = DictionaryFactory.class.getSimpleName();
+ private static final String TAG = DictionaryFactory.class.getSimpleName();
+ // This class must be located in the same package as LatinIME.java.
+ private static final String RESOURCE_PACKAGE_NAME =
+ DictionaryFactory.class.getPackage().getName();
/**
* Initializes a dictionary from a dictionary pack, with explicit flags.
@@ -166,20 +169,19 @@ public class DictionaryFactory {
*/
private static int getMainDictionaryResourceIdIfAvailableForLocale(final Resources res,
final Locale locale) {
- final String packageName = LatinIME.class.getPackage().getName();
int resId;
-
// Try to find main_language_country dictionary.
if (!locale.getCountry().isEmpty()) {
final String dictLanguageCountry = MAIN_DICT_PREFIX + locale.toString().toLowerCase();
- if ((resId = res.getIdentifier(dictLanguageCountry, "raw", packageName)) != 0) {
+ if ((resId = res.getIdentifier(
+ dictLanguageCountry, "raw", RESOURCE_PACKAGE_NAME)) != 0) {
return resId;
}
}
// Try to find main_language dictionary.
final String dictLanguage = MAIN_DICT_PREFIX + locale.getLanguage();
- if ((resId = res.getIdentifier(dictLanguage, "raw", packageName)) != 0) {
+ if ((resId = res.getIdentifier(dictLanguage, "raw", RESOURCE_PACKAGE_NAME)) != 0) {
return resId;
}
@@ -195,7 +197,6 @@ public class DictionaryFactory {
public static int getMainDictionaryResourceId(final Resources res, final Locale locale) {
int resourceId = getMainDictionaryResourceIdIfAvailableForLocale(res, locale);
if (0 != resourceId) return resourceId;
- final String packageName = LatinIME.class.getPackage().getName();
- return res.getIdentifier(DEFAULT_MAIN_DICT, "raw", packageName);
+ return res.getIdentifier(DEFAULT_MAIN_DICT, "raw", RESOURCE_PACKAGE_NAME);
}
}
diff --git a/java/src/com/android/inputmethod/latin/ImfUtils.java b/java/src/com/android/inputmethod/latin/ImfUtils.java
index bd7d89fe7..4633b82f5 100644
--- a/java/src/com/android/inputmethod/latin/ImfUtils.java
+++ b/java/src/com/android/inputmethod/latin/ImfUtils.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin;
+import static com.android.inputmethod.latin.Constants.Subtype.KEYBOARD_MODE;
+
import android.content.Context;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -131,7 +133,7 @@ public class ImfUtils {
// both explicitly and implicitly enabled input method subtype.
// (The current IME should be LatinIME.)
for (InputMethodSubtype subtype : subtypes) {
- if (SubtypeSwitcher.KEYBOARD_MODE.equals(subtype.getMode())) {
+ if (KEYBOARD_MODE.equals(subtype.getMode())) {
++keyboardCount;
}
}
diff --git a/java/src/com/android/inputmethod/latin/InputAttributes.java b/java/src/com/android/inputmethod/latin/InputAttributes.java
index a6ce04069..9c32f947c 100644
--- a/java/src/com/android/inputmethod/latin/InputAttributes.java
+++ b/java/src/com/android/inputmethod/latin/InputAttributes.java
@@ -162,4 +162,12 @@ public class InputAttributes {
+ "\n mIsSettingsSuggestionStripOn = " + mIsSettingsSuggestionStripOn
+ "\n mApplicationSpecifiedCompletionOn = " + mApplicationSpecifiedCompletionOn;
}
+
+ public static boolean inPrivateImeOptions(String packageName, String key,
+ EditorInfo editorInfo) {
+ if (editorInfo == null) return false;
+ final String findingKey = (packageName != null) ? packageName + "." + key
+ : key;
+ return StringUtils.containsInCsv(findingKey, editorInfo.privateImeOptions);
+ }
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index aea6add56..31c832c31 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -16,6 +16,10 @@
package com.android.inputmethod.latin;
+import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
+import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
+import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
+
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -81,49 +85,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private static final boolean TRACE = false;
private static boolean DEBUG;
- /**
- * The private IME option used to indicate that no microphone should be
- * shown for a given text field. For instance, this is specified by the
- * search dialog when the dialog is already showing a voice search button.
- *
- * @deprecated Use {@link LatinIME#IME_OPTION_NO_MICROPHONE} with package name prefixed.
- */
- @SuppressWarnings("dep-ann")
- public static final String IME_OPTION_NO_MICROPHONE_COMPAT = "nm";
-
- /**
- * The private IME option used to indicate that no microphone should be
- * shown for a given text field. For instance, this is specified by the
- * search dialog when the dialog is already showing a voice search button.
- */
- public static final String IME_OPTION_NO_MICROPHONE = "noMicrophoneKey";
-
- /**
- * The private IME option used to indicate that no settings key should be
- * shown for a given text field.
- */
- public static final String IME_OPTION_NO_SETTINGS_KEY = "noSettingsKey";
-
- /**
- * The private IME option used to indicate that the given text field needs
- * ASCII code points input.
- *
- * @deprecated Use {@link EditorInfo#IME_FLAG_FORCE_ASCII}.
- */
- @SuppressWarnings("dep-ann")
- public static final String IME_OPTION_FORCE_ASCII = "forceAscii";
-
- /**
- * The subtype extra value used to indicate that the subtype keyboard layout set name.
- */
- public static final String SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET = "KeyboardLayoutSet";
-
- /**
- * The subtype extra value used to indicate that the subtype keyboard layout is capable for
- * typing ASCII characters.
- */
- public static final String SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE = "AsciiCapable";
-
private static final int EXTENDED_TOUCHABLE_REGION_HEIGHT = 100;
// How many continuous deletes at which to start deleting at a higher speed.
@@ -441,8 +402,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
loadSettings();
- ImfUtils.setAdditionalInputMethodSubtypes(
- this, mSettingsValues.getPrefefinedAdditionalSubtypes());
+ ImfUtils.setAdditionalInputMethodSubtypes(this, mSettingsValues.getAdditionalSubtypes());
// TODO: remove the following when it's not needed by updateCorrectionMode() any more
mInputAttributes = new InputAttributes(null, false /* isFullscreenMode */);
@@ -650,6 +610,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
super.onStartInput(editorInfo, restarting);
}
+ @SuppressWarnings("deprecation")
private void onStartInputViewInternal(EditorInfo editorInfo, boolean restarting) {
super.onStartInputView(editorInfo, restarting);
final KeyboardSwitcher switcher = mKeyboardSwitcher;
@@ -670,12 +631,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.latinIME_onStartInputViewInternal(editorInfo);
}
- if (StringUtils.inPrivateImeOptions(null, IME_OPTION_NO_MICROPHONE_COMPAT, editorInfo)) {
+ if (InputAttributes.inPrivateImeOptions(null, NO_MICROPHONE_COMPAT, editorInfo)) {
Log.w(TAG, "Deprecated private IME option specified: "
+ editorInfo.privateImeOptions);
- Log.w(TAG, "Use " + getPackageName() + "." + IME_OPTION_NO_MICROPHONE + " instead");
+ Log.w(TAG, "Use " + getPackageName() + "." + NO_MICROPHONE + " instead");
}
- if (StringUtils.inPrivateImeOptions(getPackageName(), IME_OPTION_FORCE_ASCII, editorInfo)) {
+ if (InputAttributes.inPrivateImeOptions(getPackageName(), FORCE_ASCII, editorInfo)) {
Log.w(TAG, "Deprecated private IME option specified: "
+ editorInfo.privateImeOptions);
Log.w(TAG, "Use EditorInfo.IME_FLAG_FORCE_ASCII flag instead");
@@ -1078,7 +1039,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (ic == null) return false;
final CharSequence lastThree = ic.getTextBeforeCursor(3, 0);
if (lastThree != null && lastThree.length() == 3
- && StringUtils.canBeFollowedByPeriod(lastThree.charAt(0))
+ && canBeFollowedByPeriod(lastThree.charAt(0))
&& lastThree.charAt(1) == Keyboard.CODE_SPACE
&& lastThree.charAt(2) == Keyboard.CODE_SPACE
&& mHandler.isAcceptingDoubleSpaces()) {
@@ -1094,6 +1055,18 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return false;
}
+ private static boolean canBeFollowedByPeriod(final int codePoint) {
+ // TODO: Check again whether there really ain't a better way to check this.
+ // TODO: This should probably be language-dependant...
+ return Character.isLetterOrDigit(codePoint)
+ || codePoint == Keyboard.CODE_SINGLE_QUOTE
+ || codePoint == Keyboard.CODE_DOUBLE_QUOTE
+ || codePoint == Keyboard.CODE_CLOSING_PARENTHESIS
+ || codePoint == Keyboard.CODE_CLOSING_SQUARE_BRACKET
+ || codePoint == Keyboard.CODE_CLOSING_CURLY_BRACKET
+ || codePoint == Keyboard.CODE_CLOSING_ANGLE_BRACKET;
+ }
+
// "ic" may be null
private static void removeTrailingSpaceWhileInBatchEdit(final InputConnection ic) {
if (ic == null) return;
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 43e7e278f..13264f7e8 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -33,6 +33,7 @@ import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.inputmethod.InputMethodSubtype;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
@@ -62,6 +63,7 @@ public class Settings extends InputMethodSettingsFragment
"pref_suppress_language_switch_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
"pref_include_other_imes_in_language_switch_list";
+ public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY =
"pref_key_preview_popup_dismiss_delay";
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
@@ -254,6 +256,7 @@ public class Settings extends InputMethodSettingsFragment
}
updateShowCorrectionSuggestionsSummary();
updateKeyPreviewPopupDelaySummary();
+ updateCustomInputStylesSummary();
}
@Override
@@ -293,6 +296,21 @@ public class Settings extends InputMethodSettingsFragment
mShowCorrectionSuggestionsPreference.getValue())]);
}
+ private void updateCustomInputStylesSummary() {
+ final PreferenceScreen customInputStyles =
+ (PreferenceScreen)findPreference(PREF_CUSTOM_INPUT_STYLES);
+ final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
+ final String prefSubtype = SettingsValues.getPrefAdditionalSubtypes(prefs, getResources());
+ final InputMethodSubtype[] subtypes =
+ AdditionalSubtype.createAdditionalSubtypesArray(prefSubtype);
+ final StringBuilder styles = new StringBuilder();
+ for (final InputMethodSubtype subtype : subtypes) {
+ if (styles.length() > 0) styles.append(", ");
+ styles.append(SubtypeLocale.getFullDisplayName(subtype));
+ }
+ customInputStyles.setSummary(styles);
+ }
+
private void updateKeyPreviewPopupDelaySummary() {
final ListPreference lp = mKeyPreviewPopupDismissDelay;
lp.setSummary(lp.getEntries()[lp.findIndexOfValue(lp.getValue())]);
diff --git a/java/src/com/android/inputmethod/latin/SettingsActivity.java b/java/src/com/android/inputmethod/latin/SettingsActivity.java
index 556701364..68f8582fc 100644
--- a/java/src/com/android/inputmethod/latin/SettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/SettingsActivity.java
@@ -20,11 +20,15 @@ import android.content.Intent;
import android.preference.PreferenceActivity;
public class SettingsActivity extends PreferenceActivity {
+ private static final String DEFAULT_FRAGMENT = Settings.class.getName();
+
@Override
public Intent getIntent() {
- final Intent modIntent = new Intent(super.getIntent());
- modIntent.putExtra(EXTRA_SHOW_FRAGMENT, Settings.class.getName());
- modIntent.putExtra(EXTRA_NO_HEADERS, true);
- return modIntent;
+ final Intent intent = super.getIntent();
+ if (!intent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
+ intent.putExtra(EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT);
+ }
+ intent.putExtra(EXTRA_NO_HEADERS, true);
+ return intent;
}
}
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 539ac5963..5f9e1bc76 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -28,7 +28,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Locale;
/**
* When you call the constructor of this class, you may want to change the current system locale by
@@ -71,7 +70,7 @@ public class SettingsValues {
private final int mVibrationDurationSettingsRawValue;
@SuppressWarnings("unused") // TODO: Use this
private final float mKeypressSoundVolumeRawValue;
- private final InputMethodSubtype[] mPredefinedAdditionalSubtypes;
+ private final InputMethodSubtype[] mAdditionalSubtypes;
// Deduced settings
public final int mKeypressVibrationDuration;
@@ -148,16 +147,8 @@ public class SettingsValues {
mAutoCorrectionThresholdRawValue);
mVoiceKeyEnabled = mVoiceMode != null && !mVoiceMode.equals(voiceModeOff);
mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain);
-
- // Predefined additional subtypes
- final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype(
- Locale.GERMAN.toString(), AdditionalSubtype.QWERTY);
- final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype(
- Locale.FRENCH.toString(), AdditionalSubtype.QWERTZ);
- mPredefinedAdditionalSubtypes = new InputMethodSubtype[] {
- DE_QWERTY,
- FR_QWERTZ,
- };
+ mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray(
+ getPrefAdditionalSubtypes(prefs, res));
}
// Helper functions to create member values.
@@ -318,9 +309,14 @@ public class SettingsValues {
return res.getBoolean(R.bool.config_use_fullscreen_mode);
}
- // TODO: Should be able to add/remove/edit.
- public InputMethodSubtype[] getPrefefinedAdditionalSubtypes() {
- return mPredefinedAdditionalSubtypes;
+ public InputMethodSubtype[] getAdditionalSubtypes() {
+ return mAdditionalSubtypes;
+ }
+
+ public static String getPrefAdditionalSubtypes(final SharedPreferences prefs,
+ final Resources res) {
+ final String prefSubtypes = res.getString(R.string.predefined_subtypes, "");
+ return prefs.getString(Settings.PREF_CUSTOM_INPUT_STYLES, prefSubtypes);
}
// Accessed from the settings interface, hence public
diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java
index a599933d8..160581cbe 100644
--- a/java/src/com/android/inputmethod/latin/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/StringUtils.java
@@ -17,9 +17,6 @@
package com.android.inputmethod.latin;
import android.text.TextUtils;
-import android.view.inputmethod.EditorInfo;
-
-import com.android.inputmethod.keyboard.Keyboard;
import java.util.ArrayList;
import java.util.Locale;
@@ -29,39 +26,38 @@ public class StringUtils {
// This utility class is not publicly instantiable.
}
- public static boolean canBeFollowedByPeriod(final int codePoint) {
- // TODO: Check again whether there really ain't a better way to check this.
- // TODO: This should probably be language-dependant...
- return Character.isLetterOrDigit(codePoint)
- || codePoint == Keyboard.CODE_SINGLE_QUOTE
- || codePoint == Keyboard.CODE_DOUBLE_QUOTE
- || codePoint == Keyboard.CODE_CLOSING_PARENTHESIS
- || codePoint == Keyboard.CODE_CLOSING_SQUARE_BRACKET
- || codePoint == Keyboard.CODE_CLOSING_CURLY_BRACKET
- || codePoint == Keyboard.CODE_CLOSING_ANGLE_BRACKET;
- }
-
public static int codePointCount(String text) {
if (TextUtils.isEmpty(text)) return 0;
return text.codePointCount(0, text.length());
}
- private static boolean containsInCsv(String key, String csv) {
- if (csv == null)
- return false;
- for (String option : csv.split(",")) {
- if (option.equals(key))
- return true;
+ public static boolean containsInArray(String key, String[] array) {
+ for (final String element : array) {
+ if (key.equals(element)) return true;
}
return false;
}
- public static boolean inPrivateImeOptions(String packageName, String key,
- EditorInfo editorInfo) {
- if (editorInfo == null)
- return false;
- return containsInCsv(packageName != null ? packageName + "." + key : key,
- editorInfo.privateImeOptions);
+ public static boolean containsInCsv(String key, String csv) {
+ if (TextUtils.isEmpty(csv)) return false;
+ return containsInArray(key, csv.split(","));
+ }
+
+ public static String appendToCsvIfNotExists(String key, String csv) {
+ if (TextUtils.isEmpty(csv)) return key;
+ if (containsInCsv(key, csv)) return csv;
+ return csv + "," + key;
+ }
+
+ public static String removeFromCsvIfExists(String key, String csv) {
+ if (TextUtils.isEmpty(csv)) return "";
+ final String[] elements = csv.split(",");
+ if (!containsInArray(key, elements)) return csv;
+ final ArrayList<String> result = new ArrayList<String>(elements.length - 1);
+ for (final String element : elements) {
+ if (!key.equals(element)) result.add(element);
+ }
+ return TextUtils.join(",", result);
}
/**
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index 37f46fc79..fc6193287 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
+
import android.content.Context;
import android.content.res.Resources;
import android.view.inputmethod.InputMethodSubtype;
@@ -24,6 +26,8 @@ import java.util.HashMap;
import java.util.Locale;
public class SubtypeLocale {
+ private static final String TAG = SubtypeLocale.class.getSimpleName();
+
// Special language code to represent "no language".
public static final String NO_LANGUAGE = "zz";
@@ -56,26 +60,29 @@ public class SubtypeLocale {
// zz qwerty F QWERTY QWERTY
// fr qwertz T Fr Français Français (QWERTZ)
// de qwerty T De Deutsch Deutsch (QWERTY)
- // en azerty T En English English (AZERTY)
+ // en_US azerty T En English English (US) (AZERTY)
// zz azerty T AZERTY AZERTY
// Get InputMethodSubtype's full display name in its locale.
public static String getFullDisplayName(InputMethodSubtype subtype) {
- final String value = sExceptionalDisplayNamesMap.get(subtype.getLocale());
- if (value != null) {
- return value;
- }
-
if (isNoLanguage(subtype)) {
return getKeyboardLayoutSetDisplayName(subtype);
}
+ final String exceptionalValue = sExceptionalDisplayNamesMap.get(subtype.getLocale());
+
final Locale locale = getSubtypeLocale(subtype);
- final String language = StringUtils.toTitleCase(locale.getDisplayLanguage(locale), locale);
if (AdditionalSubtype.isAdditionalSubtype(subtype)) {
- return String.format("%s (%s)",
- language, getKeyboardLayoutSetDisplayName(subtype));
+ final String language = (exceptionalValue != null) ? exceptionalValue
+ : StringUtils.toTitleCase(locale.getDisplayLanguage(locale), locale);
+ final String layout = getKeyboardLayoutSetDisplayName(subtype);
+ return String.format("%s (%s)", language, layout);
}
+
+ if (exceptionalValue != null) {
+ return exceptionalValue;
+ }
+
return StringUtils.toTitleCase(locale.getDisplayName(locale), locale);
}
@@ -112,11 +119,14 @@ public class SubtypeLocale {
}
public static String getKeyboardLayoutSetName(InputMethodSubtype subtype) {
- final String keyboardLayoutSet = subtype.getExtraValueOf(
- LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LAYOUT_SET);
+ final String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
// TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
// fixed.
- if (keyboardLayoutSet == null) return AdditionalSubtype.QWERTY;
+ if (keyboardLayoutSet == null) {
+ android.util.Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
+ "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
+ return AdditionalSubtype.QWERTY;
+ }
return keyboardLayoutSet;
}
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index cf95a7e1a..1a9f373a1 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -16,6 +16,9 @@
package com.android.inputmethod.latin;
+import static com.android.inputmethod.latin.Constants.Subtype.KEYBOARD_MODE;
+import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.REQ_NETWORK_CONNECTIVITY;
+
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -42,11 +45,7 @@ public class SubtypeSwitcher {
private static boolean DBG = LatinImeLogger.sDBG;
private static final String TAG = SubtypeSwitcher.class.getSimpleName();
- public static final String KEYBOARD_MODE = "keyboard";
private static final char LOCALE_SEPARATOR = '_';
- private static final String SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY =
- "requireNetworkConnectivity";
-
private final TextUtils.SimpleStringSplitter mLocaleSplitter =
new TextUtils.SimpleStringSplitter(LOCALE_SEPARATOR);
@@ -309,8 +308,7 @@ public class SubtypeSwitcher {
return false;
if (mShortcutSubtype == null)
return true;
- if (mShortcutSubtype.containsExtraValueKey(
- SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY)) {
+ if (mShortcutSubtype.containsExtraValueKey(REQ_NETWORK_CONNECTIVITY)) {
return mIsNetworkConnected;
}
return true;