aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/res/xml-sw600dp/key_styles_common.xml1
-rw-r--r--java/res/xml-sw768dp/key_styles_common.xml2
-rw-r--r--java/res/xml/key_styles_common.xml3
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java17
-rw-r--r--java/src/com/android/inputmethod/latin/UserHistoryDictionary.java2
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/MakedictLog.java27
-rw-r--r--tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java128
-rw-r--r--tools/makedict/Android.mk6
-rw-r--r--tools/makedict/src/com/android/inputmethod/latin/makedict/MakedictLog.java42
10 files changed, 177 insertions, 53 deletions
diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml
index 9f16d1b17..dcaf45027 100644
--- a/java/res/xml-sw600dp/key_styles_common.xml
+++ b/java/res/xml-sw600dp/key_styles_common.xml
@@ -137,6 +137,7 @@
latin:styleName="toSymbolKeyStyle"
latin:code="!code/key_switch_alpha_symbol"
latin:keyLabel="!text/label_to_symbol_key"
+ latin:keyLabelFlags="preserveCase"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="functional" />
<key-style
diff --git a/java/res/xml-sw768dp/key_styles_common.xml b/java/res/xml-sw768dp/key_styles_common.xml
index 2cae0d2ab..f2fb90bbc 100644
--- a/java/res/xml-sw768dp/key_styles_common.xml
+++ b/java/res/xml-sw768dp/key_styles_common.xml
@@ -136,7 +136,7 @@
latin:styleName="toSymbolKeyStyle"
latin:code="!code/key_switch_alpha_symbol"
latin:keyLabel="!text/label_to_symbol_key"
- latin:keyLabelFlags="fontNormal"
+ latin:keyLabelFlags="fontNormal|preserveCase"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="functional" />
<key-style
diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml
index 7981ab3a7..6b64985a6 100644
--- a/java/res/xml/key_styles_common.xml
+++ b/java/res/xml/key_styles_common.xml
@@ -165,7 +165,7 @@
latin:code="!code/key_switch_alpha_symbol"
latin:keyIcon="!icon/shortcut_for_label"
latin:keyLabel="!text/label_to_symbol_with_microphone_key"
- latin:keyLabelFlags="withIconRight"
+ latin:keyLabelFlags="withIconRight|preserveCase"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="functional" />
</case>
@@ -174,6 +174,7 @@
latin:styleName="toSymbolKeyStyle"
latin:code="!code/key_switch_alpha_symbol"
latin:keyLabel="!text/label_to_symbol_key"
+ latin:keyLabelFlags="preserveCase"
latin:keyActionFlags="noKeyPreview"
latin:backgroundType="functional" />
</default>
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index 9f89f9ee1..7694b56fc 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -22,6 +22,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
+
import java.util.HashMap;
import java.util.Locale;
@@ -121,18 +123,27 @@ public class SubtypeLocale {
// fr azerty F Français
// fr_CA qwerty F Français (Canada)
// de qwertz F Deutsch
- // zz qwerty F No language (QWERTY)
+ // zz qwerty F No language (QWERTY) in system locale
// fr qwertz T Français (QWERTZ)
// de qwerty T Deutsch (QWERTY)
// en_US azerty T English (US) (AZERTY)
- // zz azerty T No language (AZERTY)
+ // zz azerty T No language (AZERTY) in system locale
public static String getSubtypeDisplayName(InputMethodSubtype subtype, Resources res) {
// TODO: Remove this check when InputMethodManager.getLastInputMethodSubtype is
// fixed.
if (!ImfUtils.checkIfSubtypeBelongsToThisIme(sContext, subtype)) return "";
final String language = getSubtypeLocaleDisplayName(subtype.getLocale());
- return res.getString(subtype.getNameResId(), language);
+ final int nameResId = subtype.getNameResId();
+ final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
+ @Override
+ protected String job(Resources res) {
+ return res.getString(nameResId, language);
+ }
+ };
+ final Locale locale = isNoLanguage(subtype)
+ ? res.getConfiguration().locale : getSubtypeLocale(subtype);
+ return getSubtypeName.runInLocale(res, locale);
}
public static boolean isNoLanguage(InputMethodSubtype subtype) {
diff --git a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
index 62525c205..9191aa953 100644
--- a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java
@@ -162,7 +162,7 @@ public class UserHistoryDictionary extends ExpandableDictionary {
* Return whether the passed charsequence is in the dictionary.
*/
@Override
- public boolean isValidWord(final CharSequence word) {
+ public synchronized boolean isValidWord(final CharSequence word) {
// TODO: figure out what is the correct thing to do here.
return false;
}
diff --git a/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java b/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java
index cff8d6fd0..1281c7e3a 100644
--- a/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java
+++ b/java/src/com/android/inputmethod/latin/makedict/MakedictLog.java
@@ -16,25 +16,32 @@
package com.android.inputmethod.latin.makedict;
+import android.util.Log;
+
/**
* Wrapper to redirect log events to the right output medium.
*/
public class MakedictLog {
-
- private static void print(String message) {
- System.out.println(message);
- }
+ private static final boolean DBG = false;
+ private static final String TAG = MakedictLog.class.getSimpleName();
public static void d(String message) {
- print(message);
- }
- public static void e(String message) {
- print(message);
+ if (DBG) {
+ Log.d(TAG, message);
+ }
}
+
public static void i(String message) {
- print(message);
+ if (DBG) {
+ Log.i(TAG, message);
+ }
}
+
public static void w(String message) {
- print(message);
+ Log.w(TAG, message);
+ }
+
+ public static void e(String message) {
+ Log.e(TAG, message);
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
index 663f7087d..a34e0ef8b 100644
--- a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java
@@ -21,7 +21,6 @@ import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.view.inputmethod.InputMethodSubtype;
-import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.AdditionalSubtype;
import com.android.inputmethod.latin.ImfUtils;
import com.android.inputmethod.latin.StringUtils;
@@ -41,7 +40,6 @@ public class SpacebarTextTests extends AndroidTestCase {
super.setUp();
final Context context = getContext();
mRes = context.getResources();
- InputMethodManagerCompatWrapper.init(context);
SubtypeLocale.init(context);
}
diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
index 5393b23ac..8863bcf47 100644
--- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
+++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
@@ -21,7 +21,6 @@ import android.content.res.Resources;
import android.test.AndroidTestCase;
import android.view.inputmethod.InputMethodSubtype;
-import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import java.util.ArrayList;
@@ -31,14 +30,15 @@ public class SubtypeLocaleTests extends AndroidTestCase {
// Locale to subtypes list.
private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<InputMethodSubtype>();
+ private Context mContext;
private Resources mRes;
@Override
protected void setUp() throws Exception {
super.setUp();
final Context context = getContext();
+ mContext = context;
mRes = context.getResources();
- InputMethodManagerCompatWrapper.init(context);
SubtypeLocale.init(context);
}
@@ -65,13 +65,13 @@ public class SubtypeLocaleTests extends AndroidTestCase {
// fr azerty F Français
// fr_CA qwerty F Français (Canada)
// de qwertz F Deutsch
- // zz qwerty F No language (QWERTY)
+ // zz qwerty F No language (QWERTY) in system locale
// fr qwertz T Français (QWERTZ)
// de qwerty T Deutsch (QWERTY)
// en_US azerty T English (US) (AZERTY)
- // zz azerty T No language (AZERTY)
+ // zz azerty T No language (AZERTY) in system locale
- public void testPredefinedSubtypes() {
+ public void testPredefinedSubtypesInEnglish() {
final Context context = getContext();
final InputMethodSubtype EN_US = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
context, Locale.US.toString(), "qwerty");
@@ -93,21 +93,28 @@ public class SubtypeLocaleTests extends AndroidTestCase {
assertEquals("de ", "qwertz", SubtypeLocale.getKeyboardLayoutSetName(DE));
assertEquals("zz ", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(ZZ));
- assertEquals("en_US", "English (US)",
- SubtypeLocale.getSubtypeDisplayName(EN_US, mRes));
- assertEquals("en_GB", "English (UK)",
- SubtypeLocale.getSubtypeDisplayName(EN_GB, mRes));
- assertEquals("fr ", "Français",
- SubtypeLocale.getSubtypeDisplayName(FR, mRes));
- assertEquals("fr_CA", "Français (Canada)",
- SubtypeLocale.getSubtypeDisplayName(FR_CA, mRes));
- assertEquals("de ", "Deutsch",
- SubtypeLocale.getSubtypeDisplayName(DE, mRes));
- assertEquals("zz ", "No language (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ, mRes));
+ final RunInLocale<Void> tests = new RunInLocale<Void>() {
+ @Override
+ protected Void job(Resources res) {
+ assertEquals("en_US", "English (US)",
+ SubtypeLocale.getSubtypeDisplayName(EN_US, res));
+ assertEquals("en_GB", "English (UK)",
+ SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ assertEquals("fr ", "Français",
+ SubtypeLocale.getSubtypeDisplayName(FR, res));
+ assertEquals("fr_CA", "Français (Canada)",
+ SubtypeLocale.getSubtypeDisplayName(FR_CA, res));
+ assertEquals("de ", "Deutsch",
+ SubtypeLocale.getSubtypeDisplayName(DE, res));
+ assertEquals("zz ", "No language (QWERTY)",
+ SubtypeLocale.getSubtypeDisplayName(ZZ, res));
+ return null;
+ }
+ };
+ tests.runInLocale(mRes, Locale.ENGLISH);
}
- public void testAdditionalSubtype() {
+ public void testAdditionalSubtypesInEnglish() {
final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype(
Locale.GERMAN.toString(), "qwerty", null);
final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype(
@@ -117,32 +124,87 @@ public class SubtypeLocaleTests extends AndroidTestCase {
final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype(
SubtypeLocale.NO_LANGUAGE, "azerty", null);
- assertEquals("fr qwertz", "Français (QWERTZ)",
- SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, mRes));
- assertEquals("de qwerty", "Deutsch (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, mRes));
- assertEquals("en_US azerty", "English (US) (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(US_AZERTY, mRes));
- assertEquals("zz azerty", "No language (AZERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, mRes));
+ ImfUtils.setAdditionalInputMethodSubtypes(mContext, new InputMethodSubtype[] {
+ DE_QWERTY, FR_QWERTZ, US_AZERTY, ZZ_AZERTY
+ });
+
+ final RunInLocale<Void> tests = new RunInLocale<Void>() {
+ @Override
+ protected Void job(Resources res) {
+ assertEquals("fr qwertz", "Français (QWERTZ)",
+ SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res));
+ assertEquals("de qwerty", "Deutsch (QWERTY)",
+ SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res));
+ assertEquals("en_US azerty", "English (US) (AZERTY)",
+ SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res));
+ assertEquals("zz azerty", "No language (AZERTY)",
+ SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res));
+ return null;
+ }
+ };
+ tests.runInLocale(mRes, Locale.ENGLISH);
}
- public void testNoLanguageInFrench() {
+ public void testPredefinedSubtypesInFrench() {
final Context context = getContext();
+ final InputMethodSubtype EN_US = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.US.toString(), "qwerty");
+ final InputMethodSubtype EN_GB = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.UK.toString(), "qwerty");
+ final InputMethodSubtype FR = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.FRENCH.toString(), "azerty");
+ final InputMethodSubtype FR_CA = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.CANADA_FRENCH.toString(), "qwerty");
+ final InputMethodSubtype DE = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.GERMAN.toString(), "qwertz");
final InputMethodSubtype ZZ = ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
context, 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));
+ assertEquals("en_GB", "English (UK)",
+ SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ assertEquals("fr ", "Français",
+ SubtypeLocale.getSubtypeDisplayName(FR, res));
+ assertEquals("fr_CA", "Français (Canada)",
+ SubtypeLocale.getSubtypeDisplayName(FR_CA, res));
+ assertEquals("de ", "Deutsch",
+ SubtypeLocale.getSubtypeDisplayName(DE, res));
+ assertEquals("zz ", "Pas de langue (QWERTY)",
+ SubtypeLocale.getSubtypeDisplayName(ZZ, res));
+ return null;
+ }
+ };
+ tests.runInLocale(mRes, Locale.FRENCH);
+ }
+
+ 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);
+ ImfUtils.setAdditionalInputMethodSubtypes(mContext, new InputMethodSubtype[] {
+ DE_QWERTY, FR_QWERTZ, US_AZERTY, ZZ_AZERTY
+ });
+
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job(Resources res) {
- assertEquals("zz ", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(ZZ));
- assertEquals("zz ", "azerty", SubtypeLocale.getKeyboardLayoutSetName(ZZ_AZERTY));
-
- assertEquals("zz ", "Pas de langue (QWERTY)",
- SubtypeLocale.getSubtypeDisplayName(ZZ, res));
- assertEquals("zz azerty", "Pas de langue (AZERTY)",
+ assertEquals("fr qwertz", "Français (QWERTZ)",
+ SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res));
+ assertEquals("de qwerty", "Deutsch (QWERTY)",
+ SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res));
+ assertEquals("en_US azerty", "English (US) (AZERTY)",
+ SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res));
+ assertEquals("zz azerty", "Aucune langue (AZERTY)",
SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res));
return null;
}
diff --git a/tools/makedict/Android.mk b/tools/makedict/Android.mk
index dcfad19f0..2f0957aa8 100644
--- a/tools/makedict/Android.mk
+++ b/tools/makedict/Android.mk
@@ -18,8 +18,10 @@ include $(CLEAR_VARS)
MAKEDICT_CORE_SOURCE_DIRECTORY := ../../java/src/com/android/inputmethod/latin/makedict
-LOCAL_SRC_FILES := $(call all-java-files-under,$(MAKEDICT_CORE_SOURCE_DIRECTORY))
-LOCAL_SRC_FILES += $(call all-java-files-under,src)
+LOCAL_MAIN_SRC_FILES := $(call all-java-files-under,$(MAKEDICT_CORE_SOURCE_DIRECTORY))
+LOCAL_TOOL_SRC_FILES := $(call all-java-files-under,src)
+LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \
+ $(filter-out $(addprefix %, $(LOCAL_TOOL_SRC_FILES)), $(LOCAL_MAIN_SRC_FILES))
LOCAL_SRC_FILES += $(call all-java-files-under,tests)
LOCAL_JAR_MANIFEST := etc/manifest.txt
LOCAL_MODULE_TAGS := eng
diff --git a/tools/makedict/src/com/android/inputmethod/latin/makedict/MakedictLog.java b/tools/makedict/src/com/android/inputmethod/latin/makedict/MakedictLog.java
new file mode 100644
index 000000000..1ab9f42dd
--- /dev/null
+++ b/tools/makedict/src/com/android/inputmethod/latin/makedict/MakedictLog.java
@@ -0,0 +1,42 @@
+/*
+ * 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.makedict;
+
+/**
+ * Wrapper to redirect log events to the right output medium.
+ */
+public class MakedictLog {
+ private static void print(String message) {
+ System.out.println(message);
+ }
+
+ public static void d(String message) {
+ print(message);
+ }
+
+ public static void i(String message) {
+ print(message);
+ }
+
+ public static void w(String message) {
+ print(message);
+ }
+
+ public static void e(String message) {
+ print(message);
+ }
+}