VibrationSettings.java revision 6ccc81818d954032ad38484f4df4d2636898e97d
129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright/* 229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * Copyright (C) 2018 The Android Open Source Project 329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * 429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * Licensed under the Apache License, Version 2.0 (the "License"); 529d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * you may not use this file except in compliance with the License. 629d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * You may obtain a copy of the License at 729d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * 829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * http://www.apache.org/licenses/LICENSE-2.0 929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * 1029d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * Unless required by applicable law or agreed to in writing, software 1129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * distributed under the License is distributed on an "AS IS" BASIS, 1229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * See the License for the specific language governing permissions and 1429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright * limitations under the License. 1529d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright */ 1629d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 1729d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightpackage com.android.settings.accessibility; 1829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 1929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport android.content.Context; 2029d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport android.provider.SearchIndexableResource; 2129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 2229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport com.android.internal.logging.nano.MetricsProto.MetricsEvent; 2329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport com.android.settings.R; 246ccc81818d954032ad38484f4df4d2636898e97dFan Zhangimport com.android.settings.dashboard.DashboardFragment; 2529d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport com.android.settings.search.BaseSearchIndexProvider; 266ccc81818d954032ad38484f4df4d2636898e97dFan Zhangimport com.android.settingslib.core.AbstractPreferenceController; 276ccc81818d954032ad38484f4df4d2636898e97dFan Zhangimport com.android.settingslib.core.lifecycle.Lifecycle; 2829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 2929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport java.util.ArrayList; 3029d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wrightimport java.util.List; 3129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 3229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright/** 336ccc81818d954032ad38484f4df4d2636898e97dFan Zhang * Accessibility settings for the vibration. 3429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright */ 356ccc81818d954032ad38484f4df4d2636898e97dFan Zhangpublic class VibrationSettings extends DashboardFragment { 3629d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 376ccc81818d954032ad38484f4df4d2636898e97dFan Zhang private static final String TAG = "VibrationSettings"; 3829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 3929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright @Override 4029d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright public int getMetricsCategory() { 4129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright return MetricsEvent.ACCESSIBILITY_VIBRATION; 4229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 4329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 4429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright @Override 456ccc81818d954032ad38484f4df4d2636898e97dFan Zhang protected int getPreferenceScreenResId() { 466ccc81818d954032ad38484f4df4d2636898e97dFan Zhang return R.xml.accessibility_vibration_settings; 4729d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 4829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 4929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright @Override 506ccc81818d954032ad38484f4df4d2636898e97dFan Zhang protected String getLogTag() { 516ccc81818d954032ad38484f4df4d2636898e97dFan Zhang return TAG; 5229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 5329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 5429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright @Override 556ccc81818d954032ad38484f4df4d2636898e97dFan Zhang protected List<AbstractPreferenceController> getPreferenceControllers(Context context) { 566ccc81818d954032ad38484f4df4d2636898e97dFan Zhang return buildControllers(context, getLifecycle()); 5729d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 5829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 596ccc81818d954032ad38484f4df4d2636898e97dFan Zhang public static List<AbstractPreferenceController> buildControllers(Context context, 606ccc81818d954032ad38484f4df4d2636898e97dFan Zhang Lifecycle lifecycle) { 616ccc81818d954032ad38484f4df4d2636898e97dFan Zhang 626ccc81818d954032ad38484f4df4d2636898e97dFan Zhang final List<AbstractPreferenceController> controllers = new ArrayList<>(); 636ccc81818d954032ad38484f4df4d2636898e97dFan Zhang final NotificationVibrationIntensityPreferenceController notifVibPrefController = 646ccc81818d954032ad38484f4df4d2636898e97dFan Zhang new NotificationVibrationIntensityPreferenceController(context); 656ccc81818d954032ad38484f4df4d2636898e97dFan Zhang final HapticFeedbackIntensityPreferenceController hapticPreferenceController = 666ccc81818d954032ad38484f4df4d2636898e97dFan Zhang new HapticFeedbackIntensityPreferenceController(context); 676ccc81818d954032ad38484f4df4d2636898e97dFan Zhang controllers.add(hapticPreferenceController); 686ccc81818d954032ad38484f4df4d2636898e97dFan Zhang controllers.add(notifVibPrefController); 696ccc81818d954032ad38484f4df4d2636898e97dFan Zhang if (lifecycle != null) { 706ccc81818d954032ad38484f4df4d2636898e97dFan Zhang lifecycle.addObserver(hapticPreferenceController); 716ccc81818d954032ad38484f4df4d2636898e97dFan Zhang lifecycle.addObserver(notifVibPrefController); 7229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 736ccc81818d954032ad38484f4df4d2636898e97dFan Zhang return controllers; 7429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 7529d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright 7629d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 7729d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright new BaseSearchIndexProvider() { 7829d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright @Override 7929d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, 8029d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright boolean enabled) { 8129d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright List<SearchIndexableResource> indexables = new ArrayList<>(); 8229d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright SearchIndexableResource indexable = new SearchIndexableResource(context); 8329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright indexable.xmlResId = R.xml.accessibility_vibration_settings; 8429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright indexables.add(indexable); 8529d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright return indexables; 8629d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright } 876ccc81818d954032ad38484f4df4d2636898e97dFan Zhang 886ccc81818d954032ad38484f4df4d2636898e97dFan Zhang @Override 896ccc81818d954032ad38484f4df4d2636898e97dFan Zhang public List<AbstractPreferenceController> getPreferenceControllers( 906ccc81818d954032ad38484f4df4d2636898e97dFan Zhang Context context) { 916ccc81818d954032ad38484f4df4d2636898e97dFan Zhang return buildControllers(context, null /* lifecycle */); 926ccc81818d954032ad38484f4df4d2636898e97dFan Zhang } 9329d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright }; 9429d526719ade4fc0f8ac69fac0e961f7fea35b25Michael Wright} 95