2 * Copyright (C) 2019 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
15 package com.android.settings.display.darkmode;
17 import android.content.Context;
18 import android.os.Bundle;
19 import android.app.settings.SettingsEnums;
20 import com.android.settings.R;
21 import com.android.settings.dashboard.DashboardFragment;
22 import com.android.settings.search.BaseSearchIndexProvider;
23 import com.android.settingslib.search.SearchIndexable;
26 * Settings screen for Dark UI Mode
28 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
29 public class DarkModeSettingsFragment extends DashboardFragment {
31 private static final String TAG = "DarkModeSettingsFragment";
32 private DarkModeObserver mContentObserver;
33 private Runnable mCallback = () -> {
34 updatePreferenceStates();
38 public void onCreate(Bundle savedInstanceState) {
39 super.onCreate(savedInstanceState);
41 final Context context = getContext();
42 mContentObserver = new DarkModeObserver(context);
46 public void onStart() {
48 // Listen for changes only while visible.
49 mContentObserver.subscribe(mCallback);
53 public void onStop() {
55 // Stop listening for state changes.
56 mContentObserver.unsubscribe();
60 protected int getPreferenceScreenResId() {
61 return R.xml.dark_mode_settings;
65 public int getHelpResource() {
66 return R.string.help_url_dark_theme;
70 protected String getLogTag() {
75 public int getMetricsCategory() {
76 return SettingsEnums.DARK_UI_SETTINGS;
79 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
80 new BaseSearchIndexProvider(R.xml.dark_mode_settings);