• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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.location;
18 
19 
20 import android.content.Context;
21 import android.provider.SearchIndexableResource;
22 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
23 import com.android.settings.R;
24 import com.android.settings.dashboard.DashboardFragment;
25 import com.android.settings.search.BaseSearchIndexProvider;
26 import com.android.settings.search.Indexable;
27 import com.android.settingslib.core.AbstractPreferenceController;
28 import com.android.settingslib.core.lifecycle.Lifecycle;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.List;
32 
33 /** Dashboard Fragment to display all recent location requests, sorted by recency. */
34 public class RecentLocationRequestSeeAllFragment extends DashboardFragment {
35 
36     private static final String TAG = "RecentLocationReqAll";
37 
38     public static final String PATH =
39             "com.android.settings.location.RecentLocationRequestSeeAllFragment";
40 
41     @Override
getMetricsCategory()42     public int getMetricsCategory() {
43       return MetricsEvent.RECENT_LOCATION_REQUESTS_ALL;
44     }
45 
46     @Override
getPreferenceScreenResId()47     protected int getPreferenceScreenResId() {
48         return R.xml.location_recent_requests_see_all;
49     }
50 
51     @Override
getLogTag()52     protected String getLogTag() {
53       return TAG;
54     }
55 
56     @Override
createPreferenceControllers(Context context)57     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
58         return buildPreferenceControllers(context, getLifecycle(), this);
59     }
60 
buildPreferenceControllers( Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment)61     private static List<AbstractPreferenceController> buildPreferenceControllers(
62             Context context, Lifecycle lifecycle, RecentLocationRequestSeeAllFragment fragment) {
63         final List<AbstractPreferenceController> controllers = new ArrayList<>();
64         controllers.add(
65                 new RecentLocationRequestSeeAllPreferenceController(context, lifecycle, fragment));
66         return controllers;
67     }
68 
69     /**
70      * For Search.
71      */
72     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
73             new BaseSearchIndexProvider() {
74                 @Override
75                 public List<SearchIndexableResource> getXmlResourcesToIndex(
76                         Context context, boolean enabled) {
77                     final SearchIndexableResource sir = new SearchIndexableResource(context);
78                     sir.xmlResId = R.xml.location_recent_requests_see_all;
79                     return Arrays.asList(sir);
80                 }
81 
82                 @Override
83                 public List<AbstractPreferenceController> getPreferenceControllers(Context
84                         context) {
85                     return buildPreferenceControllers(
86                             context, /* lifecycle = */ null, /* fragment = */ null);
87                 }
88             };
89 }
90