Register rule for wallpaper entry

We should keep consistent split rule for wallpaper and other home menu
item. So, we create this cl to register the split rule for wallpaper.

Also, I do some minor refactoring in this cl for reusing existing
method and better code quality.

Test: Go to wallpaper, and click back key. App can close.
Fix: 204406425
Fix: 204364572

Change-Id: Ia7de9483b351d1121cc26c4af1cb8a89ad0a16bc
This commit is contained in:
Tsung-Mao Fang
2021-11-03 16:27:30 +08:00
parent 8118b9ff29
commit b3db40a02b
5 changed files with 47 additions and 15 deletions

View File

@@ -73,6 +73,9 @@ public class ActivityEmbeddingRulesController {
boolean finishPrimaryWithSecondary,
boolean finishSecondaryWithPrimary,
boolean clearTop) {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
return;
}
final Set<SplitPairFilter> filters = new HashSet<>();
filters.add(new SplitPairFilter(primaryComponent, secondaryComponent,
secondaryIntentAction));
@@ -87,18 +90,45 @@ public class ActivityEmbeddingRulesController {
LayoutDirection.LOCALE));
}
/**
* Register a new SplitPairRule for Settings home. Because homepage is able to be opened by
* {@link Settings} or {@link SettingsHomepageActivity}, we register split rule twice for
* two cases.
*/
public static void registerTwoPanePairRuleForSettingsHome(Context context,
ComponentName secondaryComponent,
String secondaryIntentAction,
boolean clearTop) {
registerTwoPanePairRule(
context,
getComponentName(context, Settings.class),
secondaryComponent,
secondaryIntentAction,
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
clearTop);
registerTwoPanePairRule(
context,
getComponentName(context, SettingsHomepageActivity.class),
secondaryComponent,
secondaryIntentAction,
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
clearTop);
}
/** Register a SplitPairRule for SubSettings if the device supports 2-pane. */
public static void registerSubSettingsPairRuleIfNeeded(Context context, boolean clearTop) {
public static void registerSubSettingsPairRule(Context context, boolean clearTop) {
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(context)) {
return;
}
registerTwoPanePairRule(context,
getComponentName(context, Settings.class),
registerTwoPanePairRuleForSettingsHome(
context,
getComponentName(context, SubSettings.class),
null /* secondaryIntentAction */,
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
clearTop);
}
@@ -140,7 +170,7 @@ public class ActivityEmbeddingRulesController {
@NonNull
private static ComponentName getComponentName(Context context,
Class<? extends Activity> activityClass) {
Class<? extends Activity> activityClass) {
return new ComponentName(context.getPackageName(), activityClass.getName());
}
}