• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
createPreferenceControllers(Context context)54     protected List<AbstractPreferenceController> createPreferenceControllers(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
onAttach(Context context)64     public void onAttach(Context context) {
65         super.onAttach(context);
66         use(AssistGestureSettingsPreferenceController.class).setAssistOnly(true);
67     }
68 
69     @Override
onResume()70     public void onResume() {
71         super.onResume();
72 
73         mFooterPreferenceMixin.createFooterPreference()
74                 .setTitle(R.string.assist_footer);
75     }
76 
buildPreferenceControllers(Context context, Lifecycle lifecycle)77     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
78             Lifecycle lifecycle) {
79         final List<AbstractPreferenceController> controllers = new ArrayList<>();
80         controllers.add(new DefaultAssistPreferenceController(context, "default_assist",
81                 true /* showSetting */));
82         controllers.add(new AssistContextPreferenceController(context, lifecycle));
83         controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
84         controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
85         controllers.add(new DefaultVoiceInputPreferenceController(context, lifecycle));
86         return controllers;
87     }
88 
89     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
90             new BaseSearchIndexProvider() {
91                 @Override
92                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
93                         boolean enabled) {
94                     final SearchIndexableResource sir = new SearchIndexableResource(context);
95                     sir.xmlResId = R.xml.manage_assist;
96                     return Arrays.asList(sir);
97                 }
98 
99                 @Override
100                 public List<AbstractPreferenceController> createPreferenceControllers(
101                         Context context) {
102                     return buildPreferenceControllers(context, null /* lifecycle */);
103                 }
104 
105                 @Override
106                 public List<String> getNonIndexableKeys(Context context) {
107                     List<String> keys = super.getNonIndexableKeys(context);
108                     keys.add(KEY_ASSIST);
109                     return keys;
110                 }
111             };
112 }
113