Merge "Register rule for wallpaper entry" into sc-v2-dev am: 6c24e5bc33 am: d34752cce6

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

Change-Id: I90e42051ccdf056da7899bf5a04125d3d945fe20
This commit is contained in:
TreeHugger Robot
2021-11-05 01:25:37 +00:00
committed by Automerger Merge Worker
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);
}

View File

@@ -175,14 +175,10 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
if (fragment instanceof TopLevelSettings
&& ActivityEmbeddingUtils.isEmbeddingActivityEnabled(mContext)) {
// Register the rule for injected apps.
ActivityEmbeddingRulesController.registerTwoPanePairRule(mContext,
new ComponentName(activity.getPackageName(),
com.android.settings.Settings.class.getName()),
new ComponentName(tile.getPackageName(),
tile.getComponentName()),
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
mContext,
new ComponentName(tile.getPackageName(), tile.getComponentName()),
null /* secondaryIntentAction */,
true /* finishPrimaryWithSecondary */,
true /* finishSecondaryWithPrimary */,
true /* clearTop */);
// Highlight preference ui.

View File

@@ -31,6 +31,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -102,6 +103,11 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
mContext)) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
mContext,
intent.getComponent(),
null /* secondaryIntentAction */,
true /* clearTop */);
preference.getContext().startActivity(intent);
return true;
}

View File

@@ -100,7 +100,7 @@ public class TopLevelSettings extends DashboardFragment implements
@Override
public boolean onPreferenceTreeClick(Preference preference) {
// Register SplitPairRule for SubSettings.
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(getContext(),
ActivityEmbeddingRulesController.registerSubSettingsPairRule(getContext(),
true /* clearTop */);
setHighlightPreferenceKey(preference.getKey());

View File

@@ -97,7 +97,7 @@ public class SearchResultTrampoline extends Activity {
} else if (isFromSettingsIntelligence(callingActivity)) {
// Register SplitPairRule for SubSettings, set clearTop false to prevent unexpected back
// navigation behavior.
ActivityEmbeddingRulesController.registerSubSettingsPairRuleIfNeeded(this,
ActivityEmbeddingRulesController.registerSubSettingsPairRule(this,
false /* clearTop */);
// TODO: pass menu key to homepage
intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);