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 17package com.android.settings.gestures; 18 19import android.content.Context; 20import android.provider.SearchIndexableResource; 21 22import com.android.internal.logging.nano.MetricsProto; 23import com.android.settings.R; 24import com.android.settings.core.PreferenceController; 25import com.android.settings.core.lifecycle.Lifecycle; 26import com.android.settings.dashboard.DashboardFragment; 27import com.android.settings.search.BaseSearchIndexProvider; 28 29import java.util.ArrayList; 30import java.util.Arrays; 31import java.util.List; 32 33public class DoubleTwistGestureSettings extends DashboardFragment { 34 35 private static final String TAG = "DoubleTwistGesture"; 36 private static final String KEY_DOUBLE_TWIST = "gesture_double_twist"; 37 38 @Override 39 public int getMetricsCategory() { 40 return MetricsProto.MetricsEvent.SETTINGS_GESTURE_DOUBLE_TWIST; 41 } 42 43 @Override 44 protected String getLogTag() { 45 return TAG; 46 } 47 48 @Override 49 protected int getPreferenceScreenResId() { 50 return R.xml.double_twist_gesture_settings; 51 } 52 53 @Override 54 protected List<PreferenceController> getPreferenceControllers(Context context) { 55 return buildPreferenceControllers(context, getLifecycle()); 56 } 57 58 private static List<PreferenceController> buildPreferenceControllers(Context context, 59 Lifecycle lifecycle) { 60 final List<PreferenceController> controllers = new ArrayList<>(); 61 controllers.add(new DoubleTwistPreferenceController(context, lifecycle, KEY_DOUBLE_TWIST)); 62 return controllers; 63 } 64 65 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 66 new BaseSearchIndexProvider() { 67 @Override 68 public List<SearchIndexableResource> getXmlResourcesToIndex( 69 Context context, boolean enabled) { 70 final SearchIndexableResource sir = new SearchIndexableResource(context); 71 sir.xmlResId = R.xml.double_twist_gesture_settings; 72 return Arrays.asList(sir); 73 } 74 75 @Override 76 public List<PreferenceController> getPreferenceControllers(Context context) { 77 return buildPreferenceControllers(context, null /* lifecycle */); 78 } 79 }; 80 81} 82