aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-01-20 22:52:02 +0900
committerTadashi G. Takaoka <takaoka@google.com>2011-01-21 02:30:52 +0900
commit2fa21f5854e1565deb139e0bf22719fecc5340bc (patch)
tree3cc5d4ef9d743b9bd1cb4f8d31c4ea1d717b3dc9 /java/src
parentfefda4e6df5c2f8e2b2730dfe5b88644a1caaa6b (diff)
downloadlatinime-2fa21f5854e1565deb139e0bf22719fecc5340bc.tar.gz
latinime-2fa21f5854e1565deb139e0bf22719fecc5340bc.tar.xz
latinime-2fa21f5854e1565deb139e0bf22719fecc5340bc.zip
Add input method subtype selector and IME settings dialog
Bug: 3351762 Change-Id: Ic1767faac6d4470a89cacb851d449ac53b2f8205
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java74
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java8
2 files changed, 62 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index bc42dff84..fb8c9b3a8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -123,6 +123,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private AlertDialog mOptionsDialog;
private InputMethodManager mImm;
+ private Resources mResources;
+ private SharedPreferences mPrefs;
+ private String mInputMethodId;
private KeyboardSwitcher mKeyboardSwitcher;
private SubtypeSwitcher mSubtypeSwitcher;
private VoiceIMEConnector mVoiceConnector;
@@ -132,9 +135,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private ContactsDictionary mContactsDictionary;
private AutoDictionary mAutoDictionary;
- private Resources mResources;
- private SharedPreferences mPrefs;
-
// These variables are initialized according to the {@link EditorInfo#inputType}.
private boolean mAutoSpace;
private boolean mInputTypeNoAutoCorrect;
@@ -156,6 +156,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mPopupOn;
private boolean mAutoCap;
private boolean mQuickFixes;
+ private boolean mConfigEnableShowSubtypeSettings;
private boolean mConfigSwipeDownDismissKeyboardEnabled;
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
private int mConfigDurationOfFadeoutLanguageOnSpacebar;
@@ -350,6 +351,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
super.onCreate();
mImm = ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE));
+ mInputMethodId = Utils.getInputMethodId(mImm, getApplicationInfo().packageName);
mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance();
@@ -365,6 +367,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mReCorrectionEnabled = res.getBoolean(R.bool.default_recorrection_enabled);
}
+ mConfigEnableShowSubtypeSettings = res.getBoolean(
+ R.bool.config_enable_show_subtype_settings);
mConfigSwipeDownDismissKeyboardEnabled = res.getBoolean(
R.bool.config_swipe_down_dismiss_keyboard_enabled);
mConfigDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger(
@@ -462,6 +466,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
commitTyped(ic);
if (ic != null) ic.finishComposingText(); // For voice input
mOrientation = conf.orientation;
+ if (isShowingOptionDialog())
+ mOptionsDialog.dismiss();
}
mConfigurationChanging = true;
@@ -1044,7 +1050,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void onSettingsKeyPressed() {
if (!isShowingOptionDialog()) {
- if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) {
+ if (!mConfigEnableShowSubtypeSettings) {
+ showSubtypeSelectorAndSettings();
+ } else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm)) {
showOptionsMenu();
} else {
launchSettings();
@@ -2183,30 +2191,56 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return mSuggestPuncs.contains(String.valueOf((char)code));
}
- private void showOptionsMenu() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setCancelable(true);
- builder.setIcon(R.drawable.ic_dialog_keyboard);
- builder.setNegativeButton(android.R.string.cancel, null);
- CharSequence itemSettings = getString(R.string.english_ime_settings);
- CharSequence itemInputMethod = getString(R.string.selectInputMethod);
- builder.setItems(new CharSequence[] {
- itemInputMethod, itemSettings},
- new DialogInterface.OnClickListener() {
+ private void showSubtypeSelectorAndSettings() {
+ showOptionsMenuInternal(new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface di, int position) {
+ di.dismiss();
+ switch (position) {
+ case POS_SETTINGS:
+ launchSettings();
+ break;
+ case POS_METHOD:
+ Intent intent = new Intent(
+ android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(android.provider.Settings.EXTRA_INPUT_METHOD_ID,
+ mInputMethodId);
+ startActivity(intent);
+ break;
+ }
+ }
+ });
+ }
+ private void showOptionsMenu() {
+ showOptionsMenuInternal(new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface di, int position) {
di.dismiss();
switch (position) {
- case POS_SETTINGS:
- launchSettings();
- break;
- case POS_METHOD:
- mImm.showInputMethodPicker();
- break;
+ case POS_SETTINGS:
+ launchSettings();
+ break;
+ case POS_METHOD:
+ mImm.showInputMethodPicker();
+ break;
}
}
});
+ }
+
+ private void showOptionsMenuInternal(DialogInterface.OnClickListener listener) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setCancelable(true);
+ builder.setIcon(R.drawable.ic_dialog_keyboard);
+ builder.setNegativeButton(android.R.string.cancel, null);
+ CharSequence itemSettings = getString(R.string.english_ime_settings);
+ CharSequence itemInputMethod = getString(R.string.selectInputMethod);
+ builder.setItems(new CharSequence[] {
+ itemInputMethod, itemSettings}, listener);
builder.setTitle(mResources.getString(R.string.english_ime_input_options));
mOptionsDialog = builder.create();
Window window = mOptionsDialog.getWindow();
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index d2582b115..5059860d7 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -23,6 +23,7 @@ import android.os.HandlerThread;
import android.os.Process;
import android.text.format.DateUtils;
import android.util.Log;
+import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import java.io.BufferedReader;
@@ -97,6 +98,13 @@ public class Utils {
|| imm.getEnabledInputMethodSubtypeList(null, false).size() > 1;
}
+ public static String getInputMethodId(InputMethodManager imm, String packageName) {
+ for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) {
+ if (imi.getPackageName().equals(packageName))
+ return imi.getId();
+ }
+ throw new RuntimeException("Can not find input method id for " + packageName);
+ }
public static boolean shouldBlockedBySafetyNetForAutoCorrection(SuggestedWords suggestions) {
// Safety net for auto correction.