blob: fc53d4e7d8081cd10e528703e989533cb93f0053 [file] [log] [blame]
Fan Zhang51059c52017-03-24 13:43:11 -07001/*
2 * Copyright (C) 2017 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
17package com.android.settings.system;
18
Fan Zhang31b21002019-01-16 13:49:47 -080019import android.app.settings.SettingsEnums;
Fan Zhang51059c52017-03-24 13:43:11 -070020import android.content.Context;
21import android.provider.SearchIndexableResource;
22
Fan Zhang51059c52017-03-24 13:43:11 -070023import com.android.settings.R;
Fan Zhanga8cac7a2017-10-11 16:44:41 -070024import com.android.settings.applications.manageapplications.ResetAppPrefPreferenceController;
Fan Zhang51059c52017-03-24 13:43:11 -070025import com.android.settings.dashboard.DashboardFragment;
26import com.android.settings.network.NetworkResetPreferenceController;
27import com.android.settings.search.BaseSearchIndexProvider;
28import com.android.settings.search.Indexable;
Tony Mantler1d583e12017-06-13 13:09:25 -070029import com.android.settingslib.core.AbstractPreferenceController;
Juan Lang777ed252017-05-09 15:42:36 -070030import com.android.settingslib.core.lifecycle.Lifecycle;
Tony Mantler0fcd6cb2018-03-26 15:17:25 -070031import com.android.settingslib.search.SearchIndexable;
Fan Zhang51059c52017-03-24 13:43:11 -070032
33import java.util.ArrayList;
34import java.util.List;
35
Tony Mantler0fcd6cb2018-03-26 15:17:25 -070036@SearchIndexable
Fan Zhang51059c52017-03-24 13:43:11 -070037public class ResetDashboardFragment extends DashboardFragment {
38
39 private static final String TAG = "ResetDashboardFragment";
40
41 @Override
42 public int getMetricsCategory() {
Fan Zhang31b21002019-01-16 13:49:47 -080043 return SettingsEnums.RESET_DASHBOARD;
Fan Zhang51059c52017-03-24 13:43:11 -070044 }
45
46 @Override
47 protected String getLogTag() {
48 return TAG;
49 }
50
51 @Override
52 protected int getPreferenceScreenResId() {
53 return R.xml.reset_dashboard_fragment;
54 }
55
56 @Override
Fan Zhangf7843ad2018-02-22 13:51:41 -080057 protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
tmfang27c84de2018-06-28 11:39:05 +080058 return buildPreferenceControllers(context, getSettingsLifecycle());
Fan Zhang51059c52017-03-24 13:43:11 -070059 }
60
Tony Mantler1d583e12017-06-13 13:09:25 -070061 private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
Fan Zhang51059c52017-03-24 13:43:11 -070062 Lifecycle lifecycle) {
Tony Mantler1d583e12017-06-13 13:09:25 -070063 final List<AbstractPreferenceController> controllers = new ArrayList<>();
Fan Zhang51059c52017-03-24 13:43:11 -070064 controllers.add(new NetworkResetPreferenceController(context));
65 controllers.add(new FactoryResetPreferenceController(context));
66 controllers.add(new ResetAppPrefPreferenceController(context, lifecycle));
67 return controllers;
68 }
69
Raff Tsaiac3e0d02019-09-19 17:06:45 +080070 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
Raff Tsai1f30b1c2019-09-12 10:56:13 +080071 new BaseSearchIndexProvider(R.xml.reset_dashboard_fragment) {
Fan Zhang51059c52017-03-24 13:43:11 -070072
73 @Override
Fan Zhangaed89942018-02-22 13:32:32 -080074 public List<AbstractPreferenceController> createPreferenceControllers(
75 Context context) {
Fan Zhang51059c52017-03-24 13:43:11 -070076 return buildPreferenceControllers(context, null /* lifecycle */);
77 }
78 };
79}