Loading AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,19 @@ android:resource="@id/language_settings" /> </activity> <activity android:name="Settings$KeyboardLayoutPickerActivity" android:label="@string/keyboard_layout_picker_title" android:clearTaskOnLaunch="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="com.android.settings.FRAGMENT_CLASS" android:value="com.android.settings.inputmethod.KeyboardLayoutPicker" /> <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID" android:resource="@id/language_settings" /> </activity> <!-- Keep compatibility with old shortcuts. --> <activity-alias android:name="LanguageSettings" android:label="@string/language_keyboard_settings_title" Loading res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -2614,6 +2614,12 @@ <!-- On Language & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] --> <string name="pointer_speed">Pointer speed</string> <!-- Keyboard Layout Picker --> <skip /> <!-- Title for the keyboard layout picker activity. [CHAR LIMIT=35] --> <string name="keyboard_layout_picker_title">Choose keyboard layout</string> <!-- String to show when no keyboard layouts are available. [CHAR LIMIT=60] --> <string name="keyboard_layout_picker_empty_text">No keyboard layouts are available.</string> <!-- User dictionary settings --><skip /> <!-- User dictionary settings, The titlebar text of the User dictionary settings screen. --> <string name="user_dict_settings_titlebar">User dictionary</string> Loading res/xml/language_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -36,27 +36,34 @@ <PreferenceScreen android:key="current_input_method" android:title="@string/current_input_method" /> </PreferenceCategory> <PreferenceCategory android:key="hard_keyboard" android:title="@string/builtin_keyboard_settings_title" android:persistent="false"> <!-- Additional preference screens are inserted here programmatically with low order values to set the key map of each attached keyboard. --> <CheckBoxPreference android:key="auto_replace" android:title="@string/auto_replace" android:summaryOn="@string/auto_replace_summary" android:summaryOff="@string/auto_replace_summary" android:order="1000" android:persistent="false"/> <CheckBoxPreference android:key="auto_caps" android:title="@string/auto_caps" android:summaryOn="@string/auto_caps_summary" android:summaryOff="@string/auto_caps_summary" android:order="1001" android:persistent="false"/> <CheckBoxPreference android:key="auto_punctuate" android:title="@string/auto_punctuate" android:summaryOn="@string/auto_punctuate_summary" android:summaryOff="@string/auto_punctuate_summary" android:order="1002" android:persistent="false"/> </PreferenceCategory> Loading src/com/android/settings/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -609,6 +609,7 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler { public static class WifiSettingsActivity extends Settings { /* empty */ } public static class WifiP2pSettingsActivity extends Settings { /* empty */ } public static class InputMethodAndLanguageSettingsActivity extends Settings { /* empty */ } public static class KeyboardLayoutPickerActivity extends Settings { /* empty */ } public static class InputMethodAndSubtypeEnablerActivity extends Settings { /* empty */ } public static class SpellCheckersSettingsActivity extends Settings { /* empty */ } public static class LocalePickerActivity extends Settings { /* empty */ } Loading src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +106 −47 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.settings.inputmethod; import com.android.settings.R; import com.android.settings.Settings.KeyboardLayoutPickerActivity; import com.android.settings.Settings.SpellCheckersSettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; Loading @@ -29,6 +30,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.ContentObserver; import android.hardware.input.InputManager; import android.hardware.input.InputManager.KeyboardLayout; import android.os.Bundle; import android.os.Handler; import android.preference.CheckBoxPreference; Loading @@ -40,11 +43,15 @@ import android.preference.PreferenceScreen; import android.provider.Settings; import android.provider.Settings.System; import android.text.TextUtils; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.UnavailableException; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; Loading @@ -68,11 +75,13 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private int mDefaultInputMethodSelectorVisibility = 0; private ListPreference mShowInputMethodSelectorPref; private PreferenceCategory mKeyboardSettingsCategory; private PreferenceCategory mHardKeyboardCategory; private Preference mLanguagePref; private ArrayList<InputMethodPreference> mInputMethodPreferenceList = private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = new ArrayList<InputMethodPreference>(); private boolean mHaveHardKeyboard; private PreferenceCategory mHardKeyboardCategory; private final ArrayList<PreferenceScreen> mHardKeyboardPreferenceList = new ArrayList<PreferenceScreen>(); private InputMethodManager mImm; private List<InputMethodInfo> mImis; private boolean mIsOnlyImeSettings; Loading Loading @@ -108,18 +117,55 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment new VoiceInputOutputSettings(this).onCreate(); // Hard keyboard final Configuration config = getResources().getConfiguration(); mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY); // Get references to dynamically constructed categories. mHardKeyboardCategory = (PreferenceCategory)findPreference("hard_keyboard"); mKeyboardSettingsCategory = (PreferenceCategory)findPreference( "keyboard_settings_category"); // IME // Filter out irrelevant features if invoked from IME settings button. mIsOnlyImeSettings = Settings.ACTION_INPUT_METHOD_SETTINGS.equals( getActivity().getIntent().getAction()); getActivity().getIntent().setAction(null); if (mIsOnlyImeSettings) { getPreferenceScreen().removeAll(); getPreferenceScreen().addPreference(mHardKeyboardCategory); if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) { getPreferenceScreen().addPreference(mShowInputMethodSelectorPref); } getPreferenceScreen().addPreference(mKeyboardSettingsCategory); } // Build IME preference category. mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mImis = mImm.getInputMethodList(); createImePreferenceHierarchy((PreferenceGroup)findPreference("keyboard_settings_category")); mKeyboardSettingsCategory.removeAll(); if (!mIsOnlyImeSettings) { final PreferenceScreen currentIme = new PreferenceScreen(getActivity(), null); currentIme.setKey(KEY_CURRENT_INPUT_METHOD); currentIme.setTitle(getResources().getString(R.string.current_input_method)); mKeyboardSettingsCategory.addPreference(currentIme); } mInputMethodPreferenceList.clear(); final int N = (mImis == null ? 0 : mImis.size()); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = mImis.get(i); final InputMethodPreference pref = getInputMethodPreference(imi, N); mInputMethodPreferenceList.add(pref); } if (!mInputMethodPreferenceList.isEmpty()) { Collections.sort(mInputMethodPreferenceList); for (int i = 0; i < N; ++i) { mKeyboardSettingsCategory.addPreference(mInputMethodPreferenceList.get(i)); } } // Build hard keyboard preference category. updateHardKeyboards(); // Spell Checker final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(getActivity(), SpellCheckersSettingsActivity.class); final SpellCheckersPreference scp = ((SpellCheckersPreference)findPreference( Loading Loading @@ -189,7 +235,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } // Hard keyboard if (mHaveHardKeyboard) { if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { CheckBoxPreference chkPref = (CheckBoxPreference) mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i]); Loading @@ -198,6 +244,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } updateHardKeyboards(); // IME InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( this, getContentResolver(), mImis, null); Loading @@ -211,7 +259,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mShowInputMethodSelectorPref.setOnPreferenceChangeListener(null); } InputMethodAndSubtypeUtil.saveInputMethodSubtypeList( this, getContentResolver(), mImis, mHaveHardKeyboard); this, getContentResolver(), mImis, !mHardKeyboardPreferenceList.isEmpty()); } @Override Loading @@ -230,7 +278,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } else if (preference instanceof CheckBoxPreference) { final CheckBoxPreference chkPref = (CheckBoxPreference) preference; if (mHaveHardKeyboard) { if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { if (chkPref == mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i])) { System.putInt(getContentResolver(), sSystemSettingNames[i], Loading Loading @@ -315,46 +363,57 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment return pref; } private void createImePreferenceHierarchy(PreferenceGroup root) { final Preference hardKeyPref = findPreference("hard_keyboard"); if (mIsOnlyImeSettings) { getPreferenceScreen().removeAll(); if (hardKeyPref != null && mHaveHardKeyboard) { getPreferenceScreen().addPreference(hardKeyPref); } if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) { getPreferenceScreen().addPreference(mShowInputMethodSelectorPref); private void updateHardKeyboards() { mHardKeyboardPreferenceList.clear(); if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY) { final InputManager im = (InputManager)getActivity().getSystemService(Context.INPUT_SERVICE); final int[] devices = InputDevice.getDeviceIds(); for (int i = 0; i < devices.length; i++) { InputDevice device = InputDevice.getDevice(devices[i]); if (device != null && (device.getSources() & InputDevice.SOURCE_KEYBOARD) != 0 && device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { final String inputDeviceDescriptor = device.getDescriptor(); final String keyboardLayoutDescriptor = im.getInputDeviceKeyboardLayoutDescriptor(inputDeviceDescriptor); final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ? im.getKeyboardLayout(keyboardLayoutDescriptor) : null; final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(getActivity(), KeyboardLayoutPickerActivity.class); intent.putExtra(KeyboardLayoutPicker.EXTRA_INPUT_DEVICE_DESCRIPTOR, inputDeviceDescriptor); final PreferenceScreen pref = new PreferenceScreen(getActivity(), null); pref.setTitle(device.getName()); if (keyboardLayout != null) { pref.setSummary(keyboardLayout.getLabel()); } getPreferenceScreen().addPreference(root); pref.setIntent(intent); mHardKeyboardPreferenceList.add(pref); } if (hardKeyPref != null) { if (mHaveHardKeyboard) { mHardKeyboardCategory = (PreferenceCategory) hardKeyPref; } else { getPreferenceScreen().removePreference(hardKeyPref); } } root.removeAll(); mInputMethodPreferenceList.clear(); if (!mIsOnlyImeSettings) { // Current IME selection final PreferenceScreen currentIme = new PreferenceScreen(getActivity(), null); currentIme.setKey(KEY_CURRENT_INPUT_METHOD); currentIme.setTitle(getResources().getString(R.string.current_input_method)); root.addPreference(currentIme); if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = mHardKeyboardCategory.getPreferenceCount(); i-- > 0; ) { final Preference pref = mHardKeyboardCategory.getPreference(i); if (pref.getOrder() < 1000) { mHardKeyboardCategory.removePreference(pref); } final int N = (mImis == null ? 0 : mImis.size()); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = mImis.get(i); final InputMethodPreference pref = getInputMethodPreference(imi, N); mInputMethodPreferenceList.add(pref); } Collections.sort(mInputMethodPreferenceList); for (int i = 0; i < N; ++i) { root.addPreference(mInputMethodPreferenceList.get(i)); Collections.sort(mHardKeyboardPreferenceList); final int count = mHardKeyboardPreferenceList.size(); for (int i = 0; i < count; i++) { final Preference pref = mHardKeyboardPreferenceList.get(i); pref.setOrder(i); mHardKeyboardCategory.addPreference(pref); } } else { getPreferenceScreen().removePreference(mHardKeyboardCategory); } } Loading Loading
AndroidManifest.xml +13 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,19 @@ android:resource="@id/language_settings" /> </activity> <activity android:name="Settings$KeyboardLayoutPickerActivity" android:label="@string/keyboard_layout_picker_title" android:clearTaskOnLaunch="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> <meta-data android:name="com.android.settings.FRAGMENT_CLASS" android:value="com.android.settings.inputmethod.KeyboardLayoutPicker" /> <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID" android:resource="@id/language_settings" /> </activity> <!-- Keep compatibility with old shortcuts. --> <activity-alias android:name="LanguageSettings" android:label="@string/language_keyboard_settings_title" Loading
res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -2614,6 +2614,12 @@ <!-- On Language & input settings screen, setting summary. Setting for mouse pointer speed. [CHAR LIMIT=35] --> <string name="pointer_speed">Pointer speed</string> <!-- Keyboard Layout Picker --> <skip /> <!-- Title for the keyboard layout picker activity. [CHAR LIMIT=35] --> <string name="keyboard_layout_picker_title">Choose keyboard layout</string> <!-- String to show when no keyboard layouts are available. [CHAR LIMIT=60] --> <string name="keyboard_layout_picker_empty_text">No keyboard layouts are available.</string> <!-- User dictionary settings --><skip /> <!-- User dictionary settings, The titlebar text of the User dictionary settings screen. --> <string name="user_dict_settings_titlebar">User dictionary</string> Loading
res/xml/language_settings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -36,27 +36,34 @@ <PreferenceScreen android:key="current_input_method" android:title="@string/current_input_method" /> </PreferenceCategory> <PreferenceCategory android:key="hard_keyboard" android:title="@string/builtin_keyboard_settings_title" android:persistent="false"> <!-- Additional preference screens are inserted here programmatically with low order values to set the key map of each attached keyboard. --> <CheckBoxPreference android:key="auto_replace" android:title="@string/auto_replace" android:summaryOn="@string/auto_replace_summary" android:summaryOff="@string/auto_replace_summary" android:order="1000" android:persistent="false"/> <CheckBoxPreference android:key="auto_caps" android:title="@string/auto_caps" android:summaryOn="@string/auto_caps_summary" android:summaryOff="@string/auto_caps_summary" android:order="1001" android:persistent="false"/> <CheckBoxPreference android:key="auto_punctuate" android:title="@string/auto_punctuate" android:summaryOn="@string/auto_punctuate_summary" android:summaryOff="@string/auto_punctuate_summary" android:order="1002" android:persistent="false"/> </PreferenceCategory> Loading
src/com/android/settings/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -609,6 +609,7 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler { public static class WifiSettingsActivity extends Settings { /* empty */ } public static class WifiP2pSettingsActivity extends Settings { /* empty */ } public static class InputMethodAndLanguageSettingsActivity extends Settings { /* empty */ } public static class KeyboardLayoutPickerActivity extends Settings { /* empty */ } public static class InputMethodAndSubtypeEnablerActivity extends Settings { /* empty */ } public static class SpellCheckersSettingsActivity extends Settings { /* empty */ } public static class LocalePickerActivity extends Settings { /* empty */ } Loading
src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +106 −47 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.settings.inputmethod; import com.android.settings.R; import com.android.settings.Settings.KeyboardLayoutPickerActivity; import com.android.settings.Settings.SpellCheckersSettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; Loading @@ -29,6 +30,8 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.ContentObserver; import android.hardware.input.InputManager; import android.hardware.input.InputManager.KeyboardLayout; import android.os.Bundle; import android.os.Handler; import android.preference.CheckBoxPreference; Loading @@ -40,11 +43,15 @@ import android.preference.PreferenceScreen; import android.provider.Settings; import android.provider.Settings.System; import android.text.TextUtils; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyCharacterMap.UnavailableException; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; Loading @@ -68,11 +75,13 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private int mDefaultInputMethodSelectorVisibility = 0; private ListPreference mShowInputMethodSelectorPref; private PreferenceCategory mKeyboardSettingsCategory; private PreferenceCategory mHardKeyboardCategory; private Preference mLanguagePref; private ArrayList<InputMethodPreference> mInputMethodPreferenceList = private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = new ArrayList<InputMethodPreference>(); private boolean mHaveHardKeyboard; private PreferenceCategory mHardKeyboardCategory; private final ArrayList<PreferenceScreen> mHardKeyboardPreferenceList = new ArrayList<PreferenceScreen>(); private InputMethodManager mImm; private List<InputMethodInfo> mImis; private boolean mIsOnlyImeSettings; Loading Loading @@ -108,18 +117,55 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment new VoiceInputOutputSettings(this).onCreate(); // Hard keyboard final Configuration config = getResources().getConfiguration(); mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY); // Get references to dynamically constructed categories. mHardKeyboardCategory = (PreferenceCategory)findPreference("hard_keyboard"); mKeyboardSettingsCategory = (PreferenceCategory)findPreference( "keyboard_settings_category"); // IME // Filter out irrelevant features if invoked from IME settings button. mIsOnlyImeSettings = Settings.ACTION_INPUT_METHOD_SETTINGS.equals( getActivity().getIntent().getAction()); getActivity().getIntent().setAction(null); if (mIsOnlyImeSettings) { getPreferenceScreen().removeAll(); getPreferenceScreen().addPreference(mHardKeyboardCategory); if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) { getPreferenceScreen().addPreference(mShowInputMethodSelectorPref); } getPreferenceScreen().addPreference(mKeyboardSettingsCategory); } // Build IME preference category. mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mImis = mImm.getInputMethodList(); createImePreferenceHierarchy((PreferenceGroup)findPreference("keyboard_settings_category")); mKeyboardSettingsCategory.removeAll(); if (!mIsOnlyImeSettings) { final PreferenceScreen currentIme = new PreferenceScreen(getActivity(), null); currentIme.setKey(KEY_CURRENT_INPUT_METHOD); currentIme.setTitle(getResources().getString(R.string.current_input_method)); mKeyboardSettingsCategory.addPreference(currentIme); } mInputMethodPreferenceList.clear(); final int N = (mImis == null ? 0 : mImis.size()); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = mImis.get(i); final InputMethodPreference pref = getInputMethodPreference(imi, N); mInputMethodPreferenceList.add(pref); } if (!mInputMethodPreferenceList.isEmpty()) { Collections.sort(mInputMethodPreferenceList); for (int i = 0; i < N; ++i) { mKeyboardSettingsCategory.addPreference(mInputMethodPreferenceList.get(i)); } } // Build hard keyboard preference category. updateHardKeyboards(); // Spell Checker final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(getActivity(), SpellCheckersSettingsActivity.class); final SpellCheckersPreference scp = ((SpellCheckersPreference)findPreference( Loading Loading @@ -189,7 +235,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } // Hard keyboard if (mHaveHardKeyboard) { if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { CheckBoxPreference chkPref = (CheckBoxPreference) mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i]); Loading @@ -198,6 +244,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } updateHardKeyboards(); // IME InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( this, getContentResolver(), mImis, null); Loading @@ -211,7 +259,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mShowInputMethodSelectorPref.setOnPreferenceChangeListener(null); } InputMethodAndSubtypeUtil.saveInputMethodSubtypeList( this, getContentResolver(), mImis, mHaveHardKeyboard); this, getContentResolver(), mImis, !mHardKeyboardPreferenceList.isEmpty()); } @Override Loading @@ -230,7 +278,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment } } else if (preference instanceof CheckBoxPreference) { final CheckBoxPreference chkPref = (CheckBoxPreference) preference; if (mHaveHardKeyboard) { if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = 0; i < sHardKeyboardKeys.length; ++i) { if (chkPref == mHardKeyboardCategory.findPreference(sHardKeyboardKeys[i])) { System.putInt(getContentResolver(), sSystemSettingNames[i], Loading Loading @@ -315,46 +363,57 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment return pref; } private void createImePreferenceHierarchy(PreferenceGroup root) { final Preference hardKeyPref = findPreference("hard_keyboard"); if (mIsOnlyImeSettings) { getPreferenceScreen().removeAll(); if (hardKeyPref != null && mHaveHardKeyboard) { getPreferenceScreen().addPreference(hardKeyPref); } if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) { getPreferenceScreen().addPreference(mShowInputMethodSelectorPref); private void updateHardKeyboards() { mHardKeyboardPreferenceList.clear(); if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY) { final InputManager im = (InputManager)getActivity().getSystemService(Context.INPUT_SERVICE); final int[] devices = InputDevice.getDeviceIds(); for (int i = 0; i < devices.length; i++) { InputDevice device = InputDevice.getDevice(devices[i]); if (device != null && (device.getSources() & InputDevice.SOURCE_KEYBOARD) != 0 && device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { final String inputDeviceDescriptor = device.getDescriptor(); final String keyboardLayoutDescriptor = im.getInputDeviceKeyboardLayoutDescriptor(inputDeviceDescriptor); final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ? im.getKeyboardLayout(keyboardLayoutDescriptor) : null; final Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(getActivity(), KeyboardLayoutPickerActivity.class); intent.putExtra(KeyboardLayoutPicker.EXTRA_INPUT_DEVICE_DESCRIPTOR, inputDeviceDescriptor); final PreferenceScreen pref = new PreferenceScreen(getActivity(), null); pref.setTitle(device.getName()); if (keyboardLayout != null) { pref.setSummary(keyboardLayout.getLabel()); } getPreferenceScreen().addPreference(root); pref.setIntent(intent); mHardKeyboardPreferenceList.add(pref); } if (hardKeyPref != null) { if (mHaveHardKeyboard) { mHardKeyboardCategory = (PreferenceCategory) hardKeyPref; } else { getPreferenceScreen().removePreference(hardKeyPref); } } root.removeAll(); mInputMethodPreferenceList.clear(); if (!mIsOnlyImeSettings) { // Current IME selection final PreferenceScreen currentIme = new PreferenceScreen(getActivity(), null); currentIme.setKey(KEY_CURRENT_INPUT_METHOD); currentIme.setTitle(getResources().getString(R.string.current_input_method)); root.addPreference(currentIme); if (!mHardKeyboardPreferenceList.isEmpty()) { for (int i = mHardKeyboardCategory.getPreferenceCount(); i-- > 0; ) { final Preference pref = mHardKeyboardCategory.getPreference(i); if (pref.getOrder() < 1000) { mHardKeyboardCategory.removePreference(pref); } final int N = (mImis == null ? 0 : mImis.size()); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = mImis.get(i); final InputMethodPreference pref = getInputMethodPreference(imi, N); mInputMethodPreferenceList.add(pref); } Collections.sort(mInputMethodPreferenceList); for (int i = 0; i < N; ++i) { root.addPreference(mInputMethodPreferenceList.get(i)); Collections.sort(mHardKeyboardPreferenceList); final int count = mHardKeyboardPreferenceList.size(); for (int i = 0; i < count; i++) { final Preference pref = mHardKeyboardPreferenceList.get(i); pref.setOrder(i); mHardKeyboardCategory.addPreference(pref); } } else { getPreferenceScreen().removePreference(mHardKeyboardCategory); } } Loading