Enhance Settings deep link transition

Since the deep link mechanism uses a trampoline activity to redirect the
target activity, and the targeting activity is launched in a separate
task, there will be two transitions played, where one is the splash
screen with the trampoline acitvity and another one is the task
transition. This makes the UX weird.

To avoid this, this CL tries to make the targeting activity launch in
the same task as the trampoline acitivity by removing the taskAffinity,
so there won't be a task transition.

Fix: 215275940
Test: Create a settings shortcut on the home screen and launch it.
Change-Id: I7621ab9f1132acbf619495801a3b985c5c3b1b5d
This commit is contained in:
Jason Chiu
2021-12-02 14:26:24 +08:00
parent 46adb8e175
commit 177573c892
8 changed files with 24 additions and 21 deletions

View File

@@ -65,8 +65,8 @@ 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.homepage.DeepLinkHomepageActivityInternal;
import com.android.settings.homepage.SettingsHomepageActivity;
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
import com.android.settings.homepage.TopLevelSettings;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wfd.WifiDisplaySettings;
@@ -254,7 +254,7 @@ public class SettingsActivity extends SettingsBaseActivity
final Intent intent = getIntent();
if (shouldShowTwoPaneDeepLink(intent) && tryStartTwoPaneDeepLink(intent)) {
finishAndRemoveTask();
finish();
super.onCreate(savedState);
return;
}
@@ -421,7 +421,7 @@ public class SettingsActivity extends SettingsBaseActivity
mHighlightMenuKey = highlightMenuKey;
}
trampolineIntent = getTrampolineIntent(intent, mHighlightMenuKey);
trampolineIntent.setClass(this, SliceDeepLinkHomepageActivity.class);
trampolineIntent.setClass(this, DeepLinkHomepageActivityInternal.class);
} else {
trampolineIntent = getTrampolineIntent(intent, mHighlightMenuKey);
}
@@ -440,8 +440,11 @@ public class SettingsActivity extends SettingsBaseActivity
return false;
}
// If the activity is not the task root, it should not start trampoline for deep links.
if (!isTaskRoot()) {
// If the activity is task root, starting trampoline is needed in order to show two-pane UI.
// If FLAG_ACTIVITY_NEW_TASK is set, the activity will become the start of a new task on
// this history stack, so starting trampoline is needed in order to notify the homepage that
// the highlight key is changed.
if (!isTaskRoot() && (intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
return false;
}