• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 
23 import com.android.internal.hardware.AmbientDisplayConfiguration;
24 import com.android.internal.logging.nano.MetricsProto;
25 import com.android.settings.R;
26 import com.android.settings.core.PreferenceController;
27 import com.android.settings.core.lifecycle.Lifecycle;
28 import com.android.settings.dashboard.DashboardFragment;
29 import com.android.settings.search.BaseSearchIndexProvider;
30 
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.List;
34 
35 public class PickupGestureSettings extends DashboardFragment {
36 
37     private static final String TAG = "PickupGestureSettings";
38     private static final String KEY_PICK_UP = "gesture_pick_up";
39 
40     @Override
getMetricsCategory()41     public int getMetricsCategory() {
42         return MetricsProto.MetricsEvent.SETTINGS_GESTURE_PICKUP;
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.pick_up_gesture_settings;
53     }
54 
55     @Override
getPreferenceControllers(Context context)56     protected List<PreferenceController> getPreferenceControllers(Context context) {
57         return buildPreferenceControllers(context, getLifecycle());
58     }
59 
buildPreferenceControllers(Context context, Lifecycle lifecycle)60     private static List<PreferenceController> buildPreferenceControllers(Context context,
61             Lifecycle lifecycle) {
62         final List<PreferenceController> controllers = new ArrayList<>();
63         controllers.add(new PickupGesturePreferenceController(context, lifecycle,
64                 new AmbientDisplayConfiguration(context), UserHandle.myUserId(), KEY_PICK_UP));
65         return controllers;
66     }
67 
68     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
69             new BaseSearchIndexProvider() {
70                 @Override
71                 public List<SearchIndexableResource> getXmlResourcesToIndex(
72                         Context context, boolean enabled) {
73                     final SearchIndexableResource sir = new SearchIndexableResource(context);
74                     sir.xmlResId = R.xml.pick_up_gesture_settings;
75                     return Arrays.asList(sir);
76                 }
77 
78                 @Override
79                 public List<PreferenceController> getPreferenceControllers(Context context) {
80                     return buildPreferenceControllers(context, null /* lifecycle */);
81                 }
82             };
83 
84 }
85