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.core.PreferenceController; 25 import com.android.settings.core.lifecycle.Lifecycle; 26 import com.android.settings.dashboard.DashboardFragment; 27 import com.android.settings.gestures.AssistGesturePreferenceController; 28 import com.android.settings.search.BaseSearchIndexProvider; 29 import com.android.settings.search.Indexable; 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 44 protected String getLogTag() { 45 return TAG; 46 } 47 48 @Override 49 protected int getPreferenceScreenResId() { 50 return R.xml.manage_assist; 51 } 52 53 @Override 54 protected List<PreferenceController> getPreferenceControllers(Context context) { 55 return buildPreferenceControllers(context, getLifecycle()); 56 } 57 58 @Override 59 public int getMetricsCategory() { 60 return MetricsEvent.APPLICATIONS_MANAGE_ASSIST; 61 } 62 63 @Override 64 public void onResume() { 65 super.onResume(); 66 67 mFooterPreferenceMixin.createFooterPreference() 68 .setTitle(R.string.assist_footer); 69 } 70 71 private static List<PreferenceController> buildPreferenceControllers(Context context, 72 Lifecycle lifecycle) { 73 final List<PreferenceController> controllers = new ArrayList<>(); 74 controllers.add(new DefaultAssistPreferenceController(context)); 75 controllers.add(new AssistGesturePreferenceController(context, lifecycle, KEY_ASSIST)); 76 controllers.add(new AssistContextPreferenceController(context, lifecycle)); 77 controllers.add(new AssistScreenshotPreferenceController(context, lifecycle)); 78 controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle)); 79 controllers.add(new DefaultVoiceInputPreferenceController(context, lifecycle)); 80 return controllers; 81 } 82 83 84 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 85 new BaseSearchIndexProvider() { 86 @Override 87 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 88 boolean enabled) { 89 final SearchIndexableResource sir = new SearchIndexableResource(context); 90 sir.xmlResId = R.xml.manage_assist; 91 return Arrays.asList(sir); 92 } 93 94 @Override 95 public List<PreferenceController> getPreferenceControllers(Context context) { 96 return buildPreferenceControllers(context, null /* lifecycle */); 97 } 98 99 @Override 100 public List<String> getNonIndexableKeys(Context context) { 101 List<String> keys = super.getNonIndexableKeys(context); 102 keys.add(KEY_ASSIST); 103 return keys; 104 } 105 106 }; 107 } 108