1 /* 2 * Copyright (C) 2018 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.provider.SearchIndexableResource; 22 23 import com.android.settings.R; 24 import com.android.settings.dashboard.DashboardFragment; 25 import com.android.settings.search.BaseSearchIndexProvider; 26 import com.android.settingslib.core.AbstractPreferenceController; 27 import com.android.settingslib.core.lifecycle.Lifecycle; 28 import com.android.settingslib.search.SearchIndexable; 29 30 import java.util.ArrayList; 31 import java.util.Arrays; 32 import java.util.List; 33 34 @SearchIndexable 35 public class PreventRingingGestureSettings extends DashboardFragment { 36 37 private static final String TAG = "RingingGestureSettings"; 38 39 @Override onAttach(Context context)40 public void onAttach(Context context) { 41 super.onAttach(context); 42 } 43 44 @Override createPreferenceControllers(Context context)45 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { 46 return buildPreferenceControllers(context, getSettingsLifecycle()); 47 } 48 buildPreferenceControllers(Context context, Lifecycle lifecycle)49 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, 50 Lifecycle lifecycle) { 51 List<AbstractPreferenceController> controllers = new ArrayList<>(); 52 controllers.add(new PreventRingingGesturePreferenceController(context, lifecycle)); 53 controllers.add(new PreventRingingSwitchPreferenceController(context)); 54 return controllers; 55 } 56 57 @Override getMetricsCategory()58 public int getMetricsCategory() { 59 return SettingsEnums.SETTINGS_PREVENT_RINGING; 60 } 61 62 @Override getLogTag()63 protected String getLogTag() { 64 return TAG; 65 } 66 67 @Override getPreferenceScreenResId()68 protected int getPreferenceScreenResId() { 69 return R.xml.prevent_ringing_gesture_settings; 70 } 71 72 @Override getHelpResource()73 public int getHelpResource() { 74 return R.string.help_uri_prevent_ringing_gesture; 75 } 76 77 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 78 new BaseSearchIndexProvider() { 79 @Override 80 public List<SearchIndexableResource> getXmlResourcesToIndex( 81 Context context, boolean enabled) { 82 final SearchIndexableResource sir = new SearchIndexableResource(context); 83 sir.xmlResId = R.xml.prevent_ringing_gesture_settings; 84 return Arrays.asList(sir); 85 } 86 87 @Override 88 public List<AbstractPreferenceController> createPreferenceControllers( 89 Context context) { 90 return buildPreferenceControllers(context, null); 91 } 92 }; 93 94 } 95