Merge "Only show 2-pane deep link when homepage is available" into tm-dev am: f74e1195a4

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

Change-Id: Ic9e80fb5a0922b528221b44c3127d71a314ef87d
This commit is contained in:
Arc Wang
2022-03-02 07:44:53 +00:00
committed by Automerger Merge Worker

View File

@@ -24,6 +24,7 @@ import static com.android.settings.applications.appinfo.AppButtonsPreferenceCont
import android.app.ActionBar;
import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -252,8 +253,7 @@ public class SettingsActivity extends SettingsBaseActivity
getMetaData();
final Intent intent = getIntent();
if (shouldShowTwoPaneDeepLink(intent)) {
launchHomepageForTwoPaneDeepLink(intent);
if (shouldShowTwoPaneDeepLink(intent) && tryStartTwoPaneDeepLink(intent)) {
finishAndRemoveTask();
super.onCreate(savedState);
return;
@@ -411,7 +411,7 @@ public class SettingsActivity extends SettingsBaseActivity
return trampolineIntent;
}
private void launchHomepageForTwoPaneDeepLink(Intent intent) {
private boolean tryStartTwoPaneDeepLink(Intent intent) {
final Intent trampolineIntent;
if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
// Get menu key for slice deep link case.
@@ -425,7 +425,14 @@ public class SettingsActivity extends SettingsBaseActivity
} else {
trampolineIntent = getTrampolineIntent(intent, mHighlightMenuKey);
}
try {
startActivity(trampolineIntent);
} catch (ActivityNotFoundException e) {
Log.e(LOG_TAG, "Deep link homepage is not available to show 2-pane UI");
return false;
}
return true;
}
private boolean shouldShowTwoPaneDeepLink(Intent intent) {