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

Commit 3e816464 authored by Arc Wang's avatar Arc Wang
Browse files

[Large screen] Show full screen CreateShortcutActivity

Show full screen for CreateShortcutActivity because

-Launcher startActivityForResult for Intent.ACTION_CREATE_SHORTCUT and
 activity stack starts from launcher, CreateShortcutActivity will not
 follows SplitPaitRule registered by Settings.

- There is no CreateShortcutActivity entry point from Settings app UI.

Bug: 200916507
Test: manual
      Launcher menu ->  Widgets -> Settings -> select an item.
      Observe if it goes back go launcher.
Change-Id: I437ff9b82d5a4548e10aed7bd083fd01352433f4
parent d24f2895
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -52,13 +52,13 @@ import androidx.preference.PreferenceManager;

import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.gateway.SettingsGateway;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.homepage.SettingsHomepageActivity;
import com.android.settings.homepage.TopLevelSettings;
import com.android.settings.overlay.FeatureFactory;
@@ -356,11 +356,29 @@ public class SettingsActivity extends SettingsBaseActivity

    /** Returns true if the Activity is started by a deep link intent for large screen devices. */
    private boolean launchHomepageForTwonPaneDeepLink() {
        final Intent intent = getIntent();
        if (!shouldShowTwoPaneDeepLink(intent)) {
            return false;
        }

        // It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
        final Intent trampolineIntent =
                new Intent(android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK);
        trampolineIntent.replaceExtras(intent);
        trampolineIntent.putExtra(
                android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI,
                intent.toUri(Intent.URI_INTENT_SCHEME));
        trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        startActivity(trampolineIntent);

        return true;
    }

    private boolean shouldShowTwoPaneDeepLink(Intent intent) {
        if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
            return false;
        }

        final Intent intent = getIntent();
        // Only starts trampoline for deep links. Should return false for all the cases that
        // Settings app starts SettingsActivity or SubSetting by itself.
        if (intent.getAction() == null) {
@@ -377,15 +395,14 @@ public class SettingsActivity extends SettingsBaseActivity
            return false;
        }

        // It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
        final Intent trampolineIntent =
                new Intent(android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK);
        trampolineIntent.replaceExtras(intent);
        trampolineIntent.putExtra(
                android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI,
                intent.toUri(Intent.URI_INTENT_SCHEME));
        trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        startActivity(trampolineIntent);
        if (TextUtils.equals(intent.getAction(), Intent.ACTION_CREATE_SHORTCUT)) {
            // Returns false to show full screen for Intent.ACTION_CREATE_SHORTCUT because
            // - Launcher startActivityForResult for Intent.ACTION_CREATE_SHORTCUT and activity
            //   stack starts from launcher, CreateShortcutActivity will not follows SplitPaitRule
            //   registered by Settings.
            // - There is no CreateShortcutActivity entry point from Settings app UI.
            return false;
        }

        return true;
    }