Merge "Settings - Move Activity embedding split min width config to resources" into main

This commit is contained in:
Chris Göllner
2024-02-22 12:30:55 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 13 deletions

View File

@@ -679,6 +679,13 @@
<!-- The ratio to use when using the two-pane settings layout --> <!-- The ratio to use when using the two-pane settings layout -->
<item name="config_activity_embed_split_ratio" format="float" type="dimen">0.3636</item> <item name="config_activity_embed_split_ratio" format="float" type="dimen">0.3636</item>
<!-- The smallest value of the smallest-width (sw) of the window in any rotation when the split
should be used. -->
<integer name="config_activity_embed_split_min_sw_dp">600</integer>
<!-- The smallest value of current width of the window when the split should be used. -->
<integer name="config_activity_embed_split_min_cur_dp">720</integer>
<!-- The number of visible app icons while entering app list related pages for preloading. <!-- The number of visible app icons while entering app list related pages for preloading.
Take the "Unrestricted data" page as the example, the visible app icons could be 15 Take the "Unrestricted data" page as the example, the visible app icons could be 15
on 6.4 inches screen size whether the font size and display size are both small. --> on 6.4 inches screen size whether the font size and display size are both small. -->

View File

@@ -113,8 +113,9 @@ public class ActivityEmbeddingRulesController {
.setFinishPrimaryWithSecondary(finishPrimaryWithSecondary) .setFinishPrimaryWithSecondary(finishPrimaryWithSecondary)
.setFinishSecondaryWithPrimary(finishSecondaryWithPrimary) .setFinishSecondaryWithPrimary(finishSecondaryWithPrimary)
.setClearTop(clearTop) .setClearTop(clearTop)
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp(context))
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) .setMinSmallestWidthDp(
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp(context))
.setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW)
.setDefaultSplitAttributes(attributes) .setDefaultSplitAttributes(attributes)
.build(); .build();
@@ -234,8 +235,9 @@ public class ActivityEmbeddingRulesController {
.build(); .build();
final SplitPlaceholderRule placeholderRule = new SplitPlaceholderRule.Builder( final SplitPlaceholderRule placeholderRule = new SplitPlaceholderRule.Builder(
activityFilters, intent) activityFilters, intent)
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp()) .setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp(mContext))
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp()) .setMinSmallestWidthDp(
ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp(mContext))
.setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW) .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.ALWAYS_ALLOW)
.setSticky(false) .setSticky(false)
.setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT) .setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT)

View File

@@ -33,11 +33,6 @@ import com.google.android.setupcompat.util.WizardManagerHelper;
/** An util class collecting all common methods for the embedding activity features. */ /** An util class collecting all common methods for the embedding activity features. */
public class ActivityEmbeddingUtils { 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. // The minimum width of the activity to show the regular homepage layout.
private static final float MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP = 380f; private static final float MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP = 380f;
@@ -58,16 +53,16 @@ public class ActivityEmbeddingUtils {
private static final String TAG = "ActivityEmbeddingUtils"; private static final String TAG = "ActivityEmbeddingUtils";
/** Get the smallest width dp of the window when the split should be used. */ /** Get the smallest width dp of the window when the split should be used. */
public static int getMinCurrentScreenSplitWidthDp() { public static int getMinCurrentScreenSplitWidthDp(Context context) {
return MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP; 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 * Get the smallest dp value of the smallest-width (sw) of the window in any rotation when
* the split should be used. * the split should be used.
*/ */
public static int getMinSmallestScreenSplitWidthDp() { public static int getMinSmallestScreenSplitWidthDp(Context context) {
return MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP; return context.getResources().getInteger(R.integer.config_activity_embed_split_min_sw_dp);
} }
/** /**