Show physical keyboard settings even when IME is enabled.
The WindowManager lies about the configuration in order to get the IME to show but the Settings page should still show the physical keyboard options if one is connected though, so remove the configuration check and just always check to see if there's a full keyboard connected. Bug: 14066881 Change-Id: I085fe4160f3524f3c95737a6809ee03fec5230b4
This commit is contained in:
@@ -564,35 +564,33 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private void updateHardKeyboards() {
|
private void updateHardKeyboards() {
|
||||||
mHardKeyboardPreferenceList.clear();
|
mHardKeyboardPreferenceList.clear();
|
||||||
if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY) {
|
final int[] devices = InputDevice.getDeviceIds();
|
||||||
final int[] devices = InputDevice.getDeviceIds();
|
for (int i = 0; i < devices.length; i++) {
|
||||||
for (int i = 0; i < devices.length; i++) {
|
InputDevice device = InputDevice.getDevice(devices[i]);
|
||||||
InputDevice device = InputDevice.getDevice(devices[i]);
|
if (device != null
|
||||||
if (device != null
|
&& !device.isVirtual()
|
||||||
&& !device.isVirtual()
|
&& device.isFullKeyboard()) {
|
||||||
&& device.isFullKeyboard()) {
|
final InputDeviceIdentifier identifier = device.getIdentifier();
|
||||||
final InputDeviceIdentifier identifier = device.getIdentifier();
|
final String keyboardLayoutDescriptor =
|
||||||
final String keyboardLayoutDescriptor =
|
mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
|
||||||
mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
|
final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ?
|
||||||
final KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ?
|
mIm.getKeyboardLayout(keyboardLayoutDescriptor) : null;
|
||||||
mIm.getKeyboardLayout(keyboardLayoutDescriptor) : null;
|
|
||||||
|
|
||||||
final PreferenceScreen pref = new PreferenceScreen(getActivity(), null);
|
final PreferenceScreen pref = new PreferenceScreen(getActivity(), null);
|
||||||
pref.setTitle(device.getName());
|
pref.setTitle(device.getName());
|
||||||
if (keyboardLayout != null) {
|
if (keyboardLayout != null) {
|
||||||
pref.setSummary(keyboardLayout.toString());
|
pref.setSummary(keyboardLayout.toString());
|
||||||
} else {
|
} else {
|
||||||
pref.setSummary(R.string.keyboard_layout_default_label);
|
pref.setSummary(R.string.keyboard_layout_default_label);
|
||||||
}
|
|
||||||
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
showKeyboardLayoutDialog(identifier);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mHardKeyboardPreferenceList.add(pref);
|
|
||||||
}
|
}
|
||||||
|
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
showKeyboardLayoutDialog(identifier);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mHardKeyboardPreferenceList.add(pref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -795,76 +793,74 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment
|
|||||||
// Hard keyboards
|
// Hard keyboards
|
||||||
InputManager inputManager = (InputManager) context.getSystemService(
|
InputManager inputManager = (InputManager) context.getSystemService(
|
||||||
Context.INPUT_SERVICE);
|
Context.INPUT_SERVICE);
|
||||||
if (resources.getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY) {
|
boolean hasHardKeyboards = false;
|
||||||
boolean hasHardKeyboards = false;
|
|
||||||
|
|
||||||
final int[] devices = InputDevice.getDeviceIds();
|
final int[] devices = InputDevice.getDeviceIds();
|
||||||
for (int i = 0; i < devices.length; i++) {
|
for (int i = 0; i < devices.length; i++) {
|
||||||
InputDevice device = InputDevice.getDevice(devices[i]);
|
InputDevice device = InputDevice.getDevice(devices[i]);
|
||||||
if (device == null || device.isVirtual() || !device.isFullKeyboard()) {
|
if (device == null || device.isVirtual() || !device.isFullKeyboard()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
hasHardKeyboards = true;
|
|
||||||
|
|
||||||
InputDeviceIdentifier identifier = device.getIdentifier();
|
|
||||||
String keyboardLayoutDescriptor =
|
|
||||||
inputManager.getCurrentKeyboardLayoutForInputDevice(identifier);
|
|
||||||
KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ?
|
|
||||||
inputManager.getKeyboardLayout(keyboardLayoutDescriptor) : null;
|
|
||||||
|
|
||||||
String summary;
|
|
||||||
if (keyboardLayout != null) {
|
|
||||||
summary = keyboardLayout.toString();
|
|
||||||
} else {
|
|
||||||
summary = context.getString(R.string.keyboard_layout_default_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
indexable = new SearchIndexableRaw(context);
|
|
||||||
indexable.key = device.getName();
|
|
||||||
indexable.title = device.getName();
|
|
||||||
indexable.summaryOn = summary;
|
|
||||||
indexable.summaryOff = summary;
|
|
||||||
indexable.screenTitle = screenTitle;
|
|
||||||
indexables.add(indexable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasHardKeyboards) {
|
hasHardKeyboards = true;
|
||||||
// Hard keyboard category.
|
|
||||||
indexable = new SearchIndexableRaw(context);
|
|
||||||
indexable.key = "builtin_keyboard_settings";
|
|
||||||
indexable.title = context.getString(
|
|
||||||
R.string.builtin_keyboard_settings_title);
|
|
||||||
indexable.screenTitle = screenTitle;
|
|
||||||
indexables.add(indexable);
|
|
||||||
|
|
||||||
// Auto replace.
|
InputDeviceIdentifier identifier = device.getIdentifier();
|
||||||
indexable = new SearchIndexableRaw(context);
|
String keyboardLayoutDescriptor =
|
||||||
indexable.key = "auto_replace";
|
inputManager.getCurrentKeyboardLayoutForInputDevice(identifier);
|
||||||
indexable.title = context.getString(R.string.auto_replace);
|
KeyboardLayout keyboardLayout = keyboardLayoutDescriptor != null ?
|
||||||
indexable.summaryOn = context.getString(R.string.auto_replace_summary);
|
inputManager.getKeyboardLayout(keyboardLayoutDescriptor) : null;
|
||||||
indexable.summaryOff = context.getString(R.string.auto_replace_summary);
|
|
||||||
indexable.screenTitle = screenTitle;
|
|
||||||
indexables.add(indexable);
|
|
||||||
|
|
||||||
// Auto caps.
|
String summary;
|
||||||
indexable = new SearchIndexableRaw(context);
|
if (keyboardLayout != null) {
|
||||||
indexable.key = "auto_caps";
|
summary = keyboardLayout.toString();
|
||||||
indexable.title = context.getString(R.string.auto_caps);
|
} else {
|
||||||
indexable.summaryOn = context.getString(R.string.auto_caps_summary);
|
summary = context.getString(R.string.keyboard_layout_default_label);
|
||||||
indexable.summaryOff = context.getString(R.string.auto_caps_summary);
|
|
||||||
indexable.screenTitle = screenTitle;
|
|
||||||
indexables.add(indexable);
|
|
||||||
|
|
||||||
// Auto punctuate.
|
|
||||||
indexable = new SearchIndexableRaw(context);
|
|
||||||
indexable.key = "auto_punctuate";
|
|
||||||
indexable.title = context.getString(R.string.auto_punctuate);
|
|
||||||
indexable.summaryOn = context.getString(R.string.auto_punctuate_summary);
|
|
||||||
indexable.summaryOff = context.getString(R.string.auto_punctuate_summary);
|
|
||||||
indexable.screenTitle = screenTitle;
|
|
||||||
indexables.add(indexable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indexable = new SearchIndexableRaw(context);
|
||||||
|
indexable.key = device.getName();
|
||||||
|
indexable.title = device.getName();
|
||||||
|
indexable.summaryOn = summary;
|
||||||
|
indexable.summaryOff = summary;
|
||||||
|
indexable.screenTitle = screenTitle;
|
||||||
|
indexables.add(indexable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasHardKeyboards) {
|
||||||
|
// Hard keyboard category.
|
||||||
|
indexable = new SearchIndexableRaw(context);
|
||||||
|
indexable.key = "builtin_keyboard_settings";
|
||||||
|
indexable.title = context.getString(
|
||||||
|
R.string.builtin_keyboard_settings_title);
|
||||||
|
indexable.screenTitle = screenTitle;
|
||||||
|
indexables.add(indexable);
|
||||||
|
|
||||||
|
// Auto replace.
|
||||||
|
indexable = new SearchIndexableRaw(context);
|
||||||
|
indexable.key = "auto_replace";
|
||||||
|
indexable.title = context.getString(R.string.auto_replace);
|
||||||
|
indexable.summaryOn = context.getString(R.string.auto_replace_summary);
|
||||||
|
indexable.summaryOff = context.getString(R.string.auto_replace_summary);
|
||||||
|
indexable.screenTitle = screenTitle;
|
||||||
|
indexables.add(indexable);
|
||||||
|
|
||||||
|
// Auto caps.
|
||||||
|
indexable = new SearchIndexableRaw(context);
|
||||||
|
indexable.key = "auto_caps";
|
||||||
|
indexable.title = context.getString(R.string.auto_caps);
|
||||||
|
indexable.summaryOn = context.getString(R.string.auto_caps_summary);
|
||||||
|
indexable.summaryOff = context.getString(R.string.auto_caps_summary);
|
||||||
|
indexable.screenTitle = screenTitle;
|
||||||
|
indexables.add(indexable);
|
||||||
|
|
||||||
|
// Auto punctuate.
|
||||||
|
indexable = new SearchIndexableRaw(context);
|
||||||
|
indexable.key = "auto_punctuate";
|
||||||
|
indexable.title = context.getString(R.string.auto_punctuate);
|
||||||
|
indexable.summaryOn = context.getString(R.string.auto_punctuate_summary);
|
||||||
|
indexable.summaryOff = context.getString(R.string.auto_punctuate_summary);
|
||||||
|
indexable.screenTitle = screenTitle;
|
||||||
|
indexables.add(indexable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Voice recognizers.
|
// Voice recognizers.
|
||||||
|
Reference in New Issue
Block a user