Not to set IME when the current IME was disabled, because framework will find an applicable IME when the current IME was unset.

Bug: 3186000

- This enables us to share the code between Settings and the framework.
- Removed the parameter for lastImeTicked because an applicable IME can be found in the framework.

Change-Id: Icfb6168c5a22506f225bfe58425adeb540835456
This commit is contained in:
satok
2010-11-09 23:31:26 +09:00
parent 505a0c2ad0
commit 5fd39cafe1
3 changed files with 10 additions and 34 deletions

View File

@@ -52,8 +52,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
final TextUtils.SimpleStringSplitter mStringColonSplitter final TextUtils.SimpleStringSplitter mStringColonSplitter
= new TextUtils.SimpleStringSplitter(':'); = new TextUtils.SimpleStringSplitter(':');
private String mLastTickedInputMethodId;
private AlertDialog mDialog = null; private AlertDialog mDialog = null;
@@ -145,7 +143,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties); this, getContentResolver(), mInputMethodProperties);
mLastTickedInputMethodId = null;
if (mLanguagePref != null) { if (mLanguagePref != null) {
Configuration conf = getResources().getConfiguration(); Configuration conf = getResources().getConfiguration();
@@ -161,7 +158,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId); mInputMethodProperties, mHaveHardKeyboard);
} }
@Override @Override
@@ -184,7 +181,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
selImi = imi; selImi = imi;
if (isSystemIme(imi)) { if (isSystemIme(imi)) {
// This is a built-in IME, so no need to warn. // This is a built-in IME, so no need to warn.
mLastTickedInputMethodId = id;
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
} }
@@ -203,7 +199,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true); chkPref.setChecked(true);
mLastTickedInputMethodId = id;
} }
}) })
@@ -223,8 +218,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
R.string.ime_security_warning, R.string.ime_security_warning,
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager()))); selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show(); mDialog.show();
} else if (id.equals(mLastTickedInputMethodId)) {
mLastTickedInputMethodId = null;
} }
} else if (preference instanceof PreferenceScreen) { } else if (preference instanceof PreferenceScreen) {
if (preference.getFragment() != null) { if (preference.getFragment() != null) {

View File

@@ -42,8 +42,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
private List<InputMethodInfo> mInputMethodProperties; private List<InputMethodInfo> mInputMethodProperties;
private String mLastTickedInputMethodId;
private AlertDialog mDialog = null; private AlertDialog mDialog = null;
@Override @Override
@@ -60,14 +58,13 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
super.onResume(); super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties); this, getContentResolver(), mInputMethodProperties);
mLastTickedInputMethodId = null;
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId); mInputMethodProperties, mHaveHardKeyboard);
} }
@Override @Override
@@ -89,7 +86,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
this, mInputMethodProperties, id, true); this, mInputMethodProperties, id, true);
// This is a built-in IME, so no need to warn. // This is a built-in IME, so no need to warn.
mLastTickedInputMethodId = id;
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
break; break;
@@ -111,7 +107,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
InputMethodAndSubtypeEnabler.this, InputMethodAndSubtypeEnabler.this,
mInputMethodProperties, id, true); mInputMethodProperties, id, true);
mLastTickedInputMethodId = id;
} }
}) })
@@ -132,9 +127,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager()))); selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show(); mDialog.show();
} else { } else {
if (id.equals(mLastTickedInputMethodId)) {
mLastTickedInputMethodId = null;
}
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
this, mInputMethodProperties, id, false); this, mInputMethodProperties, id, false);
} }

View File

@@ -98,15 +98,13 @@ public class InputMethodAndSubtypeUtil {
public static void saveInputMethodSubtypeList( public static void saveInputMethodSubtypeList(
SettingsPreferenceFragment context, ContentResolver resolver, SettingsPreferenceFragment context, ContentResolver resolver,
List<InputMethodInfo> inputMethodProperties, List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) {
boolean hasHardKeyboard, String lastTickedInputMethodId) {
String currentInputMethodId = Settings.Secure.getString(resolver, String currentInputMethodId = Settings.Secure.getString(resolver,
Settings.Secure.DEFAULT_INPUT_METHOD); Settings.Secure.DEFAULT_INPUT_METHOD);
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver); final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
StringBuilder disabledSysImes = new StringBuilder(); StringBuilder disabledSysImes = new StringBuilder();
InputMethodInfo firstEnabledIMI = null;
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID; int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
final boolean onlyOneIME = inputMethodProperties.size() == 1; final boolean onlyOneIME = inputMethodProperties.size() == 1;
@@ -121,9 +119,6 @@ public class InputMethodAndSubtypeUtil {
|| (pref != null && pref.isChecked())) { || (pref != null && pref.isChecked())) {
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER); if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
builder.append(id); builder.append(id);
if (firstEnabledIMI == null) {
firstEnabledIMI = property;
}
for (InputMethodSubtype subtype : property.getSubtypes()) { for (InputMethodSubtype subtype : property.getSubtypes()) {
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference( CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
id + subtype.hashCode()); id + subtype.hashCode());
@@ -141,8 +136,11 @@ public class InputMethodAndSubtypeUtil {
} else if (isCurrentInputMethod) { } else if (isCurrentInputMethod) {
// We are processing the current input method, but found that it's not enabled. // We are processing the current input method, but found that it's not enabled.
// This means that the current input method has been uninstalled. // This means that the current input method has been uninstalled.
// If currentInputMethod is already uninstalled, selects last ticked IME // If currentInputMethod is already uninstalled, InputMethodManagerService will
currentInputMethodId = lastTickedInputMethodId; // find the applicable IME from the history and the system locale.
if (DEBUG) {
Log.d(TAG, "Current IME was uninstalled or disabled.");
}
} }
// If it's a disabled system ime, add it to the disabled list so that it // If it's a disabled system ime, add it to the disabled list so that it
// doesn't get enabled automatically on any changes to the package list // doesn't get enabled automatically on any changes to the package list
@@ -152,15 +150,6 @@ public class InputMethodAndSubtypeUtil {
} }
} }
// If the last input method is unset, set it as the first enabled one.
if (TextUtils.isEmpty(currentInputMethodId)) {
if (firstEnabledIMI != null) {
currentInputMethodId = firstEnabledIMI.getId();
} else {
currentInputMethodId = null;
}
}
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString()); Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
Log.d(TAG, "--- Save disable system inputmethod settings. :" Log.d(TAG, "--- Save disable system inputmethod settings. :"
@@ -183,6 +172,8 @@ public class InputMethodAndSubtypeUtil {
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString()); Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Settings.Secure.putString(resolver, Settings.Secure.putString(resolver,
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString()); Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
// If the current input method is unset, InputMethodManagerService will find the applicable
// IME from the history and the system locale.
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
currentInputMethodId != null ? currentInputMethodId : ""); currentInputMethodId != null ? currentInputMethodId : "");
} }