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