2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.applications;
19 import android.app.Activity;
20 import android.app.Application;
21 import android.app.Fragment;
22 import android.content.Context;
23 import android.provider.SearchIndexableResource;
25 import com.android.internal.logging.nano.MetricsProto;
26 import com.android.settings.R;
27 import com.android.settings.core.PreferenceController;
28 import com.android.settings.dashboard.DashboardFragment;
29 import com.android.settings.search.BaseSearchIndexProvider;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.List;
35 public class AppAndNotificationDashboardFragment extends DashboardFragment {
37 private static final String TAG = "AppAndNotifDashboard";
40 public int getMetricsCategory() {
41 return MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY;
45 protected String getLogTag() {
50 public void onAttach(Context context) {
51 super.onAttach(context);
52 mProgressiveDisclosureMixin.setTileLimit(3);
56 protected int getPreferenceScreenResId() {
57 return R.xml.app_and_notification;
61 protected List<PreferenceController> getPreferenceControllers(Context context) {
62 final Activity activity = getActivity();
63 final Application app;
64 if (activity != null) {
65 app = activity.getApplication();
69 return buildPreferenceControllers(context, app, this);
72 private static List<PreferenceController> buildPreferenceControllers(Context context,
73 Application app, Fragment host) {
74 final List<PreferenceController> controllers = new ArrayList<>();
75 controllers.add(new SpecialAppAccessPreferenceController(context));
76 controllers.add(new AppPermissionsPreferenceController(context));
77 controllers.add(new RecentAppsPreferenceController(context, app, host));
81 public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
82 new BaseSearchIndexProvider() {
84 public List<SearchIndexableResource> getXmlResourcesToIndex(
85 Context context, boolean enabled) {
86 final SearchIndexableResource sir = new SearchIndexableResource(context);
87 sir.xmlResId = R.xml.app_and_notification;
88 return Arrays.asList(sir);
92 public List<PreferenceController> getPreferenceControllers(Context context) {
93 return buildPreferenceControllers(context, null, null /* host */);