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 DoubleTapScreenSettings extends DashboardFragment { 36 37 private static final String TAG = "DoubleTapScreen"; 38 private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen"; 39 40 @Override 41 public int getMetricsCategory() { 42 return MetricsProto.MetricsEvent.SETTINGS_GESTURE_DOUBLE_TAP_SCREEN; 43 } 44 45 @Override 46 protected String getLogTag() { 47 return TAG; 48 } 49 50 @Override 51 protected int getPreferenceScreenResId() { 52 return R.xml.double_tap_screen_settings; 53 } 54 55 @Override 56 protected List<PreferenceController> getPreferenceControllers(Context context) { 57 return buildPreferenceControllers(context, getLifecycle()); 58 } 59 60 private static List<PreferenceController> buildPreferenceControllers(Context context, 61 Lifecycle lifecycle) { 62 final List<PreferenceController> controllers = new ArrayList<>(); 63 controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle, 64 new AmbientDisplayConfiguration(context), UserHandle.myUserId(), 65 KEY_DOUBLE_TAP_SCREEN)); 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.double_tap_screen_settings; 76 return Arrays.asList(sir); 77 } 78 79 @Override 80 public List<PreferenceController> getPreferenceControllers(Context context) { 81 return buildPreferenceControllers(context, null /* lifecycle */); 82 } 83 }; 84 } 85