Move physical keyboard search landing page to its Fragment

This CL moves the code building index of physical keyboards from
InputMethodAndLanguageSettings to PhysicalKeyboardFragment, so that a
search landing page becomes PhysicalKeyboardFragment as expected.

Bug: 32643633
Test: Connecting/Disconnecting Anker bluetooth keyboard while Settings
      app is/isn't running, the search Anker and verify landing page
      is PhysicalKeyboardFragment.
Test: Update robolectric DynamicIndexableContentMonitorTest.

Change-Id: I51f308ada74966a96c258f8ef50a9b4fc7bc6635
This commit is contained in:
Tadashi G. Takaoka
2017-01-10 15:02:22 +09:00
parent ae182dedee
commit 7bbc632bfb
5 changed files with 57 additions and 64 deletions

View File

@@ -22,11 +22,8 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
import android.speech.tts.TtsEngines;
import android.support.v7.preference.Preference;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
@@ -246,44 +243,7 @@ public class InputMethodAndLanguageSettings extends DashboardFragment
indexables.add(indexable);
}
// TODO: Move to PhysicalKeyboardFragment.
// Hard keyboards
InputManager inputManager = (InputManager) context.getSystemService(
Context.INPUT_SERVICE);
boolean hasHardKeyboards = false;
final int[] devices = InputDevice.getDeviceIds();
for (int i = 0; i < devices.length; i++) {
InputDevice device = InputDevice.getDevice(devices[i]);
if (device == null || device.isVirtual() || !device.isFullKeyboard()) {
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) {
if (!PhysicalKeyboardFragment.getPhysicalFullKeyboards().isEmpty()) {
// Hard keyboard category.
indexable = new SearchIndexableRaw(context);
indexable.key = "builtin_keyboard_settings";