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

Commit b3db40a0 authored by Tsung-Mao Fang's avatar Tsung-Mao Fang
Browse files

Register rule for wallpaper entry

We should keep consistent split rule for wallpaper and other home menu
item. So, we create this cl to register the split rule for wallpaper.

Also, I do some minor refactoring in this cl for reusing existing
method and better code quality.

Test: Go to wallpaper, and click back key. App can close.
Fix: 204406425
Fix: 204364572

Change-Id: Ia7de9483b351d1121cc26c4af1cb8a89ad0a16bc
parent 8118b9ff
Loading
Loading
Loading
Loading
+36 −6
Original line number Diff line number Diff line
@@ -73,6 +73,9 @@ public class ActivityEmbeddingRulesController {
            boolean finishPrimaryWithSecondary,
            boolean finishSecondaryWithPrimary,
            boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }
        final Set<SplitPairFilter> filters = new HashSet<>();
        filters.add(new SplitPairFilter(primaryComponent, secondaryComponent,
                secondaryIntentAction));
@@ -87,18 +90,45 @@ public class ActivityEmbeddingRulesController {
                LayoutDirection.LOCALE));
    }

    /**
     * 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.
     */
    public static void registerTwoPanePairRuleForSettingsHome(Context context,
            ComponentName secondaryComponent,
            String secondaryIntentAction,
            boolean clearTop) {

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

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

    /** Register a SplitPairRule for SubSettings if the device supports 2-pane. */
    public static void registerSubSettingsPairRuleIfNeeded(Context context, boolean clearTop) {
    public static void registerSubSettingsPairRule(Context context, boolean clearTop) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
            return;
        }

        registerTwoPanePairRule(context,
                getComponentName(context, Settings.class),
        registerTwoPanePairRuleForSettingsHome(
                context,
                getComponentName(context, SubSettings.class),
                null /* secondaryIntentAction */,
                true /* finishPrimaryWithSecondary */,
                true /* finishSecondaryWithPrimary */,
                clearTop);
    }

+3 −7
Original line number Diff line number Diff line
@@ -175,14 +175,10 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
                    if (fragment instanceof TopLevelSettings
                            && ActivityEmbeddingUtils.isEmbeddingActivityEnabled(mContext)) {
                        // Register the rule for injected apps.
                        ActivityEmbeddingRulesController.registerTwoPanePairRule(mContext,
                                new ComponentName(activity.getPackageName(),
                                        com.android.settings.Settings.class.getName()),
                                new ComponentName(tile.getPackageName(),
                                        tile.getComponentName()),
                        ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
                                mContext,
                                new ComponentName(tile.getPackageName(), tile.getComponentName()),
                                null /* secondaryIntentAction */,
                                true /* finishPrimaryWithSecondary */,
                                true /* finishSecondaryWithPrimary */,
                                true /* clearTop */);

                        // Highlight preference ui.
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;

import com.android.settings.R;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -102,6 +103,11 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
                    mContext)) {
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            }
            ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
                    mContext,
                    intent.getComponent(),
                    null /* secondaryIntentAction */,
                    true /* clearTop */);
            preference.getContext().startActivity(intent);
            return true;
        }
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ public class TopLevelSettings extends DashboardFragment implements
    @Override
    public boolean onPreferenceTreeClick(Preference preference) {
        // Register SplitPairRule for SubSettings.
        ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(getContext(),
        ActivityEmbeddingRulesController.registerSubSettingsPairRule(getContext(),
                true /* clearTop */);

        setHighlightPreferenceKey(preference.getKey());
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public class SearchResultTrampoline extends Activity {
        } else if (isFromSettingsIntelligence(callingActivity)) {
            // Register SplitPairRule for SubSettings, set clearTop false to prevent unexpected back
            // navigation behavior.
            ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(this,
            ActivityEmbeddingRulesController.registerSubSettingsPairRule(this,
                    false /* clearTop */);
            // TODO: pass menu key to homepage
            intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);