Update ActivityEmbedding usage.

Bug: 259592300
Test: build.
Change-Id: I8e4aa8daf51cb9c669d06b152cc5a2fc69a06571
Merged-In: I8e4aa8daf51cb9c669d06b152cc5a2fc69a06571
(cherry picked from commit a9394d1796)
(cherry picked from commit 65bb5a09f4)
This commit is contained in:
Diego Vela
2022-11-19 00:38:12 +00:00
committed by Anvesh Renikindi
parent 3773ae0d9f
commit d2dfc4285e
6 changed files with 80 additions and 55 deletions

View File

@@ -30,29 +30,25 @@ import com.android.settings.R;
/** 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 float MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720f;
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 float MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600f;
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;
private static final String TAG = "ActivityEmbeddingUtils";
/** Get the smallest pixel value of width of the window when the split should be used. */
public static int getMinCurrentScreenSplitWidthPx(Context context) {
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
return (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP, dm);
/** 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;
}
/**
* Get the smallest pixel 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.
*/
public static int getMinSmallestScreenSplitWidthPx(Context context) {
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
return (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP, dm);
public static int getMinSmallestScreenSplitWidthDp() {
return MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP;
}
/**
@@ -67,7 +63,7 @@ public class ActivityEmbeddingUtils {
public static boolean isEmbeddingActivityEnabled(Context context) {
final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context,
FeatureFlagUtils.SETTINGS_SUPPORT_LARGE_SCREEN);
final boolean isSplitSupported = SplitController.getInstance().isSplitSupported();
final boolean isSplitSupported = SplitController.getInstance(context).isSplitSupported();
Log.d(TAG, "isFlagEnabled = " + isFlagEnabled);
Log.d(TAG, "isSplitSupported = " + isSplitSupported);