• 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.gestures;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.provider.SearchIndexableResource;
22 
23 import com.android.settings.R;
24 import com.android.settings.dashboard.DashboardFragment;
25 import com.android.settings.overlay.FeatureFactory;
26 import com.android.settings.search.BaseSearchIndexProvider;
27 import com.android.settingslib.core.AbstractPreferenceController;
28 import com.android.settingslib.core.lifecycle.Lifecycle;
29 import com.android.settingslib.search.SearchIndexable;
30 
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.List;
34 
35 @SearchIndexable
36 public class AssistGestureSettings extends DashboardFragment {
37 
38     private static final String TAG = "AssistGesture";
39 
40     @Override
getMetricsCategory()41     public int getMetricsCategory() {
42         return SettingsEnums.SETTINGS_ASSIST_GESTURE;
43     }
44 
45     @Override
getLogTag()46     protected String getLogTag() {
47         return TAG;
48     }
49 
50     @Override
getPreferenceScreenResId()51     protected int getPreferenceScreenResId() {
52         return R.xml.assist_gesture_settings;
53     }
54 
55     @Override
createPreferenceControllers(Context context)56     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
57         return buildPreferenceControllers(context, getSettingsLifecycle());
58     }
59 
buildPreferenceControllers(Context context, Lifecycle lifecycle)60     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
61             Lifecycle lifecycle) {
62         final List<AbstractPreferenceController> controllers = new ArrayList<>();
63         controllers.addAll(FeatureFactory.getFactory(context).getAssistGestureFeatureProvider()
64                 .getControllers(context, lifecycle));
65 
66         return controllers;
67     }
68 
69     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
70             new BaseSearchIndexProvider() {
71                 @Override
72                 public List<SearchIndexableResource> getXmlResourcesToIndex(
73                         Context context, boolean enabled) {
74                     final SearchIndexableResource sir = new SearchIndexableResource(context);
75                     sir.xmlResId = R.xml.assist_gesture_settings;
76                     return Arrays.asList(sir);
77                 }
78 
79                 @Override
80                 public List<AbstractPreferenceController> createPreferenceControllers(
81                         Context context) {
82                     return buildPreferenceControllers(context, null /* lifecycle */);
83                 }
84 
85                 @Override
86                 protected boolean isPageSearchEnabled(Context context) {
87                     AssistGestureSettingsPreferenceController controller =
88                             new AssistGestureSettingsPreferenceController(context,
89                                     "gesture_assist_input_summary");
90                     controller.setAssistOnly(false);
91                     return controller.isAvailable();
92                 }
93             };
94 }
95 
96