Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61aaed45 authored by Sunny Shao's avatar Sunny Shao
Browse files

Add search index into WallpaperSuggestionActivity

.Use the Indexable interface for WallpaperSuggestionActivity and implement the getRawDataToIndex
.Remove the search index in the WallpaperTypeSettings
.Add full class name of the WallpaperTypeSettings into grandfather_not_implementing_index_provider

Bug: 63117104
Test: robotest & Manual View
Change-Id: I73f43e4996efbe857d74df297ea0d08eb1b640ac
parent 37d83e57
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -795,7 +795,8 @@

        <activity android:name="Settings$WallpaperSettingsActivity"
                  android:label="@string/wallpaper_settings_fragment_title"
                  android:icon="@drawable/ic_wallpaper">
                  android:icon="@drawable/ic_wallpaper"
                  android:exported="true">
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
        </activity>
+35 −1
Original line number Diff line number Diff line
@@ -28,10 +28,18 @@ import androidx.annotation.VisibleForTesting;

import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;

import com.google.android.setupcompat.util.WizardManagerHelper;

public class WallpaperSuggestionActivity extends Activity {
import java.util.ArrayList;
import java.util.List;

@SearchIndexable
public class WallpaperSuggestionActivity extends Activity implements Indexable {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -79,4 +87,30 @@ public class WallpaperSuggestionActivity extends Activity {
        return context.getResources().getBoolean(
                com.android.internal.R.bool.config_enableWallpaperService);
    }

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider() {
                private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";

                @Override
                public List<SearchIndexableRaw> getRawDataToIndex(Context context,
                        boolean enabled) {

                    final List<SearchIndexableRaw> result = new ArrayList<>();

                    SearchIndexableRaw data = new SearchIndexableRaw(context);
                    data.title = context.getString(R.string.wallpaper_settings_fragment_title);
                    data.screenTitle = context.getString(
                            R.string.wallpaper_settings_fragment_title);
                    data.intentTargetPackage = context.getString(
                            R.string.config_wallpaper_picker_package);
                    data.intentTargetClass = context.getString(
                            R.string.config_wallpaper_picker_class);
                    data.intentAction = Intent.ACTION_MAIN;
                    data.key = SUPPORT_SEARCH_INDEX_KEY;
                    result.add(data);

                    return result;
                }
            };
}
+0 −48
Original line number Diff line number Diff line
@@ -17,21 +17,11 @@
package com.android.settings.wallpaper;

import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;

import java.util.ArrayList;
import java.util.List;

@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class WallpaperTypeSettings extends DashboardFragment {
    private static final String TAG = "WallpaperTypeSettings";

@@ -54,42 +44,4 @@ public class WallpaperTypeSettings extends DashboardFragment {
    protected int getPreferenceScreenResId() {
        return R.xml.wallpaper_settings;
    }

    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<>();

                final Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
                final PackageManager pm = context.getPackageManager();
                final List<ResolveInfo> rList = pm.queryIntentActivities(intent,
                        PackageManager.MATCH_DEFAULT_ONLY);

                // Add indexable data for package that is in config_wallpaper_picker_package
                final String wallpaperPickerPackage =
                        context.getString(R.string.config_wallpaper_picker_package);
                for (ResolveInfo info : rList) {
                    if (!wallpaperPickerPackage.equals(info.activityInfo.packageName)) {
                        continue;
                    }
                    CharSequence label = info.loadLabel(pm);
                    if (label == null) {
                        label = info.activityInfo.packageName;
                    }
                    final SearchIndexableRaw data = new SearchIndexableRaw(context);
                    data.title = label.toString();
                    data.key = "wallpaper_type_settings";
                    data.screenTitle = context.getResources().getString(
                            R.string.wallpaper_settings_fragment_title);
                    data.intentAction = Intent.ACTION_SET_WALLPAPER;
                    data.intentTargetPackage = info.activityInfo.packageName;
                    data.intentTargetClass = info.activityInfo.name;
                    data.keywords = context.getString(R.string.keywords_wallpaper);
                    result.add(data);
                }

                return result;
            }
        };
}
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ com.android.settings.users.RestrictedProfileSettings
com.android.settings.users.UserDetailsSettings
com.android.settings.vpn2.AppManagementFragment
com.android.settings.vpn2.VpnSettings
com.android.settings.wallpaper.WallpaperTypeSettings
com.android.settings.wifi.calling.WifiCallingSettingsForSub
com.android.settings.wifi.ChangeWifiStateDetails
com.android.settings.wifi.details.WifiNetworkDetailsFragment