Move IME related seach landing pages to its fragments

This CL moves the code building index of IMEs from
InputMethodAndLanguageSettings to VirtualKeyboardFragment and
AvailableVirtualKeyboardFragment, so that a search landing page of IME
becomes one of the fragment correctly depending on the IME state.

Bug: 32643633
Test: Manually installing/uninstalling AOSP LatinIME.apk while
      Settings app is/isn't running, then search AOSP and verify the
      landing page is correctly determined by the IME's enable state.
Test: Update robolectric DynamicIndexableContentMonitorTest
Change-Id: Ie44f358c2d3919fc864f4f88e6229293113823dd
This commit is contained in:
Tadashi G. Takaoka
2017-01-10 15:47:19 +09:00
parent 7bbc632bfb
commit e776821a8d
6 changed files with 103 additions and 49 deletions

View File

@@ -17,16 +17,11 @@
package com.android.settings.inputmethod;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.hardware.input.InputDeviceIdentifier;
import android.speech.tts.TtsEngines;
import android.support.v7.preference.Preference;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
@@ -212,37 +207,6 @@ public class InputMethodAndLanguageSettings extends DashboardFragment
indexable.keywords = context.getString(R.string.keywords_keyboard_and_ime);
indexables.add(indexable);
InputMethodSettingValuesWrapper immValues = InputMethodSettingValuesWrapper
.getInstance(context);
immValues.refreshAllInputMethodAndSubtypes();
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(
Context.INPUT_METHOD_SERVICE);
// TODO: Move to VirtualKeyboardFragment and AvailableVirtualKeyboardFragment.
// All other IMEs.
List<InputMethodInfo> inputMethods = immValues.getInputMethodList();
final int inputMethodCount = (inputMethods == null ? 0 : inputMethods.size());
for (int i = 0; i < inputMethodCount; ++i) {
InputMethodInfo inputMethod = inputMethods.get(i);
List<InputMethodSubtype> subtypes = inputMethodManager
.getEnabledInputMethodSubtypeList(inputMethod, true);
String summary = InputMethodAndSubtypeUtil.getSubtypeLocaleNameListAsSentence(
subtypes, context, inputMethod);
ServiceInfo serviceInfo = inputMethod.getServiceInfo();
ComponentName componentName = new ComponentName(serviceInfo.packageName,
serviceInfo.name);
indexable = new SearchIndexableRaw(context);
indexable.key = componentName.flattenToString();
indexable.title = inputMethod.loadLabel(context.getPackageManager()).toString();
indexable.summaryOn = summary;
indexable.summaryOff = summary;
indexable.screenTitle = screenTitle;
indexables.add(indexable);
}
if (!PhysicalKeyboardFragment.getPhysicalFullKeyboards().isEmpty()) {
// Hard keyboard category.
indexable = new SearchIndexableRaw(context);