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.search.BaseSearchIndexProvider; 27 import com.android.settings.widget.SwitchBar; 28 import com.android.settings.widget.SwitchBarController; 29 import com.android.settingslib.development.DevelopmentSettingsEnabler; 30 import com.android.settingslib.search.SearchIndexable; 31 32 /** 33 * Dashboard for Game Driver preferences. 34 */ 35 @SearchIndexable 36 public class GraphicsDriverDashboard extends DashboardFragment { 37 38 private static final String TAG = "GraphicsDriverDashboard"; 39 40 @Override getMetricsCategory()41 public int getMetricsCategory() { 42 return SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD; 43 } 44 45 @Override getLogTag()46 protected String getLogTag() { 47 return TAG; 48 } 49 50 @Override getPreferenceScreenResId()51 protected int getPreferenceScreenResId() { 52 return R.xml.graphics_driver_settings; 53 } 54 55 @Override getHelpResource()56 public int getHelpResource() { 57 return 0; 58 } 59 60 @Override onActivityCreated(Bundle savedInstanceState)61 public void onActivityCreated(Bundle savedInstanceState) { 62 super.onActivityCreated(savedInstanceState); 63 64 final SettingsActivity activity = (SettingsActivity) getActivity(); 65 final SwitchBar switchBar = activity.getSwitchBar(); 66 final GraphicsDriverGlobalSwitchBarController switchBarController = 67 new GraphicsDriverGlobalSwitchBarController( 68 activity, new SwitchBarController(switchBar)); 69 getSettingsLifecycle().addObserver(switchBarController); 70 switchBar.show(); 71 } 72 73 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 74 new BaseSearchIndexProvider(R.xml.graphics_driver_settings) { 75 76 @Override 77 protected boolean isPageSearchEnabled(Context context) { 78 return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context); 79 } 80 }; 81 } 82