• 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.content.Context;
20 import android.os.UserHandle;
21 import android.provider.SearchIndexableResource;
22 import android.support.annotation.NonNull;
23 import android.support.annotation.Nullable;
24 
25 import com.android.internal.hardware.AmbientDisplayConfiguration;
26 import com.android.internal.logging.nano.MetricsProto;
27 import com.android.settings.R;
28 import com.android.settings.dashboard.DashboardFragment;
29 import com.android.settings.search.BaseSearchIndexProvider;
30 import com.android.settingslib.core.AbstractPreferenceController;
31 import com.android.settingslib.core.lifecycle.Lifecycle;
32 
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.List;
36 
37 public class GestureSettings extends DashboardFragment {
38 
39     private static final String TAG = "GestureSettings";
40 
41     private static final String KEY_ASSIST = "gesture_assist_input_summary";
42     private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_input_summary";
43     private static final String KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power_input_summary";
44     private static final String KEY_DOUBLE_TWIST = "gesture_double_twist_input_summary";
45     private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen_input_summary";
46     private static final String KEY_PICK_UP = "gesture_pick_up_input_summary";
47     private static final String KEY_PREVENT_RINGING = "gesture_prevent_ringing_summary";
48     private static final String KEY_SWIPE_UP = "gesture_swipe_up_input_summary";
49 
50     private AmbientDisplayConfiguration mAmbientDisplayConfig;
51 
52     @Override
getMetricsCategory()53     public int getMetricsCategory() {
54         return MetricsProto.MetricsEvent.SETTINGS_GESTURES;
55     }
56 
57     @Override
getLogTag()58     protected String getLogTag() {
59         return TAG;
60     }
61 
62     @Override
getPreferenceScreenResId()63     protected int getPreferenceScreenResId() {
64         return R.xml.gestures;
65     }
66 
67     @Override
onAttach(Context context)68     public void onAttach(Context context) {
69         super.onAttach(context);
70         use(AssistGestureSettingsPreferenceController.class).setAssistOnly(false);
71         use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
72         use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
73     }
74 
getConfig(Context context)75     private AmbientDisplayConfiguration getConfig(Context context) {
76         if (mAmbientDisplayConfig == null) {
77             mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
78         }
79         return mAmbientDisplayConfig;
80     }
81 
82     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
83             new BaseSearchIndexProvider() {
84                 @Override
85                 public List<SearchIndexableResource> getXmlResourcesToIndex(
86                         Context context, boolean enabled) {
87                     final SearchIndexableResource sir = new SearchIndexableResource(context);
88                     sir.xmlResId = R.xml.gestures;
89                     return Arrays.asList(sir);
90                 }
91 
92                 @Override
93                 public List<String> getNonIndexableKeys(Context context) {
94                     List<String> keys = super.getNonIndexableKeys(context);
95                     // Duplicates in summary and details pages.
96                     keys.add(KEY_ASSIST);
97                     keys.add(KEY_SWIPE_DOWN);
98                     keys.add(KEY_DOUBLE_TAP_POWER);
99                     keys.add(KEY_DOUBLE_TWIST);
100                     keys.add(KEY_SWIPE_UP);
101                     keys.add(KEY_DOUBLE_TAP_SCREEN);
102                     keys.add(KEY_PICK_UP);
103                     keys.add(KEY_PREVENT_RINGING);
104 
105                     return keys;
106                 }
107             };
108 }
109