Don't show autofill settings if not enabled

The non-indexable keys of language-and-input on my angler are:
  game_controller_settings_category, gesture_assist,
  gesture_double_tap_screen, default_autofill

Fixes: 35956220
Test: Disabled auto-fill and looked at settings: did not find
      autofill button and could not find auto-fill in search
      Settings robolectric test
Change-Id: I0923e707422d1b1de5153a63fa3a5fe4773c055d
This commit is contained in:
Philip P. Moltmann
2017-04-24 16:13:21 -07:00
parent 75215a9553
commit 4619ae0652
6 changed files with 142 additions and 9 deletions

View File

@@ -23,6 +23,8 @@ import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.speech.tts.TtsEngines;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
@@ -84,7 +86,16 @@ public class LanguageAndInputSettings extends DashboardFragment {
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
final Lifecycle lifecycle = getLifecycle();
if (mAmbientDisplayConfig == null) {
mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
}
return buildPreferenceControllers(context, getLifecycle(), mAmbientDisplayConfig);
}
private static List<PreferenceController> buildPreferenceControllers(@NonNull Context context,
@Nullable Lifecycle lifecycle,
@NonNull AmbientDisplayConfiguration ambientDisplayConfiguration) {
final List<PreferenceController> controllers = new ArrayList<>();
// Language
controllers.add(new PhoneLanguagePreferenceController(context));
@@ -96,11 +107,10 @@ public class LanguageAndInputSettings extends DashboardFragment {
controllers.add(new PhysicalKeyboardPreferenceController(context, lifecycle));
final GameControllerPreferenceController gameControllerPreferenceController
= new GameControllerPreferenceController(context);
lifecycle.addObserver(gameControllerPreferenceController);
if (mAmbientDisplayConfig == null) {
mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
if (lifecycle != null) {
lifecycle.addObserver(gameControllerPreferenceController);
}
controllers.add(gameControllerPreferenceController);
// Gestures
controllers.add(new AssistGesturePreferenceController(context, lifecycle));
@@ -108,9 +118,9 @@ public class LanguageAndInputSettings extends DashboardFragment {
controllers.add(new DoubleTwistPreferenceController(context, lifecycle));
controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle));
controllers.add(new PickupGesturePreferenceController(
context, lifecycle, mAmbientDisplayConfig, UserHandle.myUserId()));
context, lifecycle, ambientDisplayConfiguration, UserHandle.myUserId()));
controllers.add(new DoubleTapScreenPreferenceController(
context, lifecycle, mAmbientDisplayConfig, UserHandle.myUserId()));
context, lifecycle, ambientDisplayConfiguration, UserHandle.myUserId()));
controllers.add(new CameraLiftTriggerPreferenceController(context, lifecycle,
KEY_CAMERA_LIFT_TRIGGER));
controllers.add(new DefaultAutofillPreferenceController(context));
@@ -168,5 +178,11 @@ public class LanguageAndInputSettings extends DashboardFragment {
sir.xmlResId = R.xml.language_and_input;
return Arrays.asList(sir);
}
@Override
public List<PreferenceController> getPreferenceControllers(Context context) {
return buildPreferenceControllers(context, null,
new AmbientDisplayConfiguration(context));
}
};
}