• 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.hardware.display.AmbientDisplayConfiguration;
22 import android.provider.SearchIndexableResource;
23 
24 import com.android.settings.R;
25 import com.android.settings.dashboard.DashboardFragment;
26 import com.android.settings.search.BaseSearchIndexProvider;
27 import com.android.settingslib.search.SearchIndexable;
28 
29 import java.util.Arrays;
30 import java.util.List;
31 
32 @SearchIndexable
33 public class GestureSettings extends DashboardFragment {
34 
35     private static final String TAG = "GestureSettings";
36 
37     private AmbientDisplayConfiguration mAmbientDisplayConfig;
38 
39     @Override
getMetricsCategory()40     public int getMetricsCategory() {
41         return SettingsEnums.SETTINGS_GESTURES;
42     }
43 
44     @Override
getLogTag()45     protected String getLogTag() {
46         return TAG;
47     }
48 
49     @Override
getPreferenceScreenResId()50     protected int getPreferenceScreenResId() {
51         return R.xml.gestures;
52     }
53 
54     @Override
onAttach(Context context)55     public void onAttach(Context context) {
56         super.onAttach(context);
57         use(AssistGestureSettingsPreferenceController.class).setAssistOnly(false);
58         use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
59         use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
60     }
61 
getConfig(Context context)62     private AmbientDisplayConfiguration getConfig(Context context) {
63         if (mAmbientDisplayConfig == null) {
64             mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
65         }
66         return mAmbientDisplayConfig;
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.gestures;
76                     return Arrays.asList(sir);
77                 }
78 
79                 @Override
80                 protected boolean isPageSearchEnabled(Context context) {
81                     // All rows in this screen can lead to a different page, so suppress everything
82                     // from this page to remove duplicates.
83                     return false;
84                 }
85             };
86 }
87