Use SettingsLib Indexable
- Use SettingsLib Indexable - Directly use resource id in getPreferenceScreenResId Bug: 135053028 Test: roboletric Change-Id: I05f493b55e8b6e2091301e9231ba5615215618e6
This commit is contained in:
@@ -36,6 +36,8 @@ import com.android.settings.core.PreferenceControllerListHelper;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
@@ -134,13 +136,6 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the xml resource Id.
|
||||
*/
|
||||
public int getXmlResourceId() {
|
||||
return mXmlRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the page should be considered in search query. If return false, entire page
|
||||
* will be suppressed during search query.
|
||||
|
@@ -19,6 +19,8 @@ package com.android.settings.search;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settingslib.search.Indexable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for classes whose instances can provide data for indexing.
|
||||
*
|
||||
* Classes implementing the Indexable interface must have a static field called
|
||||
* <code>SEARCH_INDEX_DATA_PROVIDER</code>, which is an object implementing the
|
||||
* {@link Indexable.SearchIndexProvider} interface.
|
||||
*
|
||||
* See {@link android.provider.SearchIndexableResource} and {@link SearchIndexableRaw}.
|
||||
*/
|
||||
public interface Indexable {
|
||||
|
||||
interface SearchIndexProvider {
|
||||
/**
|
||||
* Return a list of references for indexing.
|
||||
*
|
||||
* See {@link android.provider.SearchIndexableResource}
|
||||
*
|
||||
* @param context the context.
|
||||
* @param enabled hint telling if the data needs to be considered into the search results
|
||||
* or not.
|
||||
* @return a list of {@link android.provider.SearchIndexableResource} references.
|
||||
* Can be null.
|
||||
*/
|
||||
@Keep
|
||||
List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled);
|
||||
|
||||
/**
|
||||
* Return a list of raw data for indexing. See {@link SearchIndexableRaw}
|
||||
*
|
||||
* @param context the context.
|
||||
* @param enabled hint telling if the data needs to be considered into the search results
|
||||
* or not.
|
||||
* @return a list of {@link SearchIndexableRaw} references. Can be null.
|
||||
*/
|
||||
@Keep
|
||||
List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled);
|
||||
|
||||
/**
|
||||
* Return a list of data keys that cannot be indexed. See {@link SearchIndexableRaw}
|
||||
*
|
||||
* @param context the context.
|
||||
* @return a list of {@link SearchIndexableRaw} references. Can be null.
|
||||
*/
|
||||
@Keep
|
||||
List<String> getNonIndexableKeys(Context context);
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableData;
|
||||
|
||||
/**
|
||||
* Indexable raw data for Search.
|
||||
*
|
||||
* This is the raw data used by the Indexer and should match its data model.
|
||||
*
|
||||
* See {@link Indexable} and {@link android.provider.SearchIndexableResource}.
|
||||
*/
|
||||
public class SearchIndexableRaw extends SearchIndexableData {
|
||||
|
||||
/**
|
||||
* Title's raw data.
|
||||
*/
|
||||
public String title;
|
||||
|
||||
/**
|
||||
* Summary's raw data when the data is "ON".
|
||||
*/
|
||||
public String summaryOn;
|
||||
|
||||
/**
|
||||
* Summary's raw data when the data is "OFF".
|
||||
*/
|
||||
public String summaryOff;
|
||||
|
||||
/**
|
||||
* Entries associated with the raw data (when the data can have several values).
|
||||
*/
|
||||
public String entries;
|
||||
|
||||
/**
|
||||
* Keywords' raw data.
|
||||
*/
|
||||
public String keywords;
|
||||
|
||||
/**
|
||||
* Fragment's or Activity's title associated with the raw data.
|
||||
*/
|
||||
public String screenTitle;
|
||||
|
||||
public SearchIndexableRaw(Context context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
@@ -65,6 +65,8 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.slices.SettingsSliceProvider;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
Reference in New Issue
Block a user