From 83f0adc5c054a702daedf1378518d7be5378421c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20G=C3=B6llner?= Date: Wed, 21 Feb 2024 15:14:30 +0000 Subject: [PATCH] Settings - Move Activity embedding split min width config to resources On some devices the values need to be configured to be different than the default. Bug: 326215764 Test: Manual Change-Id: I56a3a6608a4ac4eaf7d7dede4f6cb4278638f29c --- res/values/config.xml | 7 +++++++ .../ActivityEmbeddingRulesController.java | 10 ++++++---- .../activityembedding/ActivityEmbeddingUtils.java | 13 ++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/res/values/config.xml b/res/values/config.xml index 9d7167101d7..afd6fdd16d2 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -679,6 +679,13 @@ 0.3636 + + 600 + + + 720 + diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java index 50134ba7eb6..4e39070febd 100644 --- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java +++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java @@ -113,8 +113,9 @@ public class ActivityEmbeddingRulesController { .setFinishPrimaryWithSecondary(finishPrimaryWithSecondary) .setFinishSecondaryWithPrimary(finishSecondaryWithPrimary) .setClearTop(clearTop) - .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) - .setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) + .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp(context)) + .setMinSmallestWidthDp( + ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp(context)) .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setDefaultSplitAttributes(attributes) .build(); @@ -234,8 +235,9 @@ public class ActivityEmbeddingRulesController { .build(); final SplitPlaceholderRule placeholderRule = new SplitPlaceholderRule.Builder( activityFilters, intent) - .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) - .setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) + .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp(mContext)) + .setMinSmallestWidthDp( + ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp(mContext)) .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setSticky(false) .setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT) diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java index 74a967332da..b91e0e5eacd 100644 --- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java +++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java @@ -33,11 +33,6 @@ import com.google.android.setupcompat.util.WizardManagerHelper; /** An util class collecting all common methods for the embedding activity features. */ public class ActivityEmbeddingUtils { - // The smallest value of current width of the window when the split should be used. - private static final int MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720; - // The smallest value of the smallest-width (sw) of the window in any rotation when - // the split should be used. - private static final int MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600; // The minimum width of the activity to show the regular homepage layout. private static final float MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP = 380f; @@ -58,16 +53,16 @@ public class ActivityEmbeddingUtils { private static final String TAG = "ActivityEmbeddingUtils"; /** Get the smallest width dp of the window when the split should be used. */ - public static int getMinCurrentScreenSplitWidthDp() { - return MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP; + public static int getMinCurrentScreenSplitWidthDp(Context context) { + return context.getResources().getInteger(R.integer.config_activity_embed_split_min_cur_dp); } /** * Get the smallest dp value of the smallest-width (sw) of the window in any rotation when * the split should be used. */ - public static int getMinSmallestScreenSplitWidthDp() { - return MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP; + public static int getMinSmallestScreenSplitWidthDp(Context context) { + return context.getResources().getInteger(R.integer.config_activity_embed_split_min_sw_dp); } /**