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
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index d258cc2..4e2088e 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -65,8 +65,8 @@
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 @@
final Intent intent = getIntent();
if (shouldShowTwoPaneDeepLink(intent) && tryStartTwoPaneDeepLink(intent)) {
- finishAndRemoveTask();
+ finish();
super.onCreate(savedState);
return;
}
@@ -421,7 +421,7 @@
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 @@
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;
}