• 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 package com.android.settings.connecteddevice;
17 
18 import android.content.Context;
19 import android.content.res.Resources;
20 import com.android.internal.logging.nano.MetricsProto;
21 import com.android.settings.R;
22 import com.android.settings.dashboard.DashboardFragment;
23 import com.android.settings.search.BaseSearchIndexProvider;
24 import com.android.settings.search.SearchIndexableRaw;
25 
26 import java.util.ArrayList;
27 import java.util.List;
28 
29 /**
30  * This fragment contains previously connected device
31  */
32 public class PreviouslyConnectedDeviceDashboardFragment extends DashboardFragment {
33 
34     private static final String TAG = "PreConnectedDeviceFrag";
35     static final String KEY_PREVIOUSLY_CONNECTED_DEVICES = "saved_device_list";
36 
37     @Override
getHelpResource()38     public int getHelpResource() {
39         return R.string.help_url_previously_connected_devices;
40     }
41 
42     @Override
getPreferenceScreenResId()43     protected int getPreferenceScreenResId() {
44         return R.xml.previously_connected_devices;
45     }
46 
47     @Override
getLogTag()48     protected String getLogTag() {
49         return TAG;
50     }
51 
52     @Override
getMetricsCategory()53     public int getMetricsCategory() {
54         return MetricsProto.MetricsEvent.PREVIOUSLY_CONNECTED_DEVICES;
55     }
56 
57     @Override
onAttach(Context context)58     public void onAttach(Context context) {
59         super.onAttach(context);
60         use(SavedDeviceGroupController.class).init(this);
61     }
62 
63     /**
64      * For Search.
65      */
66     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
67             new BaseSearchIndexProvider() {
68         @Override
69         public List<SearchIndexableRaw> getRawDataToIndex(
70                 Context context, boolean enabled) {
71             final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
72             final Resources res = context.getResources();
73 
74             // Add fragment title
75             SearchIndexableRaw data = new SearchIndexableRaw(context);
76             data.key = KEY_PREVIOUSLY_CONNECTED_DEVICES;
77             data.title = res.getString(
78                     R.string.connected_device_previously_connected_title);
79             data.screenTitle = res.getString(
80                     R.string.connected_device_previously_connected_title);
81             result.add(data);
82             return result;
83         }
84     };
85 }