1 /* 2 * Copyright 2019 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.development.graphicsdriver; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Context; 21 import android.os.Bundle; 22 23 import com.android.settings.R; 24 import com.android.settings.SettingsActivity; 25 import com.android.settings.dashboard.DashboardFragment; 26 import com.android.settings.development.DeveloperOptionAwareMixin; 27 import com.android.settings.search.BaseSearchIndexProvider; 28 import com.android.settings.widget.MainSwitchBarController; 29 import com.android.settings.widget.SettingsMainSwitchBar; 30 import com.android.settingslib.development.DevelopmentSettingsEnabler; 31 import com.android.settingslib.search.SearchIndexable; 32 33 /** 34 * Dashboard for Graphics Driver preferences. 35 */ 36 @SearchIndexable 37 public class GraphicsDriverDashboard extends DashboardFragment implements 38 DeveloperOptionAwareMixin { 39 40 private static final String TAG = "GraphicsDriverDashboard"; 41 42 @Override getMetricsCategory()43 public int getMetricsCategory() { 44 return SettingsEnums.SETTINGS_GRAPHICS_DRIVER_DASHBOARD; 45 } 46 47 @Override getLogTag()48 protected String getLogTag() { 49 return TAG; 50 } 51 52 @Override getPreferenceScreenResId()53 protected int getPreferenceScreenResId() { 54 return R.xml.graphics_driver_settings; 55 } 56 57 @Override getHelpResource()58 public int getHelpResource() { 59 return 0; 60 } 61 62 @Override onActivityCreated(Bundle savedInstanceState)63 public void onActivityCreated(Bundle savedInstanceState) { 64 super.onActivityCreated(savedInstanceState); 65 66 final SettingsActivity activity = (SettingsActivity) getActivity(); 67 final SettingsMainSwitchBar switchBar = activity.getSwitchBar(); 68 final GraphicsDriverGlobalSwitchBarController switchBarController = 69 new GraphicsDriverGlobalSwitchBarController( 70 activity, new MainSwitchBarController(switchBar)); 71 getSettingsLifecycle().addObserver(switchBarController); 72 switchBar.setTitle( 73 getContext().getString(R.string.graphics_driver_main_switch_title)); 74 switchBar.show(); 75 } 76 77 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 78 new BaseSearchIndexProvider(R.xml.graphics_driver_settings) { 79 80 @Override 81 protected boolean isPageSearchEnabled(Context context) { 82 return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context); 83 } 84 }; 85 } 86