Loading java/src/com/android/inputmethod/compat/CompatUtils.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * 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 License for the specific language governing permissions and * limitations under the License. */ package com.android.inputmethod.compat; import android.content.Intent; import android.text.TextUtils; public class CompatUtils { private static final String EXTRA_INPUT_METHOD_ID = "input_method_id"; // TODO: Can these be constants instead of literal String constants? private static final String INPUT_METHOD_SUBTYPE_SETTINGS = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS"; private static final String INPUT_LANGUAGE_SELECTION = "com.android.inputmethod.latin.INPUT_LANGUAGE_SELECTION"; public static Intent getInputLanguageSelectionIntent(String inputMethodId, int flagsForSubtypeSettings) { final String action; Intent intent; if (android.os.Build.VERSION.SDK_INT >= /* android.os.Build.VERSION_CODES.HONEYCOMB */ 11) { // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS action = INPUT_METHOD_SUBTYPE_SETTINGS; intent = new Intent(action); if (!TextUtils.isEmpty(inputMethodId)) { intent.putExtra(EXTRA_INPUT_METHOD_ID, inputMethodId); } if (flagsForSubtypeSettings > 0) { intent.setFlags(flagsForSubtypeSettings); } } else { action = INPUT_LANGUAGE_SELECTION; intent = new Intent(action); } return intent; } } java/src/com/android/inputmethod/latin/LatinIME.java +3 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; Loading Loading @@ -2215,13 +2216,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen di.dismiss(); switch (position) { case 0: Intent intent = new Intent( android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK Intent intent = CompatUtils.getInputLanguageSelectionIntent( mInputMethodId, 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; case 1: Loading java/src/com/android/inputmethod/latin/Settings.java +7 −10 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.deprecated.VoiceConnector; import android.app.AlertDialog; import android.app.Dialog; import android.app.backup.BackupManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; Loading @@ -38,6 +40,7 @@ import android.text.AutoText; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.widget.TextView; import java.util.Locale; Loading Loading @@ -221,16 +224,10 @@ public class Settings extends PreferenceActivity @Override public boolean onPreferenceClick(Preference pref) { if (pref == mInputLanguageSelection) { final String action; if (android.os.Build.VERSION.SDK_INT >= /* android.os.Build.VERSION_CODES.HONEYCOMB */ 11) { // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS // TODO: Can this be a constant instead of literal String constant? action = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS"; } else { action = "com.android.inputmethod.latin.INPUT_LANGUAGE_SELECTION"; } startActivity(new Intent(action)); startActivity(CompatUtils.getInputLanguageSelectionIntent( Utils.getInputMethodId( (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE), getApplicationInfo().packageName), 0)); return true; } return false; Loading Loading
java/src/com/android/inputmethod/compat/CompatUtils.java 0 → 100644 +51 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * * 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 License for the specific language governing permissions and * limitations under the License. */ package com.android.inputmethod.compat; import android.content.Intent; import android.text.TextUtils; public class CompatUtils { private static final String EXTRA_INPUT_METHOD_ID = "input_method_id"; // TODO: Can these be constants instead of literal String constants? private static final String INPUT_METHOD_SUBTYPE_SETTINGS = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS"; private static final String INPUT_LANGUAGE_SELECTION = "com.android.inputmethod.latin.INPUT_LANGUAGE_SELECTION"; public static Intent getInputLanguageSelectionIntent(String inputMethodId, int flagsForSubtypeSettings) { final String action; Intent intent; if (android.os.Build.VERSION.SDK_INT >= /* android.os.Build.VERSION_CODES.HONEYCOMB */ 11) { // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS action = INPUT_METHOD_SUBTYPE_SETTINGS; intent = new Intent(action); if (!TextUtils.isEmpty(inputMethodId)) { intent.putExtra(EXTRA_INPUT_METHOD_ID, inputMethodId); } if (flagsForSubtypeSettings > 0) { intent.setFlags(flagsForSubtypeSettings); } } else { action = INPUT_LANGUAGE_SELECTION; intent = new Intent(action); } return intent; } }
java/src/com/android/inputmethod/latin/LatinIME.java +3 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; Loading Loading @@ -2215,13 +2216,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen di.dismiss(); switch (position) { case 0: Intent intent = new Intent( android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK Intent intent = CompatUtils.getInputLanguageSelectionIntent( mInputMethodId, 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; case 1: Loading
java/src/com/android/inputmethod/latin/Settings.java +7 −10 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.deprecated.VoiceConnector; import android.app.AlertDialog; import android.app.Dialog; import android.app.backup.BackupManager; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; Loading @@ -38,6 +40,7 @@ import android.text.AutoText; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.inputmethod.InputMethodManager; import android.widget.TextView; import java.util.Locale; Loading Loading @@ -221,16 +224,10 @@ public class Settings extends PreferenceActivity @Override public boolean onPreferenceClick(Preference pref) { if (pref == mInputLanguageSelection) { final String action; if (android.os.Build.VERSION.SDK_INT >= /* android.os.Build.VERSION_CODES.HONEYCOMB */ 11) { // Refer to android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS // TODO: Can this be a constant instead of literal String constant? action = "android.settings.INPUT_METHOD_SUBTYPE_SETTINGS"; } else { action = "com.android.inputmethod.latin.INPUT_LANGUAGE_SELECTION"; } startActivity(new Intent(action)); startActivity(CompatUtils.getInputLanguageSelectionIntent( Utils.getInputMethodId( (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE), getApplicationInfo().packageName), 0)); return true; } return false; Loading