sanders: LineageActions: add Settings search indexing
Allows Settings to search for options provided by this package. Signed-off-by: Roman Birg <roman@cyngn.com> Signed-off-by: jhenrique09 <jhenrique09.mcz@hotmail.com>
This commit is contained in:
@@ -24,6 +24,18 @@
|
||||
android:icon="@drawable/ic_gesture"
|
||||
android:persistent="true">
|
||||
|
||||
<provider
|
||||
android:name=".LineageActionsSearchIndexablesProvider"
|
||||
android:authorities="org.lineageos.settings.device"
|
||||
android:multiprocess="false"
|
||||
android:grantUriPermissions="true"
|
||||
android:permission="android.permission.READ_SEARCH_INDEXABLES"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.action.SEARCH_INDEXABLES_PROVIDER" />
|
||||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
<receiver android:name="org.lineageos.settings.device.BootCompletedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
|
||||
27
LineageActions/res/xml/doze_panel_indexable.xml
Normal file
27
LineageActions/res/xml/doze_panel_indexable.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<Preference
|
||||
android:key="doze"
|
||||
android:title="@string/ambient_display_title"
|
||||
android:summary="@string/ambient_display_manage_summary"
|
||||
android:icon="@drawable/ic_settings_doze" />
|
||||
|
||||
</PreferenceScreen>
|
||||
27
LineageActions/res/xml/fp_gesture_panel_indexable.xml
Normal file
27
LineageActions/res/xml/fp_gesture_panel_indexable.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<Preference
|
||||
android:key="fp_gestures"
|
||||
android:title="@string/fingerprint_gestures_title"
|
||||
android:summary="@string/fingerprint_gestures_manage_summary"
|
||||
android:icon="@drawable/ic_settings_fingerprint" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015-2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<Preference
|
||||
android:key="screen_off_gestures"
|
||||
android:title="@string/screen_off_gestures_title"
|
||||
android:summary="@string/screen_off_gestures_manage_summary"
|
||||
android:icon="@drawable/ic_settings_screen_off_gestures" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2015 The CyanogenMod Project
|
||||
* Copyright (c) 2017 The LineageOS 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 org.lineageos.settings.device;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.SearchIndexablesProvider;
|
||||
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
|
||||
import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
|
||||
import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
|
||||
import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
|
||||
import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
|
||||
|
||||
public class LineageActionsSearchIndexablesProvider extends SearchIndexablesProvider {
|
||||
private static final String TAG = "LineageActionsSearchIndexablesProvider";
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryXmlResources(String[] projection) {
|
||||
MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
|
||||
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.actions_panel,
|
||||
GestureSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_gestures)));
|
||||
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.fp_gesture_panel,
|
||||
FPGestureSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_fingerprint)));
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.fp_gesture_panel_indexable,
|
||||
FPGestureSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_fingerprint)));
|
||||
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.screen_off_gesture_panel,
|
||||
ScreenOffGestureSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_screen_off_gestures)));
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.screen_off_gesture_panel_indexable,
|
||||
ScreenOffGestureSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_screen_off_gestures)));
|
||||
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.doze_panel,
|
||||
DozeSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_doze)));
|
||||
cursor.addRow(generateResourceRef(new SearchIndexableResource(1, R.xml.doze_panel_indexable,
|
||||
DozeSettingsActivity.class.getName(),
|
||||
R.drawable.ic_settings_doze)));
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
private static Object[] generateResourceRef(SearchIndexableResource sir) {
|
||||
Object[] ref = new Object[7];
|
||||
ref[COLUMN_INDEX_XML_RES_RANK] = sir.rank;
|
||||
ref[COLUMN_INDEX_XML_RES_RESID] = sir.xmlResId;
|
||||
ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null;
|
||||
ref[COLUMN_INDEX_XML_RES_ICON_RESID] = sir.iconResId;
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "com.android.settings.action.EXTRA_SETTINGS";
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "org.lineageos.settings.device";
|
||||
ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = sir.className;
|
||||
return ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryRawData(String[] projection) {
|
||||
MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryNonIndexableKeys(String[] projection) {
|
||||
MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user