| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.settings.system; |
| 18 | |
| Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame] | 19 | import android.app.settings.SettingsEnums; |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.provider.SearchIndexableResource; |
| 22 | |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 23 | import com.android.settings.R; |
| Fan Zhang | a8cac7a | 2017-10-11 16:44:41 -0700 | [diff] [blame] | 24 | import com.android.settings.applications.manageapplications.ResetAppPrefPreferenceController; |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 25 | import com.android.settings.dashboard.DashboardFragment; |
| 26 | import com.android.settings.network.NetworkResetPreferenceController; |
| 27 | import com.android.settings.search.BaseSearchIndexProvider; |
| 28 | import com.android.settings.search.Indexable; |
| Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 29 | import com.android.settingslib.core.AbstractPreferenceController; |
| Juan Lang | 777ed25 | 2017-05-09 15:42:36 -0700 | [diff] [blame] | 30 | import com.android.settingslib.core.lifecycle.Lifecycle; |
| Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 31 | import com.android.settingslib.search.SearchIndexable; |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 32 | |
| 33 | import java.util.ArrayList; |
| 34 | import java.util.List; |
| 35 | |
| Tony Mantler | 0fcd6cb | 2018-03-26 15:17:25 -0700 | [diff] [blame] | 36 | @SearchIndexable |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 37 | public class ResetDashboardFragment extends DashboardFragment { |
| 38 | |
| 39 | private static final String TAG = "ResetDashboardFragment"; |
| 40 | |
| 41 | @Override |
| 42 | public int getMetricsCategory() { |
| Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame] | 43 | return SettingsEnums.RESET_DASHBOARD; |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 44 | } |
| 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 Zhang | f7843ad | 2018-02-22 13:51:41 -0800 | [diff] [blame] | 57 | protected List<AbstractPreferenceController> createPreferenceControllers(Context context) { |
| tmfang | 27c84de | 2018-06-28 11:39:05 +0800 | [diff] [blame] | 58 | return buildPreferenceControllers(context, getSettingsLifecycle()); |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 61 | private static List<AbstractPreferenceController> buildPreferenceControllers(Context context, |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 62 | Lifecycle lifecycle) { |
| Tony Mantler | 1d583e1 | 2017-06-13 13:09:25 -0700 | [diff] [blame] | 63 | final List<AbstractPreferenceController> controllers = new ArrayList<>(); |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 64 | controllers.add(new NetworkResetPreferenceController(context)); |
| 65 | controllers.add(new FactoryResetPreferenceController(context)); |
| 66 | controllers.add(new ResetAppPrefPreferenceController(context, lifecycle)); |
| 67 | return controllers; |
| 68 | } |
| 69 | |
| Raff Tsai | ac3e0d0 | 2019-09-19 17:06:45 +0800 | [diff] [blame^] | 70 | public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = |
| Raff Tsai | 1f30b1c | 2019-09-12 10:56:13 +0800 | [diff] [blame] | 71 | new BaseSearchIndexProvider(R.xml.reset_dashboard_fragment) { |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 72 | |
| 73 | @Override |
| Fan Zhang | aed8994 | 2018-02-22 13:32:32 -0800 | [diff] [blame] | 74 | public List<AbstractPreferenceController> createPreferenceControllers( |
| 75 | Context context) { |
| Fan Zhang | 51059c5 | 2017-03-24 13:43:11 -0700 | [diff] [blame] | 76 | return buildPreferenceControllers(context, null /* lifecycle */); |
| 77 | } |
| 78 | }; |
| 79 | } |