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:
@@ -53,8 +53,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
final TextUtils.SimpleStringSplitter mStringColonSplitter
|
||||
= new TextUtils.SimpleStringSplitter(':');
|
||||
|
||||
private String mLastTickedInputMethodId;
|
||||
|
||||
private AlertDialog mDialog = null;
|
||||
|
||||
static public String getInputMethodIdFromKey(String key) {
|
||||
@@ -145,7 +143,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
|
||||
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
|
||||
this, getContentResolver(), mInputMethodProperties);
|
||||
mLastTickedInputMethodId = null;
|
||||
|
||||
if (mLanguagePref != null) {
|
||||
Configuration conf = getResources().getConfiguration();
|
||||
@@ -161,7 +158,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
|
||||
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId);
|
||||
mInputMethodProperties, mHaveHardKeyboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,7 +181,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
selImi = imi;
|
||||
if (isSystemIme(imi)) {
|
||||
// This is a built-in IME, so no need to warn.
|
||||
mLastTickedInputMethodId = id;
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
}
|
||||
@@ -203,7 +199,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
chkPref.setChecked(true);
|
||||
mLastTickedInputMethodId = id;
|
||||
}
|
||||
|
||||
})
|
||||
@@ -223,8 +218,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
|
||||
R.string.ime_security_warning,
|
||||
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
|
||||
mDialog.show();
|
||||
} else if (id.equals(mLastTickedInputMethodId)) {
|
||||
mLastTickedInputMethodId = null;
|
||||
}
|
||||
} else if (preference instanceof PreferenceScreen) {
|
||||
if (preference.getFragment() != null) {
|
||||
|
@@ -42,8 +42,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
||||
|
||||
private List<InputMethodInfo> mInputMethodProperties;
|
||||
|
||||
private String mLastTickedInputMethodId;
|
||||
|
||||
private AlertDialog mDialog = null;
|
||||
|
||||
@Override
|
||||
@@ -60,14 +58,13 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
||||
super.onResume();
|
||||
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
|
||||
this, getContentResolver(), mInputMethodProperties);
|
||||
mLastTickedInputMethodId = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
|
||||
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId);
|
||||
mInputMethodProperties, mHaveHardKeyboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +86,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
||||
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
|
||||
this, mInputMethodProperties, id, true);
|
||||
// This is a built-in IME, so no need to warn.
|
||||
mLastTickedInputMethodId = id;
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
break;
|
||||
@@ -111,7 +107,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
||||
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
|
||||
InputMethodAndSubtypeEnabler.this,
|
||||
mInputMethodProperties, id, true);
|
||||
mLastTickedInputMethodId = id;
|
||||
}
|
||||
|
||||
})
|
||||
@@ -132,9 +127,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
|
||||
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
|
||||
mDialog.show();
|
||||
} else {
|
||||
if (id.equals(mLastTickedInputMethodId)) {
|
||||
mLastTickedInputMethodId = null;
|
||||
}
|
||||
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
|
||||
this, mInputMethodProperties, id, false);
|
||||
}
|
||||
|
@@ -98,15 +98,13 @@ public class InputMethodAndSubtypeUtil {
|
||||
|
||||
public static void saveInputMethodSubtypeList(
|
||||
SettingsPreferenceFragment context, ContentResolver resolver,
|
||||
List<InputMethodInfo> inputMethodProperties,
|
||||
boolean hasHardKeyboard, String lastTickedInputMethodId) {
|
||||
List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) {
|
||||
String currentInputMethodId = Settings.Secure.getString(resolver,
|
||||
Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
StringBuilder disabledSysImes = new StringBuilder();
|
||||
InputMethodInfo firstEnabledIMI = null;
|
||||
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
|
||||
|
||||
final boolean onlyOneIME = inputMethodProperties.size() == 1;
|
||||
@@ -121,9 +119,6 @@ public class InputMethodAndSubtypeUtil {
|
||||
|| (pref != null && pref.isChecked())) {
|
||||
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
|
||||
builder.append(id);
|
||||
if (firstEnabledIMI == null) {
|
||||
firstEnabledIMI = property;
|
||||
}
|
||||
for (InputMethodSubtype subtype : property.getSubtypes()) {
|
||||
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
|
||||
id + subtype.hashCode());
|
||||
@@ -141,8 +136,11 @@ public class InputMethodAndSubtypeUtil {
|
||||
} else if (isCurrentInputMethod) {
|
||||
// We are processing the current input method, but found that it's not enabled.
|
||||
// This means that the current input method has been uninstalled.
|
||||
// If currentInputMethod is already uninstalled, selects last ticked IME
|
||||
currentInputMethodId = lastTickedInputMethodId;
|
||||
// If currentInputMethod is already uninstalled, InputMethodManagerService will
|
||||
// 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
|
||||
// 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) {
|
||||
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
|
||||
Log.d(TAG, "--- Save disable system inputmethod settings. :"
|
||||
@@ -183,6 +172,8 @@ public class InputMethodAndSubtypeUtil {
|
||||
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
|
||||
Settings.Secure.putString(resolver,
|
||||
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,
|
||||
currentInputMethodId != null ? currentInputMethodId : "");
|
||||
}
|
||||
|
Reference in New Issue
Block a user