aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java (renamed from java/src/com/android/inputmethod/latin/InputLanguageSelection.java)76
-rw-r--r--java/src/com/android/inputmethod/latin/AutoDictionary.java1
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java12
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java6
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java2
5 files changed, 63 insertions, 34 deletions
diff --git a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
index 40ab28c98..6c6960cc4 100644
--- a/java/src/com/android/inputmethod/latin/InputLanguageSelection.java
+++ b/java/src/com/android/inputmethod/deprecated/languageswitcher/InputLanguageSelection.java
@@ -1,12 +1,12 @@
/*
* Copyright (C) 2008-2009 Google Inc.
- *
+ *
* 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
@@ -14,7 +14,18 @@
* the License.
*/
-package com.android.inputmethod.latin;
+package com.android.inputmethod.deprecated.languageswitcher;
+
+import com.android.inputmethod.keyboard.KeyboardParser;
+import com.android.inputmethod.latin.BinaryDictionary;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.Settings;
+import com.android.inputmethod.latin.SharedPreferencesCompat;
+import com.android.inputmethod.latin.SubtypeSwitcher;
+import com.android.inputmethod.latin.Suggest;
+import com.android.inputmethod.latin.Utils;
+
+import org.xmlpull.v1.XmlPullParserException;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -26,7 +37,9 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceManager;
import android.text.TextUtils;
+import android.util.Pair;
+import java.io.IOException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
@@ -37,9 +50,6 @@ public class InputLanguageSelection extends PreferenceActivity {
private SharedPreferences mPrefs;
private String mSelectedLanguages;
private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>();
- private static final String[] BLACKLIST_LANGUAGES = {
- "ko", "ja", "zh", "el", "zz"
- };
private static class Loc implements Comparable<Object> {
private static Collator sCollator = Collator.getInstance();
@@ -78,12 +88,18 @@ public class InputLanguageSelection extends PreferenceActivity {
mAvailableLanguages = getUniqueLocales();
PreferenceGroup parent = getPreferenceScreen();
for (int i = 0; i < mAvailableLanguages.size(); i++) {
- CheckBoxPreference pref = new CheckBoxPreference(this);
Locale locale = mAvailableLanguages.get(i).mLocale;
+ final Pair<Boolean, Boolean> hasDictionaryOrLayout = hasDictionaryOrLayout(locale);
+ final boolean hasDictionary = hasDictionaryOrLayout.first;
+ final boolean hasLayout = hasDictionaryOrLayout.second;
+ if (!hasDictionary && !hasLayout) {
+ continue;
+ }
+ CheckBoxPreference pref = new CheckBoxPreference(this);
pref.setTitle(SubtypeSwitcher.getFullDisplayName(locale, true));
boolean checked = isLocaleIn(locale, languageList);
pref.setChecked(checked);
- if (hasDictionary(locale)) {
+ if (hasDictionary) {
pref.setSummary(R.string.has_dictionary);
}
parent.addPreference(pref);
@@ -98,26 +114,39 @@ public class InputLanguageSelection extends PreferenceActivity {
return false;
}
- private boolean hasDictionary(Locale locale) {
+ private Pair<Boolean, Boolean> hasDictionaryOrLayout(Locale locale) {
+ if (locale == null) return new Pair<Boolean, Boolean>(false, false);
final Resources res = getResources();
final Configuration conf = res.getConfiguration();
final Locale saveLocale = conf.locale;
- boolean haveDictionary = false;
conf.locale = locale;
res.updateConfiguration(conf, res.getDisplayMetrics());
+ boolean hasDictionary = false;
+ boolean hasLayout = false;
- BinaryDictionary bd = BinaryDictionary.initDictionaryFromManager(this, Suggest.DIC_MAIN,
- locale, Utils.getMainDictionaryResourceId(res));
+ try {
+ BinaryDictionary bd = BinaryDictionary.initDictionaryFromManager(this, Suggest.DIC_MAIN,
+ locale, Utils.getMainDictionaryResourceId(res));
- // Is the dictionary larger than a placeholder? Arbitrarily chose a lower limit of
- // 4000-5000 words, whereas the LARGE_DICTIONARY is about 20000+ words.
- if (bd.getSize() > Suggest.LARGE_DICTIONARY_THRESHOLD / 4) {
- haveDictionary = true;
+ // Is the dictionary larger than a placeholder? Arbitrarily chose a lower limit of
+ // 4000-5000 words, whereas the LARGE_DICTIONARY is about 20000+ words.
+ if (bd.getSize() > Suggest.LARGE_DICTIONARY_THRESHOLD / 4) {
+ hasDictionary = true;
+ }
+ bd.close();
+
+ final String countryCode = locale.getLanguage();
+ final String layoutCountryCode = KeyboardParser.parseKeyboardLocale(
+ this, R.xml.kbd_qwerty);
+ if (!TextUtils.isEmpty(countryCode) && !TextUtils.isEmpty(layoutCountryCode)) {
+ hasLayout = countryCode.subSequence(0, 2).equals(layoutCountryCode.substring(0, 2));
+ }
+ } catch (XmlPullParserException e) {
+ } catch (IOException e) {
}
- bd.close();
conf.locale = saveLocale;
res.updateConfiguration(conf, res.getDisplayMetrics());
- return haveDictionary;
+ return new Pair<Boolean, Boolean>(hasDictionary, hasLayout);
}
private String get5Code(Locale locale) {
@@ -173,7 +202,7 @@ public class InputLanguageSelection extends PreferenceActivity {
Locale l = new Locale(language, country);
// Exclude languages that are not relevant to LatinIME
- if (arrayContains(BLACKLIST_LANGUAGES, language) || TextUtils.isEmpty(language)) {
+ if (TextUtils.isEmpty(language)) {
continue;
}
@@ -207,11 +236,4 @@ public class InputLanguageSelection extends PreferenceActivity {
}
return uniqueLocales;
}
-
- private boolean arrayContains(String[] array, String value) {
- for (int i = 0; i < array.length; i++) {
- if (array[i].equalsIgnoreCase(value)) return true;
- }
- return false;
- }
}
diff --git a/java/src/com/android/inputmethod/latin/AutoDictionary.java b/java/src/com/android/inputmethod/latin/AutoDictionary.java
index a00b0915c..307b81d43 100644
--- a/java/src/com/android/inputmethod/latin/AutoDictionary.java
+++ b/java/src/com/android/inputmethod/latin/AutoDictionary.java
@@ -27,7 +27,6 @@ import android.provider.BaseColumns;
import android.util.Log;
import java.util.HashMap;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 13ef4ffe8..a680b9825 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -901,15 +901,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
final KeyboardView inputView = mKeyboardSwitcher.getInputView();
+ if (inputView == null)
+ return;
+ final int containerHeight = mCandidateViewContainer.getHeight();
+ int touchY = containerHeight;
// Need to set touchable region only if input view is being shown
- if (inputView != null && mKeyboardSwitcher.isInputViewShown()) {
- final int containerHeight = mCandidateViewContainer.getHeight();
- int touchY = containerHeight;
+ if (mKeyboardSwitcher.isInputViewShown()) {
if (mCandidateViewContainer.getVisibility() == View.VISIBLE) {
touchY -= mCandidateStripHeight;
}
- outInsets.contentTopInsets = touchY;
- outInsets.visibleTopInsets = touchY;
final int touchWidth = inputView.getWidth();
final int touchHeight = inputView.getHeight() + containerHeight
// Extend touchable region below the keyboard.
@@ -920,6 +920,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
setTouchableRegionCompat(outInsets, 0, touchY, touchWidth, touchHeight);
}
+ outInsets.contentTopInsets = touchY;
+ outInsets.visibleTopInsets = touchY;
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 8f7278e3a..1725ee7aa 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
+import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.compat.VibratorCompatWrapper;
@@ -67,6 +68,7 @@ public class Settings extends PreferenceActivity
public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
public static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
public static final String PREF_DEBUG_SETTINGS = "debug_settings";
+ public static final String PREF_LANGUAGE_SELECTION = "language_selection";
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
@@ -183,6 +185,10 @@ public class Settings extends PreferenceActivity
if (!showUsabilityModeStudyOption) {
getPreferenceScreen().removePreference(findPreference(PREF_USABILITY_STUDY_MODE));
}
+
+ if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
+ generalSettings.removePreference(findPreference(PREF_LANGUAGE_SELECTION));
+ }
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index cd7f71c2a..f37206223 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -75,7 +75,7 @@ public class Suggest implements Dictionary.WordCallback {
public static final String DICT_KEY_USER_BIGRAM = "user_bigram";
public static final String DICT_KEY_WHITELIST ="whitelist";
- static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000;
+ public static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000;
private static final boolean DBG = LatinImeLogger.sDBG;