Merge "Remove popup for extension keyboard in landscape. bug: 2519903"

main
Amith Yamasani 2010-03-17 17:09:14 -07:00 committed by Android (Google) Code Review
commit 1ab409272b
3 changed files with 31 additions and 2 deletions

View File

@ -23,6 +23,8 @@ import java.util.Locale;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
@ -35,7 +37,7 @@ public class InputLanguageSelection extends PreferenceActivity {
private String mSelectedLanguages; private String mSelectedLanguages;
private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>(); private ArrayList<Loc> mAvailableLanguages = new ArrayList<Loc>();
private static final String[] BLACKLIST_LANGUAGES = { private static final String[] BLACKLIST_LANGUAGES = {
"ko", "ja", "zh" "ko", "ja", "zh", "el"
}; };
private static class Loc implements Comparable { private static class Loc implements Comparable {
@ -75,6 +77,9 @@ public class InputLanguageSelection extends PreferenceActivity {
pref.setTitle(LanguageSwitcher.toTitleCase(locale.getDisplayName(locale))); pref.setTitle(LanguageSwitcher.toTitleCase(locale.getDisplayName(locale)));
boolean checked = isLocaleIn(locale, languageList); boolean checked = isLocaleIn(locale, languageList);
pref.setChecked(checked); pref.setChecked(checked);
if (hasDictionary(locale)) {
pref.setSummary(R.string.has_dictionary);
}
parent.addPreference(pref); parent.addPreference(pref);
} }
} }
@ -92,6 +97,25 @@ public class InputLanguageSelection extends PreferenceActivity {
return false; return false;
} }
private boolean hasDictionary(Locale locale) {
Resources res = getResources();
Configuration conf = res.getConfiguration();
Locale saveLocale = conf.locale;
boolean haveDictionary = false;
conf.locale = locale;
res.updateConfiguration(conf, res.getDisplayMetrics());
BinaryDictionary bd = new BinaryDictionary(this, R.raw.main);
// 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;
}
bd.close();
conf.locale = saveLocale;
res.updateConfiguration(conf, res.getDisplayMetrics());
return haveDictionary;
}
private String get5Code(Locale locale) { private String get5Code(Locale locale) {
String country = locale.getCountry(); String country = locale.getCountry();
return locale.getLanguage() return locale.getLanguage()

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import java.util.List; import java.util.List;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard;
@ -178,6 +179,10 @@ public class LatinKeyboardView extends KeyboardView {
Keyboard keyboard; Keyboard keyboard;
mExtension.setKeyboard(keyboard = new LatinKeyboard(getContext(), mExtension.setKeyboard(keyboard = new LatinKeyboard(getContext(),
((LatinKeyboard) getKeyboard()).getExtension())); ((LatinKeyboard) getKeyboard()).getExtension()));
if (getContext().getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE) {
mExtension.setPreviewEnabled(false);
}
mExtensionPopup.setContentView(mExtension); mExtensionPopup.setContentView(mExtension);
mExtensionPopup.setWidth(getWidth()); mExtensionPopup.setWidth(getWidth());
mExtensionPopup.setHeight(keyboard.getHeight()); mExtensionPopup.setHeight(keyboard.getHeight());

View File

@ -39,7 +39,7 @@ public class Suggest implements Dictionary.WordCallback {
public static final int CORRECTION_BASIC = 1; public static final int CORRECTION_BASIC = 1;
public static final int CORRECTION_FULL = 2; public static final int CORRECTION_FULL = 2;
private static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000; static final int LARGE_DICTIONARY_THRESHOLD = 200 * 1000;
private BinaryDictionary mMainDict; private BinaryDictionary mMainDict;