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.gamedriver; 18 19 import android.app.settings.SettingsEnums; 20 import android.content.Context; 21 import android.os.Bundle; 22 import android.provider.SearchIndexableResource; 23 24 import com.android.settings.R; 25 import com.android.settings.SettingsActivity; 26 import com.android.settings.dashboard.DashboardFragment; 27 import com.android.settings.search.BaseSearchIndexProvider; 28 import com.android.settings.search.Indexable; 29 import com.android.settings.widget.SwitchBar; 30 import com.android.settings.widget.SwitchBarController; 31 import com.android.settingslib.development.DevelopmentSettingsEnabler; 32 import com.android.settingslib.search.SearchIndexable; 33 34 import java.util.ArrayList; 35 import java.util.List; 36 37 /** 38 * Dashboard for Game Driver preferences. 39 */ 40 @SearchIndexable 41 public class GameDriverDashboard extends DashboardFragment { 42 43 private static final String TAG = "GameDriverDashboard"; 44 45 @Override getMetricsCategory()46 public int getMetricsCategory() { 47 return SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD; 48 } 49 50 @Override getLogTag()51 protected String getLogTag() { 52 return TAG; 53 } 54 55 @Override getPreferenceScreenResId()56 protected int getPreferenceScreenResId() { 57 return R.xml.game_driver_settings; 58 } 59 60 @Override getHelpResource()61 public int getHelpResource() { 62 return 0; 63 } 64 65 @Override onActivityCreated(Bundle savedInstanceState)66 public void onActivityCreated(Bundle savedInstanceState) { 67 super.onActivityCreated(savedInstanceState); 68 69 final SettingsActivity activity = (SettingsActivity) getActivity(); 70 final SwitchBar switchBar = activity.getSwitchBar(); 71 final GameDriverGlobalSwitchBarController switchBarController = 72 new GameDriverGlobalSwitchBarController( 73 activity, new SwitchBarController(switchBar)); 74 getSettingsLifecycle().addObserver(switchBarController); 75 switchBar.show(); 76 } 77 78 public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 79 new BaseSearchIndexProvider() { 80 @Override 81 public List<SearchIndexableResource> getXmlResourcesToIndex( 82 Context context, boolean enabled) { 83 final List<SearchIndexableResource> result = new ArrayList<>(); 84 final SearchIndexableResource sir = new SearchIndexableResource(context); 85 sir.xmlResId = R.xml.game_driver_settings; 86 result.add(sir); 87 return result; 88 } 89 90 @Override 91 protected boolean isPageSearchEnabled(Context context) { 92 return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context); 93 } 94 }; 95 } 96