[Large screen] Fix searched Subsettings back navigation bug
Settings app registers SubSettings SplitPairRule with clearTop true, it will finish Settings app if users click back button on a SubSettings page. This change registers SubSettings SplitPairRule with clearTop true when users click a SubSettings item in Settings home menu. And this change registers SubSettings SplitPairRule with clearTop false when users click a SubSettings item in search result. Bug: 204501750 Test: manual 1. Settings -> Search settings -> search a SubSettings item (e.g., Battery) 2. Click the searched item. 3. Click back button. Change-Id: I6e1862de528e971137ae7087de608bbdd79096b2
This commit is contained in:
@@ -63,13 +63,6 @@ public class ActivityEmbeddingRulesController {
|
||||
|
||||
// Set a placeholder for home page.
|
||||
registerHomepagePlaceholderRule();
|
||||
// Set subsettings rule.
|
||||
registerTwoPanePairRule(mContext,
|
||||
getComponentName(Settings.class),
|
||||
getComponentName(SubSettings.class),
|
||||
null /* secondaryIntentAction */,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */);
|
||||
}
|
||||
|
||||
/** Register a SplitPairRule for 2-pane. */
|
||||
@@ -78,7 +71,8 @@ public class ActivityEmbeddingRulesController {
|
||||
ComponentName secondaryComponent,
|
||||
String secondaryIntentAction,
|
||||
boolean finishPrimaryWithSecondary,
|
||||
boolean finishSecondaryWithPrimary) {
|
||||
boolean finishSecondaryWithPrimary,
|
||||
boolean clearTop) {
|
||||
final Set<SplitPairFilter> filters = new HashSet<>();
|
||||
filters.add(new SplitPairFilter(primaryComponent, secondaryComponent,
|
||||
secondaryIntentAction));
|
||||
@@ -86,13 +80,28 @@ public class ActivityEmbeddingRulesController {
|
||||
SplitController.getInstance().registerRule(new SplitPairRule(filters,
|
||||
finishPrimaryWithSecondary,
|
||||
finishSecondaryWithPrimary,
|
||||
true /* clearTop */,
|
||||
clearTop,
|
||||
ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(context),
|
||||
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(context),
|
||||
ActivityEmbeddingUtils.SPLIT_RATIO,
|
||||
LayoutDirection.LOCALE));
|
||||
}
|
||||
|
||||
/** Register a SplitPairRule for SubSettings if the device supports 2-pane. */
|
||||
public static void registerSubSettingsPairRuleIfNeeded(Context context, boolean clearTop) {
|
||||
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerTwoPanePairRule(context,
|
||||
getComponentName(context, Settings.class),
|
||||
getComponentName(context, SubSettings.class),
|
||||
null /* secondaryIntentAction */,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
true /* finishSecondaryWithPrimary */,
|
||||
clearTop);
|
||||
}
|
||||
|
||||
private void registerHomepagePlaceholderRule() {
|
||||
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
||||
addActivityFilter(activityFilters, SettingsHomepageActivity.class);
|
||||
@@ -131,6 +140,12 @@ public class ActivityEmbeddingRulesController {
|
||||
|
||||
@NonNull
|
||||
private ComponentName getComponentName(Class<? extends Activity> activityClass) {
|
||||
return new ComponentName(mContext.getPackageName(), activityClass.getName());
|
||||
return getComponentName(mContext, activityClass);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static ComponentName getComponentName(Context context,
|
||||
Class<? extends Activity> activityClass) {
|
||||
return new ComponentName(context.getPackageName(), activityClass.getName());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user