fix: 首次提交
This commit is contained in:
51
SettingsLib/search/Android.bp
Normal file
51
SettingsLib/search/Android.bp
Normal file
@@ -0,0 +1,51 @@
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "frameworks_base_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["frameworks_base_license"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "SettingsLib-search-interface",
|
||||
visibility: ["//visibility:private"],
|
||||
srcs: ["interface-src/**/*.java"],
|
||||
host_supported: true,
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "SettingsLib-search",
|
||||
use_resource_processor: true,
|
||||
defaults: [
|
||||
"SettingsLintDefaults",
|
||||
],
|
||||
static_libs: [
|
||||
"SettingsLib-search-interface",
|
||||
],
|
||||
srcs: ["src/**/*.java"],
|
||||
|
||||
sdk_version: "system_current",
|
||||
min_sdk_version: "21",
|
||||
lint: {
|
||||
baseline_filename: "lint-baseline.xml",
|
||||
},
|
||||
}
|
||||
|
||||
java_plugin {
|
||||
name: "SettingsLib-annotation-processor",
|
||||
processor_class: "com.android.settingslib.search.IndexableProcessor",
|
||||
static_libs: [
|
||||
"SettingsLib-search-interface",
|
||||
"javapoet",
|
||||
],
|
||||
srcs: ["processor-src/**/*.java"],
|
||||
java_resource_dirs: ["resources"],
|
||||
}
|
||||
|
||||
// NOTE: Keep this module in sync with ./common.mk
|
||||
java_defaults {
|
||||
name: "SettingsLib-search-defaults",
|
||||
plugins: ["SettingsLib-annotation-processor"],
|
||||
static_libs: ["SettingsLib-search"],
|
||||
}
|
||||
21
SettingsLib/search/AndroidManifest.xml
Normal file
21
SettingsLib/search/AndroidManifest.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2019 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
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.settingslib.search">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Denotes that the class should participate in search indexing.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SearchIndexable {
|
||||
/**
|
||||
* Bitfield for the form factors this class should be considered indexable for.
|
||||
* Default is {@link #ALL}.
|
||||
* <p>
|
||||
* TODO: actually use this value somehow
|
||||
*/
|
||||
int forTarget() default ALL;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for Mobile.
|
||||
*/
|
||||
int MOBILE = 1 << 0;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for TV.
|
||||
*/
|
||||
int TV = 1 << 1;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for Wear.
|
||||
*/
|
||||
int WEAR = 1 << 2;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for Auto.
|
||||
*/
|
||||
int AUTO = 1 << 3;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for ARC++.
|
||||
*/
|
||||
int ARC = 1 << 4;
|
||||
|
||||
/**
|
||||
* Indicates that the class should be considered indexable for all targets.
|
||||
*/
|
||||
int ALL = MOBILE | TV | WEAR | AUTO | ARC;
|
||||
|
||||
}
|
||||
26
SettingsLib/search/lint-baseline.xml
Normal file
26
SettingsLib/search/lint-baseline.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<issues format="6" by="lint 8.4.0-alpha01" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha01">
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Class requires API level 23 (current min is 21): `android.provider.SearchIndexableData`"
|
||||
errorLine1="public class SearchIndexableRaw extends SearchIndexableData {"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/search/src/com/android/settingslib/search/SearchIndexableRaw.java"
|
||||
line="29"
|
||||
column="41"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Call requires API level 23 (current min is 21): `new android.provider.SearchIndexableData`"
|
||||
errorLine1=" super(context);"
|
||||
errorLine2=" ~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/search/src/com/android/settingslib/search/SearchIndexableRaw.java"
|
||||
line="62"
|
||||
column="9"/>
|
||||
</issue>
|
||||
|
||||
</issues>
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
import com.squareup.javapoet.ClassName;
|
||||
import com.squareup.javapoet.FieldSpec;
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterizedTypeName;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.Filer;
|
||||
import javax.annotation.processing.Messager;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.annotation.processing.SupportedOptions;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.Name;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.SimpleElementVisitor8;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
/**
|
||||
* Annotation processor for {@link SearchIndexable} that generates {@link SearchIndexableResources}
|
||||
* subclasses.
|
||||
*/
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_17)
|
||||
@SupportedOptions(IndexableProcessor.PACKAGE_KEY)
|
||||
@SupportedAnnotationTypes({"com.android.settingslib.search.SearchIndexable"})
|
||||
public class IndexableProcessor extends AbstractProcessor {
|
||||
|
||||
private static final String SETTINGSLIB_SEARCH_PACKAGE = "com.android.settingslib.search";
|
||||
private static final String CLASS_BASE = "SearchIndexableResourcesBase";
|
||||
private static final String CLASS_MOBILE = "SearchIndexableResourcesMobile";
|
||||
private static final String CLASS_TV = "SearchIndexableResourcesTv";
|
||||
private static final String CLASS_WEAR = "SearchIndexableResourcesWear";
|
||||
private static final String CLASS_AUTO = "SearchIndexableResourcesAuto";
|
||||
private static final String CLASS_ARC = "SearchIndexableResourcesArc";
|
||||
|
||||
static final String PACKAGE_KEY = "com.android.settingslib.search.processor.package";
|
||||
|
||||
private String mPackage;
|
||||
private Filer mFiler;
|
||||
private Messager mMessager;
|
||||
private boolean mRanOnce;
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnvironment) {
|
||||
if (mRanOnce) {
|
||||
// Will get called once per round, but we only want to run on the first one.
|
||||
return true;
|
||||
}
|
||||
mRanOnce = true;
|
||||
|
||||
final ClassName searchIndexableData =
|
||||
ClassName.get(SETTINGSLIB_SEARCH_PACKAGE, "SearchIndexableData");
|
||||
|
||||
final FieldSpec providers = FieldSpec.builder(
|
||||
ParameterizedTypeName.get(
|
||||
ClassName.get(Set.class),
|
||||
searchIndexableData),
|
||||
"mProviders",
|
||||
Modifier.PRIVATE, Modifier.FINAL)
|
||||
.initializer("new $T()", HashSet.class)
|
||||
.build();
|
||||
|
||||
final MethodSpec addIndex = MethodSpec.methodBuilder("addIndex")
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addParameter(searchIndexableData, "indexClass")
|
||||
.addCode("$N.add(indexClass);\n", providers)
|
||||
.build();
|
||||
|
||||
final MethodSpec.Builder baseConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
final MethodSpec.Builder mobileConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
final MethodSpec.Builder tvConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
final MethodSpec.Builder wearConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
final MethodSpec.Builder autoConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
final MethodSpec.Builder arcConstructorBuilder = MethodSpec.constructorBuilder()
|
||||
.addModifiers(Modifier.PUBLIC);
|
||||
|
||||
for (Element element : roundEnvironment.getElementsAnnotatedWith(SearchIndexable.class)) {
|
||||
if (element.getKind().isClass()) {
|
||||
Name className = element.accept(new SimpleElementVisitor8<Name, Void>() {
|
||||
@Override
|
||||
public Name visitType(TypeElement typeElement, Void aVoid) {
|
||||
return typeElement.getQualifiedName();
|
||||
}
|
||||
}, null);
|
||||
if (className != null) {
|
||||
SearchIndexable searchIndexable = element.getAnnotation(SearchIndexable.class);
|
||||
|
||||
int forTarget = searchIndexable.forTarget();
|
||||
MethodSpec.Builder builder = baseConstructorBuilder;
|
||||
|
||||
if (forTarget == SearchIndexable.ALL) {
|
||||
builder = baseConstructorBuilder;
|
||||
} else if ((forTarget & SearchIndexable.MOBILE) != 0) {
|
||||
builder = mobileConstructorBuilder;
|
||||
} else if ((forTarget & SearchIndexable.TV) != 0) {
|
||||
builder = tvConstructorBuilder;
|
||||
} else if ((forTarget & SearchIndexable.WEAR) != 0) {
|
||||
builder = wearConstructorBuilder;
|
||||
} else if ((forTarget & SearchIndexable.AUTO) != 0) {
|
||||
builder = autoConstructorBuilder;
|
||||
} else if ((forTarget & SearchIndexable.ARC) != 0) {
|
||||
builder = arcConstructorBuilder;
|
||||
}
|
||||
builder.addCode(
|
||||
"$N(new com.android.settingslib.search.SearchIndexableData($L.class, $L"
|
||||
+ ".SEARCH_INDEX_DATA_PROVIDER));\n",
|
||||
addIndex, className, className);
|
||||
} else {
|
||||
throw new IllegalStateException("Null classname from " + element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final MethodSpec getProviderValues = MethodSpec.methodBuilder("getProviderValues")
|
||||
.addAnnotation(Override.class)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.returns(ParameterizedTypeName.get(
|
||||
ClassName.get(Collection.class),
|
||||
searchIndexableData))
|
||||
.addCode("return $N;\n", providers)
|
||||
.build();
|
||||
|
||||
final TypeSpec baseClass = TypeSpec.classBuilder(CLASS_BASE)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addSuperinterface(
|
||||
ClassName.get(SETTINGSLIB_SEARCH_PACKAGE, "SearchIndexableResources"))
|
||||
.addField(providers)
|
||||
.addMethod(baseConstructorBuilder.build())
|
||||
.addMethod(addIndex)
|
||||
.addMethod(getProviderValues)
|
||||
.build();
|
||||
final JavaFile searchIndexableResourcesBase = JavaFile.builder(mPackage, baseClass).build();
|
||||
|
||||
final JavaFile searchIndexableResourcesMobile = JavaFile.builder(mPackage,
|
||||
TypeSpec.classBuilder(CLASS_MOBILE)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(ClassName.get(mPackage, baseClass.name))
|
||||
.addMethod(mobileConstructorBuilder.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
final JavaFile searchIndexableResourcesTv = JavaFile.builder(mPackage,
|
||||
TypeSpec.classBuilder(CLASS_TV)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(ClassName.get(mPackage, baseClass.name))
|
||||
.addMethod(tvConstructorBuilder.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
final JavaFile searchIndexableResourcesWear = JavaFile.builder(mPackage,
|
||||
TypeSpec.classBuilder(CLASS_WEAR)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(ClassName.get(mPackage, baseClass.name))
|
||||
.addMethod(wearConstructorBuilder.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
final JavaFile searchIndexableResourcesAuto = JavaFile.builder(mPackage,
|
||||
TypeSpec.classBuilder(CLASS_AUTO)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(ClassName.get(mPackage, baseClass.name))
|
||||
.addMethod(autoConstructorBuilder.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
final JavaFile searchIndexableResourcesArc = JavaFile.builder(mPackage,
|
||||
TypeSpec.classBuilder(CLASS_ARC)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.superclass(ClassName.get(mPackage, baseClass.name))
|
||||
.addMethod(arcConstructorBuilder.build())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
try {
|
||||
searchIndexableResourcesBase.writeTo(mFiler);
|
||||
searchIndexableResourcesMobile.writeTo(mFiler);
|
||||
searchIndexableResourcesTv.writeTo(mFiler);
|
||||
searchIndexableResourcesWear.writeTo(mFiler);
|
||||
searchIndexableResourcesAuto.writeTo(mFiler);
|
||||
searchIndexableResourcesArc.writeTo(mFiler);
|
||||
} catch (IOException e) {
|
||||
mMessager.printMessage(Kind.ERROR, "Error while writing file: " + e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment processingEnvironment) {
|
||||
super.init(processingEnvironment);
|
||||
mPackage = processingEnvironment.getOptions()
|
||||
.getOrDefault(PACKAGE_KEY, SETTINGSLIB_SEARCH_PACKAGE);
|
||||
mFiler = processingEnvironment.getFiler();
|
||||
mMessager = processingEnvironment.getMessager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright (C) 2018 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.
|
||||
#
|
||||
|
||||
com.android.settingslib.search.IndexableProcessor
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.settingslib.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for classes whose instances can provide data for indexing.
|
||||
*
|
||||
* See {@link android.provider.SearchIndexableResource} and {@link SearchIndexableRaw}.
|
||||
*/
|
||||
public interface Indexable {
|
||||
|
||||
/**
|
||||
* Interface for classes whose instances can provide data for indexing.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled);
|
||||
|
||||
/**
|
||||
* Return a list of dynamic 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.
|
||||
*/
|
||||
List<SearchIndexableRaw> getDynamicRawDataToIndex(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.
|
||||
*/
|
||||
List<String> getNonIndexableKeys(Context context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* A Bundle class used in {@link SearchIndexableResources} to provide search Index data.
|
||||
*/
|
||||
public class SearchIndexableData {
|
||||
private final Class mTargetClass;
|
||||
private final Indexable.SearchIndexProvider mSearchIndexProvider;
|
||||
|
||||
/**
|
||||
* Constructs a SearchIndexableData
|
||||
*
|
||||
* @param targetClass The target opening class of the {@link Indexable.SearchIndexProvider}. It
|
||||
* should be a {@link android.app.Activity} or fragment {@link
|
||||
* androidx.fragment.app.Fragment}.
|
||||
* But fragment is only supported in Android Settings. Other apps should use
|
||||
* {@link android.app.Activity}
|
||||
* @param provider provides searchable data for Android Settings
|
||||
*/
|
||||
public SearchIndexableData(Class targetClass, Indexable.SearchIndexProvider provider) {
|
||||
mTargetClass = targetClass;
|
||||
mSearchIndexProvider = provider;
|
||||
}
|
||||
|
||||
public Class getTargetClass() {
|
||||
return mTargetClass;
|
||||
}
|
||||
|
||||
public Indexable.SearchIndexProvider getSearchIndexProvider() {
|
||||
return mSearchIndexProvider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.settingslib.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface SearchIndexableResources {
|
||||
|
||||
/**
|
||||
* Returns a Collection of {@link SearchIndexableData} that should be indexed for search.
|
||||
*/
|
||||
Collection<SearchIndexableData> getProviderValues();
|
||||
|
||||
/**
|
||||
* Add {@link SearchIndexableData} for search in Android Settings.
|
||||
*/
|
||||
void addIndex(SearchIndexableData indexBundle);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesArc extends SearchIndexableResourcesBase {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesAuto extends SearchIndexableResourcesBase {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesBase implements SearchIndexableResources {
|
||||
|
||||
@Override
|
||||
public Collection<SearchIndexableData> getProviderValues() {
|
||||
throw new RuntimeException("STUB!");
|
||||
}
|
||||
|
||||
public void addIndex(SearchIndexableData indexClass) {
|
||||
throw new RuntimeException("STUB!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesMobile extends SearchIndexableResourcesBase {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesTv extends SearchIndexableResourcesBase {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.settingslib.search;
|
||||
|
||||
/**
|
||||
* Stub for Intellij, not compiled! See {@link IndexableProcessor}
|
||||
*/
|
||||
public class SearchIndexableResourcesWear extends SearchIndexableResourcesBase {
|
||||
}
|
||||
Reference in New Issue
Block a user