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

Commit d61e61e6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix abnormal behavior on search page" into sc-v2-dev am: ee18babe

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16284151

Change-Id: I19a8fb6310cc3399291fe38f6026d1b751390e24
parents 266663a8 ee18babe
Loading
Loading
Loading
Loading
+34 −8
Original line number Diff line number Diff line
@@ -99,20 +99,26 @@ public class ActivityEmbeddingRulesController {

    /**
     * Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
     * {@link Settings} or {@link SettingsHomepageActivity}, we register split rule twice for
     * two cases.
     * {@link Settings} or {@link SettingsHomepageActivity} or
     * {@link SliceDeepLinkHomepageActivity}, we register split rule for above cases.
     */
    public static void registerTwoPanePairRuleForSettingsHome(Context context,
            ComponentName secondaryComponent,
            String secondaryIntentAction,
            boolean finishPrimaryWithSecondary,
            boolean finishSecondaryWithPrimary,
            boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }

        registerTwoPanePairRule(
                context,
                getComponentName(context, Settings.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -120,8 +126,8 @@ public class ActivityEmbeddingRulesController {
                new ComponentName(context, DeepLinkHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -129,8 +135,8 @@ public class ActivityEmbeddingRulesController {
                getComponentName(context, SettingsHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);

        registerTwoPanePairRule(
@@ -138,6 +144,26 @@ public class ActivityEmbeddingRulesController {
                getComponentName(context, SliceDeepLinkHomepageActivity.class),
                secondaryComponent,
                secondaryIntentAction,
                finishPrimaryWithSecondary,
                finishSecondaryWithPrimary,
                clearTop);
    }

    /**
     * Register a new SplitPairRule for Settings home.
     */
    public static void registerTwoPanePairRuleForSettingsHome(Context context,
            ComponentName secondaryComponent,
            String secondaryIntentAction,
            boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }

        registerTwoPanePairRuleForSettingsHome(
                context,
                secondaryComponent,
                secondaryIntentAction,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                clearTop);
+29 −8
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
@@ -33,11 +34,14 @@ import androidx.fragment.app.FragmentActivity;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.search.SearchIndexableResources;

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

import java.util.List;

/**
 * FeatureProvider for Settings Search
 */
@@ -60,6 +64,9 @@ public interface SearchFeatureProvider {
     */
    SearchIndexableResources getSearchIndexableResources();

    /**
     * @return a package name of settings intelligence.
     */
    default String getSettingsIntelligencePkgName(Context context) {
        return context.getString(R.string.config_settingsintelligence_package_name);
    }
@@ -90,16 +97,30 @@ public interface SearchFeatureProvider {
        navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
        navView.setBackground(null);

        toolbar.setOnClickListener(tb -> {
        final Context context = activity.getApplicationContext();
        final Intent intent = buildSearchIntent(context, pageId)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            if (activity.getPackageManager().queryIntentActivities(intent,
                    PackageManager.MATCH_DEFAULT_ONLY).isEmpty()) {
        final List<ResolveInfo> resolveInfos =
                activity.getPackageManager().queryIntentActivities(intent,
                        PackageManager.MATCH_DEFAULT_ONLY);
        if (resolveInfos.isEmpty()) {
            return;
        }

        final ComponentName searchComponentName = resolveInfos.get(0)
                .getComponentInfo().getComponentName();
        // Set a component name since activity embedding requires a component name for
        // registering a rule.
        intent.setComponent(searchComponentName);
        ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
                context,
                searchComponentName,
                intent.getAction(),
                false /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                false /* clearTop */);

        toolbar.setOnClickListener(tb -> {
            FeatureFactory.getFactory(context).getSlicesFeatureProvider()
                    .indexSliceDataAsync(context);