• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 package com.android.settings.testutils;
19 
20 import android.content.Context;
21 import android.provider.SearchIndexableResource;
22 
23 import com.android.settings.R;
24 import com.android.settings.search.BaseSearchIndexProvider;
25 import com.android.settings.search.Indexable;
26 
27 import java.util.ArrayList;
28 import java.util.List;
29 
30 public class FakeIndexProvider implements Indexable {
31 
32     public static final String KEY = "TestKey";
33 
34     public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
35             new BaseSearchIndexProvider() {
36                 @Override
37                 public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
38                         boolean enabled) {
39                     List<SearchIndexableResource> resources = new ArrayList<>();
40                     SearchIndexableResource res = new SearchIndexableResource(context);
41                     res.xmlResId = R.xml.location_settings;
42                     resources.add(res);
43                     return resources;
44                 }
45 
46                 @Override
47                 public List<String> getNonIndexableKeys(Context context) {
48                     List<String> result = super.getNonIndexableKeys(context);
49                     result.add(KEY);
50                     return result;
51                 }
52             };
53 }
54