1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.applications.assist; 18 19 import android.content.Context; 20 import android.provider.SearchIndexableResource; 21 22 import com.android.internal.logging.nano.MetricsProto.MetricsEvent; 23 import com.android.settings.R; 24 import com.android.settings.dashboard.DashboardFragment; 25 import com.android.settings.gestures.AssistGestureSettingsPreferenceController; 26 import com.android.settings.search.BaseSearchIndexProvider; 27 import com.android.settings.search.Indexable; 28 import com.android.settingslib.core.AbstractPreferenceController; 29 import com.android.settingslib.core.lifecycle.Lifecycle; 30 31 import java.util.ArrayList; 32 import java.util.Arrays; 33 import java.util.List; 34 35 /** 36 * Settings screen to manage everything about assist. 37 */ 38 public class ManageAssist extends DashboardFragment { 39 40 private static final String TAG = "ManageAssist"; 41 private static final String KEY_ASSIST = "gesture_assist_application"; 42 43 @Override getLogTag()44 protected String getLogTag() { 45 return TAG; 46 } 47 48 @Override getPreferenceScreenResId()49 protected int getPreferenceScreenResId() { 50 return R.xml.manage_assist; 51 } 52 53 @Override getPreferenceControllers(Context context)54 protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { 55 return buildPreferenceControllers(context, getLifecycle()); 56 } 57 58 @Override getMetricsCategory()59 public int getMetricsCategory() { 60 return MetricsEvent.APPLICATIONS_MANAGE_ASSIST; 61 } 62 63 @Override onResume()64 public void onResume() { 65 super.onResume(); 66 67 mFooterPreferenceMixin.createFooterPreference() 68 .setTitle(R.string.assist_footer); 69 } 70 buildPreferenceControllers(Context context, Lifecycle lifecycle)71 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 72 Lifecycle lifecycle) { 73 final List<AbstractPreferenceController> controllers = new ArrayList<>(); 74 controllers.add(new DefaultAssistPreferenceController(context, "default_assist", 75 true /* showSetting */)); 76 controllers.add(new AssistGestureSettingsPreferenceController(context, lifecycle, 77 KEY_ASSIST, true /* assistOnly */)); 78 controllers.add(new AssistContextPreferenceController(context, lifecycle)); 79 controllers.add(new AssistScreenshotPreferenceController(context, lifecycle)); 80 controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle)); 81 controllers.add(new DefaultVoiceInputPreferenceController(context, lifecycle)); 82 return controllers; 83 } 84 85 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 86 new BaseSearchIndexProvider() { 87 @Override 88 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 89 boolean enabled) { 90 final SearchIndexableResource sir = new SearchIndexableResource(context); 91 sir.xmlResId = R.xml.manage_assist; 92 return Arrays.asList(sir); 93 } 94 95 @Override 96 public List<AbstractPreferenceController> getPreferenceControllers( 97 Context context) { 98 return buildPreferenceControllers(context, null /* lifecycle */); 99 } 100 101 @Override 102 public List<String> getNonIndexableKeys(Context context) { 103 List<String> keys = super.getNonIndexableKeys(context); 104 keys.add(KEY_ASSIST); 105 return keys; 106 } 107 }; 108 } 109