From c78096c69e5790779ff2e7069825c161d73d58ea Mon Sep 17 00:00:00 2001 From: Li Lin Date: Wed, 30 Apr 2025 15:25:43 -0700 Subject: [PATCH 01/25] Add a auto hide flag for Growth Framework nudge. Test: manual Bug: 411210699 Flag: com.android.launcher3.enable_growth_nudge Change-Id: I2b13dbaf82c6d80410ede6610533846ced314f32 --- .../taskbar/TaskbarAutohideSuspendController.java | 5 +++++ .../android/launcher3/taskbar/growth/NudgeController.kt | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java index 444c356e0b..32eb68b967 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java @@ -51,6 +51,8 @@ public class TaskbarAutohideSuspendController implements public static final int FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN = 1 << 7; // User has taskbar overflow open. public static final int FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW = 1 << 8; + // Growth Framework nudge overlay is open above the Taskbar. + public static final int FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN = 1 << 9; @IntDef(flag = true, value = { FLAG_AUTOHIDE_SUSPEND_FULLSCREEN, @@ -62,6 +64,7 @@ public class TaskbarAutohideSuspendController implements FLAG_AUTOHIDE_SUSPEND_HOVERING_ICONS, FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN, FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW, + FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN, }) @Retention(RetentionPolicy.SOURCE) public @interface AutohideSuspendFlag {} @@ -143,6 +146,8 @@ public class TaskbarAutohideSuspendController implements "FLAG_AUTOHIDE_SUSPEND_MULTI_INSTANCE_MENU_OPEN"); appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW, "FLAG_AUTOHIDE_SUSPEND_TASKBAR_OVERFLOW"); + appendFlag(str, flags, FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN, + "FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN"); return str.toString(); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeController.kt b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeController.kt index c3aab220c8..24f4b741fc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeController.kt @@ -32,7 +32,7 @@ import com.airbnb.lottie.LottieAnimationView import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.taskbar.TaskbarActivityContext -import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN +import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN import com.android.launcher3.taskbar.TaskbarControllers import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController import com.android.launcher3.views.ActivityContext @@ -151,16 +151,15 @@ class NudgeController(context: Context) : LoggableTaskbarController { false, ) as NudgeView - // TODO: b/411210699 - considering adding a auto hide suspend flag for the nudge. controllers.taskbarAutohideSuspendController.updateFlag( - FLAG_AUTOHIDE_SUSPEND_EDU_OPEN, + FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN, true, ) nudgeView.onCloseCallback = { this.nudgeView = null controllers.taskbarAutohideSuspendController.updateFlag( - FLAG_AUTOHIDE_SUSPEND_EDU_OPEN, + FLAG_AUTOHIDE_SUSPEND_GROWTH_NUDGE_OPEN, false, ) controllers.taskbarStashController.updateAndAnimateTransientTaskbar(true) From d0fccf87731c23d89c169cd2fff8d8684e959240 Mon Sep 17 00:00:00 2001 From: Sergey Pinkevich Date: Wed, 21 May 2025 16:01:48 +0000 Subject: [PATCH 02/25] Convert DesktopVisibilityControllerTest to multivalent Bug: 397902030 Flag: NONE test fix, not actual code editing Test: atest NexusLauncherTests:DesktopVisibilityControllerTest Change-Id: Ie6ae4abb2a894d4f7403e77cf797cdce924fd9e3 --- .../DesktopVisibilityControllerTest.kt | 14 -------------- 1 file changed, 14 deletions(-) rename quickstep/tests/{ => multivalentTests}/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt (86%) diff --git a/quickstep/tests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt similarity index 86% rename from quickstep/tests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt rename to quickstep/tests/multivalentTests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt index 4b8f2a2348..180a0fb15c 100644 --- a/quickstep/tests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/statehandlers/DesktopVisibilityControllerTest.kt @@ -21,13 +21,11 @@ import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession import com.android.launcher3.util.DaggerSingletonTracker import com.android.quickstep.SystemUiProxy import com.android.window.flags.Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND import com.android.window.flags.Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND import com.android.wm.shell.shared.desktopmode.DesktopModeStatus -import org.junit.After import org.junit.Assert.assertFalse import org.junit.Before import org.junit.Rule @@ -35,7 +33,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock import org.mockito.kotlin.whenever -import org.mockito.quality.Strictness /** * Tests the behavior of [DesktopVisibilityController] in regards to multiple desktops and multiple @@ -47,12 +44,6 @@ class DesktopVisibilityControllerTest { @get:Rule val setFlagsRule = SetFlagsRule() - private val mockitoSession = - mockitoSession() - .strictness(Strictness.LENIENT) - .mockStatic(DesktopModeStatus::class.java) - .startMocking() - private val context = mock() private val systemUiProxy = mock() private val lifeCycleTracker = mock() @@ -66,11 +57,6 @@ class DesktopVisibilityControllerTest { DesktopVisibilityController(context, systemUiProxy, lifeCycleTracker) } - @After - fun tearDown() { - mockitoSession.finishMocking() - } - @Test @EnableFlags(FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, FLAG_ENABLE_MULTIPLE_DESKTOPS_FRONTEND) fun noCrashWhenCheckingNonExistentDisplay() { From 3bd1f20e3bd0748f720e4f6b8272ca3df04e020f Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Sat, 26 Apr 2025 05:05:07 +0000 Subject: [PATCH 03/25] Implement spec to configure all apps height Adds AllAppsSpec support, that can configure all apps height so the container top aligns with the top of a row in the workspace grid. Bug: 30153091 Flag: com.android.launcher3.enable_scalability_for_desktop_experience Test: Manual Change-Id: Ia5c939c7d3b6fed29a9c2f47233348a5e55b570f --- res/values/attrs.xml | 8 ++ src/com/android/launcher3/DeviceProfile.java | 15 ++- .../launcher3/InvariantDeviceProfile.java | 91 ++++++++++++++++++- 3 files changed, 110 insertions(+), 4 deletions(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 031f291185..631dfa9cfd 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -178,6 +178,11 @@ + + + + + @@ -278,6 +283,9 @@ Needs FeatureFlags.ENABLE_RESPONSIVE_WORKSPACE enabled --> + + diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index cc9c9f7588..51da925b98 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -698,6 +698,8 @@ public class DeviceProfile { mBubbleBarSpaceThresholdPx = res.getDimensionPixelSize(R.dimen.bubblebar_hotseat_adjustment_threshold); + int allAppsTopPadding = mInsets.top; + // Needs to be calculated after hotseatBarSizePx is correct, // for the available height to be correct if (mIsResponsiveGrid) { @@ -723,9 +725,15 @@ public class DeviceProfile { mResponsiveAllAppsWidthSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.WIDTH, numShownAllAppsColumns, availableWidthPx, mResponsiveWorkspaceWidthSpec); + if (inv.appListAlignedWithWorkspaceRow >= 0) { + allAppsTopPadding += mResponsiveWorkspaceHeightSpec.getStartPaddingPx() + + inv.appListAlignedWithWorkspaceRow + * (mResponsiveWorkspaceHeightSpec.getCellSizePx() + + mResponsiveWorkspaceHeightSpec.getGutterPx()); + } mResponsiveAllAppsHeightSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.HEIGHT, inv.numAllAppsRowsForCellHeightCalculation, - heightPx - mInsets.top, mResponsiveWorkspaceHeightSpec); + heightPx - allAppsTopPadding, mResponsiveWorkspaceHeightSpec); ResponsiveSpecsProvider folderSpecs = ResponsiveSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.folderSpecsId), @@ -809,9 +817,10 @@ public class DeviceProfile { hotseatBorderSpace = cellLayoutBorderSpacePx.y; } + if (shouldShowAllAppsOnSheet()) { - allAppsPadding.top = mInsets.top; - allAppsShiftRange = heightPx; + allAppsPadding.top = allAppsTopPadding; + allAppsShiftRange = heightPx - allAppsTopPadding + mInsets.top; } else { allAppsPadding.top = 0; allAppsShiftRange = diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 18821c7cb9..f8bf01ddbb 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -16,6 +16,7 @@ package com.android.launcher3; +import static com.android.launcher3.Flags.enableScalabilityForDesktopExperience; import static com.android.launcher3.GridType.GRID_TYPE_ANY; import static com.android.launcher3.GridType.GRID_TYPE_NON_ONE_GRID; import static com.android.launcher3.GridType.GRID_TYPE_ONE_GRID; @@ -240,6 +241,11 @@ public class InvariantDeviceProfile { private String mLocale = ""; public boolean enableTwoLinesInAllApps = false; + + // If non-negative, the workspace row with which top of the all apps container is to be aligned + // with. + public int appListAlignedWithWorkspaceRow = -1; + /** * Fixed landscape mode is the landscape on the phones. */ @@ -400,6 +406,7 @@ public class InvariantDeviceProfile { allAppsCellSpecsTwoPanelId = closestProfile.mAllAppsCellSpecsTwoPanelId; numAllAppsRowsForCellHeightCalculation = closestProfile.mNumAllAppsRowsForCellHeightCalculation; + appListAlignedWithWorkspaceRow = closestProfile.mAllAppsAlignedWithWorkspaceRow; this.deviceType = displayInfo.getDeviceType(); this.displayInfo = displayInfo; @@ -633,12 +640,36 @@ public class InvariantDeviceProfile { throw new RuntimeException(e); } - // Finds the min width and height in dp for all displays. + // Finds the min width and height in px for all displays. int[] dimens = findMinWidthAndHeightPxForDevice(displayInfo); return findBestGridSize(gridSizes, dimens[0], dimens[1]); } + private static AllAppsSize getAllAppsSize(ResourceHelper resourceHelper, Context context, + Info displayInfo) { + ArrayList allAppsSizes = new ArrayList<>(); + + try (XmlResourceParser parser = resourceHelper.getXml()) { + final int depth = parser.getDepth(); + int type; + while (((type = parser.next()) != XmlPullParser.END_TAG + || parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { + if ((type == XmlPullParser.START_TAG) + && "AllAppsSize".equals(parser.getName())) { + allAppsSizes.add(new AllAppsSize(context, Xml.asAttributeSet(parser))); + } + } + } catch (IOException | XmlPullParserException e) { + throw new RuntimeException(e); + } + + // Finds the min width and height in px for all displays. + int[] dimens = findMinWidthAndHeightPxForDevice(displayInfo); + + return findBestAllAppsSize(allAppsSizes, dimens[0]); + } + /** * @return the biggest grid size that fits the display dimensions. * If no best grid size is found, return null. @@ -658,6 +689,23 @@ public class InvariantDeviceProfile { return selectedGridSize; } + /** + * @return An `AllAppsSize` spec with min width at most `targetWidthPx`. + * If multiple specs are available, selects the one closest to the `targetWidthPx`. + */ + private static AllAppsSize findBestAllAppsSize(List list, int targetWidthPx) { + AllAppsSize selectedGridSize = null; + for (AllAppsSize item : list) { + if (targetWidthPx >= item.mMinDeviceWidthPx) { + if (selectedGridSize == null + || selectedGridSize.mMinDeviceWidthPx < item.mMinDeviceWidthPx) { + selectedGridSize = item; + } + } + } + return selectedGridSize; + } + private static int[] findMinWidthAndHeightPxForDevice(Info displayInfo) { int minDisplayWidthPx = Integer.MAX_VALUE; int minDisplayHeightPx = Integer.MAX_VALUE; @@ -1065,7 +1113,11 @@ public class InvariantDeviceProfile { private final int mAllAppsCellSpecsId; private final int mAllAppsCellSpecsTwoPanelId; private final int mGridSizeSpecsId; + private final int mAllAppsSizeSpecId; private final boolean mIsFixedLandscape; + // If non-negative, the index of workspace row with which the top of the all apps container + // should be aligned with. + private final int mAllAppsAlignedWithWorkspaceRow; public GridOption(Context context, AttributeSet attrs, Info displayInfo) { TypedArray a = context.obtainStyledAttributes( @@ -1078,6 +1130,10 @@ public class InvariantDeviceProfile { DEVICE_CATEGORY_ANY); mGridSizeSpecsId = a.getResourceId( R.styleable.GridDisplayOption_gridSizeSpecsId, INVALID_RESOURCE_HANDLE); + mAllAppsSizeSpecId = enableScalabilityForDesktopExperience() + ? a.getResourceId(R.styleable.GridDisplayOption_allAppsSizeSpecsId, + INVALID_RESOURCE_HANDLE) + : INVALID_RESOURCE_HANDLE; mIsDualGrid = a.getBoolean(R.styleable.GridDisplayOption_isDualGrid, false); if (mGridSizeSpecsId != INVALID_RESOURCE_HANDLE) { ResourceHelper resourceHelper = new ResourceHelper(context, mGridSizeSpecsId); @@ -1094,6 +1150,14 @@ public class InvariantDeviceProfile { R.styleable.GridDisplayOption_defaultLayoutId, 0); } + if (mAllAppsSizeSpecId != INVALID_RESOURCE_HANDLE) { + ResourceHelper resourceHelper = new ResourceHelper(context, mAllAppsSizeSpecId); + AllAppsSize allAppsSize = getAllAppsSize(resourceHelper, context, displayInfo); + mAllAppsAlignedWithWorkspaceRow = allAppsSize.mAlignWithWorkspaceRow; + } else { + mAllAppsAlignedWithWorkspaceRow = -1; + } + numSearchContainerColumns = a.getInt( R.styleable.GridDisplayOption_numSearchContainerColumns, numColumns); @@ -1293,6 +1357,31 @@ public class InvariantDeviceProfile { } } + /** + * Optional spec that configures the size of the all apps container. + * + * Allows the all apps height to be set so the top of the all apps container aligns with the + * top of a workspace row. + */ + private static final class AllAppsSize { + // The workspace row with which top of all apps container should be aligned with. + // Negative value will be ignored, and cause all apps container to fill up vertical space. + final int mAlignWithWorkspaceRow; + + // The minimum device pixel width to which the spec can be applied. + final float mMinDeviceWidthPx; + + AllAppsSize(Context context, AttributeSet attrs) { + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AllAppsSize); + + mAlignWithWorkspaceRow = a.getInt(R.styleable.AllAppsSize_alignWithWorkspaceRow, -1); + mMinDeviceWidthPx = a.getFloat(R.styleable.AllAppsSize_minDeviceWidthDp, 0) + * DisplayMetrics.DENSITY_DEVICE_STABLE / DisplayMetrics.DENSITY_DEFAULT; + + a.recycle(); + } + } + @VisibleForTesting static final class DisplayOption { public final GridOption grid; From 492a170aafeef4972a0be11406c1cfb70b94f815 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Tue, 20 May 2025 20:34:48 -0700 Subject: [PATCH 04/25] Remove RenderEffect on blur targets when no blur is desired. This change replaces 0 blur radius RenderEffect with null RenderEffect when no blur is needed. This is because even a 0 radius RenderEffect forces the targets to be rendered on a separate layer, which clips to the view bounds (overriding clipChildren="false") and likely creates a hit to performance. Demo: https://drive.google.com/file/d/1fuFP_yaqU2KSd28aUhpuopQg6KlMKv_w/view?usp=sharing&resourcekey=0-GWMy5kKhYVo-5u69XTzihQ Fix: 413784556 Bug: 413359333 Bug: 416815515 Test: enable all apps blur, enter spring loaded from All Apps and home Flag: com.android.launcher3.all_apps_blur Change-Id: I85b0ef6c8556866821679f2f02adb4938c6431d1 --- .../com/android/quickstep/util/BaseDepthController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/BaseDepthController.java b/quickstep/src/com/android/quickstep/util/BaseDepthController.java index e74ef806f0..068f0b01ee 100644 --- a/quickstep/src/com/android/quickstep/util/BaseDepthController.java +++ b/quickstep/src/com/android/quickstep/util/BaseDepthController.java @@ -323,10 +323,10 @@ public class BaseDepthController { // Only blur workspace if the current state wants to blur based on the target state. boolean shouldBlurWorkspace = stateManager.getCurrentStableState().shouldBlurWorkspace(stateManager.getState()); - // If blur is not desired, apply 0 blur to force reset. - int blurRadius = shouldBlurWorkspace ? mCurrentBlur : 0; - RenderEffect blurEffect = - RenderEffect.createBlurEffect(blurRadius, blurRadius, Shader.TileMode.DECAL); + RenderEffect blurEffect = shouldBlurWorkspace && mCurrentBlur > 0 + ? RenderEffect.createBlurEffect(mCurrentBlur, mCurrentBlur, Shader.TileMode.DECAL) + // If blur is not desired, clear the blur effect from the depth targets. + : null; mLauncher.getDepthBlurTargets().forEach(target -> target.setRenderEffect(blurEffect)); return shouldBlurWorkspace; } From 85ac41bc7f96024eb8eff0f2cedb159c0ee52e24 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 21 May 2025 19:23:53 -0700 Subject: [PATCH 05/25] Only ignore All Apps left/right insets on tablets. This was previously the case, but I think I mistakenly updated this to include phones with the all_apps_sheet_for_handheld flag at some point. However, there was also some broken logic with the panel bounds on phones. panel.getLeft() would be 0 because that's relative to the container, so we need to do getLeft() + panel.getLeft(). Landscape (camera on left): https://hsv.googleplex.com/5035787895701504 Seascape (camera on right): https://hsv.googleplex.com/6210562886205440 Portrait: https://hsv.googleplex.com/6563945312681984 Tablet: https://hsv.googleplex.com/6704696994562048 Bug: 419235232 Test: See HSVs above compared to before images in the bug Flag: com.android.launcher3.all_apps_sheet_for_handheld Change-Id: Id8b6f3367ee94ef22cb917e00518e843553b42d8 --- .../allapps/ActivityAllAppsContainerView.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 00054591dd..4d602dd01f 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -1199,8 +1199,8 @@ public class ActivityAllAppsContainerView applyAdapterSideAndBottomPaddings(grid); MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams(); - // Ignore left/right insets on bottom sheet because we are already centered in-screen. - if (grid.shouldShowAllAppsOnSheet()) { + // Ignore left/right insets on tablet because we are already centered in-screen. + if (grid.isTablet) { mlp.leftMargin = mlp.rightMargin = 0; } else { mlp.leftMargin = insets.left; @@ -1450,13 +1450,16 @@ public class ActivityAllAppsContainerView final float horizontalScaleOffset = (1 - scale) * panel.getWidth() / 2; final float verticalScaleOffset = (1 - scale) * (panel.getHeight() - getHeight() / 2); + // Left and right insets can be applied to this container, as well as the panel. + float left = getLeft() + panel.getLeft(); + float right = left + panel.getWidth(); final float topNoScale = panel.getTop() + translationY; final float topWithScale = topNoScale + verticalScaleOffset; - final float leftWithScale = panel.getLeft() + horizontalScaleOffset; - final float rightWithScale = panel.getRight() - horizontalScaleOffset; + final float leftWithScale = left + horizontalScaleOffset; + final float rightWithScale = right - horizontalScaleOffset; final float bottomWithOffset = panel.getBottom() + bottomOffsetPx; - // Draw full background panel for tablets. + // Draw full background panel if presenting on a sheet. int bottomSheetBackgroundColor = getBottomSheetBackgroundColor(); float bottomSheetBackgroundAlpha = Color.alpha(bottomSheetBackgroundColor) / 255.0f; if (hasBottomSheet) { @@ -1535,11 +1538,11 @@ public class ActivityAllAppsContainerView } mHeaderPaint.setAlpha((int) tabAlpha); } - float left = 0f; - float right = canvas.getWidth(); + left = 0f; + right = canvas.getWidth(); if (hasBottomSheet) { - left = mBottomSheetBackground.getLeft() + horizontalScaleOffset; - right = mBottomSheetBackground.getRight() - horizontalScaleOffset; + left = leftWithScale; + right = rightWithScale; } final float tabTopWithScale = hasBottomSheet From b8c5350c07ff8cd00762954849d0a60b2a586e98 Mon Sep 17 00:00:00 2001 From: Pierre Barbier de Reuille Date: Wed, 21 May 2025 23:28:19 +0100 Subject: [PATCH 06/25] Use the developer-option flag for pin to taskbar Test: Manual Flag: com.android.window.flags.enable_pinning_app_with_context_menu Bug: 375648361 Change-Id: I2c26ae6a5f42fd01860d7534b86ff5ca11e7f7fc --- .../com/android/launcher3/taskbar/PinToTaskbarShortcut.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt b/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt index b5623cc10b..2ed31d13a7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt +++ b/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt @@ -19,6 +19,7 @@ package com.android.launcher3.taskbar import android.content.Context import android.util.SparseArray import android.view.View +import android.window.DesktopExperienceFlags import com.android.launcher3.DeviceProfile import com.android.launcher3.LauncherAppState import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT @@ -28,7 +29,6 @@ import com.android.launcher3.model.data.ItemInfo import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.popup.SystemShortcut import com.android.launcher3.views.ActivityContext -import com.android.window.flags.Flags.enablePinningAppWithContextMenu /** * A single menu item shortcut to allow users to pin an item to the taskbar and unpin an item from @@ -91,8 +91,8 @@ class PinToTaskbarShortcut( } companion object { - fun isPinningAppWithContextMenuEnabled(context: TaskbarActivityContext): Boolean { - return enablePinningAppWithContextMenu() && context.isTaskbarShowingDesktopTasks - } + fun isPinningAppWithContextMenuEnabled(context: TaskbarActivityContext): Boolean = + DesktopExperienceFlags.ENABLE_PINNING_APP_WITH_CONTEXT_MENU.isTrue && + context.isTaskbarShowingDesktopTasks } } From 6e5225bd77e36c80cb233bd962650a09dab3a7cb Mon Sep 17 00:00:00 2001 From: helen cheuk Date: Thu, 15 May 2025 13:36:57 +0000 Subject: [PATCH 07/25] [Action Corner] Add padding between action corner and taskbar This is to avoid triggering unstashing taskbar and action corner at the same time. A padding is added between the two areas. Bug: 411091884 Test: TaplTestsTransientTaskbar Flag: com.android.systemui.shared.cursor_hot_corner Change-Id: I4e380a3d004977c96502af23f6126f22749e0a8f --- quickstep/res/values/dimens.xml | 1 + .../QuickstepTestInformationHandler.java | 15 +++++++ .../TaskbarUnstashInputConsumer.java | 30 +++++++++++++- .../quickstep/TaplTestsTransientTaskbar.java | 36 +++++++++++++---- .../testing/shared/TestProtocol.java | 6 +++ .../launcher3/tapl/LaunchedAppState.java | 39 +++++++++++++++++-- .../tapl/LauncherInstrumentation.java | 28 +++++++++++++ 7 files changed, 141 insertions(+), 14 deletions(-) diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index ee3f79d921..c2839b18db 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -398,6 +398,7 @@ 32dp 8dp 400dp + 48dp 8dp 16dp 4dp diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index 72a073acb7..f99ac39fa6 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -226,6 +226,21 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { resources.getDimensionPixelSize(R.dimen.task_dismiss_detach_threshold)); return response; } + + case TestProtocol.REQUEST_TASKBAR_ACTION_CORNER_PADDING: { + final Resources resources = mContext.getResources(); + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + resources.getDimensionPixelSize( + R.dimen.transient_taskbar_action_corner_padding)); + return response; + } + case TestProtocol.REQUEST_TASKBAR_UNSTASHED_INPUT_AREA: { + final Resources resources = mContext.getResources(); + response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, + resources.getDimensionPixelSize( + R.dimen.taskbar_unstash_input_area)); + return response; + } } return super.call(method, arg, extras); diff --git a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java index d5072d3bb5..476324ec23 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/TaskbarUnstashInputConsumer.java @@ -17,20 +17,26 @@ package com.android.quickstep.inputconsumers; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.INVALID_POINTER_ID; +import static android.view.RoundedCorner.POSITION_BOTTOM_LEFT; +import static android.view.RoundedCorner.POSITION_BOTTOM_RIGHT; import static com.android.launcher3.Flags.enableCursorHoverStates; import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation; import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TOUCHING; +import static com.android.systemui.shared.Flags.cursorHotCorner; import android.content.Context; import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; +import android.hardware.display.DisplayManager; import android.os.Handler; import android.os.Looper; +import android.view.Display; import android.view.InputDevice; import android.view.MotionEvent; +import android.view.RoundedCorner; import android.view.VelocityTracker; import android.view.ViewConfiguration; @@ -62,7 +68,9 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { private final TaskbarActivityContext mTaskbarActivityContext; private final OverviewCommandHelper mOverviewCommandHelper; + private final DisplayManager mDisplayManager; private final float mUnstashArea; + private final int mActionCornerPadding; private final int mTaskbarNavThreshold; private final int mTaskbarNavThresholdY; private final boolean mIsTaskbarAllAppsOpen; @@ -100,10 +108,13 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { mTaskbarActivityContext = taskbarActivityContext; mIsTransientTaskbar = DisplayController.isTransientTaskbar(context); mOverviewCommandHelper = overviewCommandHelper; + mDisplayManager = context.getSystemService(DisplayManager.class); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); Resources res = context.getResources(); mUnstashArea = res.getDimensionPixelSize(R.dimen.taskbar_unstash_input_area); + mActionCornerPadding = res.getDimensionPixelSize( + R.dimen.transient_taskbar_action_corner_padding); boolean pinnedTaskbarWithAutoStashing = mTaskbarActivityContext.shouldAllowTaskbarToAutoStash() && !mIsTransientTaskbar; @@ -284,7 +295,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { if (mIsStashedTaskbarHovered) { updateHoveredTaskbarState((int) ev.getX(), (int) ev.getY()); } else { - updateUnhoveredTaskbarState((int) ev.getX(), (int) ev.getY()); + updateUnhoveredTaskbarState((int) ev.getX(), (int) ev.getY(), ev.getDisplayId()); } } @@ -313,7 +324,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { } } - private void updateUnhoveredTaskbarState(int x, int y) { + private void updateUnhoveredTaskbarState(int x, int y, int displayId) { sUnstashHandler.removeCallbacksAndMessages(null); DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile(); @@ -323,6 +334,21 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer { dp.widthPx, dp.heightPx); + if (cursorHotCorner() && mDisplayManager != null) { + Display display = mDisplayManager.getDisplay(displayId); + if (display != null) { + RoundedCorner leftBottomCorner = display.getRoundedCorner(POSITION_BOTTOM_LEFT); + int leftCornerRadius = + leftBottomCorner == null ? 0 : leftBottomCorner.getRadius(); + RoundedCorner rightBottomCorner = display.getRoundedCorner( + POSITION_BOTTOM_RIGHT); + int rightCornerRadius = + rightBottomCorner == null ? 0 : rightBottomCorner.getRadius(); + mBottomEdgeBounds.inset(leftCornerRadius + mActionCornerPadding, 0, + rightCornerRadius + mActionCornerPadding, 0); + } + } + if (isStashedTaskbarHovered(x, y)) { // If enter hovering stashed taskbar, start hint. startStashedTaskbarHover(/* isHovered = */ true); diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java index 4b20d600dc..821d14fd35 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTransientTaskbar.java @@ -18,6 +18,7 @@ package com.android.quickstep; import static com.android.launcher3.Flags.enableCursorHoverStates; import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME; import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT; +import static com.android.systemui.shared.Flags.cursorHotCorner; import static org.junit.Assume.assumeTrue; @@ -41,14 +42,6 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar { mLauncher.getLaunchedAppState().hoverToShowTaskbarUnstashHint(); } - @Test - @TaskbarModeSwitch(mode = TRANSIENT) - public void testUnstashTaskbarOnScreenBottomEdgeHover() { - assumeTrue(enableCursorHoverStates()); - getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); - mLauncher.getLaunchedAppState().hoverScreenBottomEdgeToUnstashTaskbar(); - } - @Test @TaskbarModeSwitch(mode = TRANSIENT) public void testHoverBelowHintedTaskbarToUnstash() { @@ -71,4 +64,31 @@ public class TaplTestsTransientTaskbar extends AbstractTaplTestsTaskbar { getTaskbar().swipeDownToStash(); mLauncher.getLaunchedAppState().swipeUpToUnstashTaskbar(); } + + @Test + @TaskbarModeSwitch(mode = TRANSIENT) + public void testUnstashTaskbarOnScreenBottomEdgeHover() { + assumeTrue(enableCursorHoverStates()); + getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); + mLauncher.getLaunchedAppState().hoverScreenBottomEdgeToUnstashTaskbar(); + mLauncher.getLaunchedAppState().assertTaskbarVisible(); + } + + @Test + @TaskbarModeSwitch(mode = TRANSIENT) + public void testUnstashTaskbarOnScreenBottomEdgeOutsideActionCornerHover() { + assumeTrue(cursorHotCorner()); + getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); + mLauncher.getLaunchedAppState().hoverScreenBottomEdgeOutsideActionCornerToUnstashTaskbar(); + mLauncher.getLaunchedAppState().assertTaskbarVisible(); + } + + @Test + @TaskbarModeSwitch(mode = TRANSIENT) + public void testNotShowTaskbarOnActionCornerPaddingHover() { + assumeTrue(cursorHotCorner()); + getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE); + mLauncher.getLaunchedAppState().hoverScreenBottomCornerToTryUnstashTaskbar(); + mLauncher.getLaunchedAppState().assertTaskbarHidden(); + } } diff --git a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java index b02695c137..eccc5e7cdc 100644 --- a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -189,6 +189,12 @@ public final class TestProtocol { public static final String REQUEST_DISMISS_MAGNETIC_DETACH_THRESHOLD = "dismiss-magnetic-detach-threshold"; + public static final String REQUEST_TASKBAR_ACTION_CORNER_PADDING = + "taskbar-action-corner-padding"; + + public static final String REQUEST_TASKBAR_UNSTASHED_INPUT_AREA = + "taskbar-unstashed-input-area"; + /** Logs {@link Log#d(String, String)} if {@link #sDebugTracing} is true. */ public static void testLogD(String tag, String message) { if (!sDebugTracing) { diff --git a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java index d3467ca725..a3262b2085 100644 --- a/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java +++ b/tests/tapl/com/android/launcher3/tapl/LaunchedAppState.java @@ -36,6 +36,7 @@ import android.view.ViewConfiguration; import androidx.annotation.NonNull; import androidx.test.uiautomator.Condition; import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject2; import com.android.launcher3.tapl.Taskbar.TaskbarLocation; import com.android.launcher3.testing.shared.ResourceUtils; @@ -240,26 +241,56 @@ public final class LaunchedAppState extends Background { *

This unstashing occurs when not actively hovering the taskbar. */ public Taskbar hoverScreenBottomEdgeToUnstashTaskbar() { + return hoverScreenBottomEdgeToTryUnstashTaskbar(/* leftEdge= */ + (mLauncher.getRealDisplaySize().x - mLauncher.getTaskbarUnstashInputArea()) / 2 + - 1); + } + + /** + * Emulate the cursor hovering the screen edge outside of action corner area to unstash the + * taskbar. + */ + public Taskbar hoverScreenBottomEdgeOutsideActionCornerToUnstashTaskbar() { + return hoverScreenBottomEdgeToTryUnstashTaskbar(/* leftEdge= */ + getLauncher().getActionCornerPadding()); + } + + /** + * Emulate the cursor hovering the screen edge in action corner padding to try unstashing the + * taskbar. + */ + public Taskbar hoverScreenBottomCornerToTryUnstashTaskbar() { + // Add 1 pixel to avoid triggering action corner which will affect test result + return hoverScreenBottomEdgeToTryUnstashTaskbar( + mLauncher.getDisplayBottomCornerRadius() + 1); + } + + private Taskbar hoverScreenBottomEdgeToTryUnstashTaskbar(int leftEdge) { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( - "cursor hover entering screen edge to unstash taskbar")) { + "cursor hover entering screen edge to try unstashing taskbar")) { mLauncher.getDevice().wait(mStashedTaskbarDefaultScaleCondition, ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT); long downTime = SystemClock.uptimeMillis(); - int leftEdge = 10; Point taskbarUnstashArea = new Point(leftEdge, mLauncher.getRealDisplaySize().y - 1); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER, new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null, InputDevice.SOURCE_MOUSE); - mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID); + UiObject2 taskbar = mLauncher.tryWaitForLauncherObject( + mLauncher.getLauncherObjectSelector(TASKBAR_RES_ID), + WAIT_TIME_MS); mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT, new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null, InputDevice.SOURCE_MOUSE); - return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); + if (taskbar == null) { + return null; + } else { + return new Taskbar(mLauncher, TaskbarLocation.LAUNCHED_APP); + } } } diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 3e3bdeca6f..05f7ffcec5 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -22,10 +22,12 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED; import static android.content.pm.PackageManager.DONT_KILL_APP; import static android.content.pm.PackageManager.MATCH_ALL; import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS; +import static android.view.Display.DEFAULT_DISPLAY; import static android.view.KeyEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_SCROLL; import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.AXIS_GESTURE_SWIPE_FINGER_COUNT; +import static android.view.RoundedCorner.POSITION_BOTTOM_LEFT; import static android.view.Surface.ROTATION_90; import static com.android.launcher3.tapl.Folder.FOLDER_CONTENT_RES_ID; @@ -51,6 +53,7 @@ import android.content.res.Resources; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; +import android.hardware.display.DisplayManager; import android.net.Uri; import android.os.Bundle; import android.os.DeadObjectException; @@ -60,6 +63,7 @@ import android.os.SystemClock; import android.os.Trace; import android.text.TextUtils; import android.util.Log; +import android.view.Display; import android.view.InputDevice; import android.view.InputEvent; import android.view.KeyCharacterMap; @@ -95,6 +99,7 @@ import java.util.Arrays; import java.util.Deque; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.TimeoutException; import java.util.function.BooleanSupplier; @@ -2460,6 +2465,17 @@ public final class LauncherInstrumentation { return new Point(displayBounds.width(), displayBounds.height()); } + int getActionCornerPadding() { + return getDisplayBottomCornerRadius() + getTaskbarActionCornerPadding(); + } + + int getDisplayBottomCornerRadius() { + final Display display = Objects.requireNonNull( + getContext().getSystemService(DisplayManager.class)) + .getDisplay(DEFAULT_DISPLAY); + return display.getRoundedCorner(POSITION_BOTTOM_LEFT).getRadius(); + } + public void enableDebugTracing() { getTestInfo(TestProtocol.REQUEST_ENABLE_DEBUG_TRACING); } @@ -2792,4 +2808,16 @@ public final class LauncherInstrumentation { return getTestInfo(TestProtocol.REQUEST_DISMISS_MAGNETIC_DETACH_THRESHOLD).getInt( TestProtocol.TEST_INFO_RESPONSE_FIELD); } + + /** Returns the taskbar action corner padding. */ + public int getTaskbarActionCornerPadding() { + return getTestInfo(TestProtocol.REQUEST_TASKBAR_ACTION_CORNER_PADDING).getInt( + TestProtocol.TEST_INFO_RESPONSE_FIELD); + } + + /** Returns the taskbar unstash input area. */ + public int getTaskbarUnstashInputArea() { + return getTestInfo(TestProtocol.REQUEST_TASKBAR_UNSTASHED_INPUT_AREA).getInt( + TestProtocol.TEST_INFO_RESPONSE_FIELD); + } } From 61aab4893bf5e211bcba176b447ea2afc03af1c3 Mon Sep 17 00:00:00 2001 From: Rob Mickle Date: Mon, 19 May 2025 17:50:56 -0700 Subject: [PATCH 08/25] Update test to use fake repository instead of mock. Bug: 378443899 Test: OverviewCommandHelperTest Flag: EXEMPT test cleanup up Change-Id: Ie449a659bf6b1b33acbb6f9f6f45b800e31cf447 --- .../src/com/android/quickstep/OverviewCommandHelperTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt index 8f3f74357e..d98cb989b5 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/OverviewCommandHelperTest.kt @@ -20,6 +20,7 @@ import android.content.Intent import android.view.Display.DEFAULT_DISPLAY import androidx.test.filters.SmallTest import com.android.app.displaylib.DisplayRepository +import com.android.app.displaylib.fakes.FakePerDisplayRepository import com.android.app.displaylib.PerDisplayRepository import com.android.launcher3.LauncherState import com.android.launcher3.statemanager.StateManager @@ -96,8 +97,6 @@ class OverviewCommandHelperTest { whenever(overviewComponentObserver.getHomeIntent(any())).thenReturn(mock()) whenever(recentView.getStateManager()).thenReturn(stateManager) whenever(containerInterface.switchToRecentsIfVisible(any())).thenReturn(true) - val taskAnimationManagerRepository = mock>() - whenever(taskAnimationManagerRepository.get(any())).thenReturn(taskAnimationManager) whenever(taskAnimationManager.maybeStartHomeAction(any())).thenAnswer { invocation -> invocation.getArgument(0).run() } @@ -110,7 +109,8 @@ class OverviewCommandHelperTest { dispatcherProvider = TestDispatcherProvider(dispatcher), displayRepository = displayRepository, taskbarManager = mock(), - taskAnimationManagerRepository = taskAnimationManagerRepository, + taskAnimationManagerRepository = + FakePerDisplayRepository { _ -> taskAnimationManager }, elapsedRealtime = ::elapsedRealtime, ) ) From 4de09ab0ee3b3c78bb88ecf399182a6813d314f4 Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Fri, 16 May 2025 15:28:40 +0100 Subject: [PATCH 09/25] Update build to support Compose tests custom directory - Support for Compose Screenshot tests using ScreenshotComposeLib. - Support for custom directory for tests to be used when compose flag is enabled. Bug: 400436593 Fix: 366387927 Flag: EXEMPT Build flag: RELEASE_ENABLE_COMPOSE_IN_LAUNCHER Test: Build Change-Id: I9a5a5fd4942da2b5d8be0e554e1a42b1cde5f2af --- Android.bp | 111 +++++++++++++++++++++++--------------- tests/AndroidManifest.xml | 1 + 2 files changed, 68 insertions(+), 44 deletions(-) diff --git a/Android.bp b/Android.bp index d10ff1a908..28936b41bc 100644 --- a/Android.bp +++ b/Android.bp @@ -61,6 +61,13 @@ filegroup { ], } +filegroup { + name: "launcher-compose-tests-src", + srcs: [ + "compose/tests/**/*.kt", + ], +} + // Source code for quickstep build, on top of launcher-src filegroup { name: "launcher-quickstep-src", @@ -73,6 +80,13 @@ filegroup { ], } +filegroup { + name: "quickstep-compose-tests-src", + srcs: [ + "quickstep/compose/tests/**/*.kt", + ], +} + // Launcher ProtoLog support filegroup { name: "launcher-quickstep-unprocessed-protolog-src", @@ -185,6 +199,10 @@ filegroup { srcs: ["proguard.flags"], } +soong_config_bool_variable { + name: "release_enable_compose_in_launcher", +} + // Opt-in configuration for Launcher3 code depending on Jetpack Compose. soong_config_module_type { name: "launcher_compose_java_defaults", @@ -197,32 +215,6 @@ soong_config_module_type { ], } -// Opt-in configuration for Launcher Quickstep code depending on Jetpack Compose. -soong_config_bool_variable { - name: "release_enable_compose_in_launcher", -} - -soong_config_module_type { - name: "quickstep_compose_java_defaults", - module_type: "java_defaults", - config_namespace: "ANDROID", - bool_variables: ["release_enable_compose_in_launcher"], - properties: [ - "srcs", - "static_libs", - ], -} - -soong_config_module_type { - name: "launcher_compose_tests_java_defaults", - module_type: "java_defaults", - config_namespace: "ANDROID", - bool_variables: ["release_enable_compose_in_launcher"], - properties: [ - "static_libs", - ], -} - launcher_compose_java_defaults { name: "launcher_compose_defaults", soong_config_variables: { @@ -235,6 +227,8 @@ launcher_compose_java_defaults { static_libs: [ "androidx.compose.runtime_runtime", "androidx.compose.material3_material3", + "androidx.compose.ui_ui-tooling-preview", + "androidx.compose.ui_ui-tooling", ], // By default, Compose is disabled and we compile the ComposeFacade @@ -249,6 +243,51 @@ launcher_compose_java_defaults { }, } +soong_config_module_type { + name: "launcher_compose_tests_java_defaults", + module_type: "java_defaults", + config_namespace: "ANDROID", + bool_variables: ["release_enable_compose_in_launcher"], + properties: [ + "srcs", + "static_libs", + ], +} + +launcher_compose_tests_java_defaults { + name: "launcher_compose_tests_defaults", + soong_config_variables: { + release_enable_compose_in_launcher: { + srcs: [ + ":launcher-compose-tests-src", + ], + // Compose dependencies + static_libs: [ + "androidx.compose.runtime_runtime", + "androidx.compose.ui_ui-test-junit4", + "androidx.compose.ui_ui-test-manifest", + ], + + conditions_default: { + srcs: [], + static_libs: [], + }, + }, + }, +} + +// Opt-in configuration for Launcher Quickstep code depending on Jetpack Compose. +soong_config_module_type { + name: "quickstep_compose_java_defaults", + module_type: "java_defaults", + config_namespace: "ANDROID", + bool_variables: ["release_enable_compose_in_launcher"], + properties: [ + "srcs", + "static_libs", + ], +} + quickstep_compose_java_defaults { name: "quickstep_compose_defaults", soong_config_variables: { @@ -261,6 +300,8 @@ quickstep_compose_java_defaults { static_libs: [ "androidx.compose.runtime_runtime", "androidx.compose.material3_material3", + "androidx.compose.ui_ui-tooling-preview", + "androidx.compose.ui_ui-tooling", ], // By default, Compose is disabled and we compile the ComposeFacade @@ -275,24 +316,6 @@ quickstep_compose_java_defaults { }, } -launcher_compose_tests_java_defaults { - name: "launcher_compose_tests_defaults", - soong_config_variables: { - release_enable_compose_in_launcher: { - // Compose dependencies - static_libs: [ - "androidx.compose.runtime_runtime", - "androidx.compose.ui_ui-test-junit4", - "androidx.compose.ui_ui-test-manifest", - ], - - conditions_default: { - static_libs: [], - }, - }, - }, -} - android_library { name: "launcher-aosp-tapl", libs: [ diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 862b862ab3..51cfe2398e 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -23,6 +23,7 @@ + Date: Thu, 22 May 2025 11:46:57 -0700 Subject: [PATCH 10/25] Prevent recents rotation animation if we are in Fixed Landscape When in this mode we can let the system rotate the device. In other cases we have a fake rotation and so we need to manually rotate. Fix: 401484242 Flag: com.android.launcher3.one_grid_specs Test: Manual testing Change-Id: I74e5cb0363a34edb69b39f9a387b9020116d5632 --- quickstep/src/com/android/quickstep/views/RecentsView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 5bd44c1ab5..5575ff8272 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2951,7 +2951,8 @@ public abstract class RecentsView< } private void animateRecentsRotationInPlace(int newRotation) { - if (mOrientationState.isRecentsActivityRotationAllowed()) { + if (mOrientationState.isRecentsActivityRotationAllowed() + || mOrientationState.isLauncherFixedLandscape()) { // Let system take care of the rotation return; } From 1fcb21621bd85f5fadc2c7274a745c901ac51490 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Thu, 22 May 2025 12:03:30 -0700 Subject: [PATCH 11/25] Removing getOnceNotNull from BaseLauncherActivityTest to launcherActivity This is to make tests by composition instead of inheritance. Bug: 324261526 Flag: EXEMPT test only Test: All test using BaseLauncherActivityTest Change-Id: I616207da890e1979480d1b748f69a9c27c53f9db --- .../quickstep/DigitalWellBeingToastTest.java | 5 ++++- .../util/LauncherActivityScenarioRule.kt | 14 ++++++++++++++ .../launcher3/util/BaseLauncherActivityTest.kt | 14 -------------- .../launcher3/widget/AddConfigWidgetTest.java | 15 ++++++++++----- .../launcher3/widget/BindWidgetTest.java | 10 ++++++++-- .../launcher3/widget/RequestPinItemTest.java | 5 ++++- .../launcher3/workspace/ThemeIconsTest.java | 18 ++++++++++++------ 7 files changed, 52 insertions(+), 29 deletions(-) diff --git a/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java b/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java index 1b71d965fb..8ee0494bd1 100644 --- a/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java +++ b/quickstep/tests/src/com/android/quickstep/DigitalWellBeingToastTest.java @@ -102,7 +102,10 @@ public class DigitalWellBeingToastTest extends BaseLauncherActivityTest getLatestTask(launcher)); + final TaskView task = getLauncherActivity().getOnceNotNull( + "No latest task", + launcher -> getLatestTask(launcher) + ); return getLauncherActivity().getFromLauncher(launcher -> { TaskContainer taskContainer = task.getFirstTaskContainer(); diff --git a/tests/src/com/android/launcher3/integration/util/LauncherActivityScenarioRule.kt b/tests/src/com/android/launcher3/integration/util/LauncherActivityScenarioRule.kt index 5cea5e5f08..a38c23658f 100644 --- a/tests/src/com/android/launcher3/integration/util/LauncherActivityScenarioRule.kt +++ b/tests/src/com/android/launcher3/integration/util/LauncherActivityScenarioRule.kt @@ -32,6 +32,7 @@ import com.android.launcher3.integration.util.events.ActivityTestEvents.createSt import com.android.launcher3.tapl.TestHelpers import com.android.launcher3.util.Executors import com.android.launcher3.util.TestUtil +import com.android.launcher3.util.Wait.atMost import java.util.ArrayDeque import java.util.Queue import java.util.concurrent.atomic.AtomicReference @@ -98,6 +99,19 @@ open class LauncherActivityScenarioRule( stateWaiter.waitForSignal() } + fun getOnceNotNull(message: String, f: Function): T? { + var output: T? = null + atMost( + message, + { + val fromLauncher = getFromLauncher { f.apply(it) } + output = fromLauncher + fromLauncher != null + }, + ) + return output + } + /** * For the given view, it iterates over all of the child views in a preorder traversal returning * the first match to the filter diff --git a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt index ecf4606956..4bc51c842b 100644 --- a/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt +++ b/tests/src/com/android/launcher3/util/BaseLauncherActivityTest.kt @@ -35,7 +35,6 @@ import com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST import com.android.launcher3.integration.util.LauncherActivityScenarioRule import com.android.launcher3.util.ModelTestExtensions.loadModelSync import com.android.launcher3.util.Wait.atMost -import java.util.function.Function import java.util.function.Predicate import java.util.function.Supplier import org.junit.Rule @@ -72,19 +71,6 @@ open class BaseLauncherActivityTest { timeout: Long, ) = atMost(message, { launcherActivity.getFromLauncher(condition)!! }, null, timeout) - protected fun getOnceNotNull(message: String, f: Function): T? { - var output: T? = null - atMost( - message, - { - val fromLauncher = launcherActivity.getFromLauncher { f.apply(it) } - output = fromLauncher - fromLauncher != null - }, - ) - return output - } - @JvmOverloads protected fun injectKeyEvent(keyCode: Int, actionDown: Boolean, metaState: Int = 0) { uiDevice.waitForIdle() diff --git a/tests/src/com/android/launcher3/widget/AddConfigWidgetTest.java b/tests/src/com/android/launcher3/widget/AddConfigWidgetTest.java index cde9d80381..cae800335d 100644 --- a/tests/src/com/android/launcher3/widget/AddConfigWidgetTest.java +++ b/tests/src/com/android/launcher3/widget/AddConfigWidgetTest.java @@ -116,10 +116,15 @@ public class AddConfigWidgetTest extends BaseLauncherActivityTest { }); uiDevice.waitForIdle(); - View widgetView = getOnceNotNull("Widget not found", l -> searchView(l.getDragLayer(), v -> - v instanceof WidgetCell - && v.getTag() instanceof PendingAddWidgetInfo pawi - && mWidgetInfo.provider.equals(pawi.componentName))); + View widgetView = getLauncherActivity() + .getOnceNotNull("Widget not found", + l -> searchView( + l.getDragLayer(), + v -> v instanceof WidgetCell + && v.getTag() instanceof PendingAddWidgetInfo pawi + && mWidgetInfo.provider.equals(pawi.componentName) + ) + ); addWidgetToWorkspace(widgetView); // Widget id for which the config activity was opened @@ -130,7 +135,7 @@ public class AddConfigWidgetTest extends BaseLauncherActivityTest { setResult(acceptConfig); if (acceptConfig) { - getOnceNotNull("Widget was not added", l -> { + getLauncherActivity().getOnceNotNull("Widget was not added", l -> { // Close the resize frame before searching for widget AbstractFloatingView.closeAllOpenViews(l); return l.getWorkspace().getFirstMatch(new WidgetSearchCondition()); diff --git a/tests/src/com/android/launcher3/widget/BindWidgetTest.java b/tests/src/com/android/launcher3/widget/BindWidgetTest.java index 1bfd5a9a34..3285f8dfc9 100644 --- a/tests/src/com/android/launcher3/widget/BindWidgetTest.java +++ b/tests/src/com/android/launcher3/widget/BindWidgetTest.java @@ -227,11 +227,17 @@ public class BindWidgetTest extends BaseLauncherActivityTest { } private void verifyWidgetPresent(LauncherAppWidgetProviderInfo info) { - getOnceNotNull("Widget is not present", widgetProvider(info)); + getLauncherActivity().getOnceNotNull( + "Widget is not present", + widgetProvider(info) + ); } private void verifyPendingWidgetPresent() { - getOnceNotNull("Widget is not present", pendingWidgetProvider()); + getLauncherActivity().getOnceNotNull( + "Widget is not present", + pendingWidgetProvider() + ); } private Function pendingWidgetProvider() { diff --git a/tests/src/com/android/launcher3/widget/RequestPinItemTest.java b/tests/src/com/android/launcher3/widget/RequestPinItemTest.java index 393dc56f63..297f0465bb 100644 --- a/tests/src/com/android/launcher3/widget/RequestPinItemTest.java +++ b/tests/src/com/android/launcher3/widget/RequestPinItemTest.java @@ -187,6 +187,9 @@ public class RequestPinItemTest extends BaseLauncherActivityTest { // Reload activity, so that the activity is focused getLauncherActivity().close(); loadLauncherSync(); - getOnceNotNull("", l -> l.getWorkspace().getFirstMatch(itemMatcher)); + getLauncherActivity().getOnceNotNull( + "", + l -> l.getWorkspace().getFirstMatch(itemMatcher) + ); } } diff --git a/tests/src/com/android/launcher3/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/workspace/ThemeIconsTest.java index 6e2b87e209..f3f3fd9331 100644 --- a/tests/src/com/android/launcher3/workspace/ThemeIconsTest.java +++ b/tests/src/com/android/launcher3/workspace/ThemeIconsTest.java @@ -84,9 +84,12 @@ public class ThemeIconsTest extends BaseLauncherActivityTest { l -> findBtv(TEST_APP_NAME, l.getAppsView())); TestUtil.runOnExecutorSync(MAIN_EXECUTOR, btv::performLongClick); - BubbleTextView menuItem = getOnceNotNull("Popup menu not open", l -> - (AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) instanceof ArrowPopup ap) - ? findBtv(SHORTCUT_NAME, ap) : null); + BubbleTextView menuItem = getLauncherActivity().getOnceNotNull( + "Popup menu not open", + l -> (AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) + instanceof ArrowPopup ap) + ? findBtv(SHORTCUT_NAME, ap) : null + ); addToWorkspace(menuItem); getLauncherActivity().executeOnLauncher( l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), false)); @@ -120,9 +123,12 @@ public class ThemeIconsTest extends BaseLauncherActivityTest { l -> findBtv(TEST_APP_NAME, l.getAppsView())); TestUtil.runOnExecutorSync(MAIN_EXECUTOR, btv::performLongClick); - BubbleTextView menuItem = getOnceNotNull("Popup menu not open", l -> - (AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) instanceof ArrowPopup ap) - ? findBtv(SHORTCUT_NAME, ap) : null); + BubbleTextView menuItem = getLauncherActivity().getOnceNotNull( + "Popup menu not open", + l -> (AbstractFloatingView.getOpenView(l, TYPE_ACTION_POPUP) + instanceof ArrowPopup ap) + ? findBtv(SHORTCUT_NAME, ap) : null + ); addToWorkspace(menuItem); getLauncherActivity().executeOnLauncher( l -> verifyIconTheme(SHORTCUT_NAME, l.getWorkspace(), true)); From 57135a85253e9709dcb9e305b95fabe187c9269b Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 22 May 2025 22:02:34 +0000 Subject: [PATCH 12/25] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I0bb238bbdc8fd0695d3bdbabd24403f471bf310a --- quickstep/res/values-ar/strings.xml | 3 +-- quickstep/res/values-be/strings.xml | 3 +-- quickstep/res/values-ca/strings.xml | 3 +-- quickstep/res/values-en-rCA/strings.xml | 3 +-- quickstep/res/values-es/strings.xml | 3 +-- quickstep/res/values-fi/strings.xml | 3 +-- quickstep/res/values-is/strings.xml | 3 +-- quickstep/res/values-ja/strings.xml | 3 +-- quickstep/res/values-km/strings.xml | 5 ++--- quickstep/res/values-lo/strings.xml | 3 +-- quickstep/res/values-mk/strings.xml | 3 +-- quickstep/res/values-ml/strings.xml | 3 +-- quickstep/res/values-ms/strings.xml | 3 +-- quickstep/res/values-or/strings.xml | 3 +-- quickstep/res/values-pt-rPT/strings.xml | 3 +-- quickstep/res/values-ru/strings.xml | 3 +-- quickstep/res/values-sk/strings.xml | 4 ++-- quickstep/res/values-sl/strings.xml | 3 +-- quickstep/res/values-th/strings.xml | 3 +-- quickstep/res/values-uz/strings.xml | 3 +-- 20 files changed, 22 insertions(+), 41 deletions(-) diff --git a/quickstep/res/values-ar/strings.xml b/quickstep/res/values-ar/strings.xml index 96da1c1d37..1744a5cfbb 100644 --- a/quickstep/res/values-ar/strings.xml +++ b/quickstep/res/values-ar/strings.xml @@ -23,8 +23,7 @@ "شكل مجاني" "الكمبيوتر المكتبي" "نقل التطبيق إلى شاشة خارجية" - - + "محو" "كمبيوتر مكتبي" "ما مِن عناصر تم استخدامها مؤخرًا" "إعدادات استخدام التطبيق" diff --git a/quickstep/res/values-be/strings.xml b/quickstep/res/values-be/strings.xml index 3575550e55..38cbc22f13 100644 --- a/quickstep/res/values-be/strings.xml +++ b/quickstep/res/values-be/strings.xml @@ -23,8 +23,7 @@ "Адвольная форма" "Працоўны стол" "Перамясціць на знешні дысплэй" - - + "Ачысціць" "Працоўны стол" "Няма новых элементаў" "Налады выкарыстання праграмы" diff --git a/quickstep/res/values-ca/strings.xml b/quickstep/res/values-ca/strings.xml index 66b7683b26..137ff006e4 100644 --- a/quickstep/res/values-ca/strings.xml +++ b/quickstep/res/values-ca/strings.xml @@ -23,8 +23,7 @@ "Format lliure" "Escriptori" "Mou a la pantalla externa" - - + "Esborra" "Escriptori" "No hi ha cap element recent" "Configuració d\'ús d\'aplicacions" diff --git a/quickstep/res/values-en-rCA/strings.xml b/quickstep/res/values-en-rCA/strings.xml index 6a95a2a5e1..677576db53 100644 --- a/quickstep/res/values-en-rCA/strings.xml +++ b/quickstep/res/values-en-rCA/strings.xml @@ -23,8 +23,7 @@ "Freeform" "Desktop" "Move to external display" - - + "Clear" "Desktop" "No recent items" "App usage settings" diff --git a/quickstep/res/values-es/strings.xml b/quickstep/res/values-es/strings.xml index 687188e191..0522e4d3fd 100644 --- a/quickstep/res/values-es/strings.xml +++ b/quickstep/res/values-es/strings.xml @@ -23,8 +23,7 @@ "Formato libre" "Escritorio" "Mover a pantalla externa" - - + "Borrar" "Ordenador" "No hay nada reciente" "Ajustes de uso de la aplicación" diff --git a/quickstep/res/values-fi/strings.xml b/quickstep/res/values-fi/strings.xml index a71b2c23b6..ee4498f4b0 100644 --- a/quickstep/res/values-fi/strings.xml +++ b/quickstep/res/values-fi/strings.xml @@ -23,8 +23,7 @@ "Vapaamuotoinen" "Tietokone" "Siirrä ulkoiselle näytölle" - - + "Tyhjennä" "Tietokone" "Ei viimeaikaisia kohteita" "Sovelluksen käyttöasetukset" diff --git a/quickstep/res/values-is/strings.xml b/quickstep/res/values-is/strings.xml index b43bb7dd6c..6de1a0c26a 100644 --- a/quickstep/res/values-is/strings.xml +++ b/quickstep/res/values-is/strings.xml @@ -23,8 +23,7 @@ "Frjálst snið" "Tölva" "Færa í annað tæki" - - + "Hreinsa" "Tölva" "Engin nýleg atriði" "Notkunarstillingar forrits" diff --git a/quickstep/res/values-ja/strings.xml b/quickstep/res/values-ja/strings.xml index 1f3b6cdec9..ed688a371a 100644 --- a/quickstep/res/values-ja/strings.xml +++ b/quickstep/res/values-ja/strings.xml @@ -23,8 +23,7 @@ "フリーフォーム" "デスクトップ" "外部ディスプレイに移動する" - - + "消去" "デスクトップ" "最近のアイテムはありません" "アプリの使用状況の設定" diff --git a/quickstep/res/values-km/strings.xml b/quickstep/res/values-km/strings.xml index 0483326cb2..aeea8b85c2 100644 --- a/quickstep/res/values-km/strings.xml +++ b/quickstep/res/values-km/strings.xml @@ -23,8 +23,7 @@ "មុខងារទម្រង់សេរី" "ដែសថប" "ផ្លាស់ទីទៅផ្ទាំងអេក្រង់ខាងក្រៅ" - - + "សម្អាត" "អេក្រង់ដើម" "មិនមានធាតុថ្មីៗទេ" "ការកំណត់​ការប្រើប្រាស់​កម្មវិធី" @@ -95,7 +94,7 @@ "អ្នកអាចចាប់ផ្ដើមប្រើឧបករណ៍របស់អ្នកបានហើយ" "ការកំណត់​ការរុករក​ប្រព័ន្ធ" "ចែករំលែក" - "រូបថតអេក្រង់" + "ថតរូបអេក្រង់" "បំបែក" "រក្សាទុកគូកម្មវិធី" "ចុចកម្មវិធី​ផ្សេងទៀត ដើម្បីប្រើ​មុខងារបំបែកអេក្រង់" diff --git a/quickstep/res/values-lo/strings.xml b/quickstep/res/values-lo/strings.xml index aba635eb42..78b100770b 100644 --- a/quickstep/res/values-lo/strings.xml +++ b/quickstep/res/values-lo/strings.xml @@ -23,8 +23,7 @@ "ຮູບແບບອິດສະຫລະ" "ເດັສທັອບ" "ຍ້າຍໄປຫາຈໍສະແດງຜົນພາຍນອກ" - - + "ລຶບລ້າງ" "ເດັສທັອບ" "ບໍ່ມີລາຍການຫຼ້າສຸດ" "ການຕັ້ງຄ່າການນຳໃຊ້ແອັບ" diff --git a/quickstep/res/values-mk/strings.xml b/quickstep/res/values-mk/strings.xml index 2a4b29986b..3ea50e9ab7 100644 --- a/quickstep/res/values-mk/strings.xml +++ b/quickstep/res/values-mk/strings.xml @@ -23,8 +23,7 @@ "Freeform" "Работна површина" "Префрлете се на надворешниот екран" - - + "Избришете" "За компјутер" "Нема неодамнешни ставки" "Поставки за користење на апликациите" diff --git a/quickstep/res/values-ml/strings.xml b/quickstep/res/values-ml/strings.xml index 323a518045..dc201705ac 100644 --- a/quickstep/res/values-ml/strings.xml +++ b/quickstep/res/values-ml/strings.xml @@ -23,8 +23,7 @@ "ഫ്രീഫോം" "ഡെസ്‌ക്ടോപ്പ്" "ബാഹ്യ ഡിസ്‌പ്ലേയിലേക്ക് നീക്കുക" - - + "മായ്ക്കുക" "ഡെസ്‌ക്ടോപ്പ്" "സമീപകാല ഇനങ്ങൾ ഒന്നുമില്ല" "ആപ്പ് ഉപയോഗ ക്രമീകരണം" diff --git a/quickstep/res/values-ms/strings.xml b/quickstep/res/values-ms/strings.xml index 8b65dd680a..18c198d9e2 100644 --- a/quickstep/res/values-ms/strings.xml +++ b/quickstep/res/values-ms/strings.xml @@ -23,8 +23,7 @@ "Bentuk bebas" "Desktop" "Alihkan kepada paparan luaran" - - + "Kosongkan" "Desktop" "Tiada item terbaharu" "Tetapan penggunaan apl" diff --git a/quickstep/res/values-or/strings.xml b/quickstep/res/values-or/strings.xml index 8f43ddc941..a031f88e77 100644 --- a/quickstep/res/values-or/strings.xml +++ b/quickstep/res/values-or/strings.xml @@ -23,8 +23,7 @@ "ଫ୍ରିଫର୍ମ" "ଡେସ୍କଟପ" "ଏକ୍ସଟର୍ନଲ ଡିସପ୍ଲେକୁ ମୁଭ କରନ୍ତୁ" - - + "ଖାଲି କରନ୍ତୁ" "ଡେସ୍କଟପ" "ବର୍ତ୍ତମାନର କୌଣସି ଆଇଟମ ନାହିଁ" "ଆପ ବ୍ୟବହାର ସେଟିଂସ" diff --git a/quickstep/res/values-pt-rPT/strings.xml b/quickstep/res/values-pt-rPT/strings.xml index ccade35a40..91729b5954 100644 --- a/quickstep/res/values-pt-rPT/strings.xml +++ b/quickstep/res/values-pt-rPT/strings.xml @@ -23,8 +23,7 @@ "Forma livre" "Computador" "Mover para o ecrã externo" - - + "Limpar" "Computador" "Nenhum item recente" "Definições de utilização de aplicações" diff --git a/quickstep/res/values-ru/strings.xml b/quickstep/res/values-ru/strings.xml index 14b27089c1..228ad0f854 100644 --- a/quickstep/res/values-ru/strings.xml +++ b/quickstep/res/values-ru/strings.xml @@ -23,8 +23,7 @@ "Произвольная форма" "Мультиоконный режим" "Перенести на внешний дисплей" - - + "Очистить" "Мультиоконный режим" "Здесь пока ничего нет." "Настройки использования приложения" diff --git a/quickstep/res/values-sk/strings.xml b/quickstep/res/values-sk/strings.xml index e93b4c08d2..1a1b42d673 100644 --- a/quickstep/res/values-sk/strings.xml +++ b/quickstep/res/values-sk/strings.xml @@ -55,7 +55,7 @@ "Musíte potiahnuť z pravého alebo ľavého okraja do stredu obrazovky a potom uvoľniť" "Naučili ste sa prejsť späť potiahnutím sprava. V ďalšom kroku sa naučíte prepínať aplikácie." "Dokončili ste gesto na prechod späť. V ďalšom kroku sa naučíte, ako prepínať aplikácie." - "Použili ste gesto na prechod späť." + "Dokončili ste gesto na prechod späť" "Nesmiete potiahnuť príliš blízko dolnej časti obrazovky" "Ak chcete zmeniť citlivosť gesta Späť, prejdite do Nastavení" "Prechod späť potiahnutím" @@ -76,7 +76,7 @@ "Skúste okno pred uvoľnením podržať dlhšie" "Musite potiahnuť priamo nahor a potom zastať." "Naučili ste sa používať gestá. Gestá môžete vypnúť v Nastaveniach." - "Použili ste gesto na prepnutie aplikácií." + "Dokončili ste gesto na prepnutie aplikácií" "Prepínanie aplikácií potiahnutím" "Aplikácie môžete prepínať potiahnutím obrazovky zdola nahor, pridržaním a následným uvoľnením." "Prepnutie aplikácií" diff --git a/quickstep/res/values-sl/strings.xml b/quickstep/res/values-sl/strings.xml index d6d0e6d9ff..7578480210 100644 --- a/quickstep/res/values-sl/strings.xml +++ b/quickstep/res/values-sl/strings.xml @@ -23,8 +23,7 @@ "Prosta oblika" "Namizni računalnik" "Premik v zunanji zaslon" - - + "Počisti" "Namizni način" "Ni nedavnih elementov" "Nastavitve uporabe aplikacij" diff --git a/quickstep/res/values-th/strings.xml b/quickstep/res/values-th/strings.xml index 382639241a..5c68c60ddb 100644 --- a/quickstep/res/values-th/strings.xml +++ b/quickstep/res/values-th/strings.xml @@ -23,8 +23,7 @@ "รูปแบบอิสระ" "เดสก์ท็อป" "ย้ายไปยังจอแสดงผลภายนอก" - - + "ล้าง" "เดสก์ท็อป" "ไม่มีรายการล่าสุด" "การตั้งค่าการใช้แอป" diff --git a/quickstep/res/values-uz/strings.xml b/quickstep/res/values-uz/strings.xml index 8289dad7c7..36676cb760 100644 --- a/quickstep/res/values-uz/strings.xml +++ b/quickstep/res/values-uz/strings.xml @@ -23,8 +23,7 @@ "Erkin shakl" "Desktop" "Tashqi displeyga olish" - - + "Tozalash" "Desktop" "Yaqinda ishlatilgan ilovalar yo‘q" "Ilovadan foydalanish sozlamalari" From 85d8ef0b87624ae249aefcfd464908743b456ce4 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 22 May 2025 22:03:41 +0000 Subject: [PATCH 13/25] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: I2e7f55ec048bd9154783bb0a8b68208160a5509e --- res/values-af/strings.xml | 3 ++- res/values-am/strings.xml | 3 ++- res/values-ar/strings.xml | 3 ++- res/values-as/strings.xml | 3 ++- res/values-az/strings.xml | 3 ++- res/values-b+sr+Latn/strings.xml | 3 ++- res/values-be/strings.xml | 3 ++- res/values-bg/strings.xml | 3 ++- res/values-bn/strings.xml | 3 ++- res/values-bs/strings.xml | 3 ++- res/values-ca/strings.xml | 3 ++- res/values-cs/strings.xml | 3 ++- res/values-da/strings.xml | 3 ++- res/values-de/strings.xml | 3 ++- res/values-el/strings.xml | 3 ++- res/values-en-rAU/strings.xml | 5 +++-- res/values-en-rCA/strings.xml | 4 ++-- res/values-en-rGB/strings.xml | 5 +++-- res/values-en-rIN/strings.xml | 5 +++-- res/values-es-rUS/strings.xml | 3 ++- res/values-es/strings.xml | 3 ++- res/values-et/strings.xml | 3 ++- res/values-eu/strings.xml | 3 ++- res/values-fa/strings.xml | 3 ++- res/values-fi/strings.xml | 3 ++- res/values-fr-rCA/strings.xml | 3 ++- res/values-fr/strings.xml | 3 ++- res/values-gl/strings.xml | 3 ++- res/values-gu/strings.xml | 3 ++- res/values-hi/strings.xml | 3 ++- res/values-hr/strings.xml | 3 ++- res/values-hu/strings.xml | 3 ++- res/values-hy/strings.xml | 3 ++- res/values-in/strings.xml | 3 ++- res/values-is/strings.xml | 3 ++- res/values-it/strings.xml | 3 ++- res/values-iw/strings.xml | 3 ++- res/values-ja/strings.xml | 3 ++- res/values-ka/strings.xml | 3 ++- res/values-kk/strings.xml | 3 ++- res/values-km/strings.xml | 3 ++- res/values-kn/strings.xml | 3 ++- res/values-ko/strings.xml | 3 ++- res/values-ky/strings.xml | 3 ++- res/values-lo/strings.xml | 3 ++- res/values-lt/strings.xml | 3 ++- res/values-lv/strings.xml | 3 ++- res/values-mk/strings.xml | 3 ++- res/values-ml/strings.xml | 3 ++- res/values-mn/strings.xml | 3 ++- res/values-mr/strings.xml | 3 ++- res/values-ms/strings.xml | 3 ++- res/values-my/strings.xml | 3 ++- res/values-nb/strings.xml | 3 ++- res/values-ne/strings.xml | 3 ++- res/values-nl/strings.xml | 3 ++- res/values-or/strings.xml | 3 ++- res/values-pa/strings.xml | 3 ++- res/values-pl/strings.xml | 3 ++- res/values-pt-rPT/strings.xml | 3 ++- res/values-pt/strings.xml | 3 ++- res/values-ro/strings.xml | 3 ++- res/values-ru/strings.xml | 3 ++- res/values-si/strings.xml | 3 ++- res/values-sk/strings.xml | 5 +++-- res/values-sl/strings.xml | 3 ++- res/values-sq/strings.xml | 3 ++- res/values-sr/strings.xml | 3 ++- res/values-sv/strings.xml | 3 ++- res/values-sw/strings.xml | 3 ++- res/values-ta/strings.xml | 3 ++- res/values-te/strings.xml | 3 ++- res/values-th/strings.xml | 3 ++- res/values-tl/strings.xml | 3 ++- res/values-tr/strings.xml | 3 ++- res/values-uk/strings.xml | 3 ++- res/values-ur/strings.xml | 3 ++- res/values-uz/strings.xml | 3 ++- res/values-vi/strings.xml | 3 ++- res/values-zh-rCN/strings.xml | 3 ++- res/values-zh-rHK/strings.xml | 3 ++- res/values-zh-rTW/strings.xml | 3 ++- res/values-zu/strings.xml | 3 ++- 83 files changed, 170 insertions(+), 88 deletions(-) diff --git a/res/values-af/strings.xml b/res/values-af/strings.xml index c8d9f48c8b..e02cc655e8 100644 --- a/res/values-af/strings.xml +++ b/res/values-af/strings.xml @@ -138,7 +138,8 @@ "Laat toe dat tuisskerm gedraai word" "Wanneer foon gedraai word" "Landskapmodus" - "Stel foon op landskapmodus" + + "Kennisgewingkolle" "Aan" "Af" diff --git a/res/values-am/strings.xml b/res/values-am/strings.xml index f54ee0239a..924753f88f 100644 --- a/res/values-am/strings.xml +++ b/res/values-am/strings.xml @@ -138,7 +138,8 @@ "የመነሻ ማያ ገፅ ማሽከርከርን ይፍቀዱ" "ስልኩ ሲዞር" "የመሬት አቀማመጥ ሁኔታ" - "ስልክን ወደ የመሬት አቀማመጥ ሁኔታ ያቀናብሩ" + + "የማሳወቂያ ነጥቦች" "አብራ" "ጠፍቷል" diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml index 2013527536..ae5885c1d7 100644 --- a/res/values-ar/strings.xml +++ b/res/values-ar/strings.xml @@ -138,7 +138,8 @@ "السماح بتدوير الشاشة الرئيسية" "عند تدوير الهاتف" "الوضع الأفقي" - "ضبط الهاتف على الوضع الأفقي" + + "نقاط الإشعارات" "الإعداد مفعّل" "غير مفعّل" diff --git a/res/values-as/strings.xml b/res/values-as/strings.xml index cd3aae4be8..aa030aebd1 100644 --- a/res/values-as/strings.xml +++ b/res/values-as/strings.xml @@ -138,7 +138,8 @@ "গৃহ স্ক্ৰীন ঘূৰোৱাৰ অনুমতি দিয়ক" "ফ\'নটো যেতিয়া ঘূৰোৱা হয়" "লেণ্ডস্কেইপ ম’ড" - "ফ’নটো লেণ্ডস্কেইপ ম’ডলৈ ছেট কৰক" + + "জাননী বিন্দু" "অন কৰা আছে" "অফ আছে" diff --git a/res/values-az/strings.xml b/res/values-az/strings.xml index c64e5c7f37..01d4fea07c 100644 --- a/res/values-az/strings.xml +++ b/res/values-az/strings.xml @@ -138,7 +138,8 @@ "Əsas ekran çevrilsin" "Telefon çevrilən zaman" "Landşaft rejimi" - "Telefonu landşaft rejiminə ayarlayın" + + "Bildiriş nöqtələri" "Aktiv" "Deaktiv" diff --git a/res/values-b+sr+Latn/strings.xml b/res/values-b+sr+Latn/strings.xml index 01f556d582..a7a378cc6f 100644 --- a/res/values-b+sr+Latn/strings.xml +++ b/res/values-b+sr+Latn/strings.xml @@ -138,7 +138,8 @@ "Dozvoli rotaciju početnog ekrana" "Kada se telefon rotira" "Vodoravni režim" - "Podesite telefon na vodoravni režim" + + "Tačke za obaveštenja" "Uključeno" "Isključeno" diff --git a/res/values-be/strings.xml b/res/values-be/strings.xml index b88dc7ebe2..2a45554fe9 100644 --- a/res/values-be/strings.xml +++ b/res/values-be/strings.xml @@ -138,7 +138,8 @@ "Дазволіць паварот галоўнага экрана" "Пры павароце тэлефона" "Альбомная арыентацыя" - "Перавядзіце тэлефон у альбомную арыентацыю" + + "Значкі апавяшчэнняў" "Уключана" "Выкл." diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index c1c07173ed..4fd2e7dbb5 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -138,7 +138,8 @@ "Разрешаване на завъртането на началния екран" "При завъртане на телефона" "Хоризонтален режим" - "Поставете телефона в хоризонтален режим" + + "Точки за известия" "Вкл." "Изкл." diff --git a/res/values-bn/strings.xml b/res/values-bn/strings.xml index 4d32936eb6..6be9229320 100644 --- a/res/values-bn/strings.xml +++ b/res/values-bn/strings.xml @@ -138,7 +138,8 @@ "হোম স্ক্রিন রোটেট করার অনুমতি দিন" "যখন ফোনটি ঘোরানো হয়" "ভূদৃশ্য মোড" - "ভূদৃশ্য মোডে ফোন সেট করুন" + + "বিজ্ঞপ্তি ডট" "চালু করা আছে" "বন্ধ" diff --git a/res/values-bs/strings.xml b/res/values-bs/strings.xml index b72fab5c5f..5fcb391724 100644 --- a/res/values-bs/strings.xml +++ b/res/values-bs/strings.xml @@ -138,7 +138,8 @@ "Dozvoli rotiranje početnog ekrana" "Kada se telefon zarotira" "Vodoravni način" - "Postavite telefon u vodoravni način" + + "Tačke za obavještenja" "Uključeno" "Isključeno" diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index 85f8088d4d..b856598df3 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -138,7 +138,8 @@ "Permet la rotació de la pantalla d\'inici" "En girar el telèfon" "Mode horitzontal" - "Posa el telèfon en mode horitzontal" + + "Punts de notificació" "Activats" "Desactivats" diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 10ac1558dc..38266253fd 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -138,7 +138,8 @@ "Povolit otáčení plochy" "Při otočení telefonu" "Režim na šířku" - "Nastavit telefon do režimu na šířku" + + "Puntíky s oznámením" "Zapnuto" "Vypnuto" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 20e6fab6f7..20f43a47a6 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -138,7 +138,8 @@ "Tillad rotation af startskærmen" "Når telefonen roteres" "Liggende format" - "Indstil telefonen til liggende format" + + "Notifikationsprikker" "Til" "Fra" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 5ca98f24d0..4d8c45fbc3 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -138,7 +138,8 @@ "Drehen des Startbildschirms zulassen" "Beim Drehen des Smartphones" "Querformat" - "Smartphone auf Querformat einstellen" + + "App-Benachrichtigungspunkte" "An" "Aus" diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index ddf4952a35..b8c7794cff 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -138,7 +138,8 @@ "Να επιτρέπεται η περιστροφή της αρχικής οθόνης" "Όταν το τηλέφωνο περιστρέφεται" "Οριζόντιος προσανατολισμός" - "Ορισμός τηλεφώνου σε οριζόντιο προσανατολισμό" + + "Κουκκίδες ειδοποίησης" "Ενεργοποίηση" "Απενεργοποίηση" diff --git a/res/values-en-rAU/strings.xml b/res/values-en-rAU/strings.xml index 3d4c7f302d..eba3d4e7fc 100644 --- a/res/values-en-rAU/strings.xml +++ b/res/values-en-rAU/strings.xml @@ -112,7 +112,7 @@ "Widget settings" "Tap to finish setup" "This is a system app and can\'t be uninstalled." - "Edit Name" + "Edit name" "Paginate left" "Paginate right" "Disabled %1$s" @@ -138,7 +138,8 @@ "Allow home screen rotation" "When phone is rotated" "Landscape mode" - "Set phone to landscape mode" + + "Notification dots" "On" "Off" diff --git a/res/values-en-rCA/strings.xml b/res/values-en-rCA/strings.xml index 90d36de573..d8994805b5 100644 --- a/res/values-en-rCA/strings.xml +++ b/res/values-en-rCA/strings.xml @@ -112,7 +112,7 @@ "Widget settings" "Tap to finish setup" "This is a system app and can\'t be uninstalled." - "Edit Name" + "Edit name" "Paginate left" "Paginate right" "Disabled %1$s" @@ -138,7 +138,7 @@ "Allow home screen rotation" "When phone is rotated" "Landscape mode" - "Set phone into landscape mode" + "Set home screen into landscape mode" "Notification dots" "On" "Off" diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 3d4c7f302d..eba3d4e7fc 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -112,7 +112,7 @@ "Widget settings" "Tap to finish setup" "This is a system app and can\'t be uninstalled." - "Edit Name" + "Edit name" "Paginate left" "Paginate right" "Disabled %1$s" @@ -138,7 +138,8 @@ "Allow home screen rotation" "When phone is rotated" "Landscape mode" - "Set phone to landscape mode" + + "Notification dots" "On" "Off" diff --git a/res/values-en-rIN/strings.xml b/res/values-en-rIN/strings.xml index 3d4c7f302d..eba3d4e7fc 100644 --- a/res/values-en-rIN/strings.xml +++ b/res/values-en-rIN/strings.xml @@ -112,7 +112,7 @@ "Widget settings" "Tap to finish setup" "This is a system app and can\'t be uninstalled." - "Edit Name" + "Edit name" "Paginate left" "Paginate right" "Disabled %1$s" @@ -138,7 +138,8 @@ "Allow home screen rotation" "When phone is rotated" "Landscape mode" - "Set phone to landscape mode" + + "Notification dots" "On" "Off" diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml index e7026ed09d..c5354e5f7f 100644 --- a/res/values-es-rUS/strings.xml +++ b/res/values-es-rUS/strings.xml @@ -138,7 +138,8 @@ "Permitir la rotación de la pantalla principal" "Al girar el teléfono" "Modo horizontal" - "Establece el teléfono en modo horizontal" + + "Puntos de notificación" "Activados" "Desactivados" diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 97fec2b8bd..5f3c3da8a6 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -138,7 +138,8 @@ "Permitir rotación de la pantalla de inicio" "Al girar el teléfono" "Modo de vista horizontal" - "Pon el teléfono en modo de vista horizontal" + + "Burbujas de notificación" "Activado" "Desactivadas" diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 8b4bf33e8e..fba2ef7444 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -138,7 +138,8 @@ "Luba avakuva pööramine" "Kui telefoni pööratakse" "Horisontaalrežiim" - "Sea telefon horisontaalrežiimi" + + "Märguandetäpid" "Sees" "Väljas" diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index 46e7a6a7ef..4d59b6f68d 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -138,7 +138,8 @@ "Eman orri nagusia biratzeko baimena" "Telefonoa biratzean" "Ikuspegi horizontala" - "Ezarri telefonoa ikuspegi horizontalean" + + "Jakinarazpen-biribiltxoak" "Aktibatuta" "Desaktibatuta" diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 9cd94ebaa9..d815a9f73e 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -138,7 +138,8 @@ "مجاز کردن چرخش صفحه اصلی" "وقتی تلفن چرخانده می‌شود" "حالت افقی" - "تنظیم تلفن روی حالت افقی" + + "نقطه‌های اعلان" "روشن" "خاموش" diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index de7a6ed9ff..e22ef97bea 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -138,7 +138,8 @@ "Salli aloitusnäytön kiertäminen" "Kun puhelinta kierretään" "Vaakasuunta" - "Aseta puhelin vaakasuuntaan" + + "Pistemerkit" "Päällä" "Ei päällä" diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml index 2ec81d4ff8..5aaf47ec5c 100644 --- a/res/values-fr-rCA/strings.xml +++ b/res/values-fr-rCA/strings.xml @@ -138,7 +138,8 @@ "Autoriser la rotation de l\'écran d\'accueil" "Lorsque vous faites pivoter le téléphone" "Mode Paysage" - "Configurez le téléphone en mode Paysage" + + "Pastilles de notification" "Activées" "Désactivé" diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index e38df2f8c9..d9f977785e 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -138,7 +138,8 @@ "Autoriser la rotation de l\'écran d\'accueil" "Lorsque vous faites pivoter le téléphone" "Mode Paysage" - "Paramétrer le téléphone en mode Paysage" + + "Pastilles de notification" "Activé" "Désactivées" diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index bbb2721314..d6ed51bda0 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -138,7 +138,8 @@ "Permitir xirar a pantalla de inicio" "Ao xirar o teléfono" "Modo horizontal" - "Pon o teléfono no modo horizontal" + + "Puntos de notificacións" "Opción activada" "Desactivados" diff --git a/res/values-gu/strings.xml b/res/values-gu/strings.xml index 86a05b88b8..bbd38f78a7 100644 --- a/res/values-gu/strings.xml +++ b/res/values-gu/strings.xml @@ -138,7 +138,8 @@ "હોમ સ્ક્રીનને ફેરવવાની મંજૂરી આપો" "જ્યારે ફોન ફેરવવામાં આવે ત્યારે" "લૅન્ડસ્કેપ મોડ" - "ફોનને લૅન્ડસ્કેપ મોડમાં સેટ કરો" + + "નોટિફિકેશન ડૉટ" "ચાલુ છે" "બંધ છે" diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 383064e101..5812b31b5f 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -138,7 +138,8 @@ "होम स्क्रीन घुमाने की अनुमति दें" "फ़ोन घुुमाए जाने पर" "लैंडस्केप मोड" - "फ़ोन को लैंडस्केप मोड में सेट करें" + + "सूचनाएं बताने वाला डॉट" "चालू है" "चालू" diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml index 4e9ab70f63..657ee44089 100644 --- a/res/values-hr/strings.xml +++ b/res/values-hr/strings.xml @@ -138,7 +138,8 @@ "Dopusti zakretanje početnog zaslona" "Kada se telefon zakrene" "Pejzažni način" - "Telefon se postavlja u pejzažni način" + + "Točke obavijesti" "Uključeno" "Isključeno" diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index da8e430542..cd6c397864 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -138,7 +138,8 @@ "A kezdőképernyő elforgatásának engedélyezése" "A telefon elforgatásakor" "Fekvő tájolás" - "Állítsa a telefont fekvő tájolásúra" + + "Értesítési pöttyök" "Be" "Ki" diff --git a/res/values-hy/strings.xml b/res/values-hy/strings.xml index 99ce26bc57..c703596052 100644 --- a/res/values-hy/strings.xml +++ b/res/values-hy/strings.xml @@ -138,7 +138,8 @@ "Թույլ տալ հիմնական էկրանի պտտումը" "Հեռախոսը պտտելու դեպքում" "Հորիզոնական" - "Հեռախոսն օգտագործել հորիզոնական ռեժիմում" + + "Ծանուցումների կետիկներ" "Միացված է" "Անջատված է" diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml index f7118c6f97..c731f68269 100644 --- a/res/values-in/strings.xml +++ b/res/values-in/strings.xml @@ -138,7 +138,8 @@ "Izinkan layar utama diputar" "Saat ponsel diputar" "Mode lanskap" - "Setel ponsel ke mode lanskap" + + "Titik notifikasi" "Aktif" "Nonaktif" diff --git a/res/values-is/strings.xml b/res/values-is/strings.xml index 3659b8c53f..05f0ebf2b5 100644 --- a/res/values-is/strings.xml +++ b/res/values-is/strings.xml @@ -138,7 +138,8 @@ "Leyfa snúning á heimaskjá" "Þegar símanum er snúið" "Langsnið" - "Stilla síma á langsnið" + + "Tilkynningapunktar" "Kveikt" "Slökkt" diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 096aff2577..ce4ac4164b 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -138,7 +138,8 @@ "Consenti rotazione della schermata Home" "Con il telefono ruotato" "Modalità Orizzontale" - "Imposta lo smartphone in modalità Orizzontale" + + "Indicatori di notifica" "On" "Off" diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 1435253703..f25c01ef96 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -138,7 +138,8 @@ "סיבוב מסך הבית" "כאשר מסובבים את הטלפון" "פריסה לרוחב" - "העברת הטלפון לפריסה לרוחב" + + "סימני ההתראות" "מופעל" "כבוי" diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 7cd58f47a6..efb3017975 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -138,7 +138,8 @@ "ホーム画面の回転を許可" "スマートフォンの向きに合わせます" "横表示" - "スマートフォンを横表示にします" + + "通知ドット" "ON" "OFF" diff --git a/res/values-ka/strings.xml b/res/values-ka/strings.xml index b00776e21a..25143397e3 100644 --- a/res/values-ka/strings.xml +++ b/res/values-ka/strings.xml @@ -138,7 +138,8 @@ "მთავარი ეკრანის შეტრიალების დაშვება" "ტელეფონის შეტრიალებისას" "პეიზაჟის რეჟიმი" - "ტელეფონის დაყენება პეიზაჟის რეჟიმში" + + "შეტყობინების ნიშნულები" "ჩართულია" "გამორთულია" diff --git a/res/values-kk/strings.xml b/res/values-kk/strings.xml index b29ec225c6..80e4cb9309 100644 --- a/res/values-kk/strings.xml +++ b/res/values-kk/strings.xml @@ -138,7 +138,8 @@ "Негізгі экранды бұруға рұқсат ету" "Телефон бұрылғанда" "Альбом режимі" - "Телефонды альбом режиміне қою" + + "Хабарландыру белгілері" "Қосулы" "Өшірулі" diff --git a/res/values-km/strings.xml b/res/values-km/strings.xml index b895875a98..f55268e760 100644 --- a/res/values-km/strings.xml +++ b/res/values-km/strings.xml @@ -138,7 +138,8 @@ "អនុញ្ញាតការបងិ្វលអេក្រង់ដើម" "នៅពេលដែលបង្វិលទូរសព្ទ" "ផ្ដេក" - "កំណត់ទូរសព្ទទៅផ្ដេក" + + "ស្លាកជូនដំណឹង" "បើក" "បិទ" diff --git a/res/values-kn/strings.xml b/res/values-kn/strings.xml index 290f3a7e0d..3477701b51 100644 --- a/res/values-kn/strings.xml +++ b/res/values-kn/strings.xml @@ -138,7 +138,8 @@ "ಹೋಮ್ ಸ್ಕ್ರೀನ್ ತಿರುಗುವಿಕೆಯನ್ನು ಅನುಮತಿಸಿ" "ಫೋನ್‌ ತಿರುಗಿಸಿದಾಗ" "ಲ್ಯಾಂಡ್‌ಸ್ಕೇಪ್ ಮೋಡ್" - "ಫೋನ್ ಅನ್ನು ಲ್ಯಾಂಡ್‌ಸ್ಕೇಪ್ ಮೋಡ್‌ಗೆ ಸೆಟ್ ಮಾಡಿ" + + "ನೋಟಿಫಿಕೇಶನ್ ಡಾಟ್‌ಗಳು" "ಆನ್ ಆಗಿದೆ" "ಆಫ್ ಆಗಿದೆ" diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 86c41335f2..3d84d9084f 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -138,7 +138,8 @@ "홈 화면 회전 허용" "휴대전화 회전 시" "가로 모드" - "휴대전화를 가로 모드로 설정" + + "알림 표시 점" "사용" "사용 안함" diff --git a/res/values-ky/strings.xml b/res/values-ky/strings.xml index 67884badc3..1130725585 100644 --- a/res/values-ky/strings.xml +++ b/res/values-ky/strings.xml @@ -138,7 +138,8 @@ "Башкы экранды бурууга уруксат берүү" "Телефон бурулганда" "Туурасынан" - "Телефонду туурасынан коюңуз" + + "Билдирмелер белгилери" "Күйүк" "Өчүк" diff --git a/res/values-lo/strings.xml b/res/values-lo/strings.xml index 1bfff560de..c4aa476c68 100644 --- a/res/values-lo/strings.xml +++ b/res/values-lo/strings.xml @@ -138,7 +138,8 @@ "ອະນຸຍາດໃຫ້ໝຸນໜ້າຈໍຢູ່ໂຮມສະກຣີນໄດ້" "ເມື່ອໝຸນໂທລະສັບ" "ໂໝດແນວນອນ" - "ຕັ້ງຄ່າໂທລະສັບເປັນໂໝດແນວນອນ" + + "ຈຸດການແຈ້ງເຕືອນ" "ເປີດ" "ປິດ" diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index ccf02fbb5a..128476d251 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -138,7 +138,8 @@ "Leisti pasukti pagrindinį ekraną" "Kai telefonas pasukamas" "Gulsčiojo ekrano režimas" - "Nustatykite telefoną į gulsčiojo ekrano režimą" + + "Pranešimų taškai" "Įjungta" "Išjungta" diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 2280268b63..f66149634d 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -138,7 +138,8 @@ "Atļaut sākuma ekrāna pagriešanu" "Pagriežot tālruni" "Ainavas režīms" - "Iestatīt tālrunī ainavas režīmu" + + "Paziņojumu punkti" "Ieslēgti" "Izslēgts" diff --git a/res/values-mk/strings.xml b/res/values-mk/strings.xml index fd6780d356..0a6e120b49 100644 --- a/res/values-mk/strings.xml +++ b/res/values-mk/strings.xml @@ -138,7 +138,8 @@ "Дозволи ротирање на почетниот екран" "Кога телефонот се ротира" "Хоризонтален режим" - "Поставете го телефонот во „Хоризонтален режим“" + + "Точки за известување" "Вклучено" "Исклучено" diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml index 66a1d3fa33..a3af341ba0 100644 --- a/res/values-ml/strings.xml +++ b/res/values-ml/strings.xml @@ -138,7 +138,8 @@ "ഹോം സ്ക്രീൻ റൊട്ടേഷൻ അനുവദിക്കുക" "ഫോൺ തിരിച്ച നിലയിലായിരിക്കുമ്പോൾ" "ലാൻഡ്‌സ്‌കേപ്പ് മോഡ്" - "ഫോൺ ലാൻഡ്‌സ്‌കേപ്പ് മോഡിലേക്ക് സജ്ജീകരിക്കുക" + + "അറിയിപ്പ് ഡോട്ടുകൾ" "ഓണാണ്" "ഓഫാണ്" diff --git a/res/values-mn/strings.xml b/res/values-mn/strings.xml index e8c071fcf8..5983c40541 100644 --- a/res/values-mn/strings.xml +++ b/res/values-mn/strings.xml @@ -138,7 +138,8 @@ "Үндсэн нүүрийг эргүүлэхийг зөвшөөрөх" "Утсыг эргүүлсэн үед" "Хэвтээ горим" - "Утсыг хэвтээ горимд тохируулах" + + "Мэдэгдлийн цэг" "Асаалттай" "Унтраалттай" diff --git a/res/values-mr/strings.xml b/res/values-mr/strings.xml index 59ae2df0bd..4a5e6b32eb 100644 --- a/res/values-mr/strings.xml +++ b/res/values-mr/strings.xml @@ -138,7 +138,8 @@ "होम स्क्रीन फिरवण्‍याची अनुमती द्या" "फोन फिरवला जातो तेव्हा" "लँडस्केप मोड" - "फोन लँडस्केप मोडमध्ये सेट करा" + + "नोटिफिकेशन बिंदू" "सुरू" "बंद" diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml index 19b5a2e8e9..a495eb7ce2 100644 --- a/res/values-ms/strings.xml +++ b/res/values-ms/strings.xml @@ -138,7 +138,8 @@ "Benarkan putaran skrin utama" "Apabila telefon diputar" "Mod landskap" - "Tetapkan telefon kepada mod landskap" + + "Titik pemberitahuan" "Hidup" "Mati" diff --git a/res/values-my/strings.xml b/res/values-my/strings.xml index 0048850543..14c9fe9b81 100644 --- a/res/values-my/strings.xml +++ b/res/values-my/strings.xml @@ -138,7 +138,8 @@ "ပင်မစာမျက်နှာလှည့်ခြင်းကို ခွင့်ပြုခြင်း" "ဖုန်းကိုလှည့်ထားစဉ်" "အလျားလိုက်" - "ဖုန်းကို အလျားလိုက်သို့ သတ်မှတ်နိုင်သည်" + + "သတိပေးချက် အစက်များ" "ဖွင့်" "ပိတ်" diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 49b4b62ee4..43ab838bf1 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -138,7 +138,8 @@ "Tillat at startskjermen roterer" "Når telefonen roteres" "Liggende retning" - "Plasser telefonen i liggende retning" + + "Varselsprikker" "På" "Av" diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml index b84a603ee4..608778c19f 100644 --- a/res/values-ne/strings.xml +++ b/res/values-ne/strings.xml @@ -138,7 +138,8 @@ "होम स्क्रिन रोटेट हुन दिइयोस्" "फोन घुमाउँदा" "ल्यान्डस्केप मोड" - "फोनमा ल्यान्डस्केप मोड अन गर्नुहोस्" + + "नोटिफिकेसन डट" "अन छ" "निष्क्रिय" diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 2ef3dbcd93..5960701993 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -138,7 +138,8 @@ "Draaien van startscherm toestaan" "Als de telefoon gedraaid is" "Liggende modus" - "Stel telefoon in op liggende modus" + + "Meldingsstipjes" "Aan" "Uit" diff --git a/res/values-or/strings.xml b/res/values-or/strings.xml index 8927bf163f..915b409905 100644 --- a/res/values-or/strings.xml +++ b/res/values-or/strings.xml @@ -138,7 +138,8 @@ "ହୋମ ସ୍କ୍ରିନ ରୋଟେସନକୁ ଅନୁମତି ଦିଅନ୍ତୁ" "ଯେତେବେଳେ ଫୋନକୁ ରୋଟେଟ କରାଯାଇଥାଏ" "ଲେଣ୍ଡସ୍କେପ ମୋଡ" - "ଫୋନକୁ ଲେଣ୍ଡସ୍କେପ ମୋଡରେ ସେଟ କରନ୍ତୁ" + + "ବିଜ୍ଞପ୍ତି ଡଟ୍ସ" "ଚାଲୁ" "ବନ୍ଦ କରନ୍ତୁ" diff --git a/res/values-pa/strings.xml b/res/values-pa/strings.xml index e28b191cfc..7851b0cc49 100644 --- a/res/values-pa/strings.xml +++ b/res/values-pa/strings.xml @@ -138,7 +138,8 @@ "ਹੋਮ ਸਕ੍ਰੀਨ ਨੂੰ ਘੁਮਾਉਣ ਦੀ ਆਗਿਆ ਦਿਓ" "ਜਦੋਂ ਫ਼ੋਨ ਘੁਮਾਇਆ ਜਾਂਦਾ ਹੈ" "ਲੈਂਡਸਕੇਪ ਮੋਡ" - "ਫ਼ੋਨ ਨੂੰ ਲੈਂਡਸਕੇਪ ਮੋਡ ਵਿੱਚ ਸੈੱਟ ਕਰੋ" + + "ਸੂਚਨਾ ਬਿੰਦੂ" "ਚਾਲੂ" "ਬੰਦ" diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index ac8733f43d..d580ceb2b6 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -138,7 +138,8 @@ "Zezwalaj na obrót ekranu głównego" "Po obróceniu telefonu" "Tryb poziomy" - "Przestaw telefon w tryb poziomy" + + "Kropki powiadomień" "Włączone" "Wyłączone" diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index bb285f91e6..c8b2ee51e9 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -138,7 +138,8 @@ "Permitir rotação do ecrã principal" "Quando o telemóvel é rodado" "Modo horizontal" - "Defina o telemóvel para o modo horizontal" + + "Pontos de notificação" "Ativados" "Desativados" diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index e95ffe8bc6..434b12b97d 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -138,7 +138,8 @@ "Permitir a rotação da tela inicial" "Quando o smartphone for girado" "Modo paisagem" - "Definir o smartphone para o modo paisagem" + + "Pontos de notificação" "Ativados" "Desativado" diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index f35c2f88fc..d2fd594241 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -138,7 +138,8 @@ "Permite rotirea ecranului de pornire" "Când telefonul este rotit" "Modul Peisaj" - "Setează telefonul în modul Peisaj" + + "Puncte de notificare" "Activate" "Dezactivate" diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index ade43a7dd6..b93755a7ad 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -138,7 +138,8 @@ "Разрешить поворачивать главный экран" "При повороте телефона" "Горизонтальный режим" - "Перевести телефон в горизонтальный режим" + + "Значки уведомлений" "Включены" "Отключены" diff --git a/res/values-si/strings.xml b/res/values-si/strings.xml index 1c81e109b2..f83b46c254 100644 --- a/res/values-si/strings.xml +++ b/res/values-si/strings.xml @@ -138,7 +138,8 @@ "මුල් තිරය කරකැවීමට ඉඩ දෙන්න" "දුරකථනය කරකවන විට" "භූ දර්ශන ආකාරය" - "දුරකථනය භූ දර්ශන ආකාරයට සකසන්න" + + "දැනුම්දීම් තිත්" "ක්‍රියාත්මකයි" "ක්‍රියාවිරහිතයි" diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index c778fe2059..e87345df33 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -47,7 +47,7 @@ "šírka %1$d, výška %2$d" "Miniaplikácia %1$s" "Miniaplikácia %1$s, %2$d na šírku, %3$d na výšku" - "Pridržaním môžete miniaplikáciu posúvať po ploche" + "Ak chcete miniaplikáciou pohybovať po ploche, pridržte ju" "Pridať na plochu" "Na plochu bola pridaná miniaplikácia %1$s" "Návrhy" @@ -138,7 +138,8 @@ "Povoliť otáčanie plochy" "Pri otočení telefónu" "Režim na šírku" - "Nastavte v telefóne režim na šírku" + + "Bodky upozornení" "Zapnuté" "Vypnuté" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 3f2b39dff2..2d389f1ceb 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -138,7 +138,8 @@ "Dovoli sukanje začetnega zaslona" "Ko se telefon zasuka" "Ležeči način" - "Telefon preklopite v ležeči način" + + "Obvestilne pike" "Vklopljeno" "Izklopljeno" diff --git a/res/values-sq/strings.xml b/res/values-sq/strings.xml index 998d9afff8..ef1c35ffa8 100644 --- a/res/values-sq/strings.xml +++ b/res/values-sq/strings.xml @@ -138,7 +138,8 @@ "Lejo rrotullimin e ekranit bazë" "Kur telefoni rrotullohet" "Modaliteti horizontal" - "Vendose telefonin në modalitetin horizontal" + + "Pikat e njoftimeve" "Aktiv" "Joaktiv" diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 2bc2405dce..6c768f8326 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -138,7 +138,8 @@ "Дозволи ротацију почетног екрана" "Када се телефон ротира" "Водоравни режим" - "Подесите телефон на водоравни режим" + + "Тачке за обавештења" "Укључено" "Искључено" diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 8709421eea..b35a5f313a 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -138,7 +138,8 @@ "Tillåt rotering av startskärmen" "När telefonen vrids" "Liggande" - "Ställ in telefonen på liggande läge" + + "Aviseringsprickar" "På" "Av" diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml index e991fb5b80..0b6b4e4f0f 100644 --- a/res/values-sw/strings.xml +++ b/res/values-sw/strings.xml @@ -138,7 +138,8 @@ "Ruhusu kipengele cha kuzungusha skrini ya kwanza" "Simu inapozungushwa" "Mkao wa mlalo" - "Weka simu katika mkao wa mlalo" + + "Vitone vya arifa" "Imewashwa" "Imezimwa" diff --git a/res/values-ta/strings.xml b/res/values-ta/strings.xml index 082fefaba6..e0e25201f2 100644 --- a/res/values-ta/strings.xml +++ b/res/values-ta/strings.xml @@ -138,7 +138,8 @@ "முகப்புத் திரை சுழற்சியை அனுமதித்தல்" "மொபைலைச் சுழற்றும் போது" "லேண்ட்ஸ்கேப் பயன்முறை" - "மொபைலை லேண்ட்ஸ்கேப் பயன்முறையில் அமைக்கலாம்" + + "அறிவிப்புப் புள்ளிகள்" "ஆன்" "ஆஃப்" diff --git a/res/values-te/strings.xml b/res/values-te/strings.xml index 2f87ffa87a..cffb185403 100644 --- a/res/values-te/strings.xml +++ b/res/values-te/strings.xml @@ -138,7 +138,8 @@ "మొదటి స్క్రీన్ రొటేషన్‌ను అనుమతించండి" "ఫోన్‌‌ను తిప్పినప్పుడు" "ల్యాండ్‌స్కేప్ మోడ్" - "ఫోన్‌ను ల్యాండ్‌స్కేప్ మోడ్‌కు సెట్ చేయండి" + + "నోటిఫికేషన్ డాట్‌లు" "ఆన్" "ఆఫ్" diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml index aaa0c0b0e3..d8725fce4a 100644 --- a/res/values-th/strings.xml +++ b/res/values-th/strings.xml @@ -138,7 +138,8 @@ "อนุญาตให้หมุนหน้าจอหลัก" "เมื่อหมุนโทรศัพท์" "โหมดแนวนอน" - "ตั้งค่าโทรศัพท์เป็นโหมดแนวนอน" + + "เครื่องหมายจุดแสดงการแจ้งเตือน" "เปิด" "ปิด" diff --git a/res/values-tl/strings.xml b/res/values-tl/strings.xml index 9d52c315f2..dc2c5ffcf2 100644 --- a/res/values-tl/strings.xml +++ b/res/values-tl/strings.xml @@ -138,7 +138,8 @@ "Payagan ang pag-rotate ng home screen" "Kailan maro-rotate ang telepono" "Landscape mode" - "Itakda ang telepono sa landscape mode" + + "Mga notification dot" "Naka-on" "Naka-off" diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 4bde4c904c..acb3d5e6c8 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -138,7 +138,8 @@ "Ana ekranı döndürmeye izin ver" "Telefon döndürüldüğünde" "Yatay mod" - "Telefonu yatay moda ayarlayın" + + "Bildirim noktaları" "Açık" "Kapalı" diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 0a19b583a3..84da3b78da 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -138,7 +138,8 @@ "Дозволити обертання головного екрана" "Коли телефон обертається" "Альбомна орієнтація" - "Змінити орієнтацію екрана телефона на альбомну" + + "Значки сповіщень" "Увімкнено" "Вимкнено" diff --git a/res/values-ur/strings.xml b/res/values-ur/strings.xml index 99ff127d4f..8e5450819f 100644 --- a/res/values-ur/strings.xml +++ b/res/values-ur/strings.xml @@ -138,7 +138,8 @@ "ہوم اسکرین گھمانے کی اجازت دیں" "جب فون گھمایا جاتا ہے" "لینڈ اسکیپ وضع" - "فون کو لینڈ اسکیپ وضع میں سیٹ کریں" + + "اطلاعاتی ڈاٹس" "آن ہے" "آف ہے" diff --git a/res/values-uz/strings.xml b/res/values-uz/strings.xml index 750ed61acd..47bf54f901 100644 --- a/res/values-uz/strings.xml +++ b/res/values-uz/strings.xml @@ -138,7 +138,8 @@ "Bosh ekranni burishga ruxsat" "Telefon burilganda" "Yotiq rejim" - "Telefonni yotiq rejimga oʻtkazish" + + "Bildirishnoma belgilari" "Yoniq" "Oʻchiq" diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index b6a138f36d..7a8a86bf10 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -138,7 +138,8 @@ "Cho phép xoay màn hình chính" "Khi xoay điện thoại" "Chế độ ngang" - "Đặt điện thoại ở chế độ ngang" + + "Dấu chấm thông báo" "Đang bật" "Tắt" diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index e7c02152a1..91f0823a20 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -138,7 +138,8 @@ "允许旋转主屏幕" "手机旋转时" "横屏模式" - "将手机设为横屏模式" + + "通知圆点" "已开启" "已关闭" diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml index 341f5d3b36..3902ddad48 100644 --- a/res/values-zh-rHK/strings.xml +++ b/res/values-zh-rHK/strings.xml @@ -138,7 +138,8 @@ "允許旋轉主畫面" "隨手機旋轉" "水平模式" - "將手機設定為水平模式" + + "通知圓點" "開啟" "關閉" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 28baa8b743..51b6b983d8 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -138,7 +138,8 @@ "允許旋轉主畫面" "當手機旋轉時" "橫向模式" - "將手機設為橫向模式" + + "通知圓點" "開啟" "關閉" diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml index 752ee7f4ab..72d0c65c90 100644 --- a/res/values-zu/strings.xml +++ b/res/values-zu/strings.xml @@ -138,7 +138,8 @@ "Vumela ukuzungezisa kwesikrini sasekhaya" "Uma ifoni iphendukiswa" "Imodi yokuvundla" - "Setha ifoni kumodi yokuvundla" + + "Amacashazi esaziso" "Vuliwe" "Valiwe" From a4ffc73d92457c96af6b44b4b0fd656d02fd42e5 Mon Sep 17 00:00:00 2001 From: Shamali Patwa Date: Thu, 22 May 2025 16:03:16 -0700 Subject: [PATCH 14/25] Updates to repository interfaces & data types for widget picker - I think the previews / featured / search all could be part of widgets repository. Internally, it will use separate datasource to prepare the respective data - but as a repository, they all are probably just a widgets repo. - Includes minor changes to data types as well to prepare for upcoming changes. Bug: 408283627 Flag: EXEMPT independent module Test: Not applicable - interface changes Change-Id: I765c11318a655603becdf2cab081f0fcf777da1a --- modules/widgetpicker/Android.bp | 6 +- ...idgetPickerSingleton.kt => Annotations.kt} | 7 +++ .../repository/WidgetAppIconsRepository.kt | 9 +++ .../WidgetRecommendationsRepository.kt | 25 -------- .../data/repository/WidgetUsersRepository.kt | 16 ++++- .../data/repository/WidgetsRepository.kt | 27 ++++++++- .../shared/model/PickableWidget.kt | 7 ++- .../model/WidgetApp.kt} | 25 ++++---- .../shared/model/WidgetHostInfo.kt | 59 +++++++++++++++++++ .../shared/model/WidgetUserProfiles.kt | 6 +- 10 files changed, 141 insertions(+), 46 deletions(-) rename modules/widgetpicker/src/com/android/launcher3/widgetpicker/{WidgetPickerSingleton.kt => Annotations.kt} (80%) delete mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetRecommendationsRepository.kt rename modules/widgetpicker/src/com/android/launcher3/widgetpicker/{data/repository/WidgetPreviewRepository.kt => shared/model/WidgetApp.kt} (55%) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetHostInfo.kt diff --git a/modules/widgetpicker/Android.bp b/modules/widgetpicker/Android.bp index 6d81149e1c..301be44f0d 100644 --- a/modules/widgetpicker/Android.bp +++ b/modules/widgetpicker/Android.bp @@ -22,7 +22,7 @@ android_library { sdk_version: "current", min_sdk_version: min_launcher3_sdk_version, srcs: [ - "src/com/android/launcher3/widgetpicker/WidgetPickerSingleton.kt", + "src/com/android/launcher3/widgetpicker/Annotations.kt", ], static_libs: [ @@ -52,11 +52,13 @@ android_library { min_sdk_version: min_launcher3_sdk_version, srcs: [ "src/com/android/launcher3/widgetpicker/shared/model/PickableWidget.kt", + "src/com/android/launcher3/widgetpicker/shared/model/WidgetApp.kt", "src/com/android/launcher3/widgetpicker/shared/model/WidgetAppIcon.kt", "src/com/android/launcher3/widgetpicker/shared/model/WidgetAppId.kt", "src/com/android/launcher3/widgetpicker/shared/model/WidgetId.kt", "src/com/android/launcher3/widgetpicker/shared/model/WidgetPreview.kt", "src/com/android/launcher3/widgetpicker/shared/model/WidgetUserProfiles.kt", + "src/com/android/launcher3/widgetpicker/shared/model/WidgetHostInfo.kt", ], static_libs: [ "androidx.core_core-ktx", @@ -70,8 +72,6 @@ android_library { min_sdk_version: min_launcher3_sdk_version, srcs: [ "src/com/android/launcher3/widgetpicker/data/repository/WidgetAppIconsRepository.kt", - "src/com/android/launcher3/widgetpicker/data/repository/WidgetPreviewRepository.kt", - "src/com/android/launcher3/widgetpicker/data/repository/WidgetRecommendationsRepository.kt", "src/com/android/launcher3/widgetpicker/data/repository/WidgetsRepository.kt", "src/com/android/launcher3/widgetpicker/data/repository/WidgetUsersRepository.kt", ], diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerSingleton.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt similarity index 80% rename from modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerSingleton.kt rename to modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt index ce6e7857a6..276ffefaf0 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerSingleton.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt @@ -16,6 +16,7 @@ package com.android.launcher3.widgetpicker +import javax.inject.Qualifier import javax.inject.Scope /** Scope annotation for singleton items within the widget picker. */ @@ -23,3 +24,9 @@ import javax.inject.Scope @Retention(AnnotationRetention.RUNTIME) @Scope annotation class WidgetPickerSingleton + +/** Qualifier annotation for information about the widget host. */ +@Qualifier +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +annotation class WidgetPickerHostInfo diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetAppIconsRepository.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetAppIconsRepository.kt index 68fd7cbe7b..bbd5f89bfd 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetAppIconsRepository.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetAppIconsRepository.kt @@ -22,9 +22,18 @@ import kotlinx.coroutines.flow.Flow /** A repository that provides app icons for the widget picker. */ interface WidgetAppIconsRepository { + /** + * A hook to setup the repository so clients can observe the widgets available on device. + * This serves as a place to start listening to the backing caches / data sources. + */ + fun initialize() + /** * Loads and returns app icon (may initially return a low res icon, followed by a high res once * available). */ fun getAppIcon(widgetAppId: WidgetAppId): Flow + + /** Clean up any external listeners or state (if necessary). */ + fun cleanUp() } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetRecommendationsRepository.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetRecommendationsRepository.kt deleted file mode 100644 index 7e5403f104..0000000000 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetRecommendationsRepository.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2025 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3.widgetpicker.data.repository - -import com.android.launcher3.widgetpicker.shared.model.WidgetId - -/** A repository of widgets that can be recommended to the users in widget picker. */ -interface WidgetRecommendationsRepository { - /** Returns a list of widgets that can be recommended to the users in the widget picker. */ - suspend fun getRecommendations(): List -} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetUsersRepository.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetUsersRepository.kt index e81c3abc16..d28b11c3dd 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetUsersRepository.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetUsersRepository.kt @@ -16,7 +16,7 @@ package com.android.launcher3.widgetpicker.data.repository -import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfileType +import android.os.UserHandle import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles import kotlinx.coroutines.flow.Flow @@ -25,6 +25,18 @@ import kotlinx.coroutines.flow.Flow * the widget picker. */ interface WidgetUsersRepository { + /** + * A hook to setup the repository so clients can observe the widgets available on device. + * This serves as a place to start listening to the backing caches / data sources. + */ + fun initialize() + /** Get and listen to the changes in available user profiles. */ - fun observeUsers(types: List): Flow + fun observeUserProfiles(): Flow + + /** Indicates if a user is a work profile user. */ + fun getWorkProfileUser(): UserHandle? + + /** Clean up any external listeners or state (if necessary). */ + fun cleanUp() } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetsRepository.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetsRepository.kt index 5f9d8a9872..a28a776380 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetsRepository.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetsRepository.kt @@ -17,11 +17,34 @@ package com.android.launcher3.widgetpicker.data.repository import com.android.launcher3.widgetpicker.shared.model.PickableWidget +import com.android.launcher3.widgetpicker.shared.model.WidgetApp +import com.android.launcher3.widgetpicker.shared.model.WidgetId +import com.android.launcher3.widgetpicker.shared.model.WidgetPreview import kotlinx.coroutines.flow.Flow /** A repository of widgets available on the device from various apps */ interface WidgetsRepository { + /** + * A hook to setup the repository so clients can observe the widgets available on device. + * This serves as a place to start listening to the backing caches / data sources. + */ + fun initialize() - /** Observe widgets available on the device. */ - fun observeWidgets(): Flow> + /** Observe widgets available on the device from different apps. */ + fun observeWidgets(): Flow> + + /** Loads a preview for an app widget. Returns a placeholder preview if the widget is not found. */ + suspend fun getWidgetPreview(id: WidgetId): WidgetPreview + + /** Get widgets that can be featured in widget picker. */ + fun getFeaturedWidgets(): Flow> + + /** + * Search widgets and their apps that match the given plain text [query] string typed by the + * user. Matches the widget's label, description and app's title (case-insensitive). + */ + suspend fun searchWidgets(query: String): List + + /** Clean up any external listeners or state (if necessary). */ + fun cleanUp() } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/PickableWidget.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/PickableWidget.kt index fb0e2863c4..d37154a4b4 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/PickableWidget.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/PickableWidget.kt @@ -39,7 +39,12 @@ data class PickableWidget( val description: CharSequence?, val appWidgetProviderInfo: AppWidgetProviderInfo, val sizeInfo: WidgetSizeInfo, -) +) { + // Custom toString to account for the appWidgetProviderInfo. + override fun toString(): String = + "PickableWidget(id=$id,appId=$appId,label=$label,description=$description," + + "sizeInfo=$sizeInfo,provider=${appWidgetProviderInfo.provider})" +} /** * Sizing information for a specific widget shown in a grid. diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetPreviewRepository.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetApp.kt similarity index 55% rename from modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetPreviewRepository.kt rename to modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetApp.kt index 8cb4265b61..b17dfe98e5 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/data/repository/WidgetPreviewRepository.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetApp.kt @@ -1,3 +1,5 @@ +package com.android.launcher3.widgetpicker.shared.model + /* * Copyright (C) 2025 The Android Open Source Project * @@ -14,13 +16,16 @@ * limitations under the License. */ -package com.android.launcher3.widgetpicker.data.repository - -import com.android.launcher3.widgetpicker.shared.model.WidgetId -import com.android.launcher3.widgetpicker.shared.model.WidgetPreview - -/** A repository that provides previews for the widgets to be displayed in the widget picker. */ -interface WidgetPreviewRepository { - /** Returns the preview for a widget represented by given [WidgetId]. */ - suspend fun getPreview(widgetId: WidgetId): WidgetPreview -} +/** + * Represents an app hosting widgets that is shown in widget picker. + * + * @param id a unique identifier for the app + * @param title a user readable title for the app; if null a placeholder text (e.g. "pending..") + * is shown until the title is loaded. + * @param widgets list of widgets available to picker from the app. + */ +data class WidgetApp( + val id: WidgetAppId, + val title: CharSequence?, + val widgets: List, +) diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetHostInfo.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetHostInfo.kt new file mode 100644 index 0000000000..6d48e5a67e --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetHostInfo.kt @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.shared.model + +import android.os.UserHandle + +/** + * Data class that holds information about the host needs to display the widget picker. + * + * @param title an optional title that should be shown in place of default "Widgets" title. + * @param description an optional 1-2 line description to be shown below the title. If not set, no + * description is shown. + * @param constraints constraints around which widgets can be shown in the picker. + */ +data class WidgetHostInfo( + val title: String? = null, + val description: String? = null, + val constraints: List = emptyList(), +) + +/** Various constraints for the widget host. */ +sealed class HostConstraint { + /** + * A constraint to apply on `widgetCategory` when deciding whether to show a widget in the + * widget picker. + * + * @param categoryInclusionMask mask that includes widgets matching the given widget category + * mask e.g. HOME_SCREEN or KEYGUARD; 0 implies no mask + * @param categoryExclusionMask mask that excludes widgets matching the mask e.g. + * NOT_KEYGUARD.inv(); 0 implies no mask + */ + data class HostCategoryConstraint( + val categoryInclusionMask: Int, + val categoryExclusionMask: Int, + ) : HostConstraint() + + /** + * A constraint to apply on `user` associated with widgets shown in widget picker. + * + * @param userFilters user profiles for which widgets list should be shown as empty. e.g. for + * lockscreen widgets, based on an admin setting, the host may filter out work widgets. In + * such case, the profile tab shows a generic no widgets available message. + */ + data class HostUserConstraint(val userFilters: List) : HostConstraint() +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetUserProfiles.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetUserProfiles.kt index 472fb6e58f..cf15959fb2 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetUserProfiles.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/shared/model/WidgetUserProfiles.kt @@ -20,7 +20,7 @@ package com.android.launcher3.widgetpicker.shared.model * Holds data about all the available user profiles on device that are supported in the widget * picker. */ -data class WidgetUserProfiles(val users: List) +data class WidgetUserProfiles(val personal: WidgetUserProfile, val work: WidgetUserProfile?) /** * Data about a specific user profile that is supported in the widget picker. @@ -36,8 +36,8 @@ data class WidgetUserProfiles(val users: List) data class WidgetUserProfile( val type: WidgetUserProfileType, val label: String, - val paused: Boolean, - val pausedProfileMessage: String, + val paused: Boolean = false, + val pausedProfileMessage: String? = null, ) /** Represents types of user profiles that are supported in the widget picker. */ From d3c07f8e9ca61256cc63143967157c2ad3ad0fb6 Mon Sep 17 00:00:00 2001 From: Shamali Patwa Date: Wed, 21 May 2025 12:45:32 -0700 Subject: [PATCH 15/25] Add use cases in widget picker domain layer that apply business rules. These will be used by the interactor classes to provide data to the ui layer. - FilterWidgetsForHostUseCase filters widgets that don't match the constraints specified by the host - GroupWidgetAppsByProfileUseCase groups widgets based on their user profile; and ensures that if work profile is paused, its widgets are treated as empty list. Bug: 408283627 Flag: EXEMPT independent module Test: Unit tests Change-Id: I676715daf5e400ba12acf50f867a5aa352d7bdf1 --- modules/widgetpicker/Android.bp | 15 ++ modules/widgetpicker/build.gradle.kts | 25 ++- .../usecase/FilterWidgetsForHostUseCase.kt | 73 ++++++++ .../GroupWidgetAppsByProfileUseCase.kt | 48 ++++++ modules/widgetpicker/tests/Android.bp | 72 ++++++++ .../widgetpicker/tests/WidgetPickerTests.xml | 49 ++++++ .../tests/config/robolectric.properties | 1 + .../launcher3/widgetpicker/TestUtils.kt | 125 ++++++++++++++ .../FilterWidgetsForHostUseCaseTest.kt | 161 ++++++++++++++++++ .../GroupWidgetAppsByProfileUseCaseTest.kt | 83 +++++++++ .../tests/multivalentTestsForDevice | 1 + 11 files changed, 649 insertions(+), 4 deletions(-) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt create mode 100644 modules/widgetpicker/tests/WidgetPickerTests.xml create mode 100644 modules/widgetpicker/tests/config/robolectric.properties create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt create mode 120000 modules/widgetpicker/tests/multivalentTestsForDevice diff --git a/modules/widgetpicker/Android.bp b/modules/widgetpicker/Android.bp index 301be44f0d..78320c5872 100644 --- a/modules/widgetpicker/Android.bp +++ b/modules/widgetpicker/Android.bp @@ -82,6 +82,21 @@ android_library { ], } +android_library { + name: "widget_picker_domain_layer", + sdk_version: "current", + min_sdk_version: min_launcher3_sdk_version, + srcs: [ + "src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt", + "src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt", + ], + static_libs: [ + "widget_picker_shared_data_types", + "widget_picker_dagger_annotations", + "dagger2", + ], +} + android_library { name: "widget_picker_ui_data_types", sdk_version: "current", diff --git a/modules/widgetpicker/build.gradle.kts b/modules/widgetpicker/build.gradle.kts index c78a6ea8a0..0c010e8b54 100644 --- a/modules/widgetpicker/build.gradle.kts +++ b/modules/widgetpicker/build.gradle.kts @@ -44,7 +44,17 @@ android { res.setSrcDirs(listOf("$widgetPickerDir/res")) } named("androidTest") { - java.setSrcDirs(listOf("$widgetPickerDir/tests/multivalentScreenshotTests/src/")) + java.setSrcDirs( + listOf( + "$widgetPickerDir/tests/multivalentScreenshotTests/src", + "$widgetPickerDir/tests/multivalentTestsForDevice/src", + ) + ) + manifest.srcFile("$widgetPickerDir/tests/AndroidManifest.xml") + } + named("test") { + java.setSrcDirs(listOf("$widgetPickerDir/tests/multivalentTests/src")) + resources.setSrcDirs(listOf("$widgetPickerDir/tests/config")) manifest.srcFile("$widgetPickerDir/tests/AndroidManifest.xml") res.setSrcDirs(listOf("$widgetPickerDir/tests/multivalentScreenshotTests/res")) } @@ -94,11 +104,13 @@ dependencies { testImplementation(libs.mockito.robolectric.bytebuddy.agent) testImplementation(libs.mockito.robolectric.bytebuddy) testImplementation(libs.mockito.robolectric) + testImplementation(libs.junit) + testImplementation(libs.google.truth) + testImplementation(libs.androidx.test.runner) + testImplementation(libs.androidx.junit) + androidTestImplementation(libs.google.truth) - androidTestImplementation(libs.junit) androidTestImplementation(libs.mockito.kotlin) - androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.test.rules) // Compose UI Tests @@ -112,3 +124,8 @@ dependencies { androidTestImplementation(project(":ScreenshotLib")) androidTestImplementation(project(":ScreenshotComposeLib")) } + +// Work around for kotlin bug with symlinked source: http://b/316363701 +tasks.matching { it.name.matches(Regex("widgetpicker.*compile.*TestKotlin")) }.configureEach { + inputs.dir("$widgetPickerDir/tests/multivalentTests/src") +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt new file mode 100644 index 0000000000..07de348c8f --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.usecase + +import com.android.launcher3.widgetpicker.WidgetPickerHostInfo +import com.android.launcher3.widgetpicker.WidgetPickerSingleton +import com.android.launcher3.widgetpicker.shared.model.HostConstraint +import com.android.launcher3.widgetpicker.shared.model.PickableWidget +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import javax.inject.Inject +import javax.inject.Named + +/** + * A usecase that hosts the business logic of filtering widgets based on host constraints and + * information. + */ +@WidgetPickerSingleton +class FilterWidgetsForHostUseCase +@Inject +constructor(@WidgetPickerHostInfo private val hostInfo: WidgetHostInfo) { + operator fun invoke(widgets: List) = + widgets.filter { widget -> + val eligibleForHost = + hostInfo.constraints.all { constraint -> + when (constraint) { + is HostConstraint.HostUserConstraint -> + !constraint.userFilters.contains(widget.id.userHandle) + + is HostConstraint.HostCategoryConstraint -> { + val widgetCategory = widget.appWidgetProviderInfo.widgetCategory + matchesCategory(constraint.categoryInclusionMask, widgetCategory) && + matchesCategory(constraint.categoryExclusionMask, widgetCategory) + } + } + } + + eligibleForHost + } + + companion object { + /** + * A filter that can be applied on the widgetCategory attribute from appwidget-provider to + * identify if the widget can be displayed on a specific widget surface. + * - Negative value (e.g. "category_a.inv() and category_b.inv()" excludes the widgets with + * given categories. + * - Positive value (e.g. "category_a or category_b" includes widgets with those categories. + * - 0 means no filter. + */ + private fun matchesCategory(categoryMask: Int, widgetCategory: Int): Boolean { + return if (categoryMask > 0) { // inclusion filter + (widgetCategory and categoryMask) != 0 + } else if (categoryMask < 0) { // exclusion filter + (widgetCategory and categoryMask) == widgetCategory + } else { + true // no filter + } + } + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt new file mode 100644 index 0000000000..f99377f6fa --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.usecase + +import android.os.UserHandle +import com.android.launcher3.widgetpicker.shared.model.WidgetApp +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import javax.inject.Inject + +/** A helper class that groups widget apps by user profiles. */ +class GroupWidgetAppsByProfileUseCase @Inject constructor() { + operator fun invoke( + widgetApps: List, + userProfiles: WidgetUserProfiles, + workProfileUser: UserHandle?, + ): Map> { + val personalProfile = userProfiles.personal + val workProfile = userProfiles.work + + return when { + (workProfile != null && workProfileUser != null) -> { + val (workWidgetApps, personalWidgetApps) = + widgetApps.partition { it.id.userHandle == workProfileUser } + val finalWorkWidgetApps = + (workWidgetApps.takeIf { !workProfile.paused } ?: emptyList()) + + mapOf(personalProfile to personalWidgetApps, workProfile to finalWorkWidgetApps) + } + + else -> mapOf(personalProfile to widgetApps) + } + } +} diff --git a/modules/widgetpicker/tests/Android.bp b/modules/widgetpicker/tests/Android.bp index ad736ebc32..762d3cac6d 100644 --- a/modules/widgetpicker/tests/Android.bp +++ b/modules/widgetpicker/tests/Android.bp @@ -30,7 +30,11 @@ android_app { system_ext_specific: true, static_libs: [ "widget_picker_ui_components", + "widget_picker_domain_layer", + "widget_picker_data_repositories", ], + kotlincflags: ["-Xjvm-default=all"], + use_resource_processor: true, } android_test { @@ -77,3 +81,71 @@ android_test { "multivalentScreenshotTests/res", ], } + +filegroup { + name: "widget-picker-multivalent-tests-src", + srcs: [ + "multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt", + ], +} + +android_test { + name: "WidgetPickerDeviceTests", + manifest: "AndroidManifest.xml", + srcs: [":widget-picker-multivalent-tests-src"], + platform_apis: true, + static_libs: [ + "widget_picker_domain_layer", + "widget_picker_data_repositories", + "collector-device-lib-platform", + "testables", + "platform-test-rules", + "platform-parametric-runner-lib", + "junit", + "androidx.test.ext.junit", + "androidx.test.rules", + "androidx.test.runner", + ], + libs: [ + "android.test.base.impl", + "android.test.runner.impl", + "android.test.mock.impl", + ], + // Libraries used by mockito inline extended + jni_libs: [ + "libdexmakerjvmtiagent", + "libstaticjvmtiagent", + ], + // Needed to link mokito libraries to run unbundled + use_embedded_native_libs: false, + // Needed to compile native libs for cuttlefish + compile_multilib: "both", + instrumentation_for: "WidgetPickerTestApp", + plugins: ["dagger2-compiler"], + test_suites: ["general-tests"], + test_config: "WidgetPickerTests.xml", +} + +android_robolectric_test { + enabled: true, + name: "WidgetPickerRoboTests", + srcs: [":widget-picker-multivalent-tests-src"], + java_resource_dirs: ["config"], + static_libs: [ + "widget_picker_domain_layer", + "widget_picker_data_repositories", + "kotlinx_coroutines_test", + "platform-test-rules-deviceless", + ], + libs: [ + "android.test.runner.impl", + "android.test.base.impl", + "android.test.mock.impl", + "truth", + ], + plugins: ["dagger2-compiler"], + instrumentation_for: "WidgetPickerTestApp", + strict_mode: false, +} diff --git a/modules/widgetpicker/tests/WidgetPickerTests.xml b/modules/widgetpicker/tests/WidgetPickerTests.xml new file mode 100644 index 0000000000..8dba04c74a --- /dev/null +++ b/modules/widgetpicker/tests/WidgetPickerTests.xml @@ -0,0 +1,49 @@ + + + + diff --git a/modules/widgetpicker/tests/config/robolectric.properties b/modules/widgetpicker/tests/config/robolectric.properties new file mode 100644 index 0000000000..fab7251d02 --- /dev/null +++ b/modules/widgetpicker/tests/config/robolectric.properties @@ -0,0 +1 @@ +sdk=NEWEST_SDK diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt new file mode 100644 index 0000000000..74b14cfdfb --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker + +import android.appwidget.AppWidgetProviderInfo +import android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN +import android.content.ComponentName +import android.os.UserHandle +import com.android.launcher3.widgetpicker.shared.model.PickableWidget +import com.android.launcher3.widgetpicker.shared.model.WidgetApp +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.shared.model.WidgetId +import com.android.launcher3.widgetpicker.shared.model.WidgetSizeInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfileType + +/** Utilities and constants to build test data. */ +object TestUtils { + val personalUser: UserHandle = UserHandle.of(1) + val workUser: UserHandle = UserHandle.of(10) + + val widgetUserProfilePersonal = + WidgetUserProfile(type = WidgetUserProfileType.PERSONAL, label = "personal") + val widgetUserProfileWork = WidgetUserProfile(type = WidgetUserProfileType.WORK, label = "work") + + private const val PACKAGE_NAME = "com.example.test" + private val PERSONAL_WIDGET_APP_1 = buildWidgetAppId("AppOne", personalUser) + private val PERSONAL_WIDGET_APP_2 = buildWidgetAppId("AppTwo", personalUser) + private val WORK_WIDGET_APP_1 = buildWidgetAppId("WAppOne", workUser) + + val PERSONAL_TEST_APPS = + listOf( + WidgetApp( + id = PERSONAL_WIDGET_APP_1, + title = "Personal App 1", + widgets = + listOf( + buildTestWidget( + providerClassName = "PersonalWidget1A", + widgetAppId = PERSONAL_WIDGET_APP_1, + userHandle = personalUser, + ) + ), + ), + WidgetApp( + id = PERSONAL_WIDGET_APP_2, + title = "Personal App 2", + widgets = + listOf( + buildTestWidget( + providerClassName = "PersonalWidget2A", + widgetAppId = PERSONAL_WIDGET_APP_2, + userHandle = personalUser, + ) + ), + ), + ) + + val WORK_TEST_APPS = + listOf( + WidgetApp( + id = WORK_WIDGET_APP_1, + title = "Work App 1", + widgets = + listOf( + buildTestWidget( + providerClassName = "WorkWidget1A", + widgetAppId = WORK_WIDGET_APP_1, + userHandle = workUser, + ), + buildTestWidget( + providerClassName = "WorkWidget1B", + widgetAppId = WORK_WIDGET_APP_1, + userHandle = workUser, + ), + ), + ) + ) + + private fun buildWidgetAppId(suffix: String, userHandle: UserHandle) = + WidgetAppId(packageName = "$PACKAGE_NAME.$suffix", category = null, userHandle = userHandle) + + fun buildTestWidget( + providerClassName: String, + category: Int = WIDGET_CATEGORY_HOME_SCREEN, + widgetAppId: WidgetAppId? = null, + userHandle: UserHandle = UserHandle.of(0), + ): PickableWidget { + val finalWidgetAppId = + widgetAppId + ?: WidgetAppId(packageName = PACKAGE_NAME, userHandle = userHandle, category = null) + + return PickableWidget( + id = + WidgetId(ComponentName.createRelative(PACKAGE_NAME, providerClassName), userHandle), + appId = finalWidgetAppId, + label = providerClassName, + description = null, + appWidgetProviderInfo = AppWidgetProviderInfo().apply { widgetCategory = category }, + sizeInfo = + WidgetSizeInfo( + spanX = 2, + spanY = 2, + widthPx = 200, + heightPx = 200, + containerWidthPx = 200, + containerHeightPx = 200, + ), + ) + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt new file mode 100644 index 0000000000..9fbe937c94 --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.usecase + +import android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN +import android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD +import android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_NOT_KEYGUARD +import android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX +import android.os.UserHandle +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.launcher3.widgetpicker.TestUtils.buildTestWidget +import com.android.launcher3.widgetpicker.shared.model.HostConstraint +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class FilterWidgetsForHostUseCaseTest { + @Test + fun noFilter_returnsAll() { + val underTest = FilterWidgetsForHostUseCase(hostInfo = WidgetHostInfo()) + val inputWidgets = listOf(buildTestWidget("provider1"), buildTestWidget("provider2")) + + val filteredWidgets = underTest(inputWidgets) + + assertThat(filteredWidgets).containsExactlyElementsIn(inputWidgets) + } + + @Test + fun userAndCategoryFilter_appliesBoth() { + val underTest = + FilterWidgetsForHostUseCase( + hostInfo = + WidgetHostInfo( + constraints = + listOf( + HostConstraint.HostUserConstraint( + userFilters = listOf(UserHandle.of(10)) + ), + HostConstraint.HostCategoryConstraint( + categoryInclusionMask = + WIDGET_CATEGORY_HOME_SCREEN or WIDGET_CATEGORY_KEYGUARD, + categoryExclusionMask = WIDGET_CATEGORY_NOT_KEYGUARD.inv(), + ), + ) + ) + ) + + val provider1 = + buildTestWidget( + providerClassName = "provider1", + category = WIDGET_CATEGORY_HOME_SCREEN, // match + userHandle = UserHandle(0), // match + ) + val provider2 = + buildTestWidget( + providerClassName = "provider2", + category = WIDGET_CATEGORY_KEYGUARD, // match + userHandle = UserHandle(0), // match + ) + val provider3 = + buildTestWidget( + providerClassName = "provider3", + category = WIDGET_CATEGORY_HOME_SCREEN, // match + userHandle = UserHandle(10), // no match + ) + val provider4 = + buildTestWidget( + providerClassName = "provider4", + category = WIDGET_CATEGORY_HOME_SCREEN or WIDGET_CATEGORY_NOT_KEYGUARD, // no match + userHandle = UserHandle(0), // match + ) + val provider5 = + buildTestWidget( + providerClassName = "provider5", + category = WIDGET_CATEGORY_SEARCHBOX, // no match + userHandle = UserHandle(0), // match + ) + val provider6 = + buildTestWidget( + providerClassName = "provider6", + category = WIDGET_CATEGORY_KEYGUARD or WIDGET_CATEGORY_HOME_SCREEN, // match + userHandle = UserHandle(0), // match + ) + val filteredWidgets = + underTest(listOf(provider1, provider2, provider3, provider4, provider5, provider6)) + + assertThat(filteredWidgets) + .containsExactlyElementsIn(listOf(provider1, provider2, provider6)) + } + + @Test + fun onlyOneOfInclusionOrExclusionFilter() { + val inclusionOnlyFilter = + FilterWidgetsForHostUseCase( + hostInfo = + WidgetHostInfo( + constraints = + listOf( + HostConstraint.HostCategoryConstraint( + categoryInclusionMask = + WIDGET_CATEGORY_HOME_SCREEN or WIDGET_CATEGORY_KEYGUARD, + categoryExclusionMask = 0, + ) + ) + ) + ) + val exclusionOnlyFilter = + FilterWidgetsForHostUseCase( + hostInfo = + WidgetHostInfo( + constraints = + listOf( + HostConstraint.HostCategoryConstraint( + categoryInclusionMask = 0, + categoryExclusionMask = WIDGET_CATEGORY_NOT_KEYGUARD.inv(), + ) + ) + ) + ) + + val provider1 = + buildTestWidget(providerClassName = "provider1", category = WIDGET_CATEGORY_HOME_SCREEN) + val provider2 = + buildTestWidget( + providerClassName = "provider2", + category = WIDGET_CATEGORY_HOME_SCREEN or WIDGET_CATEGORY_KEYGUARD, + ) + val provider3 = + buildTestWidget( + providerClassName = "provider3", + category = WIDGET_CATEGORY_HOME_SCREEN or WIDGET_CATEGORY_NOT_KEYGUARD, + ) + val provider4 = + buildTestWidget(providerClassName = "provider4", category = WIDGET_CATEGORY_SEARCHBOX) + val filteredInclusionOnlyWidgets = + inclusionOnlyFilter(listOf(provider1, provider2, provider3, provider4)) + val filteredExclusionOnlyWidgets = + exclusionOnlyFilter(listOf(provider1, provider2, provider3, provider4)) + + assertThat(filteredInclusionOnlyWidgets) + .containsExactlyElementsIn(listOf(provider1, provider2, provider3)) + assertThat(filteredExclusionOnlyWidgets) + .containsExactlyElementsIn(listOf(provider1, provider2, provider4)) + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt new file mode 100644 index 0000000000..c479ee80aa --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.usecase + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.widgetUserProfilePersonal +import com.android.launcher3.widgetpicker.TestUtils.widgetUserProfileWork +import com.android.launcher3.widgetpicker.TestUtils.workUser +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class GroupWidgetAppsByProfileUseCaseTest { + private val underTest = GroupWidgetAppsByProfileUseCase() + + @Test + fun noWorkProfile_mapsOnlyPersonalProfile() { + val allWidgetApps = PERSONAL_TEST_APPS + val personalProfile = widgetUserProfilePersonal + val workProfile = null + + val result = underTest( + workProfileUser = null, + widgetApps = allWidgetApps, + userProfiles = WidgetUserProfiles(personal = personalProfile, work = workProfile), + ) + + assertThat(result).hasSize(1) + assertThat(result).containsExactlyEntriesIn(mapOf(personalProfile to allWidgetApps)) + } + + @Test + fun workProfile_mapsBothPersonalAndWorkProfiles() { + val allWidgetApps = PERSONAL_TEST_APPS + WORK_TEST_APPS + val personalProfile = widgetUserProfilePersonal + val workProfile = widgetUserProfileWork.copy(paused = false) + + val result = underTest( + workProfileUser = workUser, + widgetApps = allWidgetApps, + userProfiles = WidgetUserProfiles(personal = personalProfile, work = workProfile), + ) + + assertThat(result).hasSize(2) + assertThat(result[personalProfile]).containsExactlyElementsIn(PERSONAL_TEST_APPS) + assertThat(result[workProfile]).containsExactlyElementsIn(WORK_TEST_APPS) + } + + @Test + fun workProfilePaused_setsWorkWidgetsToEmpty() { + val allWidgetApps = PERSONAL_TEST_APPS + WORK_TEST_APPS + val personalProfile = widgetUserProfilePersonal + val workProfile = widgetUserProfileWork.copy(paused = true) + + val result = underTest( + workProfileUser = workUser, + widgetApps = allWidgetApps, + userProfiles = WidgetUserProfiles(personal = personalProfile, work = workProfile), + ) + + assertThat(result).hasSize(2) + assertThat(result[personalProfile]).containsExactlyElementsIn(PERSONAL_TEST_APPS) + assertThat(result[workProfile]).isEmpty() + } +} diff --git a/modules/widgetpicker/tests/multivalentTestsForDevice b/modules/widgetpicker/tests/multivalentTestsForDevice new file mode 120000 index 0000000000..fa0fabf27b --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTestsForDevice @@ -0,0 +1 @@ +./multivalentTests \ No newline at end of file From cd2104334cce94bf1c5ca302696c0b3560ad0820 Mon Sep 17 00:00:00 2001 From: Shamali Patwa Date: Thu, 22 May 2025 16:37:46 -0700 Subject: [PATCH 16/25] Add WidgetsInteractor that enables view layer to interact with widgets - This is responsible for looking up data from repositories and applying business rules using use cases. Bug: 408283627 Flag: EXEMPT independent module Test: Unit tests Change-Id: I767186a38b3105085637c75d9aec8ca21788f49f --- modules/widgetpicker/Android.bp | 5 + modules/widgetpicker/TEST_MAPPING | 6 + modules/widgetpicker/build.gradle.kts | 2 + modules/widgetpicker/res/values/strings.xml | 7 + .../launcher3/widgetpicker/Annotations.kt | 11 + .../interactor/WidgetAppIconsInteractor.kt | 61 +++++ .../domain/interactor/WidgetsInteractor.kt | 140 +++++++++++ .../ui/components/WidgetAppsList.kt | 7 +- .../ui/components/WidgetAppsListHeader.kt | 10 +- modules/widgetpicker/tests/Android.bp | 22 +- ...rTests.xml => WidgetPickerDeviceTests.xml} | 0 .../WidgetAppIconsInteractorTest.kt | 102 ++++++++ .../interactor/WidgetsInteractorTest.kt | 228 ++++++++++++++++++ .../FakeWidgetAppIconsRepository.kt | 55 +++++ .../repository/FakeWidgetUsersRepository.kt | 46 ++++ .../repository/FakeWidgetsRepository.kt | 71 ++++++ 16 files changed, 759 insertions(+), 14 deletions(-) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractor.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractor.kt rename modules/widgetpicker/tests/{WidgetPickerTests.xml => WidgetPickerDeviceTests.xml} (100%) create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractorTest.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractorTest.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt diff --git a/modules/widgetpicker/Android.bp b/modules/widgetpicker/Android.bp index 78320c5872..39f9c90fa5 100644 --- a/modules/widgetpicker/Android.bp +++ b/modules/widgetpicker/Android.bp @@ -89,11 +89,16 @@ android_library { srcs: [ "src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCase.kt", "src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCase.kt", + "src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractor.kt", + "src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractor.kt", ], static_libs: [ "widget_picker_shared_data_types", + "widget_picker_data_repositories", "widget_picker_dagger_annotations", "dagger2", + "kotlinx-coroutines-android", + "kotlinx-coroutines-core", ], } diff --git a/modules/widgetpicker/TEST_MAPPING b/modules/widgetpicker/TEST_MAPPING index 2040beec54..62e9605e87 100644 --- a/modules/widgetpicker/TEST_MAPPING +++ b/modules/widgetpicker/TEST_MAPPING @@ -2,6 +2,12 @@ "presubmit": [ { "name": "WidgetPickerScreenshotTests" + }, + { + "name": "WidgetPickerDeviceTests" + }, + { + "name": "WidgetPickerRoboTests" } ] } \ No newline at end of file diff --git a/modules/widgetpicker/build.gradle.kts b/modules/widgetpicker/build.gradle.kts index 0c010e8b54..fbc0f45a48 100644 --- a/modules/widgetpicker/build.gradle.kts +++ b/modules/widgetpicker/build.gradle.kts @@ -108,10 +108,12 @@ dependencies { testImplementation(libs.google.truth) testImplementation(libs.androidx.test.runner) testImplementation(libs.androidx.junit) + testImplementation(libs.kotlinx.coroutines.test) androidTestImplementation(libs.google.truth) androidTestImplementation(libs.mockito.kotlin) androidTestImplementation(libs.androidx.test.rules) + androidTestImplementation(libs.kotlinx.coroutines.test) // Compose UI Tests androidTestApi(libs.compose.ui.test.junit4) diff --git a/modules/widgetpicker/res/values/strings.xml b/modules/widgetpicker/res/values/strings.xml index 21a15ebe74..fbd965e019 100644 --- a/modules/widgetpicker/res/values/strings.xml +++ b/modules/widgetpicker/res/values/strings.xml @@ -34,6 +34,13 @@ [CHAR_LIMIT=25] --> Featured + + Browse + + + %1$s widgets on right, search and options on left + Search diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt index 276ffefaf0..2309dfc5c8 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/Annotations.kt @@ -25,8 +25,19 @@ import javax.inject.Scope @Scope annotation class WidgetPickerSingleton +/** Qualifier annotation for the background context used in interactors. */ +@Qualifier +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +annotation class WidgetPickerBackground + /** Qualifier annotation for information about the widget host. */ @Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class WidgetPickerHostInfo + +@Qualifier +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +annotation class WidgetPickerRepository diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractor.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractor.kt new file mode 100644 index 0000000000..3b6b00da0f --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractor.kt @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.interactor + +import com.android.launcher3.widgetpicker.WidgetPickerBackground +import com.android.launcher3.widgetpicker.WidgetPickerRepository +import com.android.launcher3.widgetpicker.WidgetPickerSingleton +import com.android.launcher3.widgetpicker.data.repository.WidgetAppIconsRepository +import com.android.launcher3.widgetpicker.data.repository.WidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetAppIcon +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.flatMapLatest +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.map +import javax.inject.Inject +import kotlin.coroutines.CoroutineContext + +/** + * A domain layer object that enables the UI layer to get the apps icons from data layer. + * - Responsible for merging the necessary information from widgets and app icons repositories to + * provide the app icons. + */ +@WidgetPickerSingleton +class WidgetAppIconsInteractor @Inject constructor( + @WidgetPickerRepository + private val widgetAppIconsRepository: WidgetAppIconsRepository, + @WidgetPickerRepository + private val widgetsRepository: WidgetsRepository, + @WidgetPickerBackground + private val backgroundContext: CoroutineContext, +) { + /** Returns a flow of icons for all widget apps that host widgets. */ + @OptIn(ExperimentalCoroutinesApi::class) + fun getAllWidgetAppIcons(): Flow> = + widgetsRepository.observeWidgets().flatMapLatest { widgetApps -> + val flows: List>> = widgetApps.map { widgetApp -> + widgetAppIconsRepository.getAppIcon(widgetApp.id).map { + widgetApp.id to it + } + } + + combine(flows) { it.toMap() } + }.flowOn(backgroundContext) +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractor.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractor.kt new file mode 100644 index 0000000000..4873bb01ad --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractor.kt @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.interactor + +import com.android.launcher3.widgetpicker.WidgetPickerBackground +import com.android.launcher3.widgetpicker.WidgetPickerRepository +import com.android.launcher3.widgetpicker.WidgetPickerSingleton +import com.android.launcher3.widgetpicker.data.repository.WidgetUsersRepository +import com.android.launcher3.widgetpicker.data.repository.WidgetsRepository +import com.android.launcher3.widgetpicker.domain.usecase.FilterWidgetsForHostUseCase +import com.android.launcher3.widgetpicker.domain.usecase.GroupWidgetAppsByProfileUseCase +import com.android.launcher3.widgetpicker.shared.model.PickableWidget +import com.android.launcher3.widgetpicker.shared.model.WidgetApp +import com.android.launcher3.widgetpicker.shared.model.WidgetId +import com.android.launcher3.widgetpicker.shared.model.WidgetPreview +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.withContext +import javax.inject.Inject +import kotlin.coroutines.CoroutineContext + +/** + * A domain layer object that enables the UI layer to interact with the widgets in data layer. + * - Responsible for applying business rules such as applying host constraints, filtering data for + * paused work profile, etc. + */ +@WidgetPickerSingleton +class WidgetsInteractor +@Inject +constructor( + @WidgetPickerRepository + private val widgetsRepository: WidgetsRepository, + @WidgetPickerRepository + private val widgetUsersRepository: WidgetUsersRepository, + private val filterWidgetsForHostUseCase: FilterWidgetsForHostUseCase, + private val getWidgetAppsByProfileUseCase: GroupWidgetAppsByProfileUseCase, + @WidgetPickerBackground + private val backgroundContext: CoroutineContext, +) { + /** Returns the list of widget apps per user profiles. */ + fun getWidgetAppsByProfile(): Flow>> = + combine( + widgetsRepository.observeWidgets(), + widgetUsersRepository.observeUserProfiles() + ) { widgetApps, + widgetUserProfiles -> + val filteredWidgets = + widgetApps + .map { it.copy(widgets = filterWidgetsForHostUseCase(it.widgets)) } + .filter { it.widgets.isNotEmpty() } + .sortedBy { it.title?.toString() ?: "" } + widgetUserProfiles?.let { + getWidgetAppsByProfileUseCase( + filteredWidgets, + widgetUserProfiles, + widgetUsersRepository.getWorkProfileUser(), + ) + } ?: emptyMap() + } + .distinctUntilChanged() + .flowOn(backgroundContext) + + /** Loads and returns the preview for an appwidget. */ + suspend fun getWidgetPreview(widgetId: WidgetId): WidgetPreview = + widgetsRepository.getWidgetPreview(widgetId) + + /** Returns widgets that can be featured in the widget picker. */ + fun getFeaturedWidgets(): Flow> = + combine( + widgetsRepository.getFeaturedWidgets(), + widgetUsersRepository.observeUserProfiles(), + ) { widgets, widgetUserProfiles -> + val filteredWidgets = filterWidgetsForHostUseCase(widgets) + + val hasPausedWorkProfile = + widgetUserProfiles?.work?.paused ?: false + val workProfileUser = + if (hasPausedWorkProfile) { + checkNotNull(widgetUsersRepository.getWorkProfileUser()) + } else null + + return@combine if (hasPausedWorkProfile) { + filteredWidgets.filter { it.id.userHandle != workProfileUser } + } else { + filteredWidgets + } + } + + /*** + * Returns the list of widget apps that match the given plain text [query] string entered by the + * user. The widget's label, description and app's title is expected to be considered for + * returning matches. + * + * Filters out + * - widgets that don't match the host criteria + * - when work profile is paused, work profile widgets are also filtered out. + */ + suspend fun searchWidgetApps(query: String): Flow> = + withContext(backgroundContext) { + val matchedWidgetApps = widgetsRepository.searchWidgets(query).map { + it.copy( + widgets = filterWidgetsForHostUseCase(it.widgets) + ) + }.filter { it.widgets.isNotEmpty() } + + // business rule: We don't show work profile widgets when profile is paused. + val workProfileUser = widgetUsersRepository.getWorkProfileUser() + if (workProfileUser != null) { + widgetUsersRepository.observeUserProfiles().map { profiles -> + val paused = checkNotNull(profiles?.work).paused + if (paused) { + matchedWidgetApps.filter { it.id.userHandle != workProfileUser } + } else { + matchedWidgetApps + } + } + } else { + flowOf(matchedWidgetApps) + } + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsList.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsList.kt index a4288e98d8..d880a9aecf 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsList.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsList.kt @@ -93,12 +93,7 @@ fun WidgetAppsList( appIcon = appIcon, title = title, description = description, - widgetPreviews = - if (selected) { - widgetPreviews - } else { - emptyMap() - }, + widgetPreviews = widgetPreviews, onWidgetAppClick = onWidgetAppClick, ) } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsListHeader.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsListHeader.kt index bb4e510d12..371c08fc5e 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsListHeader.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetAppsListHeader.kt @@ -80,11 +80,11 @@ fun ExpandableListHeader( modifier .clip(shape = shape) .background(color = ExpandedListHeaderDefaults.backgroundColor) - .clickable { onClick() } Column(modifier = finalModifier) { WidgetAppHeader( - modifier = Modifier, + modifier = Modifier + .clickable { onClick() }, leadingIcon = { leadingAppIcon() }, title = title, subTitle = subTitle, @@ -192,7 +192,8 @@ fun SelectableSuggestionsHeader( imageVector = Icons.Filled.Star, contentDescription = null, modifier = - Modifier.clip(shape) + Modifier + .clip(shape) .background(MaterialTheme.colorScheme.surfaceBright) .minimumInteractiveComponentSize(), ) @@ -224,7 +225,8 @@ private fun WidgetAppHeader( leadingIcon() CenterText( modifier = - Modifier.weight(1f) + Modifier + .weight(1f) .padding(horizontal = ListHeaderDimensions.centerTextHorizontalPadding), title = title, subTitle = subTitle, diff --git a/modules/widgetpicker/tests/Android.bp b/modules/widgetpicker/tests/Android.bp index 762d3cac6d..7b1c952b8c 100644 --- a/modules/widgetpicker/tests/Android.bp +++ b/modules/widgetpicker/tests/Android.bp @@ -29,12 +29,13 @@ android_app { certificate: "platform", system_ext_specific: true, static_libs: [ + "widget_picker_ui", "widget_picker_ui_components", "widget_picker_domain_layer", "widget_picker_data_repositories", ], kotlincflags: ["-Xjvm-default=all"], - use_resource_processor: true, + use_resource_processor: false, } android_test { @@ -88,6 +89,11 @@ filegroup { "multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt", "multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/GroupWidgetAppsByProfileUseCaseTest.kt", "multivalentTests/src/com/android/launcher3/widgetpicker/domain/usecase/FilterWidgetsForHostUseCaseTest.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractorTest.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractorTest.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt", ], } @@ -101,6 +107,7 @@ android_test { "widget_picker_data_repositories", "collector-device-lib-platform", "testables", + "platform-test-annotations", "platform-test-rules", "platform-parametric-runner-lib", "junit", @@ -124,8 +131,8 @@ android_test { compile_multilib: "both", instrumentation_for: "WidgetPickerTestApp", plugins: ["dagger2-compiler"], - test_suites: ["general-tests"], - test_config: "WidgetPickerTests.xml", + test_suites: ["device-tests"], + test_config: "WidgetPickerDeviceTests.xml", } android_robolectric_test { @@ -138,6 +145,12 @@ android_robolectric_test { "widget_picker_data_repositories", "kotlinx_coroutines_test", "platform-test-rules-deviceless", + "testables", + "platform-parametric-runner-lib", + "junit", + "androidx.test.ext.junit", + "platform-test-annotations", + "androidx.test.rules", ], libs: [ "android.test.runner.impl", @@ -147,5 +160,6 @@ android_robolectric_test { ], plugins: ["dagger2-compiler"], instrumentation_for: "WidgetPickerTestApp", - strict_mode: false, + strict_mode: true, + test_suites: ["general-tests"], } diff --git a/modules/widgetpicker/tests/WidgetPickerTests.xml b/modules/widgetpicker/tests/WidgetPickerDeviceTests.xml similarity index 100% rename from modules/widgetpicker/tests/WidgetPickerTests.xml rename to modules/widgetpicker/tests/WidgetPickerDeviceTests.xml diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractorTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractorTest.kt new file mode 100644 index 0000000000..84f6e7ef9c --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetAppIconsInteractorTest.kt @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.interactor + +import android.graphics.Bitmap +import android.graphics.Color +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.repository.FakeWidgetAppIconsRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.AppIcon +import com.android.launcher3.widgetpicker.shared.model.AppIconBadge +import com.android.launcher3.widgetpicker.shared.model.WidgetAppIcon +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@OptIn(ExperimentalCoroutinesApi::class) +class WidgetAppIconsInteractorTest { + private val testDispatcher = UnconfinedTestDispatcher() + private val testScope = TestScope(testDispatcher) + private val widgetsRepository = FakeWidgetsRepository() + private val widgetAppIconsRepository = FakeWidgetAppIconsRepository() + + private val underTest = WidgetAppIconsInteractor( + widgetAppIconsRepository = widgetAppIconsRepository, + widgetsRepository = widgetsRepository, + backgroundContext = testDispatcher + ) + + @Test + fun returnsMappedAppIcons() = testScope.runTest { + widgetsRepository.seedWidgets( + listOf( + PERSONAL_TEST_APPS[0], + PERSONAL_TEST_APPS[1], + WORK_TEST_APPS[0] + ) + ) + val widgetAppId1 = PERSONAL_TEST_APPS[0].id + val widgetAppId2 = PERSONAL_TEST_APPS[1].id + val widgetAppId3 = WORK_TEST_APPS[0].id // no app icon yet + val appIcon1 = WidgetAppIcon( + icon = AppIcon.LowResColorIcon(color = Color.BLUE), + badge = AppIconBadge.NoBadge + ) + val appIcon2 = WidgetAppIcon( + icon = AppIcon.HighResBitmapIcon( + Bitmap.createBitmap( + 50, + 50, + Bitmap.Config.ARGB_8888 + ) + ), + badge = AppIconBadge.DrawableBadge( + drawableResId = android.R.drawable.ic_menu_add, + tintColor = Color.RED + ) + ) + widgetAppIconsRepository.seedAppIcons( + mapOf( + widgetAppId1 to appIcon1, + widgetAppId2 to appIcon2, + // no widgetAppId3 + ) + ) + val expected = mapOf( + widgetAppId1 to appIcon1, + widgetAppId2 to appIcon2, + widgetAppId3 to WidgetAppIcon( + icon = AppIcon.PlaceHolderAppIcon, + badge = AppIconBadge.NoBadge + ) + ) + runCurrent() + + underTest.getAllWidgetAppIcons().filter { it == expected }.first() // no error + runCurrent() + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractorTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractorTest.kt new file mode 100644 index 0000000000..0607e69359 --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/domain/interactor/WidgetsInteractorTest.kt @@ -0,0 +1,228 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.domain.interactor + +import android.graphics.Bitmap +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.widgetUserProfilePersonal +import com.android.launcher3.widgetpicker.TestUtils.widgetUserProfileWork +import com.android.launcher3.widgetpicker.TestUtils.workUser +import com.android.launcher3.widgetpicker.domain.usecase.FilterWidgetsForHostUseCase +import com.android.launcher3.widgetpicker.domain.usecase.GroupWidgetAppsByProfileUseCase +import com.android.launcher3.widgetpicker.repository.FakeWidgetUsersRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetPreview +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import com.google.common.truth.Truth.assertThat +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@OptIn(ExperimentalCoroutinesApi::class) +class WidgetsInteractorTest { + + private val testDispatcher = UnconfinedTestDispatcher() + private val testScope = TestScope(testDispatcher) + + private val widgetUsersRepository = FakeWidgetUsersRepository() + private val widgetsRepository = FakeWidgetsRepository() + private val underTest = + WidgetsInteractor( + widgetsRepository = widgetsRepository, + widgetUsersRepository = widgetUsersRepository, + getWidgetAppsByProfileUseCase = GroupWidgetAppsByProfileUseCase(), + filterWidgetsForHostUseCase = FilterWidgetsForHostUseCase(WidgetHostInfo()), + backgroundContext = testDispatcher + ) + + @Test + fun noWidgets_returnsEmpty() = + testScope.runTest { + assertThat(underTest.getWidgetAppsByProfile().first()).isEmpty() + assertThat(underTest.getFeaturedWidgets().first()).isEmpty() + runCurrent() + } + + @Test + fun userProfilesNotLoaded_returnsEmpty() = + testScope.runTest { + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + runCurrent() + + assertThat(underTest.getWidgetAppsByProfile().first()).isEmpty() + assertThat(underTest.getFeaturedWidgets().first()).isEmpty() + runCurrent() + } + + @Test + fun getWidgetAppsByProfile_returnsWidgetGroupedByProfile() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork, + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + runCurrent() + + val result = underTest.getWidgetAppsByProfile().first() + runCurrent() + + assertThat(result).hasSize(2) + assertThat(result[widgetUserProfilePersonal]) + .containsExactlyElementsIn(PERSONAL_TEST_APPS) + assertThat(result[widgetUserProfileWork]).containsExactlyElementsIn(WORK_TEST_APPS) + } + + @Test + fun getFeaturedWidgets_returnsAllFeaturedWidgets() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork, + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + val personalFeaturedWidget = PERSONAL_TEST_APPS[0].widgets[0] + val workFeaturedWidget = WORK_TEST_APPS[0].widgets[0] + widgetsRepository.seedFeaturedWidgets( + setOf(workFeaturedWidget.id, personalFeaturedWidget.id) + ) + runCurrent() + + val result = underTest.getFeaturedWidgets().first() + runCurrent() + + assertThat(result).containsExactly(personalFeaturedWidget, workFeaturedWidget) + } + + @Test + fun getFeaturedWidgets_pausedWorkProfile_returnsOnlyPersonalWidgets() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork.copy(paused = true), + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + val personalFeaturedWidget = PERSONAL_TEST_APPS[0].widgets[0] + val workFeaturedWidget = WORK_TEST_APPS[0].widgets[0] + widgetsRepository.seedFeaturedWidgets( + setOf(workFeaturedWidget.id, personalFeaturedWidget.id) + ) + runCurrent() + + val result = underTest.getFeaturedWidgets().first() + runCurrent() + + assertThat(result).containsExactly(personalFeaturedWidget) + } + + @Test + fun getWidgetPreviews_returnsExpectedPreviews() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork, + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + val personalWidgetId = PERSONAL_TEST_APPS[0].widgets[0].id + val personalWidgetPreview = + WidgetPreview.BitmapWidgetPreview( + Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888) + ) + val workWidgetId = WORK_TEST_APPS[0].widgets[0].id + widgetsRepository.seedWidgetPreviews( + mapOf( + personalWidgetId to personalWidgetPreview + ) // no work widget preview available. + ) + runCurrent() + + assertThat(underTest.getWidgetPreview(personalWidgetId)) + .isEqualTo(personalWidgetPreview) + assertThat(underTest.getWidgetPreview(workWidgetId)) + .isEqualTo(WidgetPreview.PlaceholderWidgetPreview) + } + + @Test + fun searchWidgets_returnsExpectedWidgets() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork, + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + runCurrent() + + val input = PERSONAL_TEST_APPS[0].widgets[0].label + val result = underTest.searchWidgetApps(input).first() + runCurrent() + + assertThat(result.size).isEqualTo(1) + assertThat(result[0].widgets.size).isEqualTo(1) + assertThat(result[0].widgets[0].label).isEqualTo(input) + } + + @Test + fun searchWidgets_pausedWorkProfile_returnsOnlyPersonalWidgets() = + testScope.runTest { + widgetUsersRepository.seedUserProfiles( + profiles = + WidgetUserProfiles( + personal = widgetUserProfilePersonal, + work = widgetUserProfileWork.copy(paused = true), + ), + workProfileUser = workUser, + ) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + runCurrent() + + val input = "Widget" + val result = underTest.searchWidgetApps(input).first() + runCurrent() + + assertThat(result.size).isEqualTo(PERSONAL_TEST_APPS.size) + assertThat(result.filter { it.title == WORK_TEST_APPS[0].title }).isEmpty() + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt new file mode 100644 index 0000000000..10bbca5d83 --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.repository + +import com.android.launcher3.widgetpicker.data.repository.WidgetAppIconsRepository +import com.android.launcher3.widgetpicker.shared.model.AppIcon +import com.android.launcher3.widgetpicker.shared.model.AppIconBadge +import com.android.launcher3.widgetpicker.shared.model.WidgetAppIcon +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.update + +/** A fake implementation of [WidgetAppIconsRepository] for testing */ +class FakeWidgetAppIconsRepository : WidgetAppIconsRepository { + private val _appIcons = MutableStateFlow(emptyMap()) + fun seedAppIcons(icons: Map) { + _appIcons.update { icons } + } + + override fun initialize() {} + + override fun getAppIcon(widgetAppId: WidgetAppId): Flow = flow { + emit( + WidgetAppIcon( + icon = AppIcon.PlaceHolderAppIcon, + badge = AppIconBadge.NoBadge + ) + ) + + val appIcon = _appIcons.value[widgetAppId] + if (appIcon != null) { + emit(appIcon) + } + } + + override fun cleanUp() { + _appIcons.update { emptyMap() } + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt new file mode 100644 index 0000000000..83f515924b --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.repository + +import android.os.UserHandle +import com.android.launcher3.widgetpicker.data.repository.WidgetUsersRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.update + +/** A fake implementation of [WidgetUsersRepository] for testing */ +class FakeWidgetUsersRepository : WidgetUsersRepository { + private val _userProfiles = MutableStateFlow(null) + private var workProfileUser: UserHandle? = null + + fun seedUserProfiles(profiles: WidgetUserProfiles?, workProfileUser: UserHandle?) { + this.workProfileUser = workProfileUser + _userProfiles.update { profiles } + } + + override fun initialize() {} + + override fun observeUserProfiles(): Flow = _userProfiles + + override fun getWorkProfileUser(): UserHandle? = workProfileUser + + override fun cleanUp() { + _userProfiles.update { null } + workProfileUser = null + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt new file mode 100644 index 0000000000..6ea9b71dda --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.repository + +import com.android.launcher3.widgetpicker.data.repository.WidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.PickableWidget +import com.android.launcher3.widgetpicker.shared.model.WidgetApp +import com.android.launcher3.widgetpicker.shared.model.WidgetId +import com.android.launcher3.widgetpicker.shared.model.WidgetPreview +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.update + +/** A fake implementation of [WidgetsRepository] for testing */ +class FakeWidgetsRepository : WidgetsRepository { + private val _widgetApps = MutableStateFlow>(emptyList()) + private val _widgetPreviews = MutableStateFlow>(emptyMap()) + private var _featuredWidgetIds = MutableStateFlow(emptySet()) + + fun seedWidgets(widgetApps: List) { + _widgetApps.update { widgetApps } + } + + fun seedWidgetPreviews(map: Map) { + _widgetPreviews.update { map } + } + + fun seedFeaturedWidgets(widgetIds: Set) { + _featuredWidgetIds.update { widgetIds } + } + + override fun initialize() {} + + override fun observeWidgets(): Flow> = _widgetApps + + override suspend fun getWidgetPreview(id: WidgetId): WidgetPreview = + _widgetPreviews.value[id] ?: WidgetPreview.PlaceholderWidgetPreview + + override fun getFeaturedWidgets(): Flow> = + combine(_featuredWidgetIds, _widgetApps) { widgetIds, widgetApps -> + widgetApps.flatMap { it.widgets }.filter { widgetIds.contains(it.id) } + } + + override suspend fun searchWidgets(input: String): List = _widgetApps.value.map { + it.copy(widgets = it.widgets.filter { widget -> + val description = widget.description?.toString() ?: "" + widget.label.contains(input) || description.contains(input) + }) + }.filter { it.widgets.isNotEmpty() } + + override fun cleanUp() { + _widgetApps.update { emptyList() } + _widgetPreviews.update { emptyMap() } + _featuredWidgetIds.update { emptySet() } + } +} From 0b87a4137625b3de86acb179ebc2f51b0317e301 Mon Sep 17 00:00:00 2001 From: Vinay Joglekar Date: Fri, 23 May 2025 09:47:47 +0100 Subject: [PATCH 17/25] Share buttons change Update Share Button and Share Targets to support Blur background Fix: 408439461 Test: Open chrome with a webpage, tap on smart chip Flag: com.android.launcher3.enable_overview_background_wallpaper_blur Change-Id: If9290676377a3a48a94800ac3084c52146b0c9ae --- .../com/android/quickstep/util/FontUtils.kt | 41 +++++++++++++++++++ .../android/quickstep/views/RecentsView.java | 16 +------- res/drawable/horizontal_ellipsis.xml | 27 ------------ res/values/dimens.xml | 2 +- 4 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 quickstep/src/com/android/quickstep/util/FontUtils.kt delete mode 100644 res/drawable/horizontal_ellipsis.xml diff --git a/quickstep/src/com/android/quickstep/util/FontUtils.kt b/quickstep/src/com/android/quickstep/util/FontUtils.kt new file mode 100644 index 0000000000..35a0fc7e1b --- /dev/null +++ b/quickstep/src/com/android/quickstep/util/FontUtils.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.util + +import android.content.res.Configuration +import android.content.res.Resources +import android.graphics.Typeface +import com.android.wm.shell.shared.TypefaceUtils + +object FontUtils { + + private val baseTypeface = + Typeface.create(TypefaceUtils.FontFamily.GSF_LABEL_LARGE.value, Typeface.NORMAL) + + @JvmStatic + fun getTypeFace(resources: Resources): Typeface = + Typeface.create(baseTypeface, getFontWeight(resources), /* italic= */ false) + + fun getFontWeight(resources: Resources): Int { + val fontWeightAdjustment: Int = resources.configuration.fontWeightAdjustment + return if (fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) { + Typeface.Builder.NORMAL_WEIGHT + fontWeightAdjustment + } else { + Typeface.Builder.NORMAL_WEIGHT + } + } +} diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index ebf1d7b9e9..816921d2e2 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -217,6 +217,7 @@ import com.android.quickstep.recents.viewmodel.RecentsViewModel; import com.android.quickstep.util.ActiveGestureProtoLogProxy; import com.android.quickstep.util.AnimUtils; import com.android.quickstep.util.DesktopTask; +import com.android.quickstep.util.FontUtils; import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RecentsAtomicAnimationFactory; @@ -983,12 +984,7 @@ public abstract class RecentsView< mEmptyMessagePaint.setTextSize(getResources() .getDimension(R.dimen.recents_empty_message_text_size)); - Typeface typeface = Typeface.create( - Typeface.create(TypefaceUtils.FontFamily.GSF_LABEL_LARGE.getValue(), - Typeface.NORMAL), - getFontWeight(), - false); - mEmptyMessagePaint.setTypeface(typeface); + mEmptyMessagePaint.setTypeface(FontUtils.getTypeFace(getResources())); mEmptyMessagePaint.setAntiAlias(true); mEmptyMessagePadding = getResources() .getDimensionPixelSize(R.dimen.recents_empty_message_text_padding); @@ -7002,14 +6998,6 @@ public abstract class RecentsView< } } - private int getFontWeight() { - int fontWeightAdjustment = getResources().getConfiguration().fontWeightAdjustment; - if (fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) { - return Typeface.Builder.NORMAL_WEIGHT + fontWeightAdjustment; - } - return Typeface.Builder.NORMAL_WEIGHT; - } - /** * Runs the spring animations as a task dismisses or settles back into its place in overview. * diff --git a/res/drawable/horizontal_ellipsis.xml b/res/drawable/horizontal_ellipsis.xml deleted file mode 100644 index 65e958d42b..0000000000 --- a/res/drawable/horizontal_ellipsis.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml index eaf19ca6c7..37704985f7 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -404,7 +404,7 @@ 10dp 54dp - 18dp + 24dp 24dp From 98795242ebb8c76681779ada985aec23a5e3f14a Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Fri, 16 May 2025 14:45:06 +0100 Subject: [PATCH 18/25] Add AppChip in Compose - Add a new app chip in composable. - Implement the app chip expansion animations and styles. Bug: 400436593 Bug: 366172565 Fix: 366387927 Flag: EXEMPT build flag: release_enable_compose_in_launcher. Test: AppChipTest Test: AppChipScreenshotTest Change-Id: I05ca14354ab7702026343c4e636538d507336f6a --- .../android/launcher3/util/ComposeUtils.kt | 58 +++ .../android/launcher3/helper/TestHelper.kt | 40 ++ .../facade/core/QuickstepComposeFeatures.kt | 14 +- .../facade/disabled/QuickstepComposeFacade.kt | 16 + .../facade/enabled/QuickstepComposeFacade.kt | 17 + .../recents/ui/composable/AppChip.kt | 393 ++++++++++++++++++ .../ui/composable/AppChipScreenshotTest.kt | 148 +++++++ .../recents/ui/composable/AppChipTest.kt | 108 +++++ 8 files changed, 793 insertions(+), 1 deletion(-) create mode 100644 compose/features/com/android/launcher3/util/ComposeUtils.kt create mode 100644 compose/tests/com/android/launcher3/helper/TestHelper.kt create mode 100644 quickstep/compose/features/com/android/quickstep/recents/ui/composable/AppChip.kt create mode 100644 quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipScreenshotTest.kt create mode 100644 quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipTest.kt diff --git a/compose/features/com/android/launcher3/util/ComposeUtils.kt b/compose/features/com/android/launcher3/util/ComposeUtils.kt new file mode 100644 index 0000000000..ad7319a411 --- /dev/null +++ b/compose/features/com/android/launcher3/util/ComposeUtils.kt @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.util + +import android.animation.TimeInterpolator +import android.graphics.drawable.Drawable +import androidx.compose.animation.core.Easing +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.graphics.painter.BitmapPainter +import androidx.compose.ui.graphics.painter.Painter +import androidx.compose.ui.tooling.preview.Preview +import androidx.core.graphics.drawable.toBitmap + +/** + * Converts a [TimeInterpolator] to a compose [Easing]. + * + * This function allows you to use Android's [TimeInterpolator] instances, such as those defined in + * `android.R.interpolator`, directly with Compose animations that expect an [Easing]. + */ +fun TimeInterpolator.toComposeEasing(): Easing = Easing { fraction -> getInterpolation(fraction) } + +/** + * A composable function that takes a [Drawable] and converts it into a [Painter] which can be used + * to draw the drawable on a Compose canvas. + * + * This function uses [remember] to cache the conversion of the [Drawable] to an [ImageBitmap]. This + * means that if the same [Drawable] instance is provided across recompositions, the conversion will + * only happen once, improving performance. + */ +@Composable +fun painterResource(drawable: Drawable): Painter { + val imageBitmap = remember(drawable) { drawable.toBitmap().asImageBitmap() } + return BitmapPainter(imageBitmap) +} + + +/** + * A multi-preview annotation that displays the same Composable with different font scales. + */ +@Preview(name = "normal font", group = "font scales", fontScale = 1f) +@Preview(name = "large font", group = "font scales", fontScale = 2f) +annotation class FontScalePreviews diff --git a/compose/tests/com/android/launcher3/helper/TestHelper.kt b/compose/tests/com/android/launcher3/helper/TestHelper.kt new file mode 100644 index 0000000000..001f963def --- /dev/null +++ b/compose/tests/com/android/launcher3/helper/TestHelper.kt @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.helper + +import androidx.compose.ui.input.key.KeyEvent +import androidx.compose.ui.input.key.NativeKeyEvent +import androidx.compose.ui.test.SemanticsMatcher +import androidx.compose.ui.unit.Density +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +val NATIVE_DPAD_DOWN = NativeKeyEvent(NativeKeyEvent.ACTION_DOWN, NativeKeyEvent.KEYCODE_DPAD_DOWN) +val NATIVE_TAB = NativeKeyEvent(NativeKeyEvent.ACTION_DOWN, NativeKeyEvent.KEYCODE_TAB) +val NavigateDownKeyEvent = KeyEvent(NATIVE_DPAD_DOWN) +val NavigateDownTabEvent = KeyEvent(NATIVE_TAB) + +fun hasMinTouchArea(minWidth: Dp = 48.dp, minHeight: Dp = 48.dp): SemanticsMatcher = + SemanticsMatcher("touch area is smaller than $minWidth x $minHeight") { node -> + val density: Density = node.root?.density ?: error("root node not available!") + with(density) { + val rect = node.touchBoundsInRoot + val size = node.size + (rect.width.toDp() >= minWidth && rect.height.toDp() >= minHeight) || + (size.width.toDp() >= minWidth && size.height.toDp() >= minHeight) + } + } diff --git a/quickstep/compose/facade/core/QuickstepComposeFeatures.kt b/quickstep/compose/facade/core/QuickstepComposeFeatures.kt index ca9e5c9265..9714991c66 100644 --- a/quickstep/compose/facade/core/QuickstepComposeFeatures.kt +++ b/quickstep/compose/facade/core/QuickstepComposeFeatures.kt @@ -16,4 +16,16 @@ package com.android.quickstep.compose.core -interface QuickstepComposeFeatures +import android.view.View +import com.android.quickstep.recents.ui.viewmodel.TaskViewModel +import com.android.quickstep.views.TaskViewIcon + +interface QuickstepComposeFeatures { + fun startIconAppChip( + composeView: TaskViewIcon, + viewModel: TaskViewModel, + taskId: Int, + onClick: () -> Unit = {}, + onLongClick: () -> Unit = {}, + ): View +} diff --git a/quickstep/compose/facade/disabled/QuickstepComposeFacade.kt b/quickstep/compose/facade/disabled/QuickstepComposeFacade.kt index 0a4345a839..26b5953d4a 100644 --- a/quickstep/compose/facade/disabled/QuickstepComposeFacade.kt +++ b/quickstep/compose/facade/disabled/QuickstepComposeFacade.kt @@ -17,13 +17,29 @@ package com.android.quickstep.compose import android.content.Context +import android.view.View import com.android.launcher3.compose.ComposeFacade import com.android.launcher3.compose.core.BaseComposeFacade import com.android.quickstep.compose.core.QuickstepComposeFeatures +import com.android.quickstep.recents.ui.viewmodel.TaskViewModel +import com.android.quickstep.views.TaskViewIcon object QuickstepComposeFacade : BaseComposeFacade, QuickstepComposeFeatures { override fun isComposeAvailable() = ComposeFacade.isComposeAvailable() override fun initComposeView(appContext: Context) = ComposeFacade.initComposeView(appContext) + + override fun startIconAppChip( + composeView: TaskViewIcon, + viewModel: TaskViewModel, + taskId: Int, + onClick: () -> Unit, + onLongClick: () -> Unit, + ): View { + error( + "Compose is not available. Make sure to check isComposeAvailable() before calling any" + + " other function on ComposeFacade." + ) + } } diff --git a/quickstep/compose/facade/enabled/QuickstepComposeFacade.kt b/quickstep/compose/facade/enabled/QuickstepComposeFacade.kt index 97cd3002ee..75c2055f2e 100644 --- a/quickstep/compose/facade/enabled/QuickstepComposeFacade.kt +++ b/quickstep/compose/facade/enabled/QuickstepComposeFacade.kt @@ -17,12 +17,29 @@ package com.android.quickstep.compose import android.content.Context +import android.view.View +import androidx.compose.material3.MaterialTheme +import androidx.compose.ui.platform.ComposeView import com.android.launcher3.compose.ComposeFacade import com.android.launcher3.compose.core.BaseComposeFacade import com.android.quickstep.compose.core.QuickstepComposeFeatures +import com.android.quickstep.recents.ui.composable.TaskAppChip +import com.android.quickstep.recents.ui.viewmodel.TaskViewModel +import com.android.quickstep.views.TaskViewIcon object QuickstepComposeFacade : BaseComposeFacade, QuickstepComposeFeatures { override fun isComposeAvailable() = ComposeFacade.isComposeAvailable() override fun initComposeView(appContext: Context) = ComposeFacade.initComposeView(appContext) + + override fun startIconAppChip( + composeView: TaskViewIcon, + viewModel: TaskViewModel, + taskId: Int, + onClick: () -> Unit, + onLongClick: () -> Unit, + ): View = + (composeView.asView() as ComposeView).apply { + setContent { MaterialTheme { TaskAppChip(viewModel, taskId, onClick, onLongClick) } } + } } diff --git a/quickstep/compose/features/com/android/quickstep/recents/ui/composable/AppChip.kt b/quickstep/compose/features/com/android/quickstep/recents/ui/composable/AppChip.kt new file mode 100644 index 0000000000..6865c5b874 --- /dev/null +++ b/quickstep/compose/features/com/android/quickstep/recents/ui/composable/AppChip.kt @@ -0,0 +1,393 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.recents.ui.composable + +import android.graphics.drawable.Drawable +import androidx.appcompat.content.res.AppCompatResources +import androidx.compose.animation.core.animateDp +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.tween +import androidx.compose.animation.core.updateTransition +import androidx.compose.foundation.Image +import androidx.compose.foundation.basicMarquee +import androidx.compose.foundation.border +import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.focusable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredSize +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.material3.contentColorFor +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.State +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.drawBehind +import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.draw.scale +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.graphics.BlendMode +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.CompositingStrategy +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalHapticFeedback +import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.PlatformTextStyle +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.DpOffset +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.android.app.animation.Interpolators +import com.android.launcher3.R +import com.android.launcher3.util.FontScalePreviews +import com.android.launcher3.util.painterResource +import com.android.launcher3.util.toComposeEasing +import com.android.quickstep.recents.ui.composable.AppChip.IconSize +import com.android.quickstep.recents.ui.composable.AppChip.IconSizeExpanded +import com.android.quickstep.recents.ui.viewmodel.TaskData +import com.android.quickstep.recents.ui.viewmodel.TaskTileUiState +import com.android.quickstep.recents.ui.viewmodel.TaskViewModel +import kotlinx.coroutines.flow.map + +private data class AppChipInfo(val title: String, val icon: Drawable, val expanded: Boolean) + +private fun mapAppChipInfo(state: TaskTileUiState, taskId: Int): AppChipInfo? = + state.tasks + .firstOrNull { it.taskId == taskId } + .let { + if (it is TaskData.Data && it.title != null && it.icon != null) { + AppChipInfo( + title = it.title, + icon = it.icon, + expanded = false, + // TODO: The state needs to be implemented in the VM when this AppChip + // is added to the TaskView. The state will be called isMenuExpanded, and it + // indicates whether the menu is expanded or not. When the chip is clicked, + // it will notify the VM that the menu is expanded. Then, this property will + // be either Open or Collapsed. + // state.isMenuExpanded is MenuState.Open && + // state.isMenuExpanded.taskId == taskId, + ) + } else { + null + } + } + +@Composable +fun TaskAppChip( + viewModel: TaskViewModel, + taskId: Int, + onClick: () -> Unit, + onLongClick: () -> Unit, +) { + val chipState: AppChipInfo? by + viewModel.state.map { mapAppChipInfo(it, taskId) }.collectAsState(null) + + chipState?.let { + AppChip( + title = it.title, + icon = it.icon, + expanded = it.expanded, + onClick = { + // viewModel.toggleMenu(taskId, !it.expanded) + onClick() + }, + onLongClick = { + // viewModel.toggleMenu(taskId, !it.expanded) + onLongClick() + }, + ) + } +} + +@Composable +fun AppChip( + title: String, + icon: Drawable, + modifier: Modifier = Modifier, + expanded: Boolean = false, + interactionSource: MutableInteractionSource? = remember { MutableInteractionSource() }, + onClick: () -> Unit, + onLongClick: () -> Unit = {}, +) { + val style = AppChip.getStyle(expanded) + var isFocused = remember { mutableStateOf(false) } + val haptic = LocalHapticFeedback.current + + Box(modifier = Modifier.height(52.dp), contentAlignment = Alignment.CenterStart) { + Row( + modifier = + modifier + .offset { IntOffset(style.startOffset.roundToPx(), 0) } + .size(style.width, style.height) + .shadow(AppChip.Shadow, AppChip.ChipShape) + .drawBehind { + drawRoundRect( + color = style.backgroundColor, + size = DpSize(style.width, style.height).toSize(), + ) + } + .focusBorder(isFocused, width = 2.dp, color = style.focusBorderColor) + .combinedClickable( + interactionSource = interactionSource, + indication = null, + onClick = { + haptic.performHapticFeedback(HapticFeedbackType.VirtualKey) + onClick.invoke() + }, + onLongClick = { + haptic.performHapticFeedback(HapticFeedbackType.LongPress) + onLongClick.invoke() + }, + ) + .clip(AppChip.ChipShape) + .padding( + start = style.startPadding, + top = style.topPadding, + end = style.endPadding, + bottom = style.bottomPadding, + ), + verticalAlignment = Alignment.CenterVertically, + ) { + Image( + painter = painterResource(icon), + modifier = Modifier.requiredSize(IconSize).scale(style.iconScale).clip(CircleShape), + contentDescription = title, + ) + Text( + text = title, + modifier = + Modifier.padding(start = style.dividerSize) + .weight(1f) + .fadingEdge() + .heightIn(max = IconSizeExpanded) + .then(if (expanded) Modifier.basicMarquee(1) else Modifier), + maxLines = 1, + overflow = TextOverflow.Visible, + softWrap = false, + style = + TextStyle( + platformStyle = PlatformTextStyle(includeFontPadding = false), + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + lineHeight = 20.sp, + color = style.contentColor, + ), + ) + Icon( + imageVector = ImageVector.vectorResource(R.drawable.ic_chevron_down), + contentDescription = "", + modifier = Modifier.size(24.dp).scale(1f, style.chevronScaleY), + tint = style.contentColor, + ) + } + } +} + +fun Modifier.focusBorder( + isFocused: MutableState, + width: Dp = 1.dp, + color: Color = Color.Black, + shape: Shape = CircleShape, +): Modifier = + this.onFocusChanged { isFocused.value = it.isFocused } + .focusable() + .then(if (isFocused.value) Modifier.border(width, color, shape) else Modifier) + +fun Modifier.fadingEdge(): Modifier { + val fade = Brush.horizontalGradient(.8f to Color.Red, 1f to Color.Transparent) + return this.graphicsLayer(compositingStrategy = CompositingStrategy.Offscreen).drawWithContent { + drawContent() + drawRect(brush = fade, blendMode = BlendMode.DstIn) + } +} + +private object AppChip { + private const val REVEAL_DURATION = 417 + private const val HIDE_DURATION = 333 + + val Shadow = 4.dp + val IconSize = 24.dp + val IconSizeExpanded = 32.dp + val ChipShape = RoundedCornerShape(100.dp) + + private val Collapsed = + AppChipSizes( + size = DpSize(156.dp, 36.dp), + startPadding = 6.dp, + endPadding = 8.dp, + topPadding = 6.dp, + bottomPadding = 6.dp, + offset = DpOffset(6.dp, 12.dp), + dividerSize = 8.dp, + chevronScaleY = 1f, + iconScale = 1f, + ) + + private val Expanded = + AppChipSizes( + size = DpSize(216.dp, 52.dp), + startPadding = 10.dp, + endPadding = 10.dp, + topPadding = 10.dp, + bottomPadding = 10.dp, + offset = DpOffset(0.dp, 4.dp), + dividerSize = 12.dp, + chevronScaleY = -1f, + iconScale = IconSizeExpanded / IconSize, + ) + + @Composable + fun getStyle(isExpanded: Boolean): AppChipStyle { + val backgroundColor = MaterialTheme.colorScheme.surfaceBright + val contentColor = MaterialTheme.colorScheme.contentColorFor(backgroundColor) + val focusBorderColor = MaterialTheme.colorScheme.secondary + + val transition = + updateTransition(if (isExpanded) Expanded else Collapsed, label = "AppChip State") + val emphasizedEasing = Interpolators.EMPHASIZED.toComposeEasing() + val duration = if (isExpanded) HIDE_DURATION else REVEAL_DURATION + val animationSpecInDp = tween(durationMillis = duration, easing = emphasizedEasing) + val animationSpecInFloat = + tween(durationMillis = duration, easing = emphasizedEasing) + + val width = transition.animateDp({ animationSpecInDp }) { it.size.width } + val height = transition.animateDp({ animationSpecInDp }) { it.size.height } + val iconScale = transition.animateFloat({ animationSpecInFloat }) { it.iconScale } + val dividerSize = transition.animateDp({ animationSpecInDp }) { it.dividerSize } + val chevronScaleY = transition.animateFloat({ animationSpecInFloat }) { it.chevronScaleY } + val animatedStartOffset = transition.animateDp({ animationSpecInDp }) { it.offset.x } + + val startPadding = transition.animateDp({ animationSpecInDp }) { it.startPadding } + val endPadding = transition.animateDp({ animationSpecInDp }) { it.endPadding } + val topPadding = transition.animateDp({ animationSpecInDp }) { it.topPadding } + val bottomPadding = transition.animateDp({ animationSpecInDp }) { it.bottomPadding } + + return remember(transition) { + AppChipStyle( + backgroundColor = backgroundColor, + contentColor = contentColor, + focusBorderColor = focusBorderColor, + width = width, + height = height, + iconScale = iconScale, + dividerSize = dividerSize, + chevronScaleY = chevronScaleY, + animatedStartOffset = animatedStartOffset, + startPadding = startPadding, + endPadding = endPadding, + topPadding = topPadding, + bottomPadding = bottomPadding, + ) + } + } + + private data class AppChipSizes( + val size: DpSize, + val startPadding: Dp, + val endPadding: Dp, + val topPadding: Dp, + val bottomPadding: Dp, + val offset: DpOffset, + val dividerSize: Dp, + val chevronScaleY: Float, + val iconScale: Float, + ) +} + +private class AppChipStyle( + val backgroundColor: Color, + val contentColor: Color, + val focusBorderColor: Color, + width: State, + height: State, + iconScale: State, + dividerSize: State, + chevronScaleY: State, + animatedStartOffset: State, + startPadding: State, + endPadding: State, + topPadding: State, + bottomPadding: State, +) { + val width by width + val height by height + val iconScale by iconScale + val dividerSize by dividerSize + val chevronScaleY by chevronScaleY + val startOffset by animatedStartOffset + val startPadding by startPadding + val endPadding by endPadding + val topPadding by topPadding + val bottomPadding by bottomPadding +} + +@Composable +@PreviewLightDark +@FontScalePreviews +private fun ChipPreview() { + val (expanded, setExpanded) = remember { mutableStateOf(false) } + val appName = "Very long-name-for the app that won't fit in the chip" + val appIcon = + AppCompatResources.getDrawable( + LocalContext.current, + R.drawable.ic_conversations_widget_category, + ) + + MaterialTheme { + Surface(color = MaterialTheme.colorScheme.surface) { + Box(modifier = Modifier.widthIn(170.dp)) { + AppChip( + title = appName, + icon = appIcon!!, + expanded = expanded, + onClick = { setExpanded(!expanded) }, + ) + } + } + } +} diff --git a/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipScreenshotTest.kt b/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipScreenshotTest.kt new file mode 100644 index 0000000000..85cc86a436 --- /dev/null +++ b/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipScreenshotTest.kt @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.recents.ui.composable + +import android.graphics.drawable.Drawable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.widthIn +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.test.assertIsFocused +import androidx.compose.ui.test.assertIsNotFocused +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.onRoot +import androidx.compose.ui.test.performKeyPress +import androidx.compose.ui.unit.dp +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.helper.NavigateDownTabEvent +import com.google.android.apps.nexuslauncher.imagecomparison.goldenpathmanager.ViewScreenshotGoldenPathManager +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import platform.test.runner.parameterized.ParameterizedAndroidJunit4 +import platform.test.runner.parameterized.Parameters +import platform.test.screenshot.DeviceEmulationSpec +import platform.test.screenshot.Displays +import platform.test.screenshot.getEmulatedDevicePathConfig +import platform.test.screenshot.utils.compose.ComposeScreenshotTestRule + +@RunWith(ParameterizedAndroidJunit4::class) +class AppChipScreenshotTest(emulationSpec: DeviceEmulationSpec) { + + @get:Rule val screenshotRule = composeScreenshotTestRule(emulationSpec) + + @Composable + private fun AppChipForTest(expanded: Boolean, onClick: () -> Unit = {}) { + Column( + modifier = Modifier.widthIn(min = COLLAPSED_WIDTH_OFFSET), + verticalArrangement = Arrangement.spacedBy(8.dp), + ) { + AppChip( + title = SHORT_APP_NAME, + icon = getGoogleDrawable()!!, + modifier = Modifier.testTag("appChip_short"), + expanded = expanded, + onClick = onClick, + ) + AppChip( + title = LONG_APP_NAME, + icon = getGoogleDrawable()!!, + modifier = Modifier.testTag("appChip_long"), + expanded = expanded, + onClick = onClick, + ) + } + } + + @Test + fun collapsed() = + screenshotRule.screenshotTest("appchip_collapsed") { AppChipForTest(expanded = false) } + + @Test + fun expanded() = + screenshotRule.screenshotTest("appchip_expanded") { AppChipForTest(expanded = true) } + + @Test + fun focusableState() { + screenshotRule.screenshotTest( + "appchip_focusable", + beforeScreenshot = { + val composeTestRule = screenshotRule.composeRule + composeTestRule.onNodeWithTag("appChip").assertIsNotFocused() + + // Press down to focus first element + composeTestRule.onRoot().performKeyPress(keyEvent = NavigateDownTabEvent) + + composeTestRule.onNodeWithTag("appChip").assertIsFocused() + }, + ) { + Box(modifier = Modifier.widthIn(min = COLLAPSED_WIDTH_OFFSET)) { + AppChip( + title = SHORT_APP_NAME, + icon = getGoogleDrawable()!!, + modifier = Modifier.testTag("appChip"), + expanded = false, + onClick = {}, + ) + } + } + } + + private fun getGoogleDrawable(): Drawable? { + val context = InstrumentationRegistry.getInstrumentation().context + val identifier = + context.resources.getIdentifier( + APP_ICON, + "drawable", + InstrumentationRegistry.getInstrumentation().context.packageName, + ) + return context.getDrawable(identifier) + } + + private companion object { + const val SHORT_APP_NAME = "App name" + const val LONG_APP_NAME = "Very long name for the app" + const val APP_ICON = "ic_super_g_color" + val COLLAPSED_WIDTH_OFFSET = 156.dp + 6.dp + + @Parameters(name = "{0}") + @JvmStatic + fun getTestSpecs(): List { + return DeviceEmulationSpec.forDisplays(Displays.Phone, isLandscape = false) + } + } +} + +/** + * Create a [ComposeScreenshotTestRule] for screenshot tests of Compose-based UI. If + * [enforcePerfectPixelMatch] is true, enables a strict pixel-by-pixel comparison to detect any + * visual differences between images. + */ +fun composeScreenshotTestRule( + emulationSpec: DeviceEmulationSpec, + enforcePerfectPixelMatch: Boolean = false, +): ComposeScreenshotTestRule { + return ComposeScreenshotTestRule( + emulationSpec = emulationSpec, + pathManager = ViewScreenshotGoldenPathManager(getEmulatedDevicePathConfig(emulationSpec)), + enforcePerfectPixelMatch = enforcePerfectPixelMatch, + ) +} diff --git a/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipTest.kt b/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipTest.kt new file mode 100644 index 0000000000..0389de9b6b --- /dev/null +++ b/quickstep/compose/tests/com/android/quickstep/recents/ui/composable/AppChipTest.kt @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep.recents.ui.composable + +import android.graphics.drawable.Drawable +import androidx.activity.ComponentActivity +import androidx.appcompat.content.res.AppCompatResources +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.semantics.SemanticsActions +import androidx.compose.ui.test.SemanticsMatcher +import androidx.compose.ui.test.assertAll +import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertWidthIsEqualTo +import androidx.compose.ui.test.hasContentDescription +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import androidx.compose.ui.unit.dp +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.helper.hasMinTouchArea +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class AppChipTest { + @get:Rule val composeTestRule = createAndroidComposeRule() + + @Composable + private fun AppChipForTest(expanded: Boolean, onClick: () -> Unit = {}) = + AppChip( + title = APP_NAME, + icon = getGoogleDrawable()!!, + expanded = expanded, + onClick = onClick, + ) + + @Test + fun givenIsCollapsed_whenClicked_chipExpands() { + composeTestRule.setContent { + val (expanded, setExpanded) = remember { mutableStateOf(false) } + AppChipForTest(expanded, onClick = { setExpanded(!expanded) }) + } + composeTestRule + .onNodeWithText(APP_NAME) + .assertWidthIsEqualTo(156.dp) + .assertHasClickAction() + .performClick() + .assertWidthIsEqualTo(216.dp) + } + + // Accessibility Checks + @Test + fun checkAccessibility_contentDescription() { + composeTestRule.setContent { + val (expanded, setExpanded) = remember { mutableStateOf(false) } + AppChipForTest(expanded, onClick = { setExpanded(!expanded) }) + } + composeTestRule + .onAllNodes(SemanticsMatcher.keyIsDefined(SemanticsActions.OnClick)) + .assertAll(hasContentDescription(APP_NAME)) + } + + @Test + fun checkAccessibility_touchTargetArea() { + composeTestRule.setContent { + val (expanded, setExpanded) = remember { mutableStateOf(false) } + AppChipForTest(expanded, onClick = { setExpanded(!expanded) }) + } + composeTestRule + .onAllNodes(SemanticsMatcher.keyIsDefined(SemanticsActions.OnClick)) + .assertAll(hasMinTouchArea()) + } + + private fun getGoogleDrawable(): Drawable? { + val context = InstrumentationRegistry.getInstrumentation().context + val identifier = + context.resources.getIdentifier( + APP_ICON, + "drawable", + InstrumentationRegistry.getInstrumentation().context.packageName, + ) + return AppCompatResources.getDrawable(context, identifier) + } + + private companion object { + const val APP_NAME = "Very long name for the app that won't fit in the chip" + const val APP_ICON = "ic_super_g_color" + } +} From 7d640afaba2a4378e5ef737f8ccd250ea57665de Mon Sep 17 00:00:00 2001 From: Uwais Ashraf Date: Fri, 23 May 2025 10:50:38 +0000 Subject: [PATCH 19/25] Don't launch a coroutine job if no jobs to cancel Flag: com.android.launcher3.enable_coroutine_threading_improvements Bug: 417598777 Test: Presubmits Change-Id: I474e3e12faf2886b593571e9625a1d16df742c0d --- quickstep/src/com/android/quickstep/views/TaskView.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 2d24250594..29c2dda6cf 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -952,7 +952,9 @@ constructor( // onAttach or another moment in the lifecycle. val coroutineJobsToCancel = coroutineJobs.toList() coroutineJobs.clear() - if (enableCoroutineThreadingImprovements() && coroutineJobsToCancel.isNotEmpty()) { + if (coroutineJobsToCancel.isEmpty()) return + + if (enableCoroutineThreadingImprovements()) { // TODO(b/391842220): This should ideally be handled in the completion block of the // jobs above to be cancelled. taskContainers.forEach { From 8cb1be9873b0b08eaf0b67b1edc73dcc940b5c42 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Thu, 8 May 2025 14:13:33 +0100 Subject: [PATCH 20/25] Use expressive dismiss for clear all. Fix: 416446763 Test: TaplTestsQuickstep Flag: com.android.launcher3.enable_expressive_dismiss_task_motion Change-Id: I6781e54901aa33d5f206fcb601cac76e99eee84f --- .../TaskViewDismissTouchController.kt | 10 +- .../dagger/QuickstepBaseAppComponent.java | 3 + .../quickstep/views/RecentsDismissUtils.kt | 195 +++++++++++++----- .../android/quickstep/views/RecentsView.java | 21 +- 4 files changed, 163 insertions(+), 66 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt index 36dbe977dc..bd91616ecc 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewDismissTouchController.kt @@ -323,11 +323,13 @@ CONTAINER : StatefulContainer { springAnimation = recentsView.runTaskDismissSettlingSpringAnimation( taskBeingDragged, - velocity, isDismissing, - dismissLength, - dismissThreshold, - finalPosition, + RecentsDismissUtils.DismissedTaskData( + startVelocity = velocity, + dismissLength = dismissLength, + finalPosition = finalPosition, + dismissThreshold = dismissThreshold, + ), /* shouldRemoveTaskView= */ isDismissing, /* isSplitSelection= */ false, ) diff --git a/quickstep/src/com/android/quickstep/dagger/QuickstepBaseAppComponent.java b/quickstep/src/com/android/quickstep/dagger/QuickstepBaseAppComponent.java index 3d16fc466d..8a68a612c4 100644 --- a/quickstep/src/com/android/quickstep/dagger/QuickstepBaseAppComponent.java +++ b/quickstep/src/com/android/quickstep/dagger/QuickstepBaseAppComponent.java @@ -40,6 +40,7 @@ import com.android.quickstep.logging.SettingsChangeLogger; import com.android.quickstep.util.AsyncClockEventDelegate; import com.android.quickstep.util.ContextualSearchHapticManager; import com.android.quickstep.util.ContextualSearchStateManager; +import com.android.quickstep.views.RecentsDismissUtils; /** * Launcher Quickstep base component for Dagger injection. @@ -79,6 +80,8 @@ public interface QuickstepBaseAppComponent extends LauncherBaseAppComponent { RecentsModel getRecentsModel(); + RecentsDismissUtils.Factory getRecentsDismissUtilsFactory(); + SettingsChangeLogger getSettingsChangeLogger(); SimpleOrientationTouchTransformer getSimpleOrientationTouchTransformer(); diff --git a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt index 23b0f6c180..a5413ea3ea 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt @@ -27,16 +27,24 @@ import androidx.dynamicanimation.animation.SpringForce import com.android.internal.jank.Cuj import com.android.launcher3.PagedView import com.android.launcher3.R +import com.android.launcher3.concurrent.annotations.LightweightBackground +import com.android.launcher3.concurrent.annotations.LightweightBackgroundPriority import com.android.launcher3.logging.StatsLogManager.LauncherEvent import com.android.launcher3.util.DynamicResource import com.android.launcher3.util.MSDLPlayerWrapper import com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview import com.android.launcher3.views.ActivityContext +import com.android.quickstep.SystemUiProxy import com.android.quickstep.util.TaskGridNavHelper import com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY import com.android.quickstep.views.TaskView.Companion.GRID_END_TRANSLATION_X +import com.android.systemui.shared.system.ActivityManagerWrapper import com.android.systemui.shared.system.InteractionJankMonitorWrapper import com.google.android.msdl.data.model.MSDLToken +import com.google.common.util.concurrent.ListeningExecutorService +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject import kotlin.math.abs import kotlin.math.max import kotlin.math.roundToInt @@ -46,7 +54,20 @@ import kotlin.math.sign * Helper class for [RecentsView]. This util class contains refactored and extracted functions from * RecentsView related to TaskView dismissal. */ -class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { +class RecentsDismissUtils +@AssistedInject +constructor( + @Assisted private val recentsView: RecentsView<*, *>, + private val systemUiProxy: SystemUiProxy, + @LightweightBackground(LightweightBackgroundPriority.UI) + private val uiHelperExecutor: ListeningExecutorService, + private val activityManagerWrapper: ActivityManagerWrapper, + private val msdlPlayerWrapper: MSDLPlayerWrapper, +) { + @AssistedFactory + interface Factory { + fun create(recentsView: RecentsView<*, *>): RecentsDismissUtils + } /** * Runs the default spring animation when a dismissed task view in overview is released. @@ -60,44 +81,27 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { shouldRemoveTaskView: Boolean, isSplitSelection: Boolean, ): SpringSet? { - with(recentsView) { - if (dismissedTaskView == null || isSplitSelection) { - return createTaskDismissSpringAnimation( - dismissedTaskView, - velocity = 0f, - isDismissing = true, + if (dismissedTaskView == null || isSplitSelection) { + return createTaskDismissSpringAnimation( + dismissedTaskView, + isDismissing = true, + DismissedTaskData( + startVelocity = 0f, dismissLength = 0, dismissThreshold = 0, finalPosition = 0f, - shouldRemoveTaskView, - isSplitSelection, - ) - } - - dismissedTaskView.getThumbnailBounds(mTempRect, /* relativeToDragLayer= */ true) - val secondaryLayerDimension: Int = - pagedOrientationHandler.getSecondaryDimension( - (mContainer as ActivityContext).getDragLayer() - ) - val verticalFactor = pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat() - val dismissLength = - (pagedOrientationHandler.getTaskDismissLength(secondaryLayerDimension, mTempRect) * - verticalFactor) - .toInt() - val dismissThreshold = (dismissLength * DEFAULT_DISMISS_THRESHOLD_FRACTION).toInt() - val velocity = mTempRect.height().toFloat() - val finalPosition = dismissLength.toFloat() - return createTaskDismissSpringAnimation( - dismissedTaskView, - velocity, - isDismissing = true, - dismissLength, - dismissThreshold, - finalPosition, + ), shouldRemoveTaskView, isSplitSelection, ) } + return createTaskDismissSpringAnimation( + dismissedTaskView, + isDismissing = true, + getDefaultDismissedTaskData(dismissedTaskView), + shouldRemoveTaskView, + isSplitSelection, + ) } /** @@ -109,11 +113,8 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { */ fun createTaskDismissSpringAnimation( dismissedTaskView: TaskView?, - velocity: Float, isDismissing: Boolean, - dismissLength: Int, - dismissThreshold: Int, - finalPosition: Float, + dismissedTaskData: DismissedTaskData, shouldRemoveTaskView: Boolean, isSplitSelection: Boolean, ): SpringSet? { @@ -131,7 +132,8 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { val verticalFactor = recentsView.pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat() val startVelocity = - abs(velocity).coerceAtLeast(dismissedTaskSecondaryDimension) * velocity.sign + abs(dismissedTaskData.startVelocity).coerceAtLeast(dismissedTaskSecondaryDimension) * + dismissedTaskData.startVelocity.sign // Spring that animates the dismissed task. val dismissedTaskViewSpring = @@ -140,15 +142,18 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { createDismissedTaskViewSpringAnimation( dismissedTaskView, isDismissing, - startVelocity, - dismissLength, - finalPosition, - dismissThreshold, + DismissedTaskData( + startVelocity = startVelocity, + dismissLength = dismissedTaskData.dismissLength, + finalPosition = dismissedTaskData.finalPosition, + dismissThreshold = dismissedTaskData.dismissThreshold, + ), ) } // SpringSet tracking all dismiss springs before running end-snapping and relayout. - var springSet = dismissedTaskViewSpring?.let { SpringSet(it, finalPosition) } + var springSet = + dismissedTaskViewSpring?.let { SpringSet(it, dismissedTaskData.finalPosition) } if (isDismissing) { // The spring set that will reflow the tasks to fill the gap left by the dismissed task. @@ -173,7 +178,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { val neighborSettlingSpringSet = createNeighborSettlingSpringSet(dismissedTaskView, isSpringDirectionVertical = true) springSet.playAfterThreshold( - driverThreshold = finalPosition, + driverThreshold = dismissedTaskData.finalPosition, triggeredSpringSet = neighborSettlingSpringSet, minVelocity = startVelocity, ) @@ -209,14 +214,22 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { return springSet.addEndListener(endRunnable).start() } + /** Default dismissed task view spring animation. */ + private fun createDismissedTaskViewSpringAnimation( + dismissedTaskView: TaskView + ): SpringAnimation? { + return createDismissedTaskViewSpringAnimation( + dismissedTaskView, + isDismissing = true, + getDefaultDismissedTaskData(dismissedTaskView), + ) + } + /** Dismissed task view spring animation. */ private fun createDismissedTaskViewSpringAnimation( dismissedTaskView: TaskView, isDismissing: Boolean, - startVelocity: Float, - dismissLength: Int, - finalPosition: Float, - dismissThreshold: Int, + dismissedTaskData: DismissedTaskData, ): SpringAnimation? { val taskDismissFloatProperty = FloatPropertyCompat.createFloatPropertyCompat( @@ -226,15 +239,19 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { // Animate dismissed task towards dismissal or rest state. val dismissedTaskViewSpringAnimation = SpringAnimation(dismissedTaskView, taskDismissFloatProperty) - .setSpring(createExpressiveDismissSpringForce().setFinalPosition(finalPosition)) - .setStartVelocity(startVelocity) + .setSpring( + createExpressiveDismissSpringForce() + .setFinalPosition(dismissedTaskData.finalPosition) + ) + .setStartVelocity(dismissedTaskData.startVelocity) .addUpdateListener { animation, currentDisplacement, _ -> // Play haptic as task crosses dismiss threshold from above or below. - val previousBeyondThreshold = abs(previousDisplacement) >= abs(dismissThreshold) - val currentBeyondThreshold = abs(currentDisplacement) >= abs(dismissThreshold) + val previousBeyondThreshold = + abs(previousDisplacement) >= abs(dismissedTaskData.dismissThreshold) + val currentBeyondThreshold = + abs(currentDisplacement) >= abs(dismissedTaskData.dismissThreshold) if (previousBeyondThreshold != currentBeyondThreshold) { - MSDLPlayerWrapper.INSTANCE.get(recentsView.context) - .playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR) + msdlPlayerWrapper.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR) } previousDisplacement = currentDisplacement @@ -246,13 +263,68 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { recentsView.redrawLiveTile() } // End dismissed task animation once beyond the screen so next animations play. - if (isDismissing && abs(currentDisplacement) >= abs(dismissLength)) { + if ( + isDismissing && + abs(currentDisplacement) >= abs(dismissedTaskData.dismissLength) + ) { (animation as SpringAnimation).skipToEnd() } } return dismissedTaskViewSpringAnimation } + private fun getDefaultDismissedTaskData(dismissedTaskView: TaskView): DismissedTaskData { + with(recentsView) { + dismissedTaskView.getThumbnailBounds(mTempRect, /* relativeToDragLayer= */ true) + val secondaryLayerDimension = + pagedOrientationHandler.getSecondaryDimension( + (mContainer as ActivityContext).getDragLayer() + ) + val verticalFactor = pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat() + val dismissLength = + (pagedOrientationHandler.getTaskDismissLength(secondaryLayerDimension, mTempRect) * + verticalFactor) + .toInt() + val dismissThreshold = (dismissLength * DEFAULT_DISMISS_THRESHOLD_FRACTION).toInt() + val startVelocity = mTempRect.height().toFloat() + val finalPosition = dismissLength.toFloat() + return DismissedTaskData( + startVelocity = startVelocity, + dismissLength = dismissLength, + finalPosition = finalPosition, + dismissThreshold = dismissThreshold, + ) + } + } + + /** Dismisses all */ + fun dismissAllTasks() { + val allDismissSprings = + recentsView.mUtils.taskViews + .reversed() + .filter { taskView -> recentsView.isTaskViewVisible(taskView) } + .mapNotNull { createDismissedTaskViewSpringAnimation(it) } + SpringSet(SpringAnimation(FloatValueHolder()).setSpring(SpringForce(1f))) + .playTogether(allDismissSprings) + .addEndListener { + with(recentsView) { + // Remove desktops first, since desks can be empty (so they have no recent + // tasks), and closing all tasks on a desk doesn't always necessarily mean that + // the desk will be removed. So, there are no guarantees that the below call to + // `ActivityManagerWrapper::removeAllRecentTasks()` will be enough. + systemUiProxy.removeAllDesks() + + // Remove all the task views now + finishRecentsAnimation(/* toRecents */ true, /* shouldPip */ false) { + uiHelperExecutor.execute { activityManagerWrapper.removeAllRecentTasks() } + removeAllTaskViews() + startHome() + } + } + } + .start() + } + /** Bounce neighboring tasks due to a canceled dismiss or the reflow of tasks after dismiss. */ private fun createNeighborSettlingSpringSet( dismissedTaskView: TaskView, @@ -1235,6 +1307,14 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { } return this } + + fun playTogether(springs: List): SpringSet { + springs.forEach { + trackSpring(it) + addStartListener { it.start() } + } + return this + } } data class GridEndData( @@ -1244,6 +1324,13 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { val currentPageSnapsToEndOfGrid: Boolean, ) + data class DismissedTaskData( + val startVelocity: Float, + val dismissLength: Int, + val finalPosition: Float, + val dismissThreshold: Int, + ) + private companion object { // The additional damping to apply to tasks further from the dismissed task. private const val ADDITIONAL_DISMISS_DAMPING_RATIO = 0.15f diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 9dc331cb6b..c7290822a0 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -157,6 +157,7 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.anim.SpringProperty; import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.dagger.LauncherComponentProvider; import com.android.launcher3.desktop.DesktopRecentsTransitionController; import com.android.launcher3.logger.LauncherAtom; import com.android.launcher3.logging.StatsLogManager; @@ -873,7 +874,8 @@ public abstract class RecentsView< protected final RecentsViewModel mRecentsViewModel; private final RecentsViewModelHelper mHelper; protected final RecentsViewUtils mUtils = new RecentsViewUtils(this); - protected final RecentsDismissUtils mDismissUtils = new RecentsDismissUtils(this); + protected final RecentsDismissUtils mDismissUtils = LauncherComponentProvider.get( + getContext()).getRecentsDismissUtilsFactory().create(this); private final Matrix mTmpMatrix = new Matrix(); @@ -2191,7 +2193,7 @@ public abstract class RecentsView< return mModel.isLoadingTasksInBackground(); } - private void removeAllTaskViews() { + protected void removeAllTaskViews() { // This handles an edge case where applyLoadPlan happens during a gesture when the only // Task is one with excludeFromRecents, in which case we should not remove it. CollectionsKt @@ -4572,7 +4574,11 @@ public abstract class RecentsView< @SuppressWarnings("unused") private void dismissAllTasks(View view) { - runDismissAnimation(createAllTasksDismissAnimation(DISMISS_TASK_DURATION)); + if (enableExpressiveDismissTaskMotion()) { + mDismissUtils.dismissAllTasks(); + } else { + runDismissAnimation(createAllTasksDismissAnimation(DISMISS_TASK_DURATION)); + } mContainer.getStatsLogManager().logger().log(LAUNCHER_TASK_CLEAR_ALL); } @@ -7023,12 +7029,11 @@ public abstract class RecentsView< * spring in response to the perceived impact of the settling task. */ public RecentsDismissUtils.SpringSet runTaskDismissSettlingSpringAnimation( - TaskView draggedTaskView, float velocity, boolean isDismissing, int dismissLength, - int dismissThreshold, float finalPosition, boolean shouldRemoveTaskView, + TaskView draggedTaskView, boolean isDismissing, + RecentsDismissUtils.DismissedTaskData dismissedTaskData, boolean shouldRemoveTaskView, boolean isSplitSelection) { - return mDismissUtils.createTaskDismissSpringAnimation(draggedTaskView, velocity, - isDismissing, dismissLength, dismissThreshold, finalPosition, shouldRemoveTaskView, - isSplitSelection); + return mDismissUtils.createTaskDismissSpringAnimation(draggedTaskView, isDismissing, + dismissedTaskData, shouldRemoveTaskView, isSplitSelection); } /** From e1111e28c25b5c8f2219c892958914d0b026f789 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Wed, 21 May 2025 15:10:59 -0700 Subject: [PATCH 21/25] Moving DeviceProfile properties into DeviceProperties data class Bug: 419264653 Flag: EXEMPT refactor Test: DeviceProfileDumpTest Test: All Image tests Change-Id: I638f88cd76b926917965dbf9e70b5bdfff5971e0 --- .../launcher3/QuickstepTransitionManager.java | 56 ++-- .../KeyboardQuickSwitchController.java | 2 +- .../taskbar/ManageWindowsTaskbarShortcut.kt | 9 +- .../taskbar/NavbarButtonsViewController.java | 14 +- .../taskbar/TaskbarActivityContext.java | 14 +- .../launcher3/taskbar/TaskbarEduTooltip.kt | 2 +- .../taskbar/TaskbarInsetsController.kt | 2 +- .../launcher3/taskbar/TaskbarManagerImpl.java | 10 +- .../taskbar/TaskbarStashController.java | 2 +- .../taskbar/TaskbarStashViaTouchController.kt | 3 +- .../taskbar/TaskbarThresholdUtils.java | 2 +- .../launcher3/taskbar/TaskbarView.java | 2 +- .../taskbar/TaskbarViewController.java | 4 +- .../allapps/TaskbarAllAppsSlideInView.java | 6 +- .../bubbles/BubbleBarSwipeController.kt | 3 +- .../BubbleStashedHandleViewController.java | 2 +- .../customization/TaskbarFeatureEvaluator.kt | 2 +- .../launcher3/taskbar/growth/NudgeView.kt | 2 +- .../navbutton/AbstractNavButtonLayoutter.kt | 2 +- .../navbutton/NavButtonLayoutFactory.kt | 2 +- .../navbutton/PhoneLandscapeNavLayoutter.kt | 2 +- .../navbutton/PhonePortraitNavLayoutter.kt | 12 +- .../taskbar/navbutton/SetupNavLayoutter.kt | 6 +- .../taskbar/navbutton/TaskbarNavLayoutter.kt | 12 +- .../overlay/TaskbarOverlayController.java | 2 +- .../uioverrides/QuickstepLauncher.java | 4 +- .../uioverrides/RecentsViewStateController.kt | 5 +- .../uioverrides/states/AllAppsState.java | 4 +- .../uioverrides/states/OverviewState.java | 10 +- .../QuickstepAtomicAnimationFactory.java | 2 +- .../states/SplitScreenSelectState.java | 2 +- .../NavBarToHomeTouchController.java | 2 +- ...ButtonNavbarToOverviewTouchController.java | 2 +- .../NoButtonQuickSwitchTouchController.java | 4 +- .../QuickSwitchTouchController.java | 2 +- .../TransposedQuickSwitchTouchController.java | 2 +- .../android/quickstep/AbsSwipeUpHandler.java | 26 +- .../quickstep/AspectRatioSystemShortcut.kt | 5 +- .../quickstep/BaseContainerInterface.java | 18 +- .../quickstep/FallbackActivityInterface.java | 4 +- .../quickstep/FallbackSwipeHandler.java | 4 +- .../quickstep/FallbackWindowInterface.java | 4 +- .../quickstep/LauncherActivityInterface.java | 2 +- .../quickstep/LauncherSwipeHandlerV2.java | 2 +- .../quickstep/OverviewCommandHelper.kt | 2 +- .../QuickstepTestInformationHandler.java | 2 +- .../quickstep/SwipeUpAnimationLogic.java | 18 +- .../android/quickstep/TaskOverlayFactory.java | 2 +- .../quickstep/TaskShortcutFactory.java | 6 +- .../com/android/quickstep/TaskViewUtils.java | 2 +- .../quickstep/fallback/RecentsState.java | 2 +- .../window/RecentsWindowSwipeHandler.java | 4 +- .../TaskbarUnstashInputConsumer.java | 24 +- .../quickstep/interaction/AllSetActivity.java | 4 +- .../interaction/EdgeBackGestureHandler.java | 2 +- .../interaction/GestureSandboxActivity.java | 4 +- .../interaction/NavBarGestureHandler.java | 2 +- .../SwipeUpGestureTutorialController.java | 2 +- .../interaction/TutorialController.java | 6 +- .../interaction/TutorialFragment.java | 4 +- .../orientation/LandscapePagedViewHandler.kt | 14 +- .../orientation/PortraitPagedViewHandler.kt | 57 ++-- .../orientation/SeascapePagedViewHandler.kt | 4 +- .../RecentsDeviceProfileRepositoryImpl.kt | 2 +- .../AnimatorControllerWithResistance.java | 4 +- .../LauncherUnfoldAnimationController.java | 8 +- .../util/QuickstepOnboardingPrefs.java | 2 +- .../quickstep/util/RecentsOrientedState.java | 2 +- .../quickstep/util/RectFSpringAnim.java | 8 +- .../util/SplitAnimationController.kt | 27 +- .../util/SplitToWorkspaceController.java | 2 +- .../quickstep/util/TaskViewSimulator.java | 12 +- .../LauncherUnfoldTransitionController.kt | 12 +- .../quickstep/views/AllAppsEduView.java | 4 +- .../quickstep/views/DigitalWellBeingToast.kt | 2 +- .../views/FloatingAppPairBackground.kt | 61 +++-- .../quickstep/views/FloatingTaskView.java | 6 +- .../quickstep/views/OverviewActionsView.java | 8 +- .../quickstep/views/RecentsDismissUtils.kt | 6 +- .../android/quickstep/views/RecentsView.java | 44 +-- .../quickstep/views/RecentsViewUtils.kt | 6 +- .../android/quickstep/views/TaskMenuView.kt | 4 +- .../views/TaskThumbnailViewDeprecated.java | 2 +- .../com/android/quickstep/views/TaskView.kt | 14 +- .../launcher3/taskbar/TaskbarOverflowTest.kt | 5 +- .../navbutton/NavButtonLayoutFactoryTest.kt | 26 +- .../taskbar/rules/TaskbarModeRuleTest.kt | 6 +- src/com/android/launcher3/CellLayout.java | 2 +- src/com/android/launcher3/DeviceProfile.java | 252 ++++++++---------- src/com/android/launcher3/DropTargetBar.java | 45 ++-- .../launcher3/InvariantDeviceProfile.java | 14 +- src/com/android/launcher3/Launcher.java | 18 +- src/com/android/launcher3/LauncherState.java | 10 +- src/com/android/launcher3/ModelCallbacks.kt | 13 +- src/com/android/launcher3/Workspace.java | 12 +- .../allapps/AllAppsTransitionController.java | 2 +- .../allapps/LauncherAllAppsContainerView.java | 4 +- .../launcher3/allapps/WorkUtilityView.java | 2 +- .../deviceprofile/DeviceProperties.kt | 80 ++++++ src/com/android/launcher3/folder/Folder.java | 4 +- .../graphics/LauncherPreviewRenderer.java | 14 +- .../graphics/PreviewSurfaceRenderer.java | 2 +- .../launcher3/graphics/SysUiScrim.java | 2 +- .../launcher3/model/WorkspaceItemProcessor.kt | 4 +- .../launcher3/model/data/AppPairInfo.kt | 5 +- .../popup/PopupContainerWithArrow.java | 2 +- .../launcher3/popup/SystemShortcut.java | 3 +- .../launcher3/states/RotationHelper.java | 2 +- .../testing/TestInformationHandler.java | 4 +- .../AbstractStateChangeTouchController.java | 6 +- .../touch/AllAppsSwipeController.java | 11 +- .../launcher3/touch/ItemClickHandler.java | 2 +- .../android/launcher3/util/DimensionUtils.kt | 10 +- .../launcher3/views/AbstractSlideInView.java | 2 +- .../launcher3/views/ActivityContext.java | 6 +- .../android/launcher3/views/ClipIconView.java | 22 +- .../launcher3/views/FloatingIconView.java | 8 +- .../widget/AddItemWidgetsBottomSheet.java | 2 +- .../launcher3/widget/BaseWidgetSheet.java | 6 +- .../widget/LauncherAppWidgetProviderInfo.java | 2 +- .../picker/WidgetRecommendationsView.java | 2 +- .../widget/picker/WidgetsFullSheet.java | 8 +- .../widget/picker/WidgetsTwoPaneSheet.java | 8 +- .../picker/util/WidgetPreviewContainerSize.kt | 6 +- .../uioverrides/states/AllAppsState.java | 6 +- .../util/WidgetPreviewContainerSizesTest.kt | 2 +- .../util/ui/PortraitLandscapeRunner.java | 4 +- 127 files changed, 726 insertions(+), 596 deletions(-) create mode 100644 src/com/android/launcher3/deviceprofile/DeviceProperties.kt diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 280b9eb23c..31721370f1 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -512,7 +512,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener target = t; break; } - if (target == null) return new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx); + final int widthPx = mDeviceProfile.getDeviceProperties().getWidthPx(); + final int heightPx = mDeviceProfile.getDeviceProperties().getHeightPx(); + if (target == null) return new Rect(0, 0, widthPx, heightPx); final Rect bounds = new Rect(target.screenSpaceBounds); if (target.localBounds != null) { bounds.set(target.localBounds); @@ -522,10 +524,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener if (rotationChange != 0) { if ((rotationChange % 2) == 1) { // undoing rotation, so our "original" parent size is actually flipped - Utilities.rotateBounds(bounds, mDeviceProfile.heightPx, mDeviceProfile.widthPx, + Utilities.rotateBounds(bounds, heightPx, widthPx, 4 - rotationChange); } else { - Utilities.rotateBounds(bounds, mDeviceProfile.widthPx, mDeviceProfile.heightPx, + Utilities.rotateBounds(bounds, widthPx, heightPx, 4 - rotationChange); } } @@ -564,7 +566,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final View appsView = mLauncher.getAppsView(); final float startAlpha = appsView.getAlpha(); final float startScale = SCALE_PROPERTY.get(appsView); - if (mDeviceProfile.isTablet) { + if (mDeviceProfile.getDeviceProperties().isTablet()) { + // AllApps should not fade at all in tablets. alphas = new float[]{1, 1}; } @@ -792,7 +795,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f; - final float finalWindowRadius = mDeviceProfile.isMultiWindowMode + final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher); final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius; @@ -875,8 +878,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final int windowCropWidth = crop.width(); final int windowCropHeight = crop.height(); if (rotationChange != 0) { - Utilities.rotateBounds(crop, mDeviceProfile.widthPx, - mDeviceProfile.heightPx, rotationChange); + Utilities.rotateBounds(crop, mDeviceProfile.getDeviceProperties().getWidthPx(), + mDeviceProfile.getDeviceProperties().getHeightPx(), rotationChange); } // Scale the size of the icon to match the size of the window crop. @@ -923,14 +926,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener matrix.setScale(scale, scale); if (rotationChange == 1) { matrix.postTranslate(windowTransY0, - mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth)); + mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth)); } else if (rotationChange == 2) { matrix.postTranslate( - mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth), - mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight)); + mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth), + mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight)); } else if (rotationChange == 3) { matrix.postTranslate( - mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight), + mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight), windowTransX0); } else { matrix.postTranslate(windowTransX0, windowTransY0); @@ -1022,7 +1025,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget); } - final float finalWindowRadius = mDeviceProfile.isMultiWindowMode + final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher); final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher, v, widgetBackgroundBounds, @@ -1412,9 +1415,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener DeviceProfile dp = mLauncher.getDeviceProfile(); final int halfIconSize = dp.iconSizePx / 2; float primaryDimension = orientationHandler - .getPrimaryValue(dp.availableWidthPx, dp.availableHeightPx); + .getPrimaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx()); float secondaryDimension = orientationHandler - .getSecondaryValue(dp.availableWidthPx, dp.availableHeightPx); + .getSecondaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx()); final float targetX = primaryDimension / 2f; final float targetY = secondaryDimension - dp.hotseatBarSizePx; return new RectF(targetX - halfIconSize, targetY - halfIconSize, @@ -1444,13 +1447,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener // Get floating view and target rect. boolean isInHotseat = false; if (launcherView instanceof LauncherAppWidgetHostView) { - Size windowSize = new Size(mDeviceProfile.availableWidthPx, - mDeviceProfile.availableHeightPx); + Size windowSize = new Size(mDeviceProfile.getDeviceProperties().getAvailableWidthPx(), + mDeviceProfile.getDeviceProperties().getAvailableHeightPx()); int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mLauncher, runningTaskTarget); floatingWidget = FloatingWidgetView.getFloatingWidgetView(mLauncher, (LauncherAppWidgetHostView) launcherView, targetRect, windowSize, - mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher), + mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher), isTransluscent, fallbackBackgroundColor); } else if (launcherView != null && !RemoveAnimationSettingsTracker.INSTANCE.get( mLauncher).isRemoveAnimationEnabled()) { @@ -1481,7 +1484,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Rect closingWindowStartRect = new Rect(); closingWindowStartRectF.round(closingWindowStartRect); Rect closingWindowOriginalRect = - new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx); + new Rect(0, 0, mDeviceProfile.getDeviceProperties().getWidthPx(), mDeviceProfile.getDeviceProperties().getHeightPx()); if (floatingIconView != null) { anim.addAnimatorListener(floatingIconView); floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged); @@ -1559,7 +1562,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Rect tmpRect = new Rect(); ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1); int duration = CLOSING_TRANSITION_DURATION_MS; - float windowCornerRadius = mDeviceProfile.isMultiWindowMode + float windowCornerRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher); float startShadowRadius = areAllTargetsTranslucent(appTargets) ? 0 : mMaxShadowRadius; closingAnimator.setDuration(duration); @@ -2249,17 +2252,20 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean toLauncher, RectF resultRect) { final int taskRotation = target.windowConfiguration.getRotation(); final DeviceProfile profile = mLauncher.getDeviceProfile(); + final int rotation = profile.getDeviceProperties().getRotationHint(); + final int widthPx = profile.getDeviceProperties().getWidthPx(); + final int heightPx = profile.getDeviceProperties().getWidthPx(); final int rotationDelta = toLauncher - ? android.util.RotationUtils.deltaRotation(taskRotation, profile.rotationHint) - : android.util.RotationUtils.deltaRotation(profile.rotationHint, taskRotation); + ? android.util.RotationUtils.deltaRotation(taskRotation, rotation) + : android.util.RotationUtils.deltaRotation(rotation, taskRotation); if (rotationDelta != ROTATION_0) { // Get original display size when task is on top but with different rotation - if (rotationDelta % 2 != 0 && toLauncher && (profile.rotationHint == ROTATION_0 - || profile.rotationHint == ROTATION_180)) { - mDisplayRect.set(0, 0, profile.heightPx, profile.widthPx); + if (rotationDelta % 2 != 0 && toLauncher && (rotation == ROTATION_0 + || rotation == ROTATION_180)) { + mDisplayRect.set(0, 0, heightPx, widthPx); } else { - mDisplayRect.set(0, 0, profile.widthPx, profile.heightPx); + mDisplayRect.set(0, 0, widthPx, heightPx); } currentRect.round(mTmpResult); android.util.RotationUtils.rotateBounds(mTmpResult, mDisplayRect, rotationDelta); diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index 7074a823de..d4213e59dd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -503,7 +503,7 @@ public final class KeyboardQuickSwitchController implements boolean isAspectRatioSquare() { return mControllers != null && LayoutUtils.isAspectRatioSquare( - mControllers.taskbarActivityContext.getDeviceProfile().aspectRatio); + mControllers.taskbarActivityContext.getDeviceProfile().getDeviceProperties().getAspectRatio()); } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt index bfd93dda31..2d6f1ee5be 100644 --- a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt +++ b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt @@ -225,7 +225,7 @@ class ManageWindowsTaskbarShortcut( // Calculate the Y position to place the carousel above the taskbar menuView.rootView.y = - deviceProfile.availableHeightPx - + deviceProfile.deviceProperties.availableHeightPx - menuView.menuHeight - controllers.taskbarStashController.touchableHeight - margin @@ -234,9 +234,12 @@ class ManageWindowsTaskbarShortcut( // but avoid clashing with the screen edge menuView.rootView.translationX = if (Utilities.isRtl(context.resources)) { - -(deviceProfile.availableWidthPx - menuView.menuWidth) / 2f + -(deviceProfile.deviceProperties.availableWidthPx - menuView.menuWidth) / 2f } else { - val maxX = deviceProfile.availableWidthPx - menuView.menuWidth - margin + val maxX = + deviceProfile.deviceProperties.availableWidthPx - + menuView.menuWidth - + margin minOf(originalView.x, maxX) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 77cf3d5503..71f93f9eec 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -1048,9 +1048,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // If SUW is on a large screen device that is landscape (or has a square aspect // ratio) the back button has to be placed accordingly - if ((deviceProfile.isTablet && deviceProfile.isLandscape) - || (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND - && deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) { + if ((deviceProfile.getDeviceProperties().isTablet() && deviceProfile.getDeviceProperties().isLandscape()) + || (deviceProfile.getDeviceProperties().getAspectRatio() > SQUARE_ASPECT_RATIO_BOTTOM_BOUND + && deviceProfile.getDeviceProperties().getAspectRatio() < SQUARE_ASPECT_RATIO_UPPER_BOUND)) { navButtonsLayoutParams.setMarginStart( resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)); navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize( @@ -1061,7 +1061,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize( R.dimen.taskbar_contextual_button_suw_margin); navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin); - navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape + navButtonsLayoutParams.bottomMargin = !deviceProfile.getDeviceProperties().isLandscape() ? 0 : phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize( R.dimen.taskbar_nav_buttons_size) / 2); @@ -1427,7 +1427,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // If the taskbar is start aligned the navigation bar is aligned to the start or end of // the container, depending on the bubble bar location if (isNavbarOnRight) { - navBarTargetStartX = dp.widthPx - navBarSpacing - mNavButtonContainer.getWidth(); + navBarTargetStartX = dp.getDeviceProperties().getWidthPx() - navBarSpacing - mNavButtonContainer.getWidth(); } else { navBarTargetStartX = navBarSpacing; } @@ -1440,7 +1440,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT if (isNavbarOnRight) { if (mNavButtonsView.isLayoutRtl()) { float taskBarEnd = taskbarBounds.right; - navBarTargetStartX = (dp.widthPx + taskBarEnd - navbarWidth) / 2; + navBarTargetStartX = (dp.getDeviceProperties().getWidthPx() + taskBarEnd - navbarWidth) / 2; } else { navBarTargetStartX = mNavButtonContainer.getLeft(); } @@ -1458,7 +1458,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // screen. Rect transientTaskbarIconLayoutBoundsInParent = mControllers.taskbarViewController .getTransientTaskbarIconLayoutBoundsInParent(); - if (mContext.getDeviceProfile().isPhone + if (mContext.getDeviceProfile().getDeviceProperties().isPhone() || transientTaskbarIconLayoutBoundsInParent.isEmpty() || mNavButtonsView.getWidth() == 0) { return; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 26479c1543..ac05982ccf 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -316,7 +316,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { Optional bubbleControllersOptional = Optional.empty(); BubbleBarController.onTaskbarRecreated(); final boolean deviceBubbleBarEnabled = enableBubbleBarOnPhones() - || (!mDeviceProfile.isPhone && !mDeviceProfile.isVerticalBarLayout()); + || (!mDeviceProfile.getDeviceProperties().isPhone() && !mDeviceProfile.isVerticalBarLayout()); if (BubbleBarController.isBubbleBarEnabled() && deviceBubbleBarEnabled && bubbleBarView != null && isPrimaryDisplay) { Optional bubbleHandleController = Optional.empty(); @@ -398,7 +398,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { onViewCreated(); } - /** Updates {@link DeviceProfile} instances for any Taskbar windows. */ + /** Updates {@link deviceprofile} instances for any Taskbar windows. */ public void updateDeviceProfile(DeviceProfile launcherDp) { applyDeviceProfile(launcherDp); mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp); @@ -591,7 +591,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { */ public boolean isPhoneMode() { return ENABLE_TASKBAR_NAVBAR_UNIFICATION - && mDeviceProfile.isPhone + && mDeviceProfile.getDeviceProperties().isPhone() && !mDeviceProfile.isTaskbarPresent; } @@ -620,11 +620,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext { /** Returns {@code true} iff a tiny version of taskbar is shown on phone. */ public boolean isTinyTaskbar() { - return enableTinyTaskbar() && mDeviceProfile.isPhone && mDeviceProfile.isTaskbarPresent; + return enableTinyTaskbar() && mDeviceProfile.getDeviceProperties().isPhone() && mDeviceProfile.isTaskbarPresent; } public boolean isBubbleBarOnPhone() { - return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.isPhone; + return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.getDeviceProperties().isPhone(); } /** @@ -1310,13 +1310,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { public void setTaskbarWindowSize(int size) { // In landscape phone button nav mode, we should set the task bar width instead of height // because this is the only case in which the nav bar is not on the display bottom. - boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.isLandscape; + boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.getDeviceProperties().isLandscape(); if ((landscapePhoneButtonNav ? mWindowLayoutParams.width : mWindowLayoutParams.height) == size || mIsDestroyed) { return; } if (size == MATCH_PARENT) { - size = mDeviceProfile.heightPx; + size = mDeviceProfile.getDeviceProperties().getHeightPx(); } else { mLastRequestedNonFullscreenSize = size; if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt index d85dd50bb3..f3ea655866 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt @@ -86,7 +86,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) if ( measuredHeight + activityContext.deviceProfile.taskbarHeight >= - activityContext.deviceProfile.availableHeightPx + activityContext.deviceProfile.deviceProperties.availableHeightPx ) { updateLayoutParams { width = MATCH_PARENT } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index c9e613b913..21fe03f290 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -172,7 +172,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas // only add the taskbar touch region if not on home val bottom = windowLayoutParams.height val top = bottom - taskbarTouchableHeight - val right = context.deviceProfile.widthPx + val right = context.deviceProfile.deviceProperties.widthPx defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom)) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java index 1346d4403f..b55efb7181 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java @@ -196,7 +196,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { new SparseArray<>(); /** DisplayId - {@link ComponentCallbacks} map for Connected Display. */ private final SparseArray mComponentCallbacks = new SparseArray<>(); - /** DisplayId - {@link DeviceProfile} map for Connected Display. */ + /** DisplayId - {@link deviceprofile} map for Connected Display. */ private final SparseArray mExternalDeviceProfiles = new SparseArray<>(); private StatefulActivity mActivity; private RecentsViewContainer mRecentsViewContainer; @@ -1373,7 +1373,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Creates a {@link TaskbarActivityContext} for the given display and adds it to the map. * - * @param dp The {@link DeviceProfile} for the display. + * @param dp The {@link deviceprofile} for the display. * @param displayId The ID of the display. */ private @Nullable TaskbarActivityContext createTaskbarActivityContext(DeviceProfile dp, @@ -1400,7 +1400,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Creates a {@link DeviceProfile} for the given display and adds it to the map. + * Creates a {@link deviceprofile} for the given display and adds it to the map. * * @param displayId The ID of the display. */ @@ -1425,7 +1425,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Gets a {@link DeviceProfile} for the given displayId. + * Gets a {@link deviceprofile} for the given displayId. * * @param displayId The ID of the display. */ @@ -1447,7 +1447,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Removes the {@link DeviceProfile} associated with the given display ID from the map. + * Removes the {@link deviceprofile} associated with the given display ID from the map. * * @param displayId The ID of the display for which to remove the taskbar. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 1abcaa093a..2583137a32 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -1239,7 +1239,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba } // Do not stash if in small screen, with 3 button nav, and in landscape. if (mActivity.isPhoneMode() && mActivity.isThreeButtonNav() - && mActivity.getDeviceProfile().isLandscape) { + && mActivity.getDeviceProfile().getDeviceProperties().isLandscape()) { return false; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt index cbb69ba7c7..7793642eda 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt @@ -68,7 +68,8 @@ class TaskbarStashViaTouchController(val controllers: TaskbarControllers) : Touc ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, activity.resources, ) - gestureHeightYThreshold = (activity.deviceProfile.heightPx - gestureHeight).toFloat() + gestureHeightYThreshold = + (activity.deviceProfile.deviceProperties.heightPx - gestureHeight).toFloat() } private fun createSwipeListener() = diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java index 17516f3616..d3d7f5e143 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java @@ -38,7 +38,7 @@ public class TaskbarThresholdUtils { private static int getThreshold(Resources r, DeviceProfile dp, int thresholdDimen, int multiplierDimen) { - float landscapeScreenHeight = dp.isLandscape ? dp.heightPx : dp.widthPx; + float landscapeScreenHeight = dp.getDeviceProperties().isLandscape() ? dp.getDeviceProperties().getHeightPx() : dp.getDeviceProperties().getWidthPx(); float screenPart = (landscapeScreenHeight * SCREEN_UNITS); float defaultDp = dpiFromPx(screenPart, DisplayMetrics.DENSITY_DEVICE_STABLE); float thisDp = dpToPx(defaultDp); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index e4d44c1a84..c6ae854ccf 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -209,7 +209,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar */ private int calculateMaxNumIcons() { DeviceProfile deviceProfile = mActivityContext.getDeviceProfile(); - int availableWidth = deviceProfile.widthPx; + int availableWidth = deviceProfile.getDeviceProperties().getWidthPx(); int defaultEdgeMargin = (int) getResources().getDimension(deviceProfile.inv.inlineNavButtonsEndSpacing); int spaceForBubbleBar = diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 98710863dc..12f5e925ae 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -985,7 +985,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar float scaleUp = ((float) launcherDp.iconSizePx) / taskbarDp.taskbarIconSize; int borderSpacing = launcherDp.hotseatBorderSpace; int hotseatCellSize = DeviceProfile.calculateCellWidth( - launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right, + launcherDp.getDeviceProperties().getAvailableWidthPx() - hotseatPadding.left - hotseatPadding.right, borderSpacing, launcherDp.numShownHotseatIcons); @@ -1066,7 +1066,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar if (child == mTaskbarView.getQsb()) { boolean isRtl = Utilities.isRtl(child.getResources()); float hotseatIconCenter = isRtl - ? launcherDp.widthPx - hotseatPadding.right + borderSpacing + ? launcherDp.getDeviceProperties().getWidthPx() - hotseatPadding.right + borderSpacing + launcherDp.hotseatQsbWidth / 2f : hotseatPadding.left - borderSpacing - launcherDp.hotseatQsbWidth / 2f; if (taskbarDp.isQsbInline) { diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 9e2399e609..254ba5173b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -147,7 +147,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView= top && x >= mStashedHandleBounds.left && x <= mStashedHandleBounds.right; diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt index 3245c3db27..10e0cd2ef2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt +++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt @@ -38,7 +38,7 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext) get() = taskbarActivityContext.isTransientTaskbar val isLandscape: Boolean - get() = taskbarActivityContext.deviceProfile.isLandscape + get() = taskbarActivityContext.deviceProfile.deviceProperties.isLandscape val isTnMinimalState: Boolean get() = taskbarActivityContext.isTaskbarInMinimalState diff --git a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt index 17ee50e367..2290192ae7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt +++ b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt @@ -69,7 +69,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) if ( measuredHeight + activityContext.deviceProfile.taskbarHeight >= - activityContext.deviceProfile.availableHeightPx + activityContext.deviceProfile.deviceProperties.availableHeightPx ) { updateLayoutParams { width = LayoutParams.MATCH_PARENT } } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt index 3712a76eab..918d5cf71e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt @@ -90,7 +90,7 @@ abstract class AbstractNavButtonLayoutter( resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin) nearestTouchFrameLayoutParams.marginStart = phoneOrPortraitSetupMargin nearestTouchFrameLayoutParams.bottomMargin = - if (!deviceProfile.isLandscape) 0 + if (!deviceProfile.deviceProperties.isLandscape) 0 else phoneOrPortraitSetupMargin - resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2 diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index a199dba0bd..17e63e8bd3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -90,7 +90,7 @@ class NavButtonLayoutFactory { ) } isPhoneNavMode -> { - if (!deviceProfile.isLandscape) { + if (!deviceProfile.deviceProperties.isLandscape) { navButtonsView.setIsVertical(false) PhonePortraitNavLayoutter( resources, diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt index d989f6b534..00ba40c7f9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt @@ -48,7 +48,7 @@ open class PhoneLandscapeNavLayoutter( ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { - val totalHeight = context.deviceProfile.heightPx + val totalHeight = context.deviceProfile.deviceProperties.heightPx val homeButtonHeight = resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size) val roundedCornerContentMargin = diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt index 5b24ebfe1d..833a309e83 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt @@ -34,7 +34,7 @@ class PhonePortraitNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space? + space: Space?, ) : AbstractNavButtonLayoutter( resources, @@ -43,11 +43,11 @@ class PhonePortraitNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space + space, ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { - val totalWidth = context.deviceProfile.widthPx + val totalWidth = context.deviceProfile.deviceProperties.widthPx val homeButtonWidth = resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size) val roundedCornerContentMargin = @@ -63,7 +63,7 @@ class PhonePortraitNavLayoutter( val navContainerParams = FrameLayout.LayoutParams( navButtonContainerWidth.toInt(), - ViewGroup.LayoutParams.MATCH_PARENT + ViewGroup.LayoutParams.MATCH_PARENT, ) navContainerParams.apply { topMargin = 0 @@ -120,14 +120,14 @@ class PhonePortraitNavLayoutter( contextualButtonWidth.toInt(), roundedCornerContentMargin + contentPadding, 0, - Gravity.START + Gravity.START, ) repositionContextualContainer( endContextualContainer, contextualButtonWidth.toInt(), 0, roundedCornerContentMargin + contentPadding, - Gravity.END + Gravity.END, ) startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT) diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt index 99a2382827..f558122b3d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt @@ -78,9 +78,9 @@ class SetupNavLayoutter( // If SUW is on a large screen device that is landscape (or has a square aspect // ratio) the back button has to be placed accordingly if ( - deviceProfile.isTablet && deviceProfile.isLandscape || - (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND && - deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND) + deviceProfile.deviceProperties.isTablet && deviceProfile.deviceProperties.isLandscape || + (deviceProfile.deviceProperties.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND && + deviceProfile.deviceProperties.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND) ) { navButtonsLayoutParams.marginStart = resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin) diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt index a59e8a847b..bef432e668 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt @@ -35,7 +35,7 @@ class TaskbarNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space? + space: Space?, ) : AbstractNavButtonLayoutter( resources, @@ -44,7 +44,7 @@ class TaskbarNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space + space, ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { @@ -69,7 +69,7 @@ class TaskbarNavLayoutter( val navButtonParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.MATCH_PARENT + ViewGroup.LayoutParams.MATCH_PARENT, ) navButtonParams.apply { gravity = Gravity.END or Gravity.CENTER_VERTICAL @@ -101,7 +101,7 @@ class TaskbarNavLayoutter( endContextualContainer.removeAllViews() startContextualContainer.removeAllViews() - if (!context.deviceProfile.isGestureMode) { + if (!context.deviceProfile.deviceProperties.isGestureMode) { val contextualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_padding) repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END) @@ -110,7 +110,7 @@ class TaskbarNavLayoutter( WRAP_CONTENT, contextualMargin, contextualMargin, - Gravity.START + Gravity.START, ) if (imeSwitcher != null) { @@ -122,7 +122,7 @@ class TaskbarNavLayoutter( val imeSwitcherButtonParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT + ViewGroup.LayoutParams.MATCH_PARENT, ) imeSwitcherButtonParams.apply { marginStart = imeStartMargin diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java index 82916031a0..219c2b01ff 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java @@ -189,7 +189,7 @@ public final class TaskbarOverlayController { return mLauncherDeviceProfile; } - /** Updates {@link DeviceProfile} instance for Taskbar's overlay window. */ + /** Updates {@link deviceprofile} instance for Taskbar's overlay window. */ public void updateLauncherDeviceProfile(DeviceProfile dp) { mLauncherDeviceProfile = dp; Optional.ofNullable(mOverlayContext).ifPresent(c -> { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 13d6dc43fe..af83d13e1c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -515,7 +515,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, } private List> getSplitShortcuts() { - if (!mDeviceProfile.isTablet || mSplitSelectStateController.isSplitSelectActive()) { + if (!mDeviceProfile.getDeviceProperties().isTablet() || mSplitSelectStateController.isSplitSelectActive()) { return Collections.emptyList(); } RecentsView recentsView = getOverviewPanel(); @@ -704,7 +704,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, break; } - if (!getDeviceProfile().isMultiWindowMode) { + if (!getDeviceProfile().getDeviceProperties().isMultiWindowMode()) { list.add(new StatusBarTouchController( this, () -> this.isInState(LauncherState.NORMAL))); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt index 9bc1290d36..927d94c2f6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt @@ -246,7 +246,10 @@ class RecentsViewStateController(private val launcher: QuickstepLauncher) : launcher.deviceProfile, ) - val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet) + val timings = + AnimUtils.getDeviceOverviewToSplitTimings( + launcher.deviceProfile.getDeviceProperties().isTablet + ) if (!goingToOverviewFromWorkspaceContextual) { // This animation is already done for the contextual case, don't redo it recentsView.createSplitSelectInitAnimation( diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 19e98fafea..d6b7c3dd74 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -176,7 +176,7 @@ public class AllAppsState extends LauncherState { } private static boolean isWorkspaceVisible(DeviceProfile deviceProfile) { - return deviceProfile.isTablet || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur()); + return deviceProfile.getDeviceProperties().isTablet() || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur()); } @Override @@ -199,7 +199,7 @@ public class AllAppsState extends LauncherState { @Override public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { DeviceProfile dp = launcher.getDeviceProfile(); - return dp.isPhone && !dp.isLandscape; + return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape(); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index 4d32f7d690..a8be0545ec 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -82,7 +82,7 @@ public class OverviewState extends LauncherState { recentsView.getTaskSize(sTempRect); float scale; DeviceProfile deviceProfile = launcher.getDeviceProfile(); - if (deviceProfile.isTwoPanels) { + if (deviceProfile.getDeviceProperties().isTwoPanels()) { // In two panel layout, width does not include both panels or space between them, so // use height instead. We do not use height for handheld, as cell layout can be // shorter than a task and we want the workspace to scale down to task size. @@ -114,9 +114,9 @@ public class OverviewState extends LauncherState { int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS | ADD_DESK_BUTTON; DeviceProfile dp = launcher.getDeviceProfile(); boolean showFloatingSearch; - if (dp.isPhone) { + if (dp.getDeviceProperties().isPhone()) { // Only show search in phone overview in portrait mode. - showFloatingSearch = !dp.isLandscape; + showFloatingSearch = !dp.getDeviceProperties().isLandscape(); } else { // Only show search in tablet overview if taskbar is not visible. showFloatingSearch = !dp.isTaskbarPresent || isTaskbarStashed(launcher); @@ -148,7 +148,7 @@ public class OverviewState extends LauncherState { @Override public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { DeviceProfile dp = launcher.getDeviceProfile(); - return dp.isPhone && !dp.isLandscape; + return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape(); } @Override @@ -163,7 +163,7 @@ public class OverviewState extends LauncherState { @Override public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) { - return deviceProfile.isTablet; + return deviceProfile.getDeviceProperties().isTablet(); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java index 44f8bf1e07..3a6de197ac 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java @@ -220,7 +220,7 @@ public class QuickstepAtomicAnimationFactory extends } else if (fromState == NORMAL && toState == ALL_APPS) { AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mContainer, config); } else if (fromState == OVERVIEW && toState == OVERVIEW_SPLIT_SELECT) { - SplitAnimationTimings timings = mContainer.getDeviceProfile().isTablet + SplitAnimationTimings timings = mContainer.getDeviceProfile().getDeviceProperties().isTablet() ? SplitAnimationTimings.TABLET_OVERVIEW_TO_SPLIT : SplitAnimationTimings.PHONE_OVERVIEW_TO_SPLIT; config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java b/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java index 2631fbf0b6..c2ec17ab3f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java @@ -43,7 +43,7 @@ public class SplitScreenSelectState extends OverviewState { @Override public int getTransitionDuration(ActivityContext context, boolean isToState) { - if (isToState && context.getDeviceProfile().isTablet) { + if (isToState && context.getDeviceProfile().getDeviceProperties().isTablet()) { return SplitAnimationTimings.TABLET_ENTER_DURATION; } else if (isToState) { return SplitAnimationTimings.PHONE_ENTER_DURATION; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index 38775625b8..dce158f63f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -136,7 +136,7 @@ public class NavBarToHomeTouchController implements TouchController, } private float getShiftRange() { - return mLauncher.getDeviceProfile().heightPx; + return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx(); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 5a8a3a3406..7140d0f010 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -136,7 +136,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch float progressMultiplier = super.initCurrentAnimation(); if (mToState == HINT_STATE) { // Track the drag across the entire height of the screen. - progressMultiplier = -1f / mLauncher.getDeviceProfile().heightPx; + progressMultiplier = -1f / mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx(); } return progressMultiplier; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index b3c424f3f0..60bd54431f 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -130,13 +130,13 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mLauncher = launcher; mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this); mRecentsView = mLauncher.getOverviewPanel(); - mXRange = mLauncher.getDeviceProfile().widthPx / 2f; + mXRange = mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f; mYRange = LayoutUtils.getShelfTrackingDistance( mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler(), mRecentsView.getContainerInterface()); - mMaxYProgress = mLauncher.getDeviceProfile().heightPx / mYRange; + mMaxYProgress = mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / mYRange; mMotionPauseDetector = new MotionPauseDetector(mLauncher); mMotionPauseMinDisplacement = mLauncher.getResources().getDimension( R.dimen.motion_pause_detector_min_displacement_from_app); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index f582324f23..14896e53c7 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -161,6 +161,6 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll @Override protected float getShiftRange() { - return mLauncher.getDeviceProfile().widthPx / 2f; + return mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java index b70cabe76d..e7d2cd23c6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java @@ -39,6 +39,6 @@ public class TransposedQuickSwitchTouchController extends QuickSwitchTouchContro @Override protected float getShiftRange() { - return mLauncher.getDeviceProfile().heightPx / 2f; + return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / 2f; } } diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 86efe9b7ca..30fc6b5df5 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1024,7 +1024,7 @@ public abstract class AbsSwipeUpHandler< } dp.updateInsets(targets.homeContentInsets); initTransitionEndpoints(dp); - orientationState.setMultiWindowMode(dp.isMultiWindowMode); + orientationState.setMultiWindowMode(dp.getDeviceProperties().isMultiWindowMode()); } // Notify when the animation starts @@ -1539,7 +1539,7 @@ public abstract class AbsSwipeUpHandler< } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTaskView) { - if (mDp == null || !mDp.isGestureMode) { + if (mDp == null || !mDp.getDeviceProperties().isGestureMode()) { // We probably never received an animation controller, skip logging. return; } @@ -1973,24 +1973,26 @@ public abstract class AbsSwipeUpHandler< private Rect getKeepClearAreaForHotseat() { Rect keepClearArea; + final int heightPx = mDp.getDeviceProperties().getHeightPx(); + final int widthPx = mDp.getDeviceProperties().getWidthPx(); // the keep clear area in global screen coordinates, in pixels - if (mDp.isPhone) { + if (mDp.getDeviceProperties().isPhone()) { if (mDp.isSeascape()) { // in seascape the Hotseat is on the left edge of the screen - keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, mDp.heightPx); - } else if (mDp.isLandscape) { + keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, heightPx); + } else if (mDp.getDeviceProperties().isLandscape()) { // in landscape the Hotseat is on the right edge of the screen - keepClearArea = new Rect(mDp.widthPx - mDp.hotseatBarSizePx, 0, - mDp.widthPx, mDp.heightPx); + keepClearArea = new Rect(widthPx - mDp.hotseatBarSizePx, 0, + widthPx, heightPx); } else { // in portrait mode the Hotseat is at the bottom of the screen - keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx, - mDp.widthPx, mDp.heightPx); + keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx, + widthPx, heightPx); } } else { // large screens have Hotseat always at the bottom of the screen - keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx, - mDp.widthPx, mDp.heightPx); + keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx, + widthPx, heightPx); } return keepClearArea; } @@ -2754,7 +2756,7 @@ public abstract class AbsSwipeUpHandler< // Scaling of RecentsView during quick switch based on amount of recents scroll private float getScaleProgressDueToScroll() { - if (mContainer == null || !mContainer.getDeviceProfile().isTablet || mRecentsView == null + if (mContainer == null || !mContainer.getDeviceProfile().getDeviceProperties().isTablet() || mRecentsView == null || !shouldLinkRecentsViewScroll()) { return 0; } diff --git a/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt index 68860ac91b..f2242d8d4b 100644 --- a/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt +++ b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt @@ -58,8 +58,7 @@ class AspectRatioSystemShortcut( } mTarget.startActivitySafely(view, intent, mItemInfo) - mTarget - .statsLogManager + mTarget.statsLogManager .logger() .withItemInfo(mItemInfo) .log(LauncherEvent.LAUNCHER_ASPECT_RATIO_SETTINGS_SYSTEM_SHORTCUT_TAP) @@ -81,7 +80,7 @@ class AspectRatioSystemShortcut( !universalResizableByDefault() -> null // The option is only shown on sw600dp+ screens (checked by isTablet) - !viewContainer.deviceProfile.isTablet -> null + !viewContainer.deviceProfile.deviceProperties.isTablet -> null else -> { listOf( diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java index 52512f1498..cc787ccfc0 100644 --- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java +++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java @@ -253,7 +253,7 @@ public abstract class BaseContainerInterface { * For this state, whether tasks should layout as a grid rather than a list. */ public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) { - return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.isTablet; + return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.getDeviceProperties().isTablet(); } @Override diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java index e55b2eeb68..289baef349 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java @@ -283,7 +283,7 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler deviceProfile.heightPx) { + if (outStartRect.left > deviceProfile.deviceProperties.heightPx) { outStartRect.offsetTo(0f, outStartRect.top) - } else if (outStartRect.left < -deviceProfile.heightPx) { + } else if (outStartRect.left < -deviceProfile.deviceProperties.heightPx) { outStartRect.offsetTo(0f, outStartRect.top) } } @@ -394,15 +394,15 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { ) { // In fake land/seascape, the placeholder always needs to go to the "top" of the device, // which is the same bounds as 0 rotation. - val width = dp.widthPx + val width = dp.deviceProperties.widthPx val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp) out.set(0, 0, width, placeholderHeight + insetSizeAdjustment) out.inset(placeholderInset, 0) // Adjust the top to account for content off screen. This will help to animate the view in // with rounded corners. - val screenWidth = dp.widthPx - val screenHeight = dp.heightPx + val screenWidth = dp.deviceProperties.widthPx + val screenHeight = dp.deviceProperties.heightPx val totalHeight = (1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset) / screenWidth).toInt() out.top -= totalHeight - placeholderHeight @@ -467,8 +467,8 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { out2: Rect, ) { // In fake land/seascape, the window bounds are always top and bottom half - val screenHeight = dp.heightPx - val screenWidth = dp.widthPx + val screenHeight = dp.deviceProperties.heightPx + val screenWidth = dp.deviceProperties.widthPx out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize) out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight) } diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt index 4e1b1ad390..dd22b92d23 100644 --- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt @@ -63,9 +63,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat } override fun fixBoundsForHomeAnimStartRect(outStartRect: RectF, deviceProfile: DeviceProfile) { - if (outStartRect.left > deviceProfile.widthPx) { + if (outStartRect.left > deviceProfile.deviceProperties.widthPx) { outStartRect.offsetTo(0f, outStartRect.top) - } else if (outStartRect.left < -deviceProfile.widthPx) { + } else if (outStartRect.left < -deviceProfile.deviceProperties.widthPx) { outStartRect.offsetTo(0f, outStartRect.top) } } @@ -139,7 +139,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat if (enableOverviewIconMenu()) { x } else { - if (deviceProfile.isLandscape) { + if (deviceProfile.deviceProperties.isLandscape) { (x + taskInsetMargin + (thumbnailView.measuredWidth - thumbnailView.measuredHeight) / 2f) @@ -181,7 +181,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat ) } - (deviceProfile.isLandscape && !deviceProfile.isTablet) -> { + (deviceProfile.deviceProperties.isLandscape && + !deviceProfile.deviceProperties.isTablet) -> { val padding = thumbnailView.resources.getDimensionPixelSize(R.dimen.task_menu_edge_padding) thumbnailView.measuredHeight - (2 * padding) @@ -200,7 +201,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat taskMenuX: Float, taskMenuY: Float, ): Int = - deviceProfile.heightPx - + deviceProfile.deviceProperties.heightPx - deviceProfile.insets.top - taskMenuY.toInt() - deviceProfile.overviewActionsClaimedSpaceBelow @@ -331,11 +332,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat /* -------------------- */ override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int = - dp.heightPx - rect.bottom + dp.deviceProperties.heightPx - rect.bottom override fun getSplitPositionOptions(dp: DeviceProfile): List = when { - dp.isTablet -> { + dp.deviceProperties.isTablet -> { Utilities.getSplitPositionOptions(dp) } @@ -381,8 +382,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat @StagePosition stagePosition: Int, out: Rect, ) { - val screenWidth = dp.widthPx - val screenHeight = dp.heightPx + val screenWidth = dp.deviceProperties.widthPx + val screenHeight = dp.deviceProperties.heightPx val pinToRight = stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight) @@ -466,7 +467,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat */ private fun getPlaceholderSizeAdjustment(dp: DeviceProfile, pinToRight: Boolean): Int { val insetThickness = - if (!dp.isLandscape) { + if (!dp.deviceProperties.isLandscape) { dp.insets.top } else { if (pinToRight) dp.insets.right else dp.insets.left @@ -484,8 +485,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat out.pivotY = splitInstructionsHeight.toFloat() out.rotation = degreesRotated val distanceToEdge = - if (dp.isPhone) { - if (dp.isLandscape) { + if (dp.deviceProperties.isPhone) { + if (dp.deviceProperties.isLandscape) { out.resources.getDimensionPixelSize( R.dimen.split_instructions_bottom_margin_phone_landscape ) @@ -516,8 +517,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat out1: Rect, out2: Rect, ) { - val screenHeight = dp.heightPx - val screenWidth = dp.widthPx + val screenHeight = dp.deviceProperties.heightPx + val screenWidth = dp.deviceProperties.widthPx out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize) out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight) if (!dp.isLeftRightSplit) { @@ -556,10 +557,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat val dividerBarPercent = splitInfo.dividerPercent val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight - val scale = outRect.height().toFloat() / (dp.availableHeightPx - taskbarHeight) - val topTaskHeight = dp.availableHeightPx * topLeftTaskPercent + val scale = + outRect.height().toFloat() / (dp.deviceProperties.availableHeightPx - taskbarHeight) + val topTaskHeight = dp.deviceProperties.availableHeightPx * topLeftTaskPercent val scaledTopTaskHeight = topTaskHeight * scale - val dividerHeight = dp.availableHeightPx * dividerBarPercent + val dividerHeight = dp.deviceProperties.availableHeightPx * dividerBarPercent val scaledDividerHeight = dividerHeight * scale if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { @@ -668,8 +670,10 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat secondTaskViewSize.y = totalThumbnailHeight } else { val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight - val scale = totalThumbnailHeight.toFloat() / (dp.availableHeightPx - taskbarHeight) - val topTaskHeight = dp.availableHeightPx * taskPercent + val scale = + totalThumbnailHeight.toFloat() / + (dp.deviceProperties.availableHeightPx - taskbarHeight) + val topTaskHeight = dp.deviceProperties.availableHeightPx * taskPercent val finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale).toFloat() val scaledTopTaskHeight = topTaskHeight * scale firstTaskViewSize.x = parentWidth @@ -779,7 +783,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat .toInt() secondaryAppChipView.setSplitTranslationY( (primarySnapshotHeight + - (if (deviceProfile.isTablet) 0 else dividerThickness)) + (if (deviceProfile.deviceProperties.isTablet) 0 + else dividerThickness)) .toFloat() ) } @@ -792,9 +797,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat if (deviceProfile.isSeascape) deviceProfile.insets.right else deviceProfile.insets.left val fullscreenMidpointFromBottom = - ((deviceProfile.widthPx - fullscreenInsetThickness) / 2) - val midpointFromEndPct = fullscreenMidpointFromBottom.toFloat() / deviceProfile.widthPx - val insetPct = fullscreenInsetThickness.toFloat() / deviceProfile.widthPx + ((deviceProfile.deviceProperties.widthPx - fullscreenInsetThickness) / 2) + val midpointFromEndPct = + fullscreenMidpointFromBottom.toFloat() / deviceProfile.deviceProperties.widthPx + val insetPct = + fullscreenInsetThickness.toFloat() / deviceProfile.deviceProperties.widthPx val spaceAboveSnapshots = 0 val overviewThumbnailAreaThickness = groupedTaskViewWidth - spaceAboveSnapshots val bottomToMidpointOffset = @@ -895,7 +902,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat } override fun getDefaultSplitPosition(deviceProfile: DeviceProfile): Int { - check(deviceProfile.isTablet) { "Default position available only for large screens" } + check(deviceProfile.deviceProperties.isTablet) { + "Default position available only for large screens" + } return if (deviceProfile.isLeftRightSplit) { SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT } else { diff --git a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt index 7db9d30bc5..470db5e36a 100644 --- a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt @@ -113,7 +113,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() { deviceProfile: DeviceProfile, taskMenuX: Float, taskMenuY: Float, - ): Int = (deviceProfile.availableWidthPx - taskInsetMargin - taskMenuX).toInt() + ): Int = (deviceProfile.deviceProperties.availableWidthPx - taskInsetMargin - taskMenuX).toInt() override fun setSplitTaskSwipeRect( dp: DeviceProfile, @@ -187,7 +187,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() { } override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int = - dp.widthPx - rect.right + dp.deviceProperties.widthPx - rect.right override fun getSplitPositionOptions(dp: DeviceProfile): List = // Add "right" option which is actually the top diff --git a/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt b/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt index 8450f09cea..5397638ce1 100644 --- a/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt +++ b/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt @@ -29,7 +29,7 @@ class RecentsDeviceProfileRepositoryImpl(private val container: RecentsViewConta override fun getRecentsDeviceProfile() = with(container.deviceProfile) { RecentsDeviceProfile( - isLargeScreen = isTablet, + isLargeScreen = deviceProperties.isTablet, canEnterDesktopMode = DesktopModeStatus.canEnterDesktopMode(container.asContext()), ) } diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index 37d7030832..a2e0628da8 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -183,7 +183,7 @@ public class AnimatorControllerWithResistance { params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR); float prevScaleRate = (fullscreenScale - params.startScale) - / (params.dp.heightPx - startRect.bottom); + / (params.dp.getDeviceProperties().getHeightPx() - startRect.bottom); // This is what the scale would be at the end of the drag if we didn't apply resistance. float endScale = params.startScale - prevScaleRate * distanceToCover; // Create an interpolator that resists the scale so the scale doesn't get smaller than @@ -256,7 +256,7 @@ public class AnimatorControllerWithResistance { this.scaleProperty = scaleProperty; this.translationTarget = translationTarget; this.translationProperty = translationProperty; - if (dp.isTablet) { + if (dp.getDeviceProperties().isTablet()) { resistanceParams = RecentsResistanceParams.FROM_APP_TABLET; } else { resistanceParams = RecentsResistanceParams.FROM_APP; diff --git a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java index 4c26761440..fd1fbe6299 100644 --- a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java +++ b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java @@ -163,7 +163,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL @Override public void onDeviceProfileChanged(DeviceProfile dp) { - if (mIsTablet != null && dp.isTablet != mIsTablet) { + if (mIsTablet != null && dp.getDeviceProperties().isTablet() != mIsTablet) { // We should preemptively start the animation only if: // - We changed to the unfolded screen // - SystemUI IPC connection is alive, so we won't end up in a situation that we won't @@ -173,7 +173,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL // if Launcher was not open during unfold, in this case we receive the configuration // change only after we went back to home screen and we don't want to start the // animation in this case. - if (dp.isTablet + if (dp.getDeviceProperties().isTablet() && SystemUiProxy.INSTANCE.get(mLauncher).isActive() && !mExternalTransitionStatusProvider.hasRun()) { // Preemptively start the unfold animation to make sure that we have drawn @@ -181,12 +181,12 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL preemptivelyStartAnimationOnNextFrame(); } - if (!dp.isTablet) { + if (!dp.getDeviceProperties().isTablet()) { mExternalTransitionStatusProvider.onFolded(); } } - mIsTablet = dp.isTablet; + mIsTablet = dp.getDeviceProperties().isTablet(); } private class QsbAnimationListener implements TransitionProgressListener { diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java index 70ef47cc77..a6da2e9e02 100644 --- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java +++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java @@ -82,7 +82,7 @@ public class QuickstepOnboardingPrefs { public void onStateTransitionComplete(LauncherState finalState) { HotseatPredictionController client = launcher.getHotseatPredictionController(); if (mFromAllApps && finalState == NORMAL && client.hasPredictions()) { - if (!launcher.getDeviceProfile().isTablet + if (!launcher.getDeviceProfile().getDeviceProperties().isTablet() && HOTSEAT_DISCOVERY_TIP_COUNT.increment(launcher)) { client.showEdu(); stateManager.removeStateListener(this); diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 079478ccf1..51645356b8 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -175,7 +175,7 @@ public class RecentsOrientedState implements LauncherPrefChangeListener { */ public void setDeviceProfile(DeviceProfile deviceProfile) { boolean oldMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice(); - setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.isTablet); + setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.getDeviceProperties().isTablet()); if (mListenersInitialized) { boolean newMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice(); // If isMultipleOrientationSupportedByDevice is changed, init or destroy listeners diff --git a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java index 00b40116f7..f56c7a27d5 100644 --- a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java +++ b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java @@ -346,7 +346,7 @@ public class RectFSpringAnim extends ReleaseCheck { // Increase the stiffness for devices where we want the window size to transform // quicker. boolean shouldUseHigherStiffness = profile != null - && (profile.isLandscape || profile.isTablet); + && (profile.getDeviceProperties().isLandscape() || profile.getDeviceProperties().isTablet()); float stiffness = shouldUseHigherStiffness ? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness) : rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness); @@ -549,7 +549,7 @@ public class RectFSpringAnim extends ReleaseCheck { // Increase the stiffness for devices where we want the window size to transform // quicker. boolean shouldUseHigherStiffness = deviceProfile != null - && (deviceProfile.isLandscape || deviceProfile.isTablet); + && (deviceProfile.getDeviceProperties().isLandscape() || deviceProfile.getDeviceProperties().isTablet()); rectStiffness = shouldUseHigherStiffness ? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness) : rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness); @@ -562,11 +562,11 @@ public class RectFSpringAnim extends ReleaseCheck { ? TRACKING_BOTTOM : TRACKING_TOP; } else { - int heightPx = deviceProfile.heightPx; + int heightPx = deviceProfile.getDeviceProperties().getHeightPx(); Rect padding = deviceProfile.workspacePadding; final float topThreshold = heightPx / 3f; - final float bottomThreshold = deviceProfile.heightPx - padding.bottom; + final float bottomThreshold = deviceProfile.getDeviceProperties().getHeightPx() - padding.bottom; if (targetRect.bottom > bottomThreshold) { if (enableScalingRevealHomeAnimation()) { diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index d6d265b89d..c28e8c224c 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -328,14 +328,16 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC // Make the scrim fullscreen val lp = scrim.layoutParams as InsettableFrameLayout.LayoutParams lp.topMargin = 0 - lp.height = dp.heightPx - lp.width = dp.widthPx + lp.height = dp.deviceProperties.heightPx + lp.width = dp.deviceProperties.widthPx scrim.alpha = 0f scrim.setBackgroundColor( container.asContext().resources.getColor(R.color.taskbar_background_dark) ) - val timings = AnimUtils.getDeviceSplitToConfirmTimings(dp.isTablet) as SplitToConfirmTimings + val timings = + AnimUtils.getDeviceSplitToConfirmTimings(dp.deviceProperties.isTablet) + as SplitToConfirmTimings pendingAnimation.setViewAlpha( scrim, 1f, @@ -428,7 +430,10 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC safeRemoveViewFromDragLayer(container, splitSelectStateController.splitInstructionsView) val splitInstructionsView = SplitInstructionsView.getSplitInstructionsView(container) splitSelectStateController.splitInstructionsView = splitInstructionsView - val timings = AnimUtils.getDeviceOverviewToSplitTimings(container.deviceProfile.isTablet) + val timings = + AnimUtils.getDeviceOverviewToSplitTimings( + container.deviceProfile.deviceProperties.isTablet + ) val anim = PendingAnimation(100 /*duration */) splitInstructionsView.alpha = 0f anim.setViewAlpha( @@ -471,7 +476,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC ) { val stagedTaskView = view as FloatingTaskView - val isTablet: Boolean = container.deviceProfile.isTablet + val isTablet: Boolean = container.deviceProfile.deviceProperties.isTablet val duration = if (isTablet) SplitAnimationTimings.TABLET_CONFIRM_DURATION else SplitAnimationTimings.PHONE_CONFIRM_DURATION @@ -891,7 +896,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC rootCandidate: Change, ): ValueAnimator { val progressUpdater = ValueAnimator.ofFloat(0f, 1f) - val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.isTablet) + val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.deviceProperties.isTablet) progressUpdater.setDuration(timings.getDuration().toLong()) progressUpdater.interpolator = Interpolators.LINEAR @@ -915,7 +920,8 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mDx = FloatProp( floatingView.startingPosition.left, - dp.widthPx / 2f - floatingView.startingPosition.width() / 2f, + dp.deviceProperties.widthPx / 2f - + floatingView.startingPosition.width() / 2f, Interpolators.clampToProgress( timings.getStagedRectXInterpolator(), timings.stagedRectSlideStartOffset, @@ -925,7 +931,8 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mDy = FloatProp( floatingView.startingPosition.top, - dp.heightPx / 2f - floatingView.startingPosition.height() / 2f, + dp.deviceProperties.heightPx / 2f - + floatingView.startingPosition.height() / 2f, Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, @@ -935,7 +942,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mScaleX = FloatProp( 1f /* start */, - dp.widthPx / floatingView.startingPosition.width(), + dp.deviceProperties.widthPx / floatingView.startingPosition.width(), Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, @@ -945,7 +952,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mScaleY = FloatProp( 1f /* start */, - dp.heightPx / floatingView.startingPosition.height(), + dp.deviceProperties.heightPx / floatingView.startingPosition.height(), Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, diff --git a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java index d3390b4ed9..abd24588d4 100644 --- a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java +++ b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java @@ -157,7 +157,7 @@ public class SplitToWorkspaceController { private void startWorkspaceAnimation(@NonNull View view, @Nullable Bitmap bitmap, @Nullable Drawable icon) { DeviceProfile dp = mLauncher.getDeviceProfile(); - boolean isTablet = dp.isTablet; + boolean isTablet = dp.getDeviceProperties().isTablet(); SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet); PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration()); diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 7fbc7bd4e0..b34587c525 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -152,7 +152,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mLayoutValid = false; mOrientationState.setDeviceProfile(dp); if (enableGridOnlyOverview()) { - mIsGridTask = dp.isTablet && !mIsDesktopTask; + mIsGridTask = dp.getDeviceProperties().isTablet() && !mIsDesktopTask; } calculateTaskSize(); } @@ -325,7 +325,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { public void addAppToCarouselAnim(PendingAnimation pa, Interpolator interpolator, boolean isHandlingAtomicEvent) { pa.addFloat(fullScreenProgress, AnimatedFloat.VALUE, 1, 0, interpolator); - if (enableGridOnlyOverview() && mDp.isTablet && !isHandlingAtomicEvent) { + if (enableGridOnlyOverview() && mDp.getDeviceProperties().isTablet() && !isHandlingAtomicEvent) { mIsAnimatingToCarousel = true; carouselScale.value = mCarouselTaskSize.width() / (float) mFullTaskSize.width(); } @@ -357,7 +357,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { public RectF getCurrentRect() { RectF result = getCurrentCropRect(); mMatrixTmp.set(mMatrix); - preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.widthPx, mDp.heightPx, + preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(), mMatrixTmp); mMatrixTmp.mapRect(result); return result; @@ -411,11 +411,11 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { * window coordinate space. */ public void applyWindowToHomeRotation(Matrix matrix) { - matrix.postTranslate(mDp.windowX, mDp.windowY); + matrix.postTranslate(mDp.getDeviceProperties().getWindowX(), mDp.getDeviceProperties().getWindowY()); postDisplayRotation(deltaRotation( mOrientationState.getRecentsActivityRotation(), mOrientationState.getDisplayRotation()), - mDp.widthPx, mDp.heightPx, matrix); + mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(), matrix); } /** @@ -450,7 +450,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { boolean isRtlEnabled = !mIsRecentsRtl; mPositionHelper.updateThumbnailMatrix( mThumbnailPosition, mThumbnailData, mTaskRect.width(), mTaskRect.height(), - mDp.isTablet, mOrientationState.getRecentsActivityRotation(), isRtlEnabled); + mDp.getDeviceProperties().isTablet(), mOrientationState.getRecentsActivityRotation(), isRtlEnabled); mPositionHelper.getMatrix().invert(mInversePositionMatrix); if (DEBUG) { Log.d(TAG, " taskRect: " + mTaskRect); diff --git a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt index 915c9e5305..6fc450a01b 100644 --- a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt +++ b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt @@ -56,7 +56,7 @@ class LauncherUnfoldTransitionController( } override fun onDeviceProfileChanged(dp: DeviceProfile) { - if (isTablet != null && dp.isTablet != isTablet) { + if (isTablet != null && dp.getDeviceProperties().isTablet != isTablet) { // We should preemptively start the animation only if: // - We changed to the unfolded screen // - SystemUI IPC connection is alive, so we won't end up in a situation that we won't @@ -66,20 +66,24 @@ class LauncherUnfoldTransitionController( // if Launcher was not open during unfold, in this case we receive the configuration // change only after we went back to home screen and we don't want to start the // animation in this case. - if (dp.isTablet && progressProvider.isActive && !hasUnfoldTransitionStarted) { + if ( + dp.getDeviceProperties().isTablet && + progressProvider.isActive && + !hasUnfoldTransitionStarted + ) { // Preemptively start the unfold animation to make sure that we have drawn // the first frame of the animation before the screen gets unblocked onTransitionStarted() Trace.beginAsyncSection("$TAG#startedPreemptively", 0) timeoutAlarm.setAlarm(PREEMPTIVE_UNFOLD_TIMEOUT_MS) } - if (!dp.isTablet) { + if (!dp.getDeviceProperties().isTablet) { // Reset unfold transition status when folded hasUnfoldTransitionStarted = false } } - isTablet = dp.isTablet + isTablet = dp.getDeviceProperties().isTablet } override fun onTransitionStarted() { diff --git a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java index 121d8ede11..166ed7916c 100644 --- a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java +++ b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java @@ -267,8 +267,8 @@ public class AllAppsEduView extends AbstractFloatingView { DeviceProfile grid = launcher.getDeviceProfile(); DragLayer.LayoutParams lp = new DragLayer.LayoutParams(mWidthPx, mMaxHeightPx); lp.ignoreInsets = true; - lp.leftMargin = (grid.widthPx - mWidthPx) / 2; - lp.topMargin = grid.heightPx - grid.hotseatBarSizePx - mMaxHeightPx; + lp.leftMargin = (grid.getDeviceProperties().getWidthPx() - mWidthPx) / 2; + lp.topMargin = grid.getDeviceProperties().getHeightPx() - grid.hotseatBarSizePx - mMaxHeightPx; setLayoutParams(lp); } diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt index 10d4377424..fd5c1336a3 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt @@ -178,7 +178,7 @@ constructor( val splitBounds = splitBounds return when { splitBounds == null || - !recentsViewContainer.deviceProfile.isTablet || + !recentsViewContainer.deviceProfile.deviceProperties.isTablet || taskView.isLargeTile -> SplitBannerConfig.SPLIT_BANNER_FULLSCREEN // For portrait grid only height of task changes, not width. So we keep the text the // same diff --git a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt index 6bbd6b2c15..4361a33aa5 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt +++ b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt @@ -37,12 +37,12 @@ import com.android.systemui.shared.system.QuickStepContract * increase in size during the animation. */ open class FloatingAppPairBackground( - context: Context, - // the view that we will draw this background on - protected val floatingView: FloatingAppPairView, - private val appIcon1: Drawable, - private val appIcon2: Drawable?, - dividerPos: Int + context: Context, + // the view that we will draw this background on + protected val floatingView: FloatingAppPairView, + private val appIcon1: Drawable, + private val appIcon2: Drawable?, + dividerPos: Int, ) : Drawable() { companion object { // Design specs -- app icons start small and expand during the animation @@ -79,41 +79,44 @@ open class FloatingAppPairBackground( backgroundPaint.color = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0) ta.recycle() // Set up timings and interpolators - val timings = AnimUtils.getDeviceAppPairLaunchTimings(container.deviceProfile.isTablet) + val timings = + AnimUtils.getDeviceAppPairLaunchTimings( + container.deviceProfile.deviceProperties.isTablet + ) expandXInterpolator = Interpolators.clampToProgress( timings.getStagedRectScaleXInterpolator(), timings.stagedRectSlideStartOffset, - timings.stagedRectSlideEndOffset + timings.stagedRectSlideEndOffset, ) expandYInterpolator = Interpolators.clampToProgress( timings.getStagedRectScaleYInterpolator(), timings.stagedRectSlideStartOffset, - timings.stagedRectSlideEndOffset + timings.stagedRectSlideEndOffset, ) cellSplitInterpolator = Interpolators.clampToProgress( timings.cellSplitInterpolator, timings.cellSplitStartOffset, - timings.cellSplitEndOffset + timings.cellSplitEndOffset, ) iconFadeInterpolator = Interpolators.clampToProgress( timings.iconFadeInterpolator, timings.iconFadeStartOffset, - timings.iconFadeEndOffset + timings.iconFadeEndOffset, ) // Find device-specific measurements val resources = context.resources deviceCornerRadius = QuickStepContract.getWindowCornerRadius(context) deviceHalfDividerSize = - resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f + resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f val dividerCenterPos = dividerPos + deviceHalfDividerSize desiredSplitRatio = - if (dp.isLeftRightSplit) dividerCenterPos / dp.widthPx - else dividerCenterPos / dp.heightPx + if (dp.isLeftRightSplit) dividerCenterPos / dp.deviceProperties.widthPx + else dividerCenterPos / dp.deviceProperties.heightPx dividerPaint.color = resources.getColor(R.color.taskbar_background_dark, null /*theme*/) } @@ -157,8 +160,13 @@ open class FloatingAppPairBackground( // The right half of the background image val rightSide = RectF(dividerCenterPos + changingDividerSize, 0f, width, height) // Middle part is for divider background - val middleRect = RectF(leftSide.right - deviceHalfDividerSize, 0f, - rightSide.left + deviceHalfDividerSize, height) + val middleRect = + RectF( + leftSide.right - deviceHalfDividerSize, + 0f, + rightSide.left + deviceHalfDividerSize, + height, + ) // Draw background canvas.drawRect(middleRect, dividerPaint) @@ -174,7 +182,7 @@ open class FloatingAppPairBackground( changingInnerRadiusY, cornerRadiusX, cornerRadiusY, - ) + ), ) drawCustomRoundedRect( canvas, @@ -188,7 +196,7 @@ open class FloatingAppPairBackground( cornerRadiusY, changingInnerRadiusX, changingInnerRadiusY, - ) + ), ) // Calculate changing measurements for icons. @@ -259,8 +267,13 @@ open class FloatingAppPairBackground( // The bottom half of the background image val bottomSide = RectF(0f, dividerCenterPos + changingDividerSize, width, height) // Middle part is for divider background - val middleRect = RectF(0f, topSide.bottom - deviceHalfDividerSize, - width, bottomSide.top + deviceHalfDividerSize) + val middleRect = + RectF( + 0f, + topSide.bottom - deviceHalfDividerSize, + width, + bottomSide.top + deviceHalfDividerSize, + ) // Draw background canvas.drawRect(middleRect, dividerPaint) @@ -275,8 +288,8 @@ open class FloatingAppPairBackground( changingInnerRadiusX, changingInnerRadiusY, changingInnerRadiusX, - changingInnerRadiusY - ) + changingInnerRadiusY, + ), ) drawCustomRoundedRect( canvas, @@ -289,8 +302,8 @@ open class FloatingAppPairBackground( cornerRadiusX, cornerRadiusY, cornerRadiusX, - cornerRadiusY - ) + cornerRadiusY, + ), ) // Calculate changing measurements for icons. diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java index acbb2eccbb..72a823efe1 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java @@ -239,7 +239,7 @@ public class FloatingTaskView extends FrameLayout { // Position the floating view exactly on top of the original lp.topMargin = Math.round(pos.top); if (mIsRtl) { - lp.setMarginStart(mContainer.getDeviceProfile().widthPx - Math.round(pos.right)); + lp.setMarginStart(mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() - Math.round(pos.right)); } else { lp.setMarginStart(Math.round(pos.left)); } @@ -256,7 +256,7 @@ public class FloatingTaskView extends FrameLayout { */ public void addStagingAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { - boolean isTablet = mContainer.getDeviceProfile().isTablet; + boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet(); boolean splittingFromOverview = fadeWithThumbnail; SplitAnimationTimings timings; @@ -280,7 +280,7 @@ public class FloatingTaskView extends FrameLayout { public void addConfirmAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { SplitAnimationTimings timings = - AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().isTablet); + AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); addAnimation(animation, startingBounds, endBounds, fadeWithThumbnail, isStagedTask, timings); diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index efc7eea84d..8ac15cb447 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -273,7 +273,7 @@ public class OverviewActionsView extends FrameLayo private void updateForIsTablet() { assert mDp != null; // Update flags to see if split button should be hidden. - updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.isTablet); + updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.getDeviceProperties().isTablet()); updateActionButtonsVisibility(); } @@ -282,7 +282,7 @@ public class OverviewActionsView extends FrameLayo return; } boolean showSingleTaskActions = !mIsGroupedTask; - boolean showGroupActions = mIsGroupedTask && mDp.isTablet && mCanSaveAppPair; + boolean showGroupActions = mIsGroupedTask && mDp.getDeviceProperties().isTablet() && mCanSaveAppPair; Log.d(TAG, "updateActionButtonsVisibility() called: showSingleTaskActions = [" + showSingleTaskActions + "], showGroupActions = [" + showGroupActions + "]"); getActionsAlphas().get(INDEX_GROUPED_ALPHA).setValue(showSingleTaskActions ? 1 : 0); @@ -384,12 +384,12 @@ public class OverviewActionsView extends FrameLayo return 0; } - if (mDp.isTablet && enableGridOnlyOverview()) { + if (mDp.getDeviceProperties().isTablet() && enableGridOnlyOverview()) { return mDp.stashedTaskbarHeight; } // Align to bottom of task Rect. - return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx + return mDp.getDeviceProperties().getHeightPx() - mTaskSize.bottom - mDp.overviewActionsTopMarginPx - mDp.overviewActionsHeight; } diff --git a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt index 23b0f6c180..b24b71c395 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt @@ -1004,7 +1004,11 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { dispatchScrollChanged() updateActionsViewFocusedScroll() if ( - isClearAllHidden && !(mContainer as ActivityContext).getDeviceProfile().isTablet + isClearAllHidden && + !(mContainer as ActivityContext) + .getDeviceProfile() + .deviceProperties + .isTablet ) { actionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false) } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index b4c04bbb40..9c5f604c78 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1475,9 +1475,9 @@ public abstract class RecentsView< for (int i = apps.length - 1; i >= 0; --i) { RemoteAnimationTarget app = apps[i]; - float dx = mContainer.getDeviceProfile().widthPx * (1 - percent) / 2 + float dx = mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() * (1 - percent) / 2 + app.screenSpaceBounds.left * percent; - float dy = mContainer.getDeviceProfile().heightPx * (1 - percent) / 2 + float dy = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() * (1 - percent) / 2 + app.screenSpaceBounds.top * percent; matrix.setScale(percent, percent); matrix.postTranslate(dx, dy); @@ -1714,7 +1714,7 @@ public abstract class RecentsView< @Override protected void onPageBeginTransition() { super.onPageBeginTransition(); - if (!mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, true); } if (mOverviewStateEnabled) { // only when in overview @@ -1726,7 +1726,7 @@ public abstract class RecentsView< protected void onPageEndTransition() { super.onPageEndTransition(); ActiveGestureProtoLogProxy.logOnPageEndTransition(getNextPage()); - if (!mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } if (getNextPage() > 0) { @@ -1738,12 +1738,12 @@ public abstract class RecentsView< @Override protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) { DeviceProfile deviceProfile = mContainer.getDeviceProfile(); - if (!deviceProfile.isTablet) { + if (!deviceProfile.getDeviceProperties().isTablet()) { return super.isSignificantMove(absoluteDelta, pageOrientedSize); } return absoluteDelta - > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; + > deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; } @Override @@ -2300,7 +2300,7 @@ public abstract class RecentsView< setOverviewGridEnabled( getStateManager().getState().displayOverviewTasksAsGrid(dp)); if (enableGridOnlyOverview()) { - mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.isTablet); + mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.getDeviceProperties().isTablet()); } setPageSpacing(dp.overviewPageSpacing); @@ -2378,8 +2378,8 @@ public abstract class RecentsView< mTaskHeight = mLastComputedTaskSize.height(); setPadding(mLastComputedTaskSize.left - mInsets.left, mLastComputedTaskSize.top - dp.overviewTaskThumbnailTopMarginPx - mInsets.top, - dp.widthPx - mInsets.right - mLastComputedTaskSize.right, - dp.heightPx - mInsets.bottom - mLastComputedTaskSize.bottom); + dp.getDeviceProperties().getWidthPx() - mInsets.right - mLastComputedTaskSize.right, + dp.getDeviceProperties().getHeightPx() - mInsets.bottom - mLastComputedTaskSize.bottom); mContainerInterface.calculateGridSize(dp, mContainer, mLastComputedGridSize); mContainerInterface.calculateGridTaskSize(mContainer, dp, mLastComputedGridTaskSize, @@ -2461,7 +2461,7 @@ public abstract class RecentsView< */ private float getTaskAlignmentTranslationY() { DeviceProfile deviceProfile = mContainer.getDeviceProfile(); - if (deviceProfile.isTablet) { + if (deviceProfile.getDeviceProperties().isTablet()) { return deviceProfile.overviewRowSpacing; } return deviceProfile.overviewTaskThumbnailTopMarginPx / 2.0f; @@ -2562,7 +2562,7 @@ public abstract class RecentsView< @Override protected int getDestinationPage(int scaledScroll) { - if (!mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { return super.getDestinationPage(scaledScroll); } if (!isPageScrollsInitialized()) { @@ -3491,7 +3491,7 @@ public abstract class RecentsView< int minimumDistance = (mIsRtl ? mLastComputedTaskSize.left - : deviceProfile.widthPx - mLastComputedTaskSize.right) + : deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right) - deviceProfile.overviewGridSideMargin - mPageSpacing + (mTaskWidth - snappedTaskView.getLayoutParams().width) - mClearAllShortTotalWidthTranslation; @@ -3648,7 +3648,7 @@ public abstract class RecentsView< mSplitPlaceholderInset, mContainer.getDeviceProfile(), mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect); SplitAnimationTimings timings = - AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet); + AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); RectF startingTaskRect = new RectF(); safeRemoveDragLayerView(mSplitSelectStateController.getFirstFloatingTaskView()); @@ -3880,7 +3880,7 @@ public abstract class RecentsView< } SplitAnimationTimings splitTimings = - AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet); + AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); int distanceFromDismissedTask = 1; int slidingTranslation = 0; @@ -4245,7 +4245,7 @@ public abstract class RecentsView< // Update various scroll-dependent UI. dispatchScrollChanged(); updateActionsViewFocusedScroll(); - if (!mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } @@ -5131,7 +5131,7 @@ public abstract class RecentsView< if (isTopShift) { distanceToOffscreen = -taskPosition.bottom; } else if (isBottomShift) { - distanceToOffscreen = mContainer.getDeviceProfile().heightPx - taskPosition.top; + distanceToOffscreen = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() - taskPosition.top; } return distanceToOffscreen * offsetProgress; } @@ -5232,7 +5232,7 @@ public abstract class RecentsView< public void handleDesktopTaskInSplitSelectState(PendingAnimation builder, Interpolator deskTopFadeInterPolator) { SplitAnimationTimings timings = AnimUtils.getDeviceOverviewToSplitTimings( - mContainer.getDeviceProfile().isTablet); + mContainer.getDeviceProfile().getDeviceProperties().isTablet()); if (enableLargeDesktopWindowingTile()) { getTaskViews().forEachWithIndexInParent((index, taskView) -> { if (taskView instanceof DesktopTaskView) { @@ -5344,7 +5344,7 @@ public abstract class RecentsView< builder.addOnFrameListener((animator) -> { SplitAnimationTimings splitTimings = AnimUtils.getDeviceOverviewToSplitTimings( - mContainer.getDeviceProfile().isTablet); + mContainer.getDeviceProfile().getDeviceProperties().isTablet()); if (animator.getAnimatedFraction() > splitTimings.getGridSlideStartOffset() && !hasRunDismiss.get()) { mDismissUtils.createTaskDismissSpringAnimation( @@ -5410,7 +5410,7 @@ public abstract class RecentsView< Rect firstTaskStartingBounds = new Rect(); Rect firstTaskEndingBounds = mTempRect; - boolean isTablet = mContainer.getDeviceProfile().isTablet; + boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet(); SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet); PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration()); @@ -5490,7 +5490,7 @@ public abstract class RecentsView< if (mSplitHiddenTaskViewIndex == -1) { return; } - if (!mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { int pageToSnapTo = mCurrentPage; if (mSplitHiddenTaskViewIndex <= pageToSnapTo) { pageToSnapTo += 1; @@ -5540,11 +5540,11 @@ public abstract class RecentsView< int direction = orientationHandler.getSplitTranslationDirectionFactor( splitPosition, deviceProfile); - if (deviceProfile.isTablet && deviceProfile.isLeftRightSplit) { + if (deviceProfile.getDeviceProperties().isTablet() && deviceProfile.isLeftRightSplit) { // Only shift TaskViews if there is not enough space on the side of // mLastComputedTaskSize to minimize motion. int sideSpace = mIsRtl - ? deviceProfile.widthPx - mLastComputedTaskSize.right + ? deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right : mLastComputedTaskSize.left; int extraSpace = splitPlaceholderSize + mPageSpacing - sideSpace; if (extraSpace <= 0f) { diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index 7a53b109c5..e46891a3f1 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -213,7 +213,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi if (desktopTaskView != null) return recentsView.indexOfChild(desktopTaskView) } val firstTaskViewIndex = recentsView.indexOfChild(getFirstTaskView()) - return if (getDeviceProfile().isTablet) { + return if (getDeviceProfile().deviceProperties.isTablet) { var index = firstTaskViewIndex if (enableLargeDesktopWindowingTile() && runningTaskView !is DesktopTaskView) { // For fullsreen tasks, skip over Desktop tasks in its section @@ -402,7 +402,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi outTopRowRect: Rect, outBottomRowRect: Rect, ) { - if (!getDeviceProfile().isTablet) { + if (!getDeviceProfile().deviceProperties.isTablet) { getRowRect(getFirstTaskView(), getLastTaskView(), outTaskViewRowRect) return } @@ -468,7 +468,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi } fun updateCentralTask() { - val isTablet: Boolean = getDeviceProfile().isTablet + val isTablet: Boolean = getDeviceProfile().deviceProperties.isTablet val actionsViewCanRelateToTaskView = !(isTablet && enableGridOnlyOverview()) val focusedTaskView = recentsView.focusedTaskView val currentPageTaskView = recentsView.currentPageTaskView diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt index 1d12d119b3..09a358a39d 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt @@ -75,7 +75,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : // Spaced claimed below Overview (taskbar and insets) private val taskbarTop by lazy { - recentsViewContainer.deviceProfile.heightPx - + recentsViewContainer.deviceProfile.deviceProperties.heightPx - recentsViewContainer.deviceProfile.overviewActionsClaimedSpaceBelow } private val minMenuTop by lazy { taskContainer.iconView.asView().height.toFloat() } @@ -478,7 +478,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : additionalTranslationX = max( (translationX + width - - (recentsViewContainer.deviceProfile.widthPx - + (recentsViewContainer.deviceProfile.deviceProperties.widthPx - resources.getDimensionPixelSize( R.dimen.task_menu_edge_padding ) * 2)) diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java index 74d76e6432..859feb2ec5 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java @@ -469,7 +469,7 @@ public class TaskThumbnailViewDeprecated extends View implements ViewPool.Reusab int currentRotation = mTaskView.getOrientedState().getRecentsActivityRotation(); boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData, - getMeasuredWidth(), getMeasuredHeight(), dp.isTablet, currentRotation, isRtl); + getMeasuredWidth(), getMeasuredHeight(), dp.getDeviceProperties().isTablet(), currentRotation, isRtl); mBitmapShader.setLocalMatrix(mPreviewPositionHelper.getMatrix()); mPaint.setShader(mBitmapShader); diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 3cefe68f99..8bd64b0e1f 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -155,7 +155,7 @@ constructor( val isGridTask: Boolean /** Returns whether the task is part of overview grid and not being focused. */ - get() = container.deviceProfile.isTablet && !isLargeTile + get() = container.deviceProfile.getDeviceProperties().isTablet && !isLargeTile val isRunningTask: Boolean get() = this === recentsView?.runningTaskView @@ -678,7 +678,7 @@ constructor( pivotY = modalPivot.y } else { val thumbnailTopMargin = container.deviceProfile.overviewTaskThumbnailTopMarginPx - if (container.deviceProfile.isTablet) { + if (container.deviceProfile.getDeviceProperties().isTablet) { pivotX = (if (layoutDirection == LAYOUT_DIRECTION_RTL) 0 else right - left).toFloat() pivotY = thumbnailTopMargin.toFloat() @@ -1128,7 +1128,7 @@ constructor( val boxTranslationY: Float val expectedWidth: Int val expectedHeight: Int - if (container.deviceProfile.isTablet) { + if (container.deviceProfile.getDeviceProperties().isTablet) { val boxWidth: Int val boxHeight: Int @@ -1622,7 +1622,9 @@ constructor( // Don't show menu when selecting second split screen app return true } - if (!container.deviceProfile.isTablet && !recentsView.isClearAllHidden) { + if ( + !container.deviceProfile.getDeviceProperties().isTablet && !recentsView.isClearAllHidden + ) { recentsView.snapToPage(recentsView.indexOfChild(this)) return false } @@ -1658,11 +1660,11 @@ constructor( } else { TaskMenuView.showForTask(menuContainer) { recentsView.setTaskBorderEnabled(true) } } - } else if (container.deviceProfile.isTablet) { + } else if (container.deviceProfile.getDeviceProperties().isTablet) { val alignedOptionIndex = if ( recentsView.isOnGridBottomRow(menuContainer.taskView) && - container.deviceProfile.isLandscape + container.deviceProfile.deviceProperties.isLandscape ) { if (enableGridOnlyOverview()) { // With no focused task, there is less available space below the tasks, so diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt index c4b27eda22..a23ebe9914 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -625,7 +625,8 @@ class TaskbarOverflowTest { return getOnUiThread { val iconLayoutBounds = taskbarViewController.transientTaskbarIconLayoutBoundsInParent - val availableWidth = taskbarUnitTestRule.activityContext.deviceProfile.widthPx + val availableWidth = + taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx iconLayoutBounds.left - (availableWidth - iconLayoutBounds.right) < 2 } } @@ -633,7 +634,7 @@ class TaskbarOverflowTest { private val taskbarEndMargin: Int get() { return getOnUiThread { - taskbarUnitTestRule.activityContext.deviceProfile.widthPx - + taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx - taskbarViewController.transientTaskbarIconLayoutBoundsInParent.right } } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt index c8f79463b1..579c10f712 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt @@ -14,6 +14,7 @@ import androidx.test.runner.AndroidJUnit4 import com.android.launcher3.DeviceProfile import com.android.launcher3.R import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION +import com.android.launcher3.deviceprofile.DeviceProperties import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS @@ -50,6 +51,8 @@ class NavButtonLayoutFactoryTest { whenever(mockNavLayout.findViewById(R.id.back)).thenReturn(mockBackButton) whenever(mockNavLayout.findViewById(R.id.home)).thenReturn(mockHomeButton) whenever(mockNavLayout.findViewById(R.id.recent_apps)).thenReturn(mockRecentsButton) + val devicePropertiesMock: DeviceProperties = mock() + whenever(mockDeviceProfile.deviceProperties).thenReturn(devicePropertiesMock) // Init top level layout whenever(mockParentButtonContainer.requireViewById(ID_END_NAV_BUTTONS)) @@ -73,7 +76,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is KidsNavLayoutter) } @@ -88,7 +91,7 @@ class NavButtonLayoutFactoryTest { isInSetup = true, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is SetupNavLayoutter) } @@ -103,7 +106,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is TaskbarNavLayoutter) } @@ -117,7 +120,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) } @@ -131,7 +134,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is PhonePortraitNavLayoutter) } @@ -147,7 +150,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is PhoneLandscapeNavLayoutter) } @@ -163,7 +166,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = ROTATION_270 + surfaceRotation = ROTATION_270, ) assert(layoutter is PhoneSeascapeNavLayoutter) } @@ -178,16 +181,13 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = true, - surfaceRotation = surfaceRotation + surfaceRotation = surfaceRotation, ) assert(layoutter is PhoneGestureLayoutter) } private fun setDeviceProfileLandscape() { - // Use reflection to modify landscape field - val landscapeField = mockDeviceProfile.javaClass.getDeclaredField("isLandscape") - landscapeField.isAccessible = true - landscapeField.set(mockDeviceProfile, true) + whenever(mockDeviceProfile.deviceProperties.isLandscape).thenReturn(true) } private fun getLayoutter( @@ -195,7 +195,7 @@ class NavButtonLayoutFactoryTest { isInSetup: Boolean, isThreeButtonNav: Boolean, phoneMode: Boolean, - @Rotation surfaceRotation: Int + @Rotation surfaceRotation: Int, ): NavButtonLayoutFactory.NavButtonLayoutter { return NavButtonLayoutFactory.getUiLayoutter( deviceProfile = mockDeviceProfile, diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt index 0dd1324c0f..6b41475dd6 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt @@ -50,7 +50,7 @@ class TaskbarModeRuleTest { fun testTaskbarMode_transient_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isTrue() - assertThat(dp.isGestureMode).isTrue() + assertThat(dp.deviceProperties.isGestureMode).isTrue() } @Test @@ -66,7 +66,7 @@ class TaskbarModeRuleTest { fun testTaskbarMode_pinned_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isFalse() - assertThat(dp.isGestureMode).isTrue() + assertThat(dp.deviceProperties.isGestureMode).isTrue() } @Test @@ -83,6 +83,6 @@ class TaskbarModeRuleTest { fun testTaskbarMode_threeButtons_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isFalse() - assertThat(dp.isGestureMode).isFalse() + assertThat(dp.deviceProperties.isGestureMode).isFalse() } } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 74572fc38a..4fda8a58c6 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1052,7 +1052,7 @@ public class CellLayout extends ViewGroup { /** * Returns the amount of space left over after subtracting padding and cells. This space will be * very small, a few pixels at most, and is a result of rounding down when calculating the cell - * width in {@link DeviceProfile#calculateCellWidth(int, int, int)}. + * width in {@link deviceprofile#calculateCellWidth(int, int, int)}. */ public int getUnusedHorizontalSpace() { return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 51da925b98..5d51007025 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -56,6 +56,7 @@ import androidx.core.content.res.ResourcesCompat; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.DevicePaddings.DevicePadding; import com.android.launcher3.InvariantDeviceProfile.DisplayOptionSpec; +import com.android.launcher3.deviceprofile.DeviceProperties; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.model.data.ItemInfo; @@ -102,31 +103,15 @@ public class DeviceProfile { private final IconSizeSteps mIconSizeSteps; // Device properties - public final boolean isTablet; - public final boolean isPhone; - public final boolean transposeLayoutWithOrientation; - public final boolean isMultiDisplay; - public final boolean isTwoPanels; + + private final DeviceProperties mDeviceProperties; + public boolean isPredictiveBackSwipe; public final boolean isQsbInline; // Device properties in current orientation - public final boolean isLandscape; - public final boolean isMultiWindowMode; - public final boolean isGestureMode; public final boolean isLeftRightSplit; - - public final int windowX; - public final int windowY; - public final int widthPx; - public final int heightPx; - public final int availableWidthPx; - public final int availableHeightPx; - public final int rotationHint; - - public final float aspectRatio; - private final boolean mIsScalableGrid; private final int mTypeIndex; @@ -327,30 +312,29 @@ public class DeviceProfile { /** Used only as an alternative to mocking when null values cannot be used. */ @VisibleForTesting public DeviceProfile() { + mDeviceProperties = new DeviceProperties( + 0,0, + 0, + 0,0, + 0,0, + 0.0f, + false, + false, + false, + false, + false, + false, + false, + false + ); inv = null; mDisplayOptionSpec = null; mInfo = null; mMetrics = null; mIconSizeSteps = null; - isTablet = false; - isPhone = false; - transposeLayoutWithOrientation = false; - isMultiDisplay = false; - isTwoPanels = false; isPredictiveBackSwipe = false; isQsbInline = false; - isLandscape = false; - isMultiWindowMode = false; - isGestureMode = false; isLeftRightSplit = false; - windowX = 0; - windowY = 0; - widthPx = 0; - heightPx = 0; - availableWidthPx = 0; - availableHeightPx = 0; - rotationHint = 0; - aspectRatio = 1; mIsScalableGrid = false; mTypeIndex = 0; mIsResponsiveGrid = false; @@ -402,14 +386,15 @@ public class DeviceProfile { boolean isTransientTaskbar, DisplayOptionSpec displayOptionSpec) { this.inv = inv; - this.isLandscape = windowBounds.isLandscape(); - this.isMultiWindowMode = isMultiWindowMode; - this.transposeLayoutWithOrientation = transposeLayoutWithOrientation; - this.isMultiDisplay = isMultiDisplay; - this.isGestureMode = isGestureMode; - windowX = windowBounds.bounds.left; - windowY = windowBounds.bounds.top; - this.rotationHint = windowBounds.rotationHint; + mDeviceProperties = DeviceProperties.Factory.createDeviceProperties( + info, + windowBounds, + transposeLayoutWithOrientation, + isMultiDisplay, + isMultiWindowMode, + isGestureMode + ); + mInsets.set(windowBounds.insets); this.mDisplayOptionSpec = displayOptionSpec; @@ -424,18 +409,15 @@ public class DeviceProfile { mIsScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode; // Determine device posture. mInfo = info; - isTablet = info.isTablet(windowBounds); - isPhone = !isTablet; - isTwoPanels = isTablet && isMultiDisplay; boolean taskbarOrBubbleBarOnPhones = enableTinyTaskbar() || (enableBubbleBar() && enableBubbleBarOnPhones()); - isTaskbarPresent = (isTablet || (taskbarOrBubbleBarOnPhones && isGestureMode)) + isTaskbarPresent = (mDeviceProperties.isTablet() || (taskbarOrBubbleBarOnPhones && isGestureMode)) && wmProxy.isTaskbarDrawnInProcess(); // Some more constants. context = getContext(context, info, inv.isFixedLandscape || isVerticalBarLayout() - || (isTablet && isLandscape) + || (mDeviceProperties.isTablet() && mDeviceProperties.isLandscape()) ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT, windowBounds); @@ -444,13 +426,6 @@ public class DeviceProfile { mIconSizeSteps = new IconSizeSteps(res); - // Determine sizes. - widthPx = windowBounds.bounds.width(); - heightPx = windowBounds.bounds.height(); - availableWidthPx = windowBounds.availableSize.x; - availableHeightPx = windowBounds.availableSize.y; - - aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx); mTypeIndex = displayOptionSpec.typeIndex; this.isTransientTaskbar = isTransientTaskbar; @@ -492,13 +467,13 @@ public class DeviceProfile { { // In large screens, in portrait mode, a bottom sheet can appear too elongated, so, we // apply additional padding. - final boolean applyExtraTopPadding = isTablet - && !isLandscape - && (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); - final int derivedTopPadding = heightPx / 6; + final boolean applyExtraTopPadding = mDeviceProperties.isTablet() + && !mDeviceProperties.isLandscape() + && (mDeviceProperties.getAspectRatio() > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); + final int derivedTopPadding = mDeviceProperties.getHeightPx() / 6; bottomSheetTopPadding = mInsets.top // statusbar height + (applyExtraTopPadding ? derivedTopPadding : 0) - + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + + (mDeviceProperties.isTablet() ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding } bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); @@ -582,9 +557,9 @@ public class DeviceProfile { dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size); // Some foldable portrait modes are too wide in terms of aspect ratio so we need to tweak // the dimensions for edit state. - final boolean shouldApplyWidePortraitDimens = isTablet - && !isLandscape - && aspectRatio < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE; + final boolean shouldApplyWidePortraitDimens = mDeviceProperties.isTablet() + && !mDeviceProperties.isLandscape() + && mDeviceProperties.getAspectRatio() < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE; dropTargetBarTopMarginPx = shouldApplyWidePortraitDimens ? 0 : res.getDimensionPixelSize(R.dimen.drop_target_top_margin); @@ -623,15 +598,15 @@ public class DeviceProfile { int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin); if (mIsResponsiveGrid) { - float responsiveAspectRatio = (float) widthPx / heightPx; + float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx(); HotseatSpecsProvider hotseatSpecsProvider = HotseatSpecsProvider.create(new ResourceHelper(context, displayOptionSpec.hotseatSpecsId)); mResponsiveHotseatSpec = isVerticalBarLayout() ? hotseatSpecsProvider.getCalculatedSpec( - responsiveAspectRatio, DimensionType.WIDTH, widthPx) + responsiveAspectRatio, DimensionType.WIDTH, mDeviceProperties.getWidthPx()) : hotseatSpecsProvider.getCalculatedSpec(responsiveAspectRatio, - DimensionType.HEIGHT, heightPx); + DimensionType.HEIGHT, mDeviceProperties.getHeightPx()); hotseatQsbSpace = mResponsiveHotseatSpec.getHotseatQsbSpace(); hotseatBarBottomSpace = isVerticalBarLayout() ? 0 : mResponsiveHotseatSpec.getEdgePadding(); @@ -642,7 +617,7 @@ public class DeviceProfile { ResponsiveCellSpecsProvider workspaceCellSpecs = ResponsiveCellSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.workspaceCellSpecsId)); mResponsiveWorkspaceCellSpec = workspaceCellSpecs.getCalculatedSpec( - responsiveAspectRatio, heightPx); + responsiveAspectRatio, mDeviceProperties.getHeightPx()); } else { hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics); hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics); @@ -684,7 +659,7 @@ public class DeviceProfile { updateHotseatSizes(pxFromDp(inv.iconSize[mTypeIndex], mMetrics)); } - if (areNavButtonsInline && !isPhone) { + if (areNavButtonsInline && !mDeviceProperties.isPhone()) { inlineNavButtonsEndSpacingPx = res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing); /* 3 nav buttons + Spacing between nav buttons */ @@ -704,12 +679,12 @@ public class DeviceProfile { // for the available height to be correct if (mIsResponsiveGrid) { int availableResponsiveWidth = - availableWidthPx - (isVerticalBarLayout() ? hotseatBarSizePx : 0); + mDeviceProperties.getAvailableWidthPx() - (isVerticalBarLayout() ? hotseatBarSizePx : 0); int numWorkspaceColumns = getPanelCount() * inv.numColumns; // don't use availableHeightPx because it subtracts mInsets.bottom - int availableResponsiveHeight = heightPx - mInsets.top + int availableResponsiveHeight = mDeviceProperties.getHeightPx() - mInsets.top - (isVerticalBarLayout() ? 0 : hotseatBarSizePx); - float responsiveAspectRatio = (float) widthPx / heightPx; + float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx(); ResponsiveSpecsProvider workspaceSpecs = ResponsiveSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.workspaceSpecsId), @@ -723,7 +698,7 @@ public class DeviceProfile { new ResourceHelper(context, displayOptionSpec.allAppsSpecsId), ResponsiveSpecType.AllApps); mResponsiveAllAppsWidthSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, - DimensionType.WIDTH, numShownAllAppsColumns, availableWidthPx, + DimensionType.WIDTH, numShownAllAppsColumns, mDeviceProperties.getAvailableWidthPx(), mResponsiveWorkspaceWidthSpec); if (inv.appListAlignedWithWorkspaceRow >= 0) { allAppsTopPadding += mResponsiveWorkspaceHeightSpec.getStartPaddingPx() @@ -733,7 +708,7 @@ public class DeviceProfile { } mResponsiveAllAppsHeightSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.HEIGHT, inv.numAllAppsRowsForCellHeightCalculation, - heightPx - allAppsTopPadding, mResponsiveWorkspaceHeightSpec); + mDeviceProperties.getHeightPx() - allAppsTopPadding, mResponsiveWorkspaceHeightSpec); ResponsiveSpecsProvider folderSpecs = ResponsiveSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.folderSpecsId), @@ -785,10 +760,10 @@ public class DeviceProfile { boolean allowLeftRightSplitInPortrait = leftRightSplitPortraitResId > 0 && res.getBoolean(leftRightSplitPortraitResId); - if (allowLeftRightSplitInPortrait && isTablet) { - isLeftRightSplit = !isLandscape; + if (allowLeftRightSplitInPortrait && mDeviceProperties.isTablet()) { + isLeftRightSplit = !mDeviceProperties.isLandscape(); } else { - isLeftRightSplit = isLandscape; + isLeftRightSplit = mDeviceProperties.isLandscape(); } // Calculate all of the remaining variables. @@ -797,7 +772,7 @@ public class DeviceProfile { calculateAndSetWorkspaceVerticalPadding(context, inv, extraSpace); int cellLayoutPadding = - isTwoPanels ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize( + mDeviceProperties.isTwoPanels() ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize( R.dimen.cell_layout_padding); cellLayoutPaddingPx = new Rect(cellLayoutPadding, cellLayoutPadding, cellLayoutPadding, cellLayoutPadding); @@ -820,7 +795,7 @@ public class DeviceProfile { if (shouldShowAllAppsOnSheet()) { allAppsPadding.top = allAppsTopPadding; - allAppsShiftRange = heightPx - allAppsTopPadding + mInsets.top; + allAppsShiftRange = mDeviceProperties.getHeightPx() - allAppsTopPadding + mInsets.top; } else { allAppsPadding.top = 0; allAppsShiftRange = @@ -841,6 +816,10 @@ public class DeviceProfile { mDotRendererAllApps = createDotRenderer(themeManager, allAppsIconSizePx, dotRendererCache); } + public DeviceProperties getDeviceProperties() { + return mDeviceProperties; + } + /** * Takes care of the logic that determines if we show a the QSB inline or not. */ @@ -852,7 +831,7 @@ public class DeviceProfile { // In tablets we inline in both orientations but only if we have enough space in the QSB boolean tabletInlineQsb = inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE]; - boolean canQsbInline = isTwoPanels ? twoPanelCanInline : tabletInlineQsb; + boolean canQsbInline = mDeviceProperties.isTwoPanels() ? twoPanelCanInline : tabletInlineQsb; canQsbInline = canQsbInline && hotseatQsbHeight > 0; return (mIsScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline) @@ -879,7 +858,7 @@ public class DeviceProfile { * reasonable over estimation is fine. */ public int getMaxAllAppsRowCount() { - return (int) (Math.ceil((availableHeightPx - allAppsPadding.top) + return (int) (Math.ceil((mDeviceProperties.getAvailableHeightPx() - allAppsPadding.top) / (float) allAppsCellHeightPx)); } @@ -969,7 +948,7 @@ public class DeviceProfile { updateHotseatWidthAndBorderSpace(inv.numColumns); int numWorkspaceColumns = getPanelCount() * inv.numColumns; - if (isTwoPanels) { + if (mDeviceProperties.isTwoPanels()) { updateHotseatWidthAndBorderSpace(inv.numDatabaseHotseatIcons); // If hotseat doesn't fit with current width, increase column span to fit by multiple // of 2. @@ -999,7 +978,7 @@ public class DeviceProfile { // The side space with inline buttons should be what is defined in InvariantDeviceProfile int sideSpacePx = inlineNavButtonsEndSpacingPx; - int maxHotseatWidthPx = availableWidthPx - sideSpacePx - hotseatBarEndOffset; + int maxHotseatWidthPx = mDeviceProperties.getAvailableWidthPx() - sideSpacePx - hotseatBarEndOffset; int maxHotseatIconsWidthPx = maxHotseatWidthPx - (isQsbInline ? hotseatQsbWidth : 0); hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx, (isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1); @@ -1074,8 +1053,13 @@ public class DeviceProfile { public Builder toBuilder(Context context) { WindowBounds bounds = new WindowBounds( - widthPx, heightPx, availableWidthPx, availableHeightPx, rotationHint); - bounds.bounds.offsetTo(windowX, windowY); + mDeviceProperties.getWidthPx(), + mDeviceProperties.getHeightPx(), + mDeviceProperties.getAvailableWidthPx(), + mDeviceProperties.getAvailableHeightPx(), + mDeviceProperties.getRotationHint() + ); + bounds.bounds.offsetTo(mDeviceProperties.getWindowX(), mDeviceProperties.getWindowY()); bounds.insets.set(mInsets); SparseArray dotRendererCache = new SparseArray<>(); @@ -1084,10 +1068,10 @@ public class DeviceProfile { return inv.newDPBuilder(context, mInfo) .setWindowBounds(bounds) - .setIsMultiDisplay(isMultiDisplay) - .setMultiWindowMode(isMultiWindowMode) + .setIsMultiDisplay(mDeviceProperties.isMultiDisplay()) + .setMultiWindowMode(mDeviceProperties.isMultiWindowMode()) .setDotRendererCache(dotRendererCache) - .setGestureMode(isGestureMode) + .setGestureMode(mDeviceProperties.isGestureMode()) .setDisplayOptionSpec(mDisplayOptionSpec); } @@ -1179,7 +1163,7 @@ public class DeviceProfile { float usedWidth = getCellLayoutWidthSpecification() + (desiredWorkspaceHorizontalMarginPx * 2); // We do not subtract padding here, as we also scale the workspace padding if needed. - scaleX = availableWidthPx / usedWidth; + scaleX = mDeviceProperties.getAvailableWidthPx() / usedWidth; shouldScale = true; } @@ -1344,7 +1328,7 @@ public class DeviceProfile { maxIconTextLineCount = 1; int cellPaddingY = (getCellSize().y - cellHeightPx) / 2; if (iconDrawablePaddingPx > cellPaddingY && !isVerticalLayout - && !isMultiWindowMode) { + && !mDeviceProperties.isMultiWindowMode()) { // Ensures that the label is closer to its corresponding icon. This is not an issue // with vertical bar layout or multi-window mode since the issue is handled // separately with their calls to {@link #adjustToHideWorkspaceLabels}. @@ -1522,11 +1506,11 @@ public class DeviceProfile { private void updateAllAppsContainerWidth() { int cellLayoutHorizontalPadding = (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2; - if (isTablet) { + if (mDeviceProperties.isTablet()) { int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns) + (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1)) + allAppsPadding.left + allAppsPadding.right; - allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2); + allAppsLeftRightMargin = Math.max(1, (mDeviceProperties.getAvailableWidthPx() - usedWidth) / 2); } else if (!mIsResponsiveGrid) { allAppsPadding.left = allAppsPadding.right = Math.max(0, desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding @@ -1536,7 +1520,7 @@ public class DeviceProfile { /** Whether All Apps should be presented on a bottom sheet. */ public boolean shouldShowAllAppsOnSheet() { - return isTablet || Flags.allAppsSheetForHandheld(); + return mDeviceProperties.isTablet() || Flags.allAppsSheetForHandheld(); } private void setupAllAppsStyle(Context context) { @@ -1563,14 +1547,14 @@ public class DeviceProfile { + ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) + folderFooterHeightPx + folderContentPaddingTop; - int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y; + int contentMaxHeight = mDeviceProperties.getAvailableHeightPx() - totalWorkspacePadding.y; float scaleY = contentMaxHeight / contentUsedHeight; // Check if the folder fit within the available width. float contentUsedWidth = folderCellWidthPx * numFolderColumns + ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) + folderContentPaddingLeftRight * 2; - int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x; + int contentMaxWidth = mDeviceProperties.getAvailableWidthPx() - totalWorkspacePadding.x; float scaleX = contentMaxWidth / contentUsedWidth; float scale = Math.min(scaleX, scaleY); @@ -1722,7 +1706,7 @@ public class DeviceProfile { * Gets the number of panels within the workspace. */ public int getPanelCount() { - return isTwoPanels ? 2 : 1; + return mDeviceProperties.isTwoPanels() ? 2 : 1; } /** @@ -1732,7 +1716,7 @@ public class DeviceProfile { private int getVerticalHotseatLastItemBottomOffset(Context context) { Rect hotseatBarPadding = getHotseatLayoutPadding(context); int cellHeight = calculateCellHeight( - heightPx - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace, + mDeviceProperties.getHeightPx() - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace, numShownHotseatIcons); int extraIconEndSpacing = (cellHeight - iconSizePx) / 2; return extraIconEndSpacing + hotseatBarPadding.bottom; @@ -1751,7 +1735,7 @@ public class DeviceProfile { */ public float getCellLayoutSpringLoadShrunkBottom(Context context) { int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx; - return heightPx - (isVerticalBarLayout() + return mDeviceProperties.getHeightPx() - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset(context) : topOfHotseat); } @@ -1765,7 +1749,7 @@ public class DeviceProfile { scale = Math.min(scale, 1f); // Reduce scale if next pages would not be visible after scaling the workspace. - int workspaceWidth = availableWidthPx; + int workspaceWidth = mDeviceProperties.getAvailableWidthPx(); float scaledWorkspaceWidth = workspaceWidth * scale; float maxAvailableWidth = workspaceWidth - (2 * workspaceSpringLoadedMinNextPageVisiblePx); if (scaledWorkspaceWidth > maxAvailableWidth) { @@ -1781,7 +1765,7 @@ public class DeviceProfile { * layouts have two Cell Layouts per workspace. */ public int getCellLayoutWidth() { - return (availableWidthPx - getTotalWorkspacePadding().x) / getPanelCount(); + return (mDeviceProperties.getAvailableWidthPx() - getTotalWorkspacePadding().x) / getPanelCount(); } /** @@ -1790,7 +1774,7 @@ public class DeviceProfile { *

This is the height of a Workspace, less its vertical padding. */ public int getCellLayoutHeight() { - return availableHeightPx - getTotalWorkspacePadding().y; + return mDeviceProperties.getAvailableHeightPx() - getTotalWorkspacePadding().y; } public Point getTotalWorkspacePadding() { @@ -1955,7 +1939,7 @@ public class DeviceProfile { int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx); int qsbWidth = getAdditionalQsbSpace() + iconExtraSpacePx / 2; - int availableWidthPxForHotseat = availableWidthPx - Math.abs(workspacePadding.width()) + int availableWidthPxForHotseat = mDeviceProperties.getAvailableWidthPx() - Math.abs(workspacePadding.width()) - Math.abs(cellLayoutPaddingPx.width()); int remainingSpaceOnSide = (availableWidthPxForHotseat - hotseatPlusQSBWidth) / 2; @@ -1984,9 +1968,9 @@ public class DeviceProfile { // Hotseat aligns to the left with nav buttons if (hotseatBarEndOffset > 0) { startSpacing = inlineNavButtonsEndSpacingPx; - endSpacing = availableWidthPx - hotseatWidth - startSpacing + hotseatBorderSpace; + endSpacing = mDeviceProperties.getAvailableWidthPx() - hotseatWidth - startSpacing + hotseatBorderSpace; } else { - startSpacing = (availableWidthPx - hotseatWidth) / 2; + startSpacing = (mDeviceProperties.getAvailableWidthPx() - hotseatWidth) / 2; endSpacing = startSpacing; } startSpacing += getAdditionalQsbSpace(); @@ -2004,7 +1988,7 @@ public class DeviceProfile { } else if (mIsScalableGrid) { int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx); - int sideSpacing = (availableWidthPx - (hotseatQsbWidth + iconExtraSpacePx)) / 2; + int sideSpacing = (mDeviceProperties.getAvailableWidthPx() - (hotseatQsbWidth + iconExtraSpacePx)) / 2; hotseatBarPadding.set(sideSpacing, 0, sideSpacing, @@ -2014,8 +1998,8 @@ public class DeviceProfile { // icons in the hotseat are a different size, and so don't line up perfectly. To account // for this, we pad the left and right of the hotseat with half of the difference of a // workspace cell vs a hotseat cell. - float workspaceCellWidth = (float) widthPx / inv.numColumns; - float hotseatCellWidth = (float) widthPx / numShownHotseatIcons; + float workspaceCellWidth = (float) mDeviceProperties.getWidthPx() / inv.numColumns; + float hotseatCellWidth = (float) mDeviceProperties.getWidthPx() / numShownHotseatIcons; int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2); hotseatBarPadding.set( hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left @@ -2040,7 +2024,7 @@ public class DeviceProfile { } int cellWidth = DeviceProfile.calculateCellWidth( - availableWidthPx - allAppsSpacing, + mDeviceProperties.getAvailableWidthPx() - allAppsSpacing, 0 /* borderSpace */, numShownAllAppsColumns); int iconAlignmentMargin = (cellWidth - getIconVisibleSizePx(allAppsIconSizePx)) / 2; @@ -2122,7 +2106,7 @@ public class DeviceProfile { /** Returns whether bubble bar should be aligned with the hotseat. */ public boolean shouldAlignBubbleBarWithHotseat() { - return isQsbInline || isGestureMode; + return isQsbInline || mDeviceProperties.isGestureMode(); } /** @@ -2142,7 +2126,7 @@ public class DeviceProfile { /** Gets the space that the overview actions will take, including bottom margin. */ public int getOverviewActionsClaimedSpace() { - int overviewActionsSpace = isTablet && enableGridOnlyOverview() + int overviewActionsSpace = mDeviceProperties.isTablet() && enableGridOnlyOverview() ? 0 : (overviewActionsTopMarginPx + overviewActionsHeight); return overviewActionsSpace + getOverviewActionsClaimedSpaceBelow(); @@ -2169,15 +2153,15 @@ public class DeviceProfile { // Folders should only appear right of the drop target bar and left of the hotseat return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx, mInsets.top, - mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx, - mInsets.top + availableHeightPx); + mInsets.left + mDeviceProperties.getAvailableWidthPx() - hotseatBarSizePx - edgeMarginPx, + mInsets.top + mDeviceProperties.getAvailableHeightPx()); } else { // Folders should only appear below the drop target bar and above the hotseat int hotseatTop = isTaskbarPresent ? taskbarHeight : hotseatBarSizePx; return new Rect(mInsets.left + edgeMarginPx, mInsets.top + dropTargetBarSizePx + edgeMarginPx, - mInsets.left + availableWidthPx - edgeMarginPx, - mInsets.top + availableHeightPx - hotseatTop + mInsets.left + mDeviceProperties.getAvailableWidthPx() - edgeMarginPx, + mInsets.top + mDeviceProperties.getAvailableHeightPx() - hotseatTop - workspacePageIndicatorHeight - edgeMarginPx); } } @@ -2196,11 +2180,11 @@ public class DeviceProfile { * the hotseat is on the bottom row. */ public boolean isVerticalBarLayout() { - return isLandscape && transposeLayoutWithOrientation; + return mDeviceProperties.isLandscape() && mDeviceProperties.getTransposeLayoutWithOrientation(); } public boolean isSeascape() { - return rotationHint == Surface.ROTATION_270 + return mDeviceProperties.getRotationHint() == Surface.ROTATION_270 && (isVerticalBarLayout() || inv.isFixedLandscape); } @@ -2237,29 +2221,29 @@ public class DeviceProfile { writer.println(prefix + "DeviceProfile:"); writer.println(prefix + "\t1 dp = " + mMetrics.density + " px"); - writer.println(prefix + "\tisTablet:" + isTablet); - writer.println(prefix + "\tisPhone:" + isPhone); + writer.println(prefix + "\tisTablet:" + mDeviceProperties.isTablet()); + writer.println(prefix + "\tisPhone:" + mDeviceProperties.isPhone()); writer.println(prefix + "\ttransposeLayoutWithOrientation:" - + transposeLayoutWithOrientation); - writer.println(prefix + "\tisGestureMode:" + isGestureMode); + + mDeviceProperties.getTransposeLayoutWithOrientation()); + writer.println(prefix + "\tisGestureMode:" + mDeviceProperties.isGestureMode()); - writer.println(prefix + "\tisLandscape:" + isLandscape); - writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode); - writer.println(prefix + "\tisTwoPanels:" + isTwoPanels); + writer.println(prefix + "\tisLandscape:" + mDeviceProperties.isLandscape()); + writer.println(prefix + "\tisMultiWindowMode:" + mDeviceProperties.isMultiWindowMode()); + writer.println(prefix + "\tisTwoPanels:" + mDeviceProperties.isTwoPanels()); writer.println(prefix + "\tisLeftRightSplit:" + isLeftRightSplit); - writer.println(prefix + pxToDpStr("windowX", windowX)); - writer.println(prefix + pxToDpStr("windowY", windowY)); - writer.println(prefix + pxToDpStr("widthPx", widthPx)); - writer.println(prefix + pxToDpStr("heightPx", heightPx)); - writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx)); - writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx)); + writer.println(prefix + pxToDpStr("windowX", mDeviceProperties.getWindowX())); + writer.println(prefix + pxToDpStr("windowY", mDeviceProperties.getWindowY())); + writer.println(prefix + pxToDpStr("widthPx", mDeviceProperties.getWidthPx())); + writer.println(prefix + pxToDpStr("heightPx", mDeviceProperties.getHeightPx())); + writer.println(prefix + pxToDpStr("availableWidthPx", mDeviceProperties.getAvailableWidthPx())); + writer.println(prefix + pxToDpStr("availableHeightPx", mDeviceProperties.getAvailableHeightPx())); writer.println(prefix + pxToDpStr("mInsets.left", mInsets.left)); writer.println(prefix + pxToDpStr("mInsets.top", mInsets.top)); writer.println(prefix + pxToDpStr("mInsets.right", mInsets.right)); writer.println(prefix + pxToDpStr("mInsets.bottom", mInsets.bottom)); - writer.println(prefix + "\taspectRatio:" + aspectRatio); + writer.println(prefix + "\taspectRatio:" + mDeviceProperties.getAspectRatio()); writer.println(prefix + "\tisResponsiveGrid:" + mIsResponsiveGrid); writer.println(prefix + "\tisScalableGrid:" + mIsScalableGrid); @@ -2442,12 +2426,12 @@ public class DeviceProfile { /** Returns a reduced representation of this DeviceProfile. */ public String toSmallString() { - return "isTablet:" + isTablet + ", " - + "isMultiDisplay:" + isMultiDisplay + ", " - + "widthPx:" + widthPx + ", " - + "heightPx:" + heightPx + ", " + return "isTablet:" + mDeviceProperties.isTablet() + ", " + + "mDeviceProperties.isMultiDisplay():" + mDeviceProperties.isMultiDisplay() + ", " + + "widthPx:" + mDeviceProperties.getWidthPx() + ", " + + "heightPx:" + mDeviceProperties.getHeightPx() + ", " + "insets:" + mInsets + ", " - + "rotationHint:" + rotationHint; + + "rotationHint:" + mDeviceProperties.getRotationHint(); } private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) { diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java index 1d5f185635..57a924faae 100644 --- a/src/com/android/launcher3/DropTargetBar.java +++ b/src/com/android/launcher3/DropTargetBar.java @@ -85,8 +85,9 @@ public class DropTargetBar extends FrameLayout @Override public void setInsets(Rect insets) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); - DeviceProfile grid = mLauncher.getDeviceProfile(); - mIsVertical = grid.isVerticalBarLayout(); + DeviceProfile deviceProfile = mLauncher.getDeviceProfile(); + mIsVertical = deviceProfile.isVerticalBarLayout(); + int widthPx = deviceProfile.getDeviceProperties().getWidthPx(); lp.leftMargin = insets.left; lp.topMargin = insets.top; @@ -95,25 +96,25 @@ public class DropTargetBar extends FrameLayout int tooltipLocation = TOOLTIP_DEFAULT; int horizontalMargin; - if (grid.isTablet) { + if (deviceProfile.getDeviceProperties().isTablet()) { // XXX: If the icon size changes across orientations, we will have to take // that into account here too. - horizontalMargin = ((grid.widthPx - 2 * grid.edgeMarginPx - - (grid.inv.numColumns * grid.cellWidthPx)) - / (2 * (grid.inv.numColumns + 1))) - + grid.edgeMarginPx; + horizontalMargin = ((widthPx - 2 * deviceProfile.edgeMarginPx + - (deviceProfile.inv.numColumns * deviceProfile.cellWidthPx)) + / (2 * (deviceProfile.inv.numColumns + 1))) + + deviceProfile.edgeMarginPx; } else { horizontalMargin = getContext().getResources() .getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal); } - lp.topMargin += grid.dropTargetBarTopMarginPx; - lp.bottomMargin += grid.dropTargetBarBottomMarginPx; - lp.width = grid.availableWidthPx - 2 * horizontalMargin; + lp.topMargin += deviceProfile.dropTargetBarTopMarginPx; + lp.bottomMargin += deviceProfile.dropTargetBarBottomMarginPx; + lp.width = deviceProfile.getDeviceProperties().getAvailableWidthPx() - 2 * horizontalMargin; if (mIsVertical) { - lp.leftMargin = (grid.widthPx - lp.width) / 2; - lp.rightMargin = (grid.widthPx - lp.width) / 2; + lp.leftMargin = (widthPx - lp.width) / 2; + lp.rightMargin = (widthPx - lp.width) / 2; } - lp.height = grid.dropTargetBarSizePx; + lp.height = deviceProfile.dropTargetBarSizePx; lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; DeviceProfile dp = mLauncher.getDeviceProfile(); @@ -121,7 +122,7 @@ public class DropTargetBar extends FrameLayout int verticalPadding = dp.dropTargetVerticalPaddingPx; setLayoutParams(lp); for (ButtonDropTarget button : mDropTargets) { - button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx); + button.setTextSize(TypedValue.COMPLEX_UNIT_PX, deviceProfile.dropTargetTextSizePx); button.setToolTipLocation(tooltipLocation); button.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); @@ -175,15 +176,15 @@ public class DropTargetBar extends FrameLayout // Reset second button padding in case it was previously changed to multi-line text. secondButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); - + int availableWidth; - if (dp.isTwoPanels) { + if (dp.getDeviceProperties().isTwoPanels()) { // Each button for two panel fits to half the width of the screen excluding the // center gap between the buttons. - availableWidth = (dp.availableWidthPx - dp.dropTargetGapPx) / 2; + availableWidth = (dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx) / 2; } else { // Both buttons plus the button gap do not display past the edge of the screen. - availableWidth = dp.availableWidthPx - dp.dropTargetGapPx; + availableWidth = dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx; } int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); @@ -199,7 +200,7 @@ public class DropTargetBar extends FrameLayout } } - if (!dp.isTwoPanels) { + if (!dp.getDeviceProperties().isTwoPanels()) { availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx; widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); } @@ -239,11 +240,11 @@ public class DropTargetBar extends FrameLayout float scale = dp.getWorkspaceSpringLoadScale(mLauncher); Workspace ws = mLauncher.getWorkspace(); int barCenter; - if (dp.isTwoPanels) { + if (dp.getDeviceProperties().isTwoPanels()) { barCenter = (right - left) / 2; } else { int workspaceCenter = (ws.getLeft() + ws.getRight()) / 2; - int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.widthPx + int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.getDeviceProperties().getWidthPx() - dp.getInsets().right - dp.workspacePadding.right)) / 2; int cellLayoutCenterOffset = (int) ((cellLayoutCenter - workspaceCenter) * scale); barCenter = workspaceCenter + cellLayoutCenterOffset - left; @@ -258,7 +259,7 @@ public class DropTargetBar extends FrameLayout ButtonDropTarget leftButton = mTempTargets[0]; ButtonDropTarget rightButton = mTempTargets[1]; - if (dp.isTwoPanels) { + if (dp.getDeviceProperties().isTwoPanels()) { leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0, barCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); rightButton.layout(barCenter + (buttonGap / 2), 0, diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index f8bf01ddbb..76f4eb31e6 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -207,7 +207,7 @@ public class InvariantDeviceProfile { public @StyleRes int allAppsStyle; /** - * Do not query directly. see {@link DeviceProfile#isScalableGrid}. + * Do not query directly. see {@link deviceprofile#isScalableGrid}. */ protected boolean isScalable; @XmlRes @@ -488,14 +488,14 @@ public class InvariantDeviceProfile { int numMinShownHotseatIconsForTablet = supportedProfiles .stream() - .filter(deviceProfile -> deviceProfile.isTablet) + .filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet()) .mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons) .min() .orElse(0); supportedProfiles .stream() - .filter(deviceProfile -> deviceProfile.isTablet) + .filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet()) .forEach(deviceProfile -> { deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet; deviceProfile.recalculateHotseatWidthAndBorderSpace(); @@ -924,12 +924,12 @@ public class InvariantDeviceProfile { float minDiff = Float.MAX_VALUE; for (DeviceProfile profile : supportedProfiles) { - float diff = Math.abs(profile.widthPx - screenWidth) - + Math.abs(profile.heightPx - screenHeight); + float diff = Math.abs(profile.getDeviceProperties().getWidthPx() - screenWidth) + + Math.abs(profile.getDeviceProperties().getHeightPx() - screenHeight); if (diff < minDiff) { minDiff = diff; bestMatch = profile; - } else if (diff == minDiff && profile.rotationHint == rotation) { + } else if (diff == minDiff && profile.getDeviceProperties().getRotationHint() == rotation) { bestMatch = profile; } } @@ -995,7 +995,7 @@ public class InvariantDeviceProfile { displayInfo.getDeviceType()), isLandscape); } - /** Class to expose properties required for external displays to {@link DeviceProfile} */ + /** Class to expose properties required for external displays to {@link deviceprofile} */ public static final class DisplayOptionSpec { public final int typeIndex; public final int numShownHotseatIcons; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 3b982debe9..178630cd0e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -677,9 +677,9 @@ public class Launcher extends StatefulActivity // When the flag oneGridSpecs is on we want to disable ALLOW_ROTATION which is replaced // by FIXED_LANDSCAPE_MODE, ALLOW_ROTATION will only be used on Tablets and foldables // afterwards. - if (getDeviceProfile().isPhone) { + if (getDeviceProfile().getDeviceProperties().isPhone()) { LauncherPrefs.get(this).put(LauncherPrefs.ALLOW_ROTATION, false); - } else if (getDeviceProfile().isTablet) { + } else if (getDeviceProfile().getDeviceProperties().isTablet()) { // Tablet do not use fixed landscape mode, make sure it can't be activated by mistake LauncherPrefs.get(this).put(FIXED_LANDSCAPE_MODE, false); } @@ -708,7 +708,7 @@ public class Launcher extends StatefulActivity this, getMultiWindowDisplaySize()); } - if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.isTwoPanels) { + if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.getDeviceProperties().isTwoPanels()) { mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns); } else { mCellPosMapper = new CellPosMapper(mDeviceProfile.isVerticalBarLayout(), @@ -1883,13 +1883,15 @@ public class Launcher extends StatefulActivity public void updateOpenFolderPosition(int[] inOutPosition, Rect bounds, int width, int height) { int left = inOutPosition[0]; int top = inOutPosition[1]; - DeviceProfile grid = getDeviceProfile(); + DeviceProfile deviceProfile = getDeviceProfile(); int distFromEdgeOfScreen = getWorkspace().getPaddingLeft(); - if (grid.isPhone && (grid.availableWidthPx - width) < 4 * distFromEdgeOfScreen) { + final int availableWidth = deviceProfile.getDeviceProperties().getAvailableWidthPx(); + if (deviceProfile.getDeviceProperties().isPhone() + && (availableWidth - width) < 4 * distFromEdgeOfScreen) { // Center the folder if it is very close to being centered anyway, by virtue of // filling the majority of the viewport. ie. remove it from the uncanny valley // of centeredness. - left = (grid.availableWidthPx - width) / 2; + left = (availableWidth - width) / 2; } else if (width >= bounds.width()) { // If the folder doesn't fit within the bounds, center it about the desired bounds left = bounds.left + (bounds.width() - width) / 2; @@ -1900,7 +1902,7 @@ public class Launcher extends StatefulActivity } else { // Folder height is less than page height, so bound it to the absolute open folder // bounds if necessary - Rect folderBounds = grid.getAbsoluteOpenFolderBounds(); + Rect folderBounds = deviceProfile.getAbsoluteOpenFolderBounds(); left = Math.max(folderBounds.left, Math.min(left, folderBounds.right - width)); top = Math.max(folderBounds.top, Math.min(top, folderBounds.bottom - height)); } @@ -2540,7 +2542,7 @@ public class Launcher extends StatefulActivity if (BuildCompat.isAtLeastV() && Flags.enableDesktopWindowingMode() && !Flags.enableDesktopWindowingWallpaperActivity() - && mDeviceProfile.isTablet) { + && mDeviceProfile.getDeviceProperties().isTablet()) { // TODO(b/333533253): Clean up after desktop wallpaper activity flag is rolled out return; } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 9fb3d15a94..fd91b59aa7 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -242,7 +242,7 @@ public abstract class LauncherState implements BaseState { DeviceProfile dp = launcher.getDeviceProfile(); if (dp.isQsbInline) { int marginStart = getFloatingSearchBarRestingMarginStart(launcher); - return dp.widthPx - marginStart - dp.hotseatQsbWidth; + return dp.getDeviceProperties().getWidthPx() - marginStart - dp.hotseatQsbWidth; } boolean isRtl = Utilities.isRtl(launcher.getResources()); @@ -258,7 +258,7 @@ public abstract class LauncherState implements BaseState { public int getVisibleElements(Launcher launcher) { int elements = HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR; // Floating search bar is visible in normal state except in landscape on phones. - if (!(launcher.getDeviceProfile().isPhone && launcher.getDeviceProfile().isLandscape)) { + if (!(launcher.getDeviceProfile().getDeviceProperties().isPhone() && launcher.getDeviceProfile().getDeviceProperties().isLandscape())) { elements |= FLOATING_SEARCH_BAR; } return elements; @@ -346,7 +346,7 @@ public abstract class LauncherState implements BaseState { public final float getDepth(DEVICE_PROFILE_CONTEXT context) { return getDepth(context, - ActivityContext.lookupContext(context).getDeviceProfile().isMultiWindowMode); + ActivityContext.lookupContext(context).getDeviceProfile().getDeviceProperties().isMultiWindowMode()); } /** @@ -390,7 +390,7 @@ public abstract class LauncherState implements BaseState { boolean shouldFadeAdjacentScreens = (this == NORMAL || this == HINT_STATE) && dp.shouldFadeAdjacentWorkspaceScreens(); // Avoid showing adjacent screens behind handheld All Apps sheet. - if (Flags.allAppsSheetForHandheld() && dp.isPhone && this == ALL_APPS) { + if (Flags.allAppsSheetForHandheld() && dp.getDeviceProperties().isPhone() && this == ALL_APPS) { shouldFadeAdjacentScreens = true; } if (!shouldFadeAdjacentScreens) { @@ -410,7 +410,7 @@ public abstract class LauncherState implements BaseState { */ public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) { if (!(this == SPRING_LOADED || this == EDIT_MODE) - || !launcher.getDeviceProfile().isTwoPanels) { + || !launcher.getDeviceProfile().getDeviceProperties().isTwoPanels()) { return DEFAULT_PAGE_TRANSLATION_PROVIDER; } final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f; diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index 407e126215..ba5c0dbf59 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -158,7 +158,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true) launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ false, - deviceProfile.isTwoPanels, + deviceProfile.deviceProperties.isTwoPanels, ) launcher.finishBindingItems(pagesBoundFirst) } @@ -270,12 +270,13 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { // in single panel. if (actualIds.contains(firstId)) { result.add(firstId) - if (launcher.deviceProfile.isTwoPanels && actualIds.contains(pairId)) { + if (launcher.deviceProfile.deviceProperties.isTwoPanels && actualIds.contains(pairId)) { result.add(pairId) } } else if ( - LauncherAppState.getIDP(launcher).supportedProfiles.any(DeviceProfile::isTwoPanels) && - actualIds.contains(pairId) + LauncherAppState.getIDP(launcher).supportedProfiles.any { + it.deviceProperties.isTwoPanels + } && actualIds.contains(pairId) ) { // Add the right panel if left panel is hidden when switching display, due to empty // pages being hidden in single panel. @@ -287,7 +288,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { private fun bindScreens(orderedScreenIds: LIntArray) { launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ true, - launcher.deviceProfile.isTwoPanels, + launcher.deviceProfile.deviceProperties.isTwoPanels, ) val firstScreenPosition = 0 if (orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition) { @@ -345,7 +346,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { private fun bindAddScreens(orderedScreenIdsArg: LIntArray) { var orderedScreenIds = orderedScreenIdsArg - if (launcher.deviceProfile.isTwoPanels) { + if (launcher.deviceProfile.deviceProperties.isTwoPanels) { if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds) } else { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 9e07bb74b7..b410c54929 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -534,7 +534,7 @@ public class Workspace extends PagedView } private boolean isTwoPanelEnabled() { - return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels; + return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.getDeviceProperties().isTwoPanels(); } public void deferRemoveExtraEmptyScreen() { @@ -692,7 +692,7 @@ public class Workspace extends PagedView // created CellLayout. DeviceProfile dp = mLauncher.getDeviceProfile(); CellLayout newScreen; - if (FOLDABLE_SINGLE_PAGE.get() && dp.isTwoPanels) { + if (FOLDABLE_SINGLE_PAGE.get() && dp.getDeviceProperties().isTwoPanels()) { newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate( R.layout.workspace_screen_foldable, this, false /* attachToRoot */); } else { @@ -3443,13 +3443,13 @@ public class Workspace extends PagedView @Override public int getExpectedHeight() { return getMeasuredHeight() <= 0 || !mIsLayoutValid - ? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight(); + ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : getMeasuredHeight(); } @Override public int getExpectedWidth() { return getMeasuredWidth() <= 0 || !mIsLayoutValid - ? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth(); + ? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() : getMeasuredWidth(); } @Override @@ -3515,12 +3515,12 @@ public class Workspace extends PagedView @Override protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) { DeviceProfile deviceProfile = mLauncher.getDeviceProfile(); - if (!deviceProfile.isTablet) { + if (!deviceProfile.getDeviceProperties().isTablet()) { return super.isSignificantMove(absoluteDelta, pageOrientedSize); } return absoluteDelta - > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; + > deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 7224b1cfdf..2e50bb2618 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -235,7 +235,7 @@ public class AllAppsTransitionController boolean fromBackground = mLauncher.getStateManager().getCurrentStableState() == BACKGROUND_APP; // Allow apps panel to shift the full screen if coming from another app. - float shiftRange = fromBackground ? mLauncher.getDeviceProfile().heightPx : mShiftRange; + float shiftRange = fromBackground ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : mShiftRange; getAppsViewProgressTranslationY().setValue(mProgress * shiftRange); mLauncher.onAllAppsTransition(1 - progress); diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java index 1e0f2892d6..6daba68102 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -99,7 +99,7 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView 0; - mDrawBottomScrim = !dp.isVerticalBarLayout() && !dp.isGestureMode && !dp.isTaskbarPresent; + mDrawBottomScrim = !dp.isVerticalBarLayout() && !dp.getDeviceProperties().isGestureMode() && !dp.isTaskbarPresent; } @Override diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 0cd8573466..17807bcab5 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -689,8 +689,8 @@ class WorkspaceItemProcessor( deviceProfile.getCellSize(cellSize) FileLog.d( TAG, - "DeviceProfile available width: ${deviceProfile.availableWidthPx}," + - " available height: ${deviceProfile.availableHeightPx}," + + "DeviceProfile available width: ${deviceProfile.deviceProperties.availableWidthPx}," + + " available height: ${deviceProfile.deviceProperties.availableHeightPx}," + " cellLayoutBorderSpacePx Horizontal: ${deviceProfile.cellLayoutBorderSpacePx.x}," + " cellLayoutBorderSpacePx Vertical: ${deviceProfile.cellLayoutBorderSpacePx.y}," + " cellSize: $cellSize", diff --git a/src/com/android/launcher3/model/data/AppPairInfo.kt b/src/com/android/launcher3/model/data/AppPairInfo.kt index 49273fedd3..486b9958ea 100644 --- a/src/com/android/launcher3/model/data/AppPairInfo.kt +++ b/src/com/android/launcher3/model/data/AppPairInfo.kt @@ -70,7 +70,10 @@ class AppPairInfo() : CollectionInfo() { /** Checks if member apps are launchable at the current screen size. */ fun isLaunchable(context: Context): Pair { val isTablet = - (ActivityContext.lookupContext(context) as ActivityContext).getDeviceProfile().isTablet + (ActivityContext.lookupContext(context) as ActivityContext) + .getDeviceProfile() + .deviceProperties + .isTablet return Pair( isTablet || !getFirstApp().isNonResizeable, isTablet || !getSecondApp().isNonResizeable, diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 9a226df8db..8a277c36dc 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -413,7 +413,7 @@ public class PopupContainerWithArrow for (int i = deepShortcutCount; i > 0; i--) { currentHeight += mShortcutHeight; // when there is limited vertical screen space, limit total popup rows to fit - if (currentHeight >= mActivityContext.getDeviceProfile().availableHeightPx) break; + if (currentHeight >= mActivityContext.getDeviceProfile().getDeviceProperties().getAvailableHeightPx()) break; DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, mDeepShortcutContainer); v.getLayoutParams().width = mContainerWidth; diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 82b6747da7..0b68315a8f 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -432,7 +432,8 @@ public abstract class SystemShortcut extends ItemInfo // basically is a check for small screens including Foldables when folded. // However, the name is a bit misleading, so considering renaming. WorkspaceItemInfo wsItemInfo = (WorkspaceItemInfo) itemInfo; - if (wsItemInfo.isNonResizeable() && activity.getDeviceProfile().isPhone) { + if (wsItemInfo.isNonResizeable() + && activity.getDeviceProfile().getDeviceProperties().isPhone()) { return null; } } diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java index 9376518ddb..c37f259422 100644 --- a/src/com/android/launcher3/states/RotationHelper.java +++ b/src/com/android/launcher3/states/RotationHelper.java @@ -138,7 +138,7 @@ public class RotationHelper implements LauncherPrefChangeListener, @Override public void onDeviceProfileChanged(DeviceProfile dp) { - onIgnoreAutoRotateChanged(dp.isTablet); + onIgnoreAutoRotateChanged(dp.getDeviceProperties().isTablet()); } private void onIgnoreAutoRotateChanged(boolean ignoreAutoRotateSettings) { diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 6aa2200969..cb5725e89b 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -203,7 +203,7 @@ public class TestInformationHandler implements ResourceBasedOverride { return response; case TestProtocol.REQUEST_IS_TABLET: - response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet); + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.getDeviceProperties().isTablet()); return response; case TestProtocol.REQUEST_IS_PREDICTIVE_BACK_SWIPE_ENABLED: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, @@ -230,7 +230,7 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_IS_TWO_PANELS: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, - FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.isTwoPanels); + FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.getDeviceProperties().isTwoPanels()); return response; case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS: diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index 7df47273f6..a1fc607b3d 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -312,13 +312,13 @@ public abstract class AbstractStateChangeTouchController // snap to top or bottom using the release velocity } else { float successTransitionProgress = SUCCESS_TRANSITION_PROGRESS; - if (mLauncher.getDeviceProfile().isTablet + if (mLauncher.getDeviceProfile().getDeviceProperties().isTablet() && (mToState == ALL_APPS || mFromState == ALL_APPS)) { successTransitionProgress = TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS; - } else if (!mLauncher.getDeviceProfile().isTablet + } else if (!mLauncher.getDeviceProfile().getDeviceProperties().isTablet() && mToState == ALL_APPS && mFromState == NORMAL) { successTransitionProgress = AllAppsSwipeController.ALL_APPS_STATE_TRANSITION_MANUAL; - } else if (!mLauncher.getDeviceProfile().isTablet + } else if (!mLauncher.getDeviceProfile().getDeviceProperties().isTablet() && mToState == NORMAL && mFromState == ALL_APPS) { successTransitionProgress = 1 - AllAppsSwipeController.ALL_APPS_STATE_TRANSITION_MANUAL; diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java index 3312844954..5fc9560822 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -209,11 +209,10 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { if (!config.isUserControlled()) { config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED); } - config.setInterpolator(ANIM_WORKSPACE_SCALE, - Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); - config.setInterpolator(ANIM_HOTSEAT_SCALE, Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); - config.setInterpolator(ANIM_DEPTH, Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); - if (!Flags.allAppsBlur() && launcher.getDeviceProfile().isPhone) { + config.setInterpolator(ANIM_WORKSPACE_SCALE, ALL_APPS_SHEET_DEPTH); + config.setInterpolator(ANIM_HOTSEAT_SCALE, ALL_APPS_SHEET_DEPTH); + config.setInterpolator(ANIM_DEPTH, ALL_APPS_SHEET_DEPTH); + if (!Flags.allAppsBlur() && launcher.getDeviceProfile().getDeviceProperties().isPhone()) { // On phones without blur, reveal the workspace and hotseat when leaving All Apps. config.setInterpolator(ANIM_WORKSPACE_FADE, INSTANT); config.setInterpolator(ANIM_HOTSEAT_FADE, INSTANT); @@ -261,7 +260,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { config.setInterpolator(ANIM_WORKSPACE_SCALE, ALL_APPS_SHEET_DEPTH); config.setInterpolator(ANIM_HOTSEAT_SCALE, ALL_APPS_SHEET_DEPTH); config.setInterpolator(ANIM_DEPTH, ALL_APPS_SHEET_DEPTH); - if (!Flags.allAppsBlur() && launcher.getDeviceProfile().isPhone) { + if (!Flags.allAppsBlur() && launcher.getDeviceProfile().getDeviceProperties().isPhone()) { // On phones without blur, hide the workspace and hotseat when entering All Apps. config.setInterpolator(ANIM_WORKSPACE_FADE, FINAL_FRAME); config.setInterpolator(ANIM_HOTSEAT_FADE, FINAL_FRAME); diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 32aec92f4a..1c30338ac1 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -160,7 +160,7 @@ public class ItemClickHandler { if (!isApp1Launchable || !isApp2Launchable) { // App pair is unlaunchable due to screen size. boolean isFoldable = InvariantDeviceProfile.INSTANCE.get(launcher) - .supportedProfiles.stream().anyMatch(dp -> dp.isTwoPanels); + .supportedProfiles.stream().anyMatch(dp -> dp.getDeviceProperties().isTwoPanels()); Toast.makeText(launcher, isFoldable ? R.string.app_pair_needs_unfold : R.string.app_pair_unlaunchable_at_screen_size, diff --git a/src/com/android/launcher3/util/DimensionUtils.kt b/src/com/android/launcher3/util/DimensionUtils.kt index 821dda789f..9941b66618 100644 --- a/src/com/android/launcher3/util/DimensionUtils.kt +++ b/src/com/android/launcher3/util/DimensionUtils.kt @@ -29,10 +29,10 @@ object DimensionUtils { */ @JvmStatic fun getTaskbarPhoneDimensions( - deviceProfile: DeviceProfile, - res: Resources, - isPhoneMode: Boolean, - isGestureNav: Boolean, + deviceProfile: DeviceProfile, + res: Resources, + isPhoneMode: Boolean, + isGestureNav: Boolean, ): Point { val p = Point() // Taskbar for large screen @@ -50,7 +50,7 @@ object DimensionUtils { } // Taskbar on phone, portrait - if (!deviceProfile.isLandscape) { + if (!deviceProfile.deviceProperties.isLandscape) { p.x = ViewGroup.LayoutParams.MATCH_PARENT p.y = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) return p diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java index 65d02d0177..6301e5d132 100644 --- a/src/com/android/launcher3/views/AbstractSlideInView.java +++ b/src/com/android/launcher3/views/AbstractSlideInView.java @@ -435,7 +435,7 @@ public abstract class AbstractSlideInView @Override public void onDragEnd(float velocity) { - float successfulShiftThreshold = mActivityContext.getDeviceProfile().isTablet + float successfulShiftThreshold = mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() ? TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS : SUCCESS_TRANSITION_PROGRESS; if ((mSwipeDetector.isFling(velocity) && velocity > 0) || mTranslationShift > successfulShiftThreshold) { diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index 3c563d935e..09d083c68d 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -240,7 +240,7 @@ public interface ActivityContext extends SavedStateRegistryOwner { /** Registered {@link OnDeviceProfileChangeListener} instances. */ List getOnDeviceProfileChangeListeners(); - /** Notifies listeners of a {@link DeviceProfile} change. */ + /** Notifies listeners of a {@link deviceprofile} change. */ default void dispatchDeviceProfileChanged() { DeviceProfile deviceProfile = getDeviceProfile(); List listeners = getOnDeviceProfileChangeListeners(); @@ -249,12 +249,12 @@ public interface ActivityContext extends SavedStateRegistryOwner { } } - /** Register listener for {@link DeviceProfile} changes. */ + /** Register listener for {@link deviceprofile} changes. */ default void addOnDeviceProfileChangeListener(OnDeviceProfileChangeListener listener) { getOnDeviceProfileChangeListeners().add(listener); } - /** Unregister listener for {@link DeviceProfile} changes. */ + /** Unregister listener for {@link deviceprofile} changes. */ default void removeOnDeviceProfileChangeListener(OnDeviceProfileChangeListener listener) { getOnDeviceProfileChangeListeners().remove(listener); } diff --git a/src/com/android/launcher3/views/ClipIconView.java b/src/com/android/launcher3/views/ClipIconView.java index eb25003925..f7fdd613a0 100644 --- a/src/com/android/launcher3/views/ClipIconView.java +++ b/src/com/android/launcher3/views/ClipIconView.java @@ -122,7 +122,7 @@ public class ClipIconView extends View implements ClipPathView { MarginLayoutParams lp = (MarginLayoutParams) container.getLayoutParams(); float dX = mIsRtl - ? rect.left - (dp.widthPx - lp.getMarginStart() - lp.width) + ? rect.left - (dp.getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width) : rect.left - lp.getMarginStart(); float dY = rect.top - lp.topMargin; container.setTranslationX(dX); @@ -164,7 +164,7 @@ public class ClipIconView extends View implements ClipPathView { float shapeRevealProgress = boundToRange(mapToRange(max(shapeProgressStart, progress), shapeProgressStart, 1f, 0, toMax, LINEAR), 0, 1); - if (dp.isLandscape) { + if (dp.getDeviceProperties().isLandscape()) { mOutline.right = (int) (rect.width() / scale); } else { mOutline.bottom = (int) (rect.height() / scale); @@ -188,16 +188,16 @@ public class ClipIconView extends View implements ClipPathView { mRevealAnimator.setCurrentFraction(shapeRevealProgress); } - float drawableScale = (dp.isLandscape ? mOutline.width() : mOutline.height()) + float drawableScale = (dp.getDeviceProperties().isLandscape() ? mOutline.width() : mOutline.height()) / minSize; - setBackgroundDrawableBounds(drawableScale, dp.isLandscape); + setBackgroundDrawableBounds(drawableScale, dp.getDeviceProperties().isLandscape()); // Center align foreground int height = mFinalDrawableBounds.height(); int width = mFinalDrawableBounds.width(); - int diffY = dp.isLandscape ? 0 + int diffY = dp.getDeviceProperties().isLandscape() ? 0 : (int) (((height * drawableScale) - height) / 2); - int diffX = dp.isLandscape ? (int) (((width * drawableScale) - width) / 2) + int diffX = dp.getDeviceProperties().isLandscape() ? (int) (((width * drawableScale) - width) / 2) : 0; sTmpRect.set(mFinalDrawableBounds); sTmpRect.offset(diffX, diffY); @@ -264,14 +264,14 @@ public class ClipIconView extends View implements ClipPathView { Utilities.scaleRectAboutCenter(mStartRevealRect, ICON_VISIBLE_AREA_FACTOR); } - if (dp.isLandscape) { - lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio); + if (dp.getDeviceProperties().isLandscape()) { + lp.width = (int) Math.max(lp.width, lp.height * dp.getDeviceProperties().getAspectRatio()); } else { - lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio); + lp.height = (int) Math.max(lp.height, lp.width * dp.getDeviceProperties().getAspectRatio()); } int left = mIsRtl - ? dp.widthPx - lp.getMarginStart() - lp.width + ? dp.getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width : lp.leftMargin; layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height); @@ -285,7 +285,7 @@ public class ClipIconView extends View implements ClipPathView { bgDrawableStartScale = scale; mOutline.set(0, 0, lp.width, lp.height); } - setBackgroundDrawableBounds(bgDrawableStartScale, dp.isLandscape); + setBackgroundDrawableBounds(bgDrawableStartScale, dp.getDeviceProperties().isLandscape()); mEndRevealRect.set(0, 0, lp.width, lp.height); setOutlineProvider(new ViewOutlineProvider() { @Override diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index e2b56bef10..d9d20d54aa 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -226,14 +226,14 @@ public class FloatingIconView extends FrameLayout implements // Position the floating view exactly on top of the original lp.topMargin = Math.round(pos.top); if (mIsRtl) { - lp.setMarginStart(Math.round(mLauncher.getDeviceProfile().widthPx - pos.right)); + lp.setMarginStart(Math.round(mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() - pos.right)); } else { lp.setMarginStart(Math.round(pos.left)); } // Set the properties here already to make sure they are available when running the first // animation frame. int left = mIsRtl - ? mLauncher.getDeviceProfile().widthPx - lp.getMarginStart() - lp.width + ? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width : lp.leftMargin; layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height); } @@ -370,8 +370,8 @@ public class FloatingIconView extends FrameLayout implements mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight); - float aspectRatio = mLauncher.getDeviceProfile().aspectRatio; - if (dp.isLandscape) { + float aspectRatio = mLauncher.getDeviceProfile().getDeviceProperties().getAspectRatio(); + if (dp.getDeviceProperties().isLandscape()) { lp.width = (int) Math.max(lp.width, lp.height * aspectRatio); } else { lp.height = (int) Math.max(lp.height, lp.width * aspectRatio); diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java index 5e702aa37f..a6deee5340 100644 --- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java @@ -101,7 +101,7 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView 0) { diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index af31276ff9..9a2f096f1f 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -355,7 +355,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView protected int getInsetsWidth() { int widthUsed; DeviceProfile deviceProfile = mActivityContext.getDeviceProfile(); - if (deviceProfile.isTablet) { + if (deviceProfile.getDeviceProperties().isTablet()) { widthUsed = Math.max(2 * getTabletHorizontalMargin(deviceProfile), 2 * (mInsets.left + mInsets.right)); } else if (mInsets.bottom > 0) { @@ -375,7 +375,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView @Override protected Interpolator getIdleInterpolator() { - return mActivityContext.getDeviceProfile().isTablet + return mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() ? EMPHASIZED : super.getIdleInterpolator(); } @@ -394,7 +394,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView // In light mode, landscape reverses navbar background color. boolean isPhoneLandscape = - !mActivityContext.getDeviceProfile().isTablet && mInsets.bottom == 0; + !mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() && mInsets.bottom == 0; if (!isNavBarDark && isPhoneLandscape) { isNavBarDark = true; } diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java index 94ae69cccd..7a7f1f2a06 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java @@ -114,7 +114,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme // On phones we no longer support regular landscape, only fixed landscape for this // reason we don't need to take regular landscape into account in phones if (Flags.oneGridSpecs() && dp.inv.deviceType == TYPE_PHONE - && dp.inv.isFixedLandscape != dp.isLandscape) { + && dp.inv.isFixedLandscape != dp.getDeviceProperties().isLandscape()) { continue; } diff --git a/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java b/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java index ec916228db..12ea5064a9 100644 --- a/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java +++ b/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java @@ -174,7 +174,7 @@ public final class WidgetRecommendationsView extends PagedViewIn case of a single category, no title is displayed for it.

* * @param recommendations a map of widget items per recommendation category - * @param deviceProfile the current {@link DeviceProfile} + * @param deviceProfile the current {@link deviceprofile} * @param availableHeight height in px that can be used to display the recommendations; * recommendations that don't fit in this height won't be shown * @param availableWidth width in px that the recommendations should display in diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 44c0ebde4b..77efe5e495 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -653,11 +653,11 @@ public class WidgetsFullSheet extends BaseWidgetSheet protected float getMaxAvailableHeightForRecommendations() { // There isn't enough space to show recommendations in landscape orientation on phones with // a full sheet design. Tablets use a two pane picker. - if (mDeviceProfile.isLandscape) { + if (mDeviceProfile.getDeviceProperties().isLandscape()) { return 0f; } - return (mDeviceProfile.heightPx - mDeviceProfile.bottomSheetTopPadding) + return (mDeviceProfile.getDeviceProperties().getHeightPx() - mDeviceProfile.bottomSheetTopPadding) * RECOMMENDATION_TABLE_HEIGHT_RATIO; } @@ -775,7 +775,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet } private static int getWidgetSheetId(BaseActivity activity) { - boolean isTwoPane = activity.getDeviceProfile().isTablet; + boolean isTwoPane = activity.getDeviceProfile().getDeviceProperties().isTablet(); return isTwoPane ? R.layout.widgets_two_pane_sheet : R.layout.widgets_full_sheet; } @@ -922,7 +922,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private static boolean shouldRecreateLayout(DeviceProfile oldDp, DeviceProfile newDp) { // When folding/unfolding the foldables, we need to switch between the regular widget picker // and the two pane picker, so we rebuild the picker with the correct layout. - return oldDp.isTwoPanels != newDp.isTwoPanels; + return oldDp.getDeviceProperties().isTwoPanels() != newDp.getDeviceProperties().isTwoPanels(); } /** diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java index 9ffaf5100b..113d9c0632 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java @@ -136,7 +136,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { mWidgetRecommendationsView.initParentViews(mWidgetRecommendationsContainer); mWidgetRecommendationsView.setWidgetCellLongClickListener(this); mWidgetRecommendationsView.setWidgetCellOnClickListener(this); - if (!mDeviceProfile.isTwoPanels) { + if (!mDeviceProfile.getDeviceProperties().isTwoPanels()) { mWidgetRecommendationsView.enableFullPageViewIfLowDensity(); } // To save the currently displayed page, so that, it can be requested when rebinding @@ -242,7 +242,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - if (changed && mDeviceProfile.isTwoPanels) { + if (changed && mDeviceProfile.getDeviceProperties().isTwoPanels()) { LinearLayout layout = mContent.findViewById(R.id.linear_layout_container); FrameLayout leftPane = layout.findViewById(R.id.recycler_view_container); LinearLayout.LayoutParams layoutParams = (LayoutParams) leftPane.getLayoutParams(); @@ -403,7 +403,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { return Float.MAX_VALUE; } - return (mDeviceProfile.heightPx - mDeviceProfile.bottomSheetTopPadding) + return (mDeviceProfile.getDeviceProperties().getHeightPx() - mDeviceProfile.bottomSheetTopPadding) * RECOMMENDATION_SECTION_HEIGHT_RATIO_TWO_PANE; } @@ -412,7 +412,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { protected int getAvailableWidthForSuggestions(int pickerAvailableWidth) { int rightPaneWidth = (int) Math.ceil(0.67 * pickerAvailableWidth); - if (mDeviceProfile.isTwoPanels) { + if (mDeviceProfile.getDeviceProperties().isTwoPanels()) { // See onLayout int leftPaneWidth = (int) (0.33 * pickerAvailableWidth); @Px int minLeftPaneWidthPx = Utilities.dpToPx(MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP); diff --git a/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt b/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt index a0414ba136..66d8b7c21d 100644 --- a/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt +++ b/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt @@ -29,7 +29,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp */ fun forItem(item: WidgetItem, dp: DeviceProfile): WidgetPreviewContainerSize { val sizes = - if (dp.isTablet && !dp.isTwoPanels) { + if (dp.deviceProperties.isTablet && !dp.deviceProperties.isTwoPanels) { TABLET_WIDGET_PREVIEW_SIZES } else { HANDHELD_WIDGET_PREVIEW_SIZES @@ -43,7 +43,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp return findClosestFittingContainer( containerSizes = sizes.toList(), startIndex = index, - item = item + item = item, ) } } @@ -54,7 +54,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp private fun findClosestFittingContainer( containerSizes: List, startIndex: Int, - item: WidgetItem + item: WidgetItem, ): WidgetPreviewContainerSize { // Checks if it's a smaller container, but close enough to keep the down-scale minimal. fun hasAcceptableSize(currentIndex: Int): Boolean { diff --git a/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java index 03a553534f..4882f83f6e 100644 --- a/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -65,7 +65,7 @@ public class AllAppsState extends LauncherState { @Override public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { - if (launcher.getDeviceProfile().isTablet) { + if (launcher.getDeviceProfile().getDeviceProperties().isTablet()) { return getWorkspaceScaleAndTranslation(launcher); } else { ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW @@ -83,7 +83,7 @@ public class AllAppsState extends LauncherState { return new PageAlphaProvider(DECELERATE) { @Override public float getPageAlpha(int pageIndex) { - return launcher.getDeviceProfile().isTablet + return launcher.getDeviceProfile().getDeviceProperties().isTablet() ? superPageAlphaProvider.getPageAlpha(pageIndex) : 0; } @@ -97,7 +97,7 @@ public class AllAppsState extends LauncherState { @Override public int getWorkspaceScrimColor(Launcher launcher) { - return launcher.getDeviceProfile().isTablet + return launcher.getDeviceProfile().getDeviceProperties().isTablet() ? launcher.getResources().getColor(R.color.widgets_picker_scrim) : Themes.getAttrColor(launcher, R.attr.allAppsScrimColor); } diff --git a/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt b/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt index 2452a88b14..65bf6a2006 100644 --- a/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt @@ -134,7 +134,7 @@ class WidgetPreviewContainerSizesTest { ) private fun getTestSizes(dp: DeviceProfile) = - if (dp.isTablet && !dp.isTwoPanels) { + if (dp.deviceProperties.isTablet && !dp.deviceProperties.isTwoPanels) { TABLET_TEST_SIZES } else { HANDHELD_TEST_SIZES diff --git a/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java b/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java index e5b45b9277..9f58ffff5c 100644 --- a/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java +++ b/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java @@ -125,8 +125,8 @@ public class PortraitLandscapeRunner Date: Fri, 23 May 2025 11:52:46 -0700 Subject: [PATCH 22/25] Adds widget picker landing screens This CL includes following: * ViewModel base class for reuse across widget picker. * Landing screens implemented in both compact and expanded mode. * Test cases for the same. Bug: 408283627 Flag: EXEMPT independent module Test: Unit tests Change-Id: Ia4a7f0b972ca0d3863f041aac276cb3c5096a258 --- modules/widgetpicker/Android.bp | 32 ++ modules/widgetpicker/build.gradle.kts | 1 + .../launcher3/widgetpicker/ui/ViewModel.kt | 71 +++ .../ui/components/LeadingIconToolbarTab.kt | 10 +- .../ui/components/SinglePaneLayout.kt | 32 +- .../ui/components/WidgetDetails.kt | 8 +- .../screens/landing/LandingScreen.kt | 138 ++++++ .../landing/LandingScreenSinglePane.kt | 254 ++++++++++ .../screens/landing/LandingScreenTwoPane.kt | 443 ++++++++++++++++++ .../screens/landing/LandingScreenViewModel.kt | 299 ++++++++++++ .../ui/model/DisplayableWidgetApp.kt | 30 +- modules/widgetpicker/tests/Android.bp | 14 + .../launcher3/widgetpicker/TestUtils.kt | 8 +- .../landing/LandingScreenSinglePaneTest.kt | 204 ++++++++ .../landing/LandingScreenTwoPaneTest.kt | 261 +++++++++++ 15 files changed, 1787 insertions(+), 18 deletions(-) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/ViewModel.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePaneTest.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPaneTest.kt diff --git a/modules/widgetpicker/Android.bp b/modules/widgetpicker/Android.bp index 39f9c90fa5..9ca26f06b5 100644 --- a/modules/widgetpicker/Android.bp +++ b/modules/widgetpicker/Android.bp @@ -157,6 +157,38 @@ android_library { ], } +android_library { + name: "widget_picker_ui", + sdk_version: "current", + min_sdk_version: min_launcher3_sdk_version, + srcs: [ + "src/com/android/launcher3/widgetpicker/ui/ViewModel.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt", + ], + static_libs: [ + "widget_picker_ui_components", + "widget_picker_ui_data_types", + "widget_picker_domain_layer", + "dagger2", + "widget_picker_dagger_annotations", + "androidx.compose.foundation_foundation", + "androidx.compose.foundation_foundation-layout", + "androidx.compose.runtime_runtime", + "androidx.compose.ui_ui", + "androidx.compose.ui_ui-tooling", + "androidx.compose.material3_material3", + "androidx.compose.material3_material3-window-size-class", + "androidx.compose.material_material-icons-extended", + "androidx.activity_activity-compose", + "widget_picker_window_size_class", + "kotlinx-coroutines-android", + "kotlinx-coroutines-core", + ], +} + android_library { name: "widget_picker_window_size_class", sdk_version: "current", diff --git a/modules/widgetpicker/build.gradle.kts b/modules/widgetpicker/build.gradle.kts index fbc0f45a48..227abebff6 100644 --- a/modules/widgetpicker/build.gradle.kts +++ b/modules/widgetpicker/build.gradle.kts @@ -116,6 +116,7 @@ dependencies { androidTestImplementation(libs.kotlinx.coroutines.test) // Compose UI Tests + testApi(libs.compose.ui.test.junit4) androidTestApi(libs.compose.ui.test.junit4) debugApi(libs.compose.ui.test.manifest) diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/ViewModel.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/ViewModel.kt new file mode 100644 index 0000000000..6a2f86ff84 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/ViewModel.kt @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui + +import android.animation.ValueAnimator +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import kotlinx.coroutines.delay + +/** + * An interface defining general structure of a view model in widget picker. + */ +// TODO(b/419844646): Once stable, introduce a reusable library. +internal interface ViewModel { + /** + * Implement this function to initialize the state of viewmodel by binding to the flows from the + * interactors. + * + * Then when the UI calls [rememberViewModel], this callback function will be invoked. + * + * e.g. coroutineScope { + * launch { myInteractor.myData().collectLatest {..} } + * launch { myChildViewModel.onInit() } + * + * awaitCancellation() + * } + */ + suspend fun onInit() {} +} + +/** + * Returns a remembered instance of the [ViewModel] of type [T]. + * + * Also, initialize the view model. + * @param key a unique key to remember the view model + * @param animationDelay delay for animations to finish (if animations are enabled) before binding + * data in view model for a smoother transition. + */ +@Composable +fun rememberViewModel( + key: Any = Unit, + animationDelay: Long = 0L, + factory: () -> T, +): T { + val instance = remember(key) { factory() } + // Here we initialize our view model using the launched effect so that it is tied to lifecycle + // of the UI. + LaunchedEffect(instance) { + if (ValueAnimator.areAnimatorsEnabled() && animationDelay > 0) { + delay(animationDelay) + } + instance.onInit() + } + + return instance +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/LeadingIconToolbarTab.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/LeadingIconToolbarTab.kt index 518094e2e7..ebbc4c9b75 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/LeadingIconToolbarTab.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/LeadingIconToolbarTab.kt @@ -24,11 +24,11 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.shrinkOut import androidx.compose.foundation.background -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -70,9 +70,13 @@ fun LeadingIconToolbarTab( Row( modifier = - Modifier.fillMaxWidth() + Modifier + .fillMaxWidth() .clip(CircleShape) - .clickable { onClick() } + .selectable( + selected = selected, + onClick = onClick + ) .background(color = backgroundColor) .minimumInteractiveComponentSize() .padding(horizontal = LeadingIconToolbarTabDefaults.horizontalPadding), diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/SinglePaneLayout.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/SinglePaneLayout.kt index e53e86b224..a6b8c9e528 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/SinglePaneLayout.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/SinglePaneLayout.kt @@ -32,8 +32,9 @@ package com.android.launcher3.widgetpicker.ui.components * limitations under the License. */ +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -48,29 +49,40 @@ import com.android.launcher3.widgetpicker.ui.components.SinglePaneLayoutDimensio * A layout that shows all the widget picker content in a column like pane. * * @param searchBar A sticky search bar shown on top in the left pane. - * @param toolbar an option toolbar shown at bottom of the screen that allows users to select what - * to see in the [content] * @param content the primary content e.g. widgets expand collapse list. + * @param bottomFloatingContent an option toolbar that floats at the bottom of the screen and + * allows users to choose what to see in the [content] */ @Composable fun SinglePaneLayout( searchBar: @Composable () -> Unit, - toolbar: (@Composable () -> Unit)? = null, content: @Composable () -> Unit, + bottomFloatingContent: (@Composable () -> Unit)? = null, ) { - val topContent: @Composable ColumnScope.() -> Unit = { - Column(modifier = Modifier.fillMaxWidth().weight(1f)) { + val topContent: @Composable BoxScope.() -> Unit = { + Column(modifier = Modifier.fillMaxSize()) { searchBar() - Spacer(modifier = Modifier.fillMaxWidth().height(searchBarBottomMargin)) + Spacer( + modifier = Modifier + .fillMaxWidth() + .height(searchBarBottomMargin) + ) content() } } - val bottomContent: @Composable ColumnScope.() -> Unit = { toolbar?.let { it() } } + val floatingContent: @Composable BoxScope.() -> Unit = { + Box( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.BottomCenter), + contentAlignment = Alignment.Center + ) { bottomFloatingContent?.let { it() } } + } - Column(modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) { + Box(modifier = Modifier.fillMaxSize()) { topContent() - bottomContent() + floatingContent() } } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetDetails.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetDetails.kt index b04016f619..b83d59fba6 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetDetails.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetDetails.kt @@ -60,7 +60,10 @@ fun WidgetDetails( Column( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top, - modifier = modifier.fillMaxSize().padding(WidgetDetailsDimension.padding), + modifier = modifier.fillMaxSize().padding( + horizontal = WidgetDetailsDimension.horizontalPadding, + vertical = WidgetDetailsDimension.verticalPadding + ), ) { WidgetLabel(label = widget.label, appIcon = appIcon, modifier = Modifier) if (showAllDetails) { @@ -134,6 +137,7 @@ private fun WidgetSpanSizeLabel(spanX: Int, spanY: Int) { } private object WidgetDetailsDimension { - val padding: Dp = 4.dp + val horizontalPadding: Dp = 4.dp + val verticalPadding: Dp = 12.dp val appIconLabelSpacing = 8.dp } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt new file mode 100644 index 0000000000..393655aa5a --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.ui.components.WidgetsGrid +import com.android.launcher3.widgetpicker.ui.components.WidgetsSearchBar + +/** + * View displayed when user opens the full catalog of widgets in widget picker. + * + * @param isCompact indicates whether to show the compact single pane layout or the two pane layout. + * @param onEnterSearchMode callback for when user focuses on the search bar. + * @param viewModel the view model backing the state and data for the landing screen. + */ +@Composable +fun LandingScreen( + isCompact: Boolean, + onEnterSearchMode: () -> Unit, + viewModel: LandingScreenViewModel, +) { + val browseState = viewModel.browseWidgetsState + + if (browseState is BrowseWidgetsState.Data) { + val searchBar: @Composable () -> Unit = remember { + { + WidgetsSearchBar( + text = "", + isSearching = false, + onSearch = {}, + onToggleSearchMode = { enter -> + if (enter) { + viewModel.onSelectedPersonalAppToggle(null) + viewModel.onSelectedWorkAppToggle(null) + onEnterSearchMode() + } + }, + modifier = Modifier.fillMaxWidth(), + ) + } + } + + LandingScreen( + isCompact = isCompact, + searchBarContent = searchBar, + featuredWidgetsState = viewModel.featuredWidgetsState, + featuredWidgetPreviewsState = viewModel.featuredWidgetPreviewsState, + widgetAppIconsState = viewModel.appIconsState, + browseWidgetsState = browseState, + personalWidgetPreviewsState = viewModel.personalWidgetsPreviewsState, + workWidgetPreviewsState = viewModel.workWidgetsPreviewState, + selectedPersonalWidgetAppId = viewModel.selectedPersonalAppId, + onPersonalWidgetAppToggle = viewModel::onSelectedPersonalAppToggle, + selectedWorkWidgetAppId = viewModel.selectedWorkAppId, + onWorkWidgetAppToggle = viewModel::onSelectedWorkAppToggle, + ) + } +} + +@Composable +private fun LandingScreen( + isCompact: Boolean, + searchBarContent: @Composable () -> Unit, + featuredWidgetsState: FeaturedWidgetsState, + featuredWidgetPreviewsState: PreviewsState, + widgetAppIconsState: AppIconsState, + browseWidgetsState: BrowseWidgetsState.Data, + personalWidgetPreviewsState: PreviewsState, + workWidgetPreviewsState: PreviewsState, + selectedPersonalWidgetAppId: WidgetAppId?, + onPersonalWidgetAppToggle: (WidgetAppId?) -> Unit, + selectedWorkWidgetAppId: WidgetAppId?, + onWorkWidgetAppToggle: (WidgetAppId?) -> Unit, +) { + val featuredWidgetsContent: @Composable () -> Unit = { + WidgetsGrid( + modifier = Modifier + .fillMaxSize() + .verticalScroll(rememberScrollState()), + widgetSizeGroups = featuredWidgetsState.sizeGroups, + showAllWidgetDetails = false, + previews = featuredWidgetPreviewsState.previews, + appIcons = widgetAppIconsState.icons + ) + } + + when { + isCompact -> + LandingScreenSinglePane( + searchBarContent = searchBarContent, + featuredWidgetsContent = featuredWidgetsContent, + widgetAppIconsState = widgetAppIconsState, + browseWidgetsState = browseWidgetsState, + personalWidgetPreviewsState = personalWidgetPreviewsState, + workWidgetPreviewsState = workWidgetPreviewsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + onPersonalWidgetAppToggle = onPersonalWidgetAppToggle, + selectedWorkWidgetAppId = selectedWorkWidgetAppId, + onWorkWidgetAppToggle = onWorkWidgetAppToggle + ) + + else -> + LandingScreenTwoPane( + searchBar = searchBarContent, + featuredWidgets = featuredWidgetsContent, + featuredWidgetsCount = featuredWidgetsState.widgetsCount, + widgetAppIconsState = widgetAppIconsState, + browseWidgetsState = browseWidgetsState, + personalWidgetPreviewsState = personalWidgetPreviewsState, + workWidgetPreviewsState = workWidgetPreviewsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + onPersonalWidgetAppToggle = onPersonalWidgetAppToggle, + selectedWorkWidgetAppId = selectedWorkWidgetAppId, + onWorkWidgetAppToggle = onWorkWidgetAppToggle, + ) + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt new file mode 100644 index 0000000000..ec4a2238a8 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt @@ -0,0 +1,254 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.PagerState +import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.List +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.filled.Star +import androidx.compose.material.icons.outlined.Work +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import com.android.launcher3.widgetpicker.ui.components.AppHeaderDescriptionStyle +import com.android.launcher3.widgetpicker.ui.components.LeadingIconToolbarTab +import com.android.launcher3.widgetpicker.ui.components.ScrollableFloatingToolbar +import com.android.launcher3.widgetpicker.ui.components.SinglePaneLayout +import com.android.launcher3.widgetpicker.ui.components.WidgetAppHeaderStyle +import com.android.launcher3.widgetpicker.ui.components.WidgetAppsList +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.DEFAULT_SELECTED_TAB +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.FEATURED_TAB_INDEX +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.PERSONAL_TAB_INDEX +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.TABS_COUNT_WITHOUT_WORK_PROFILE +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.TABS_COUNT_WITH_WORK_PROFILE +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.WORK_TAB_INDEX +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.bottomTabsBottomPadding +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.bottomTabsHorizontalPadding +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.bottomTabsTopPadding +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.contentShape +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenSinglePaneDimens.pagerItemsSpacing +import kotlinx.coroutines.launch + +/** + * A composable function that provides a single pane layout for landing screen of the full catalog + * of widgets in the widget picker. + */ +@Composable +fun LandingScreenSinglePane( + searchBarContent: @Composable () -> Unit, + featuredWidgetsContent: @Composable () -> Unit, + widgetAppIconsState: AppIconsState, + browseWidgetsState: BrowseWidgetsState.Data, + personalWidgetPreviewsState: PreviewsState, + workWidgetPreviewsState: PreviewsState, + selectedPersonalWidgetAppId: WidgetAppId?, + onPersonalWidgetAppToggle: (WidgetAppId) -> Unit, + selectedWorkWidgetAppId: WidgetAppId?, + onWorkWidgetAppToggle: (WidgetAppId) -> Unit, +) { + val hasWorkProfile = remember(browseWidgetsState) { browseWidgetsState.workProfile != null } + + val pagerState = rememberPagerState( + initialPage = DEFAULT_SELECTED_TAB, + pageCount = { + if (hasWorkProfile) { + TABS_COUNT_WITH_WORK_PROFILE + } else { + TABS_COUNT_WITHOUT_WORK_PROFILE + } + } + ) + + SinglePaneLayout( + searchBar = searchBarContent, + bottomFloatingContent = { + BottomTabs( + personalUserProfile = browseWidgetsState.personalProfile, + workUserProfile = browseWidgetsState.workProfile, + pagerState = pagerState + ) + }, + content = { + HorizontalPager( + state = pagerState, + verticalAlignment = Alignment.Top, + pageSpacing = pagerItemsSpacing, + modifier = Modifier + .fillMaxWidth() + .clip(contentShape), + ) { pageIndex -> + when (pageIndex) { + FEATURED_TAB_INDEX -> { + Box( + modifier = Modifier + .fillMaxSize() + .clip(contentShape) + .background(MaterialTheme.colorScheme.surfaceBright) + ) { + featuredWidgetsContent() + } + } + + PERSONAL_TAB_INDEX -> { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = browseWidgetsState.personalWidgetApps, + selectedWidgetAppId = selectedPersonalWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.EXPANDABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.WIDGETS_COUNT, + onWidgetAppClick = { widgetApp -> + onPersonalWidgetAppToggle(widgetApp.id) + }, + appIcons = widgetAppIconsState.icons, + widgetPreviews = personalWidgetPreviewsState.previews + ) + } + } + + WORK_TAB_INDEX -> if (hasWorkProfile) { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = browseWidgetsState.workWidgetApps, + selectedWidgetAppId = selectedWorkWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.EXPANDABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.WIDGETS_COUNT, + onWidgetAppClick = { widgetApp -> + onWorkWidgetAppToggle(widgetApp.id) + }, + appIcons = widgetAppIconsState.icons, + widgetPreviews = workWidgetPreviewsState.previews + ) + } + } + } + } + } + ) +} + +@Composable +private fun BottomTabs( + pagerState: PagerState, + personalUserProfile: WidgetUserProfile, + workUserProfile: WidgetUserProfile? +) { + val scope = rememberCoroutineScope() + + val tabs: List<@Composable () -> Unit> = buildList { + add { + LeadingIconToolbarTab( + label = stringResource(R.string.featured_widgets_tab_label), + leadingIcon = Icons.Filled.Star, + selected = pagerState.currentPage == FEATURED_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(FEATURED_TAB_INDEX) + } + }, + ) + } + + if (workUserProfile == null) { + add { + LeadingIconToolbarTab( + label = stringResource(R.string.browse_widgets_tab_label), + leadingIcon = Icons.AutoMirrored.Filled.List, + selected = pagerState.currentPage == PERSONAL_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(PERSONAL_TAB_INDEX) + } + }, + ) + } + } else { + add { + LeadingIconToolbarTab( + label = personalUserProfile.label, + leadingIcon = Icons.Filled.Person, + selected = pagerState.currentPage == PERSONAL_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(PERSONAL_TAB_INDEX) + } + }, + ) + } + add { + LeadingIconToolbarTab( + label = workUserProfile.label, + leadingIcon = Icons.Outlined.Work, + selected = pagerState.currentPage == WORK_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(WORK_TAB_INDEX) + } + }, + ) + } + } + } + + ScrollableFloatingToolbar( + modifier = + Modifier + .padding(horizontal = bottomTabsHorizontalPadding) + .padding( + top = bottomTabsTopPadding, + bottom = bottomTabsBottomPadding + ), + selectedTabIndex = pagerState.currentPage, + tabs = tabs + ) +} + +private object LandingScreenSinglePaneDimens { + const val TABS_COUNT_WITH_WORK_PROFILE = 3 + const val TABS_COUNT_WITHOUT_WORK_PROFILE = 2 + + const val FEATURED_TAB_INDEX = 0 + const val PERSONAL_TAB_INDEX = 1 + const val WORK_TAB_INDEX = 2 + const val DEFAULT_SELECTED_TAB = FEATURED_TAB_INDEX + + val contentShape = RoundedCornerShape(24.dp) + val pagerItemsSpacing = 8.dp + + val bottomTabsTopPadding = 8.dp + val bottomTabsHorizontalPadding = 32.dp + val bottomTabsBottomPadding = 8.dp +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt new file mode 100644 index 0000000000..ebd5b9d63a --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.pager.HorizontalPager +import androidx.compose.foundation.pager.PagerState +import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Person +import androidx.compose.material.icons.outlined.Work +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import com.android.launcher3.widgetpicker.ui.components.AppHeaderDescriptionStyle +import com.android.launcher3.widgetpicker.ui.components.LeadingIconToolbarTab +import com.android.launcher3.widgetpicker.ui.components.ScrollableFloatingToolbar +import com.android.launcher3.widgetpicker.ui.components.SelectableSuggestionsHeader +import com.android.launcher3.widgetpicker.ui.components.TwoPaneLayout +import com.android.launcher3.widgetpicker.ui.components.WidgetAppHeaderStyle +import com.android.launcher3.widgetpicker.ui.components.WidgetAppsList +import com.android.launcher3.widgetpicker.ui.components.WidgetsGrid +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.DEFAULT_SELECTED_TAB +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.PERSONAL_TAB_INDEX +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.TABS_COUNT_WITHOUT_WORK_PROFILE +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.TABS_COUNT_WITH_WORK_PROFILE +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.WORK_TAB_INDEX +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.contentShape +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.leftPaneContentBottomPadding +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenTwoPaneDimens.pagerItemsSpacing +import kotlinx.coroutines.launch + + +/** + * A composable function that provides a two pane layout for landing screen of the full catalog + * of widgets in the widget picker. + * + * Ideal for large screens. + */ +@Composable +fun LandingScreenTwoPane( + searchBar: @Composable () -> Unit, + featuredWidgets: @Composable () -> Unit, + featuredWidgetsCount: Int, + widgetAppIconsState: AppIconsState, + browseWidgetsState: BrowseWidgetsState.Data, + personalWidgetPreviewsState: PreviewsState, + workWidgetPreviewsState: PreviewsState, + selectedPersonalWidgetAppId: WidgetAppId?, + onPersonalWidgetAppToggle: (WidgetAppId?) -> Unit, + selectedWorkWidgetAppId: WidgetAppId?, + onWorkWidgetAppToggle: (WidgetAppId?) -> Unit, +) { + val hasWorkProfile = remember(browseWidgetsState) { browseWidgetsState.workProfile != null } + var isFeaturedSectionShowing by rememberSaveable { mutableStateOf(true) } + val pageCount = remember { + if (hasWorkProfile) { + TABS_COUNT_WITH_WORK_PROFILE + } else { + TABS_COUNT_WITHOUT_WORK_PROFILE + } + } + + val pagerState = + rememberPagerState( + initialPage = DEFAULT_SELECTED_TAB, + pageCount = { pageCount } + ) + + Box(modifier = Modifier.fillMaxSize()) { + TwoPaneLayout( + searchBar = searchBar, + leftContent = { + LeftPaneContent( + isFeaturedSectionSelected = isFeaturedSectionShowing, + featuredWidgetsCount = featuredWidgetsCount, + pagerState = pagerState, + hasWorkProfile = hasWorkProfile, + browseWidgetsState = browseWidgetsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + widgetAppIconsState = widgetAppIconsState, + personalWidgetPreviewsState = personalWidgetPreviewsState, + selectedWorkWidgetAppId = selectedWorkWidgetAppId, + workWidgetPreviewsState = workWidgetPreviewsState, + onFeaturedHeaderClick = { + isFeaturedSectionShowing = true + onPersonalWidgetAppToggle(null) + onWorkWidgetAppToggle(null) + }, + onPersonalWidgetAppToggle = { id -> + isFeaturedSectionShowing = false + onPersonalWidgetAppToggle(id) + }, + onWorkWidgetAppToggle = { id -> + isFeaturedSectionShowing = false + onWorkWidgetAppToggle(id) + }, + ) + }, + rightPaneTitle = rightPaneTitle( + showingFeaturedTab = isFeaturedSectionShowing, + currentPageIndex = pagerState.currentPage, + browseWidgetsState = browseWidgetsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + selectedWorkWidgetAppId = selectedWorkWidgetAppId + ), + rightContent = { + RightPaneContent( + pagerState = pagerState, + isFeaturedSectionSelected = isFeaturedSectionShowing, + featuredWidgets = featuredWidgets, + browseWidgetsState = browseWidgetsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + personalWidgetPreviewsState = personalWidgetPreviewsState, + widgetAppIconsState = widgetAppIconsState, + selectedWorkWidgetAppId = selectedWorkWidgetAppId, + workWidgetPreviewsState = workWidgetPreviewsState, + ) + } + ) + } +} + +/** + * Title for the right pane that is updated when selected tab on left changes. When set, a talkback + * user can use four finger swipe down to switch to right pane. + */ +@Composable +private fun rightPaneTitle( + showingFeaturedTab: Boolean, + currentPageIndex: Int, + browseWidgetsState: BrowseWidgetsState.Data, + selectedPersonalWidgetAppId: WidgetAppId?, + selectedWorkWidgetAppId: WidgetAppId?, +): String? { + val selectedAppName: CharSequence? = + if (currentPageIndex == 0) { + selectedPersonalWidgetAppId?.let { selectedId -> + browseWidgetsState.personalWidgetApps.find { it.id == selectedId }?.title + } + } else { + selectedWorkWidgetAppId?.let { selectedId -> + browseWidgetsState.workWidgetApps.find { it.id == selectedId }?.title + } + } + + + return if (showingFeaturedTab) { + stringResource( + R.string.widget_picker_right_pane_accessibility_label, + stringResource(R.string.featured_widgets_tab_label) + ) + } else if (selectedAppName != null) { + stringResource( + R.string.widget_picker_right_pane_accessibility_label, + selectedAppName + ) + } else { + null + } +} + +@Composable +private fun RightPaneContent( + pagerState: PagerState, + isFeaturedSectionSelected: Boolean, + featuredWidgets: @Composable () -> Unit, + browseWidgetsState: BrowseWidgetsState.Data, + selectedPersonalWidgetAppId: WidgetAppId?, + personalWidgetPreviewsState: PreviewsState, + widgetAppIconsState: AppIconsState, + selectedWorkWidgetAppId: WidgetAppId?, + workWidgetPreviewsState: PreviewsState +) { + when { + isFeaturedSectionSelected -> featuredWidgets() + + pagerState.currentPage == PERSONAL_TAB_INDEX -> { + selectedPersonalWidgetAppId?.let { + val selectedPersonalWidgets = + remember(selectedPersonalWidgetAppId, browseWidgetsState.personalWidgetApps) { + selectedPersonalWidgetAppId.let { selectedId -> + browseWidgetsState.personalWidgetApps.find { + it.id == selectedId + }?.widgetSizeGroups + } ?: listOf() + } + + WidgetsGrid( + modifier = Modifier + .fillMaxWidth() + .wrapContentSize() + .verticalScroll(rememberScrollState()), + showAllWidgetDetails = true, + widgetSizeGroups = selectedPersonalWidgets, + previews = personalWidgetPreviewsState.previews, + appIcons = widgetAppIconsState.icons + ) + } + } + + pagerState.currentPage == WORK_TAB_INDEX -> { + selectedWorkWidgetAppId?.let { + val selectedWorkWidgets = + remember(selectedWorkWidgetAppId, browseWidgetsState.workWidgetApps) { + selectedWorkWidgetAppId.let { selectedId -> + browseWidgetsState.workWidgetApps.find { + it.id == selectedId + }?.widgetSizeGroups + } ?: listOf() + } + + WidgetsGrid( + modifier = Modifier + .fillMaxWidth() + .wrapContentSize() + .verticalScroll(rememberScrollState()), + showAllWidgetDetails = true, + widgetSizeGroups = selectedWorkWidgets, + previews = workWidgetPreviewsState.previews, + appIcons = widgetAppIconsState.icons + ) + } + } + } +} + +@Composable +private fun LeftPaneContent( + isFeaturedSectionSelected: Boolean, + onFeaturedHeaderClick: () -> Unit, + featuredWidgetsCount: Int, + pagerState: PagerState, + hasWorkProfile: Boolean, + browseWidgetsState: BrowseWidgetsState.Data, + selectedPersonalWidgetAppId: WidgetAppId?, + widgetAppIconsState: AppIconsState, + personalWidgetPreviewsState: PreviewsState, + onPersonalWidgetAppToggle: (WidgetAppId) -> Unit, + selectedWorkWidgetAppId: WidgetAppId?, + workWidgetPreviewsState: PreviewsState, + onWorkWidgetAppToggle: (WidgetAppId) -> Unit, +) { + Box(modifier = Modifier.fillMaxSize()) { + Column(modifier = Modifier.fillMaxSize()) { + SelectableSuggestionsHeader( + selected = isFeaturedSectionSelected, + onSelect = onFeaturedHeaderClick, + count = featuredWidgetsCount, + shape = contentShape, + modifier = Modifier.fillMaxWidth() + ) + HorizontalPager( + state = pagerState, + verticalAlignment = Alignment.Top, + pageSpacing = pagerItemsSpacing, + modifier = Modifier + .fillMaxWidth() + .padding( + bottom = leftPaneContentBottomPadding( + hasFloatingToolbar = hasWorkProfile + ) + ) + .weight(1f), + ) { index -> + when (index) { + PERSONAL_TAB_INDEX -> { + PersonalSection( + browseWidgetsState = browseWidgetsState, + selectedPersonalWidgetAppId = selectedPersonalWidgetAppId, + widgetAppIconsState = widgetAppIconsState, + personalWidgetPreviewsState = personalWidgetPreviewsState, + onPersonalWidgetAppToggle = onPersonalWidgetAppToggle + ) + } + + WORK_TAB_INDEX -> if (hasWorkProfile) { + WorkSection( + browseWidgetsState = browseWidgetsState, + selectedWorkWidgetAppId = selectedWorkWidgetAppId, + widgetAppIconsState = widgetAppIconsState, + workWidgetPreviewsState = workWidgetPreviewsState, + onWorkWidgetAppToggle = onWorkWidgetAppToggle + ) + } + } + } + } + browseWidgetsState.workProfile?.let { workProfile -> + PersonalWorkToolbar( + pagerState = pagerState, + personalUserProfile = browseWidgetsState.personalProfile, + workUserProfile = workProfile, + modifier = Modifier + .align(Alignment.BottomCenter), + ) + } + } +} + +@Composable +private fun PersonalSection( + browseWidgetsState: BrowseWidgetsState.Data, + selectedPersonalWidgetAppId: WidgetAppId?, + widgetAppIconsState: AppIconsState, + personalWidgetPreviewsState: PreviewsState, + onPersonalWidgetAppToggle: (WidgetAppId) -> Unit +) { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = browseWidgetsState.personalWidgetApps, + selectedWidgetAppId = selectedPersonalWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.CLICKABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.WIDGETS_COUNT, + appIcons = widgetAppIconsState.icons, + widgetPreviews = personalWidgetPreviewsState.previews, + onWidgetAppClick = { widgetApp -> + onPersonalWidgetAppToggle(widgetApp.id) + }, + ) + } +} + +@Composable +private fun WorkSection( + browseWidgetsState: BrowseWidgetsState.Data, + selectedWorkWidgetAppId: WidgetAppId?, + widgetAppIconsState: AppIconsState, + workWidgetPreviewsState: PreviewsState, + onWorkWidgetAppToggle: (WidgetAppId) -> Unit +) { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = browseWidgetsState.workWidgetApps, + selectedWidgetAppId = selectedWorkWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.CLICKABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.WIDGETS_COUNT, + appIcons = widgetAppIconsState.icons, + widgetPreviews = workWidgetPreviewsState.previews, + onWidgetAppClick = { widgetApp -> + onWorkWidgetAppToggle(widgetApp.id) + }, + ) + } +} + +@Composable +private fun PersonalWorkToolbar( + pagerState: PagerState, + personalUserProfile: WidgetUserProfile, + workUserProfile: WidgetUserProfile, + modifier: Modifier, +) { + val scope = rememberCoroutineScope() + val currentPage = pagerState.currentPage + + val tabs: List<@Composable () -> Unit> = + remember(currentPage, personalUserProfile, workUserProfile) { + buildList { + add { + LeadingIconToolbarTab( + label = personalUserProfile.label, + leadingIcon = Icons.Filled.Person, + selected = currentPage == PERSONAL_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(PERSONAL_TAB_INDEX) + } + } + ) + } + add { + LeadingIconToolbarTab( + label = workUserProfile.label, + leadingIcon = Icons.Outlined.Work, + selected = currentPage == WORK_TAB_INDEX, + onClick = { + scope.launch { + pagerState.animateScrollToPage(WORK_TAB_INDEX) + } + }, + ) + } + } + } + + ScrollableFloatingToolbar( + modifier = modifier, + selectedTabIndex = currentPage, + tabs = tabs + ) +} + +private object LandingScreenTwoPaneDimens { + val contentShape = RoundedCornerShape(24.dp) + val pagerItemsSpacing = 8.dp + + fun leftPaneContentBottomPadding(hasFloatingToolbar: Boolean) = if (hasFloatingToolbar) { + 56.dp + } else 0.dp + + const val TABS_COUNT_WITH_WORK_PROFILE = 2 + const val TABS_COUNT_WITHOUT_WORK_PROFILE = 1 + + const val PERSONAL_TAB_INDEX = 0 + const val WORK_TAB_INDEX = 1 + const val DEFAULT_SELECTED_TAB = PERSONAL_TAB_INDEX +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt new file mode 100644 index 0000000000..22356dd21c --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import com.android.launcher3.widgetpicker.domain.interactor.WidgetAppIconsInteractor +import com.android.launcher3.widgetpicker.domain.interactor.WidgetsInteractor +import com.android.launcher3.widgetpicker.shared.model.WidgetAppIcon +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.shared.model.WidgetId +import com.android.launcher3.widgetpicker.shared.model.WidgetPreview +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfile +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfileType +import com.android.launcher3.widgetpicker.ui.ViewModel +import com.android.launcher3.widgetpicker.ui.model.DisplayableWidgetApp +import com.android.launcher3.widgetpicker.ui.model.DisplayableWidgetApp.Companion.getWidgetIdsForApp +import com.android.launcher3.widgetpicker.ui.model.WidgetSizeGroup +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import kotlinx.coroutines.awaitCancellation +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch + +/** + * A view model responsible for providing the data to the landing screen UI within the full catalog + * of widgets in widget picker. + */ +class LandingScreenViewModel @AssistedInject constructor( + private val widgetsInteractor: WidgetsInteractor, + private val widgetAppIconsInteractor: WidgetAppIconsInteractor +) : ViewModel { + override suspend fun onInit() { + coroutineScope { + launch { initBrowseWidgets() } + launch { initBrowseWidgetPreviews() } + launch { initWorkWidgetPreviews() } + launch { initFeaturedWidgets() } + launch { initAppIcons() } + + awaitCancellation() + } + } + + /** Data backing the browse section in the landing screen. */ + var browseWidgetsState by mutableStateOf(BrowseWidgetsState.NoData) + private set + + /** Previews for the widgets shown for personal tab in browse section of landing screen. */ + var personalWidgetsPreviewsState by mutableStateOf(PreviewsState()) + private set + + /** Previews for the widgets shown for work tab in browse section of landing screen. */ + var workWidgetsPreviewState by mutableStateOf(PreviewsState()) + private set + + /** Data about all app icons shown on landing screen. */ + var appIconsState by mutableStateOf(AppIconsState()) + private set + + /** + * Id of the app that is currently selected / expanded in personal list of apps. When null, + * implies none of the apps is expanded. + */ + var selectedPersonalAppId by mutableStateOf(null) + private set + private val _selectedPersonalWidgetAppWidgetIds = snapshotFlow { + val selectedId = selectedPersonalAppId + val currentBrowseState = browseWidgetsState + when { + selectedId != null && currentBrowseState is BrowseWidgetsState.Data -> + currentBrowseState.personalWidgetApps.getWidgetIdsForApp(selectedId) + + else -> + listOf() + } + } + + /** + * Id of the app that is currently selected / expanded in work list of apps. When null, + * implies none of the apps is expanded. + */ + var selectedWorkAppId by mutableStateOf(null) + private set + private val _selectedWorkWidgetAppWidgetIds = snapshotFlow { + val selectedId = selectedWorkAppId + val currentBrowseState = browseWidgetsState + when { + selectedId != null && currentBrowseState is BrowseWidgetsState.Data -> + currentBrowseState.workWidgetApps.getWidgetIdsForApp(selectedId) + + else -> + listOf() + } + } + + /** Data backing the featured section in landing screen; holds widgets that are featured. */ + var featuredWidgetsState by mutableStateOf(FeaturedWidgetsState()) + private set + + /** Preview information about the widgets shown in the featured section. */ + var featuredWidgetPreviewsState by mutableStateOf(PreviewsState()) + private set + + private suspend fun initBrowseWidgets() { + widgetsInteractor.getWidgetAppsByProfile().collect { result -> + val personalEntry = + result.entries.find { it.key.type == WidgetUserProfileType.PERSONAL } + val workEntry = result.entries.find { it.key.type == WidgetUserProfileType.WORK } + browseWidgetsState = if (personalEntry == null) { + BrowseWidgetsState.NoData + } else { + BrowseWidgetsState.Data( + personalProfile = personalEntry.key, + personalWidgetApps = personalEntry.value.map { + DisplayableWidgetApp.fromWidgetApp(it) + }, + workProfile = workEntry?.key, + workWidgetApps = workEntry?.value?.map { + DisplayableWidgetApp.fromWidgetApp(it) + } ?: emptyList(), + ) + } + } + + awaitCancellation() + } + + private suspend fun initBrowseWidgetPreviews() { + _selectedPersonalWidgetAppWidgetIds.collect { ids -> + personalWidgetsPreviewsState = + PreviewsState( + personalWidgetsPreviewsState.previews + ids.associateWith { + widgetsInteractor.getWidgetPreview( + it + ) + }) + } + + awaitCancellation() + } + + private suspend fun initWorkWidgetPreviews() { + _selectedWorkWidgetAppWidgetIds.collect { ids -> + workWidgetsPreviewState = + PreviewsState(workWidgetsPreviewState.previews + ids.associateWith { + widgetsInteractor.getWidgetPreview( + it + ) + }) + } + + awaitCancellation() + } + + private suspend fun initFeaturedWidgets() { + widgetsInteractor.getFeaturedWidgets().collect { result -> + featuredWidgetsState = FeaturedWidgetsState(result.groupBy { + Pair(it.sizeInfo.containerWidthPx, it.sizeInfo.containerHeightPx) + }.map { (containerSize, value) -> + WidgetSizeGroup( + previewContainerWidthPx = containerSize.first, + previewContainerHeightPx = containerSize.second, + widgets = value + ) + }, result.size) + + featuredWidgetPreviewsState = + PreviewsState(result.associate { res -> + res.id to widgetsInteractor.getWidgetPreview(res.id) + }) + } + awaitCancellation() + } + + private suspend fun initAppIcons() { + widgetAppIconsInteractor.getAllWidgetAppIcons().collect { result -> + appIconsState = AppIconsState(icons = result) + } + awaitCancellation() + } + + /** + * Callback to handle the toggle of a personal widget app; e.g. when user clicks an app to + * expand or collapse. + * + * @param id id of the widget app that was tapped; if its same as last id that was tapped, the + * [selectedPersonalAppId] is reset to null (aka toggled); if its different, then the provided + * id is set as the [selectedPersonalAppId]. To clear the [selectedPersonalAppId] invoke this + * with `null` + */ + fun onSelectedPersonalAppToggle(id: WidgetAppId?) { + selectedPersonalAppId = if (id == selectedPersonalAppId) { + null + } else { + id + } + } + + /** + * Callback to handle the toggle of a work widget app; e.g. when user clicks an app to expand or + * collapse. + * + * @param id id of the widget app that was tapped; if its same as last id that was tapped, the + * [selectedWorkAppId] is reset to null (aka toggled); if its different, then the provided id is + * set as the [selectedWorkAppId]. To clear the [selectedWorkAppId] invoke this with `null` + */ + fun onSelectedWorkAppToggle(id: WidgetAppId?) { + selectedWorkAppId = if (id == selectedWorkAppId) { + null + } else { + id + } + } + + /** A factory that should be injected whenever [LandingScreenViewModel] is required. */ + @AssistedFactory + interface Factory { + fun create(): LandingScreenViewModel + } +} + +/** Represents data that backs the widgets browsing experience in the full catalog. */ +@Stable +@Immutable +sealed class BrowseWidgetsState { + /** + * Information that is displayed when user taps browse tab. + * + * @param personalProfile data about the personal user profile that is used to display the + * personal tab; when there is no work profile, it is referred to as "browse" tab. + * @param personalWidgetApps list of apps (with their widgets) belonging to the personal user + * profile + * @param workProfile data about the work user profile that is used to display the work tab. + * @param workWidgetApps list of apps (with their widgets) belonging to the work user profile. + */ + data class Data( + val personalProfile: WidgetUserProfile, + val personalWidgetApps: List, + val workProfile: WidgetUserProfile?, + val workWidgetApps: List + ) : BrowseWidgetsState() + + /** No data loaded yet or unavailable for some reason. */ + data object NoData : BrowseWidgetsState() +} + +/** + * Represents widgets data to be shown in the "featured" section. + * @param sizeGroups groups holding widgets of similar sizes that can be presented in a coherent + * manner in the featured section. + * @param widgetsCount total count of widgets in the size groups (pre-computed so UI doesn't need to + * count). + */ +@Stable +@Immutable +data class FeaturedWidgetsState( + val sizeGroups: List = emptyList(), + val widgetsCount: Int = 0 +) + +/** + * State class holding preview information about widgets in a specific section (featured, browse, + * etc) + * @param previews previews per widget (keyed by its id) + */ +@Stable +@Immutable +data class PreviewsState( + val previews: Map = emptyMap() +) + +/** + * State class holding app icons shown in a specific section (featured, browse, etc.) + * @param icons icons per app (keyed by its app id) + */ +@Stable +@Immutable +data class AppIconsState( + val icons: Map = emptyMap() +) diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/model/DisplayableWidgetApp.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/model/DisplayableWidgetApp.kt index a0fbf0ddc2..ecdfa72593 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/model/DisplayableWidgetApp.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/model/DisplayableWidgetApp.kt @@ -18,6 +18,7 @@ package com.android.launcher3.widgetpicker.ui.model import androidx.compose.runtime.Immutable import androidx.compose.runtime.Stable +import com.android.launcher3.widgetpicker.shared.model.WidgetApp import com.android.launcher3.widgetpicker.shared.model.WidgetAppId /** @@ -35,4 +36,31 @@ data class DisplayableWidgetApp( val title: CharSequence?, val widgetSizeGroups: List, val widgetsCount: Int, -) +) { + companion object { + /** + * Helper function to create a [DisplayableWidgetApp] from a [WidgetApp]. + * Converts the list of widgets in the app to a list of [WidgetSizeGroup]s. + */ + fun fromWidgetApp(widgetApp: WidgetApp): DisplayableWidgetApp = + DisplayableWidgetApp( + id = widgetApp.id, + title = widgetApp.title, + widgetSizeGroups = widgetApp.widgets.groupBy { + Pair(it.sizeInfo.containerWidthPx, it.sizeInfo.containerHeightPx) + }.map { (containerSize, value) -> + WidgetSizeGroup( + previewContainerWidthPx = containerSize.first, + previewContainerHeightPx = containerSize.second, + widgets = value + ) + }, + widgetsCount = widgetApp.widgets.size, + ) + + fun List.getWidgetIdsForApp(appId: WidgetAppId) = + find { it.id == appId }?.widgetSizeGroups?.flatMap { group -> + group.widgets.map { it.id } + } ?: listOf() + } +} diff --git a/modules/widgetpicker/tests/Android.bp b/modules/widgetpicker/tests/Android.bp index 7b1c952b8c..e20eea3f43 100644 --- a/modules/widgetpicker/tests/Android.bp +++ b/modules/widgetpicker/tests/Android.bp @@ -94,6 +94,8 @@ filegroup { "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetsRepository.kt", "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetUsersRepository.kt", "multivalentTests/src/com/android/launcher3/widgetpicker/repository/FakeWidgetAppIconsRepository.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePaneTest.kt", + "multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPaneTest.kt", ], } @@ -103,8 +105,14 @@ android_test { srcs: [":widget-picker-multivalent-tests-src"], platform_apis: true, static_libs: [ + "widget_picker_ui", + "widget_picker_ui_components", "widget_picker_domain_layer", "widget_picker_data_repositories", + "androidx.compose.ui_ui-test-junit4", + "androidx.compose.ui_ui-test-manifest", + "androidx.compose.runtime_runtime", + "androidx.compose.ui_ui", "collector-device-lib-platform", "testables", "platform-test-annotations", @@ -141,8 +149,14 @@ android_robolectric_test { srcs: [":widget-picker-multivalent-tests-src"], java_resource_dirs: ["config"], static_libs: [ + "widget_picker_ui", + "widget_picker_ui_components", "widget_picker_domain_layer", "widget_picker_data_repositories", + "androidx.compose.runtime_runtime", + "androidx.compose.ui_ui", + "androidx.compose.ui_ui-test-junit4", + "androidx.compose.ui_ui-test-manifest", "kotlinx_coroutines_test", "platform-test-rules-deviceless", "testables", diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt index 74b14cfdfb..a4ec82c24d 100644 --- a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/TestUtils.kt @@ -33,9 +33,13 @@ object TestUtils { val personalUser: UserHandle = UserHandle.of(1) val workUser: UserHandle = UserHandle.of(10) + val PERSONAL_LABEL = "personal" + val WORK_LABEL = "work" + val widgetUserProfilePersonal = - WidgetUserProfile(type = WidgetUserProfileType.PERSONAL, label = "personal") - val widgetUserProfileWork = WidgetUserProfile(type = WidgetUserProfileType.WORK, label = "work") + WidgetUserProfile(type = WidgetUserProfileType.PERSONAL, label = PERSONAL_LABEL) + val widgetUserProfileWork = + WidgetUserProfile(type = WidgetUserProfileType.WORK, label = WORK_LABEL) private const val PACKAGE_NAME = "com.example.test" private val PERSONAL_WIDGET_APP_1 = buildWidgetAppId("AppOne", personalUser) diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePaneTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePaneTest.kt new file mode 100644 index 0000000000..851b7708c0 --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePaneTest.kt @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import android.platform.test.rule.AllowedDevices +import android.platform.test.rule.DeviceProduct +import android.platform.test.rule.LimitDevicesRule +import androidx.activity.ComponentActivity +import androidx.compose.runtime.Composable +import androidx.compose.ui.test.assertCountEquals +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.assertIsNotSelected +import androidx.compose.ui.test.assertIsSelected +import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.hasTextExactly +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onSiblings +import androidx.compose.ui.test.performClick +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.TestUtils +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_LABEL +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_LABEL +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.workUser +import com.android.launcher3.widgetpicker.domain.interactor.WidgetAppIconsInteractor +import com.android.launcher3.widgetpicker.domain.interactor.WidgetsInteractor +import com.android.launcher3.widgetpicker.domain.usecase.FilterWidgetsForHostUseCase +import com.android.launcher3.widgetpicker.domain.usecase.GroupWidgetAppsByProfileUseCase +import com.android.launcher3.widgetpicker.repository.FakeWidgetAppIconsRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetUsersRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import com.android.launcher3.widgetpicker.ui.rememberViewModel +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@AllowedDevices(allowed = [DeviceProduct.CF_PHONE]) +class LandingScreenSinglePaneTest { + @get:Rule + val limitDevicesRule = LimitDevicesRule() + @get:Rule + val composeTestRule = createAndroidComposeRule() + + @OptIn(ExperimentalCoroutinesApi::class) + private val testDispatcher = UnconfinedTestDispatcher() + private val testScope = TestScope(testDispatcher) + private val context = InstrumentationRegistry.getInstrumentation().context + + private lateinit var viewModel: LandingScreenViewModel + private val widgetsRepository = FakeWidgetsRepository() + private val widgetAppIconsRepository = FakeWidgetAppIconsRepository() + private val widgetsUsersRepository = FakeWidgetUsersRepository() + + private lateinit var featuredTabLabel: String + private lateinit var browseTabLabel: String + private val featuredWidgetA = PERSONAL_TEST_APPS[0].widgets[0] + private val featuredWidgetB = WORK_TEST_APPS[0].widgets[0] + + @Before + fun setUp() { + viewModel = LandingScreenViewModel( + widgetsInteractor = WidgetsInteractor( + widgetsRepository = widgetsRepository, + widgetUsersRepository = widgetsUsersRepository, + filterWidgetsForHostUseCase = FilterWidgetsForHostUseCase(WidgetHostInfo()), + getWidgetAppsByProfileUseCase = GroupWidgetAppsByProfileUseCase(), + backgroundContext = testDispatcher + ), + widgetAppIconsInteractor = WidgetAppIconsInteractor( + widgetAppIconsRepository = widgetAppIconsRepository, + widgetsRepository = widgetsRepository, + backgroundContext = testDispatcher + ) + ) + + featuredTabLabel = + context.resources.getString(R.string.featured_widgets_tab_label) + browseTabLabel = + context.resources.getString(R.string.browse_widgets_tab_label) + + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + widgetsRepository.seedFeaturedWidgets(setOf(featuredWidgetA.id, featuredWidgetB.id)) + widgetsUsersRepository.seedUserProfiles( + WidgetUserProfiles( + personal = TestUtils.widgetUserProfilePersonal, + work = TestUtils.widgetUserProfileWork + ), + workProfileUser = workUser + ) + } + + @Composable + private fun SinglePaneTestContent() { + val viewModel = rememberViewModel { viewModel } + + LandingScreen( + isCompact = true, + onEnterSearchMode = {}, + viewModel = viewModel, + ) + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun showsFeaturedSectionByDefault() = testScope.runTest { + composeTestRule.setContent { SinglePaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + // Toolbar tabs state + composeTestRule.onNode(hasTextExactly(featuredTabLabel)) + .assertIsSelected() + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().assertIsNotSelected() + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().assertIsNotSelected() + // Featured Widgets state + composeTestRule.onNode(hasTextExactly(featuredWidgetA.label)).assertExists() + composeTestRule.onNode(hasTextExactly(featuredWidgetB.label)).assertExists() + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun clickingOnAnotherTabShowsAppsList() = testScope.runTest { + composeTestRule.setContent { SinglePaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().performClick() + runCurrent() + composeTestRule.waitForIdle() + + // Toolbar tabs state + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().assertIsSelected() + composeTestRule.onNode(hasTextExactly(featuredTabLabel)) + .assertIsNotSelected() + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().assertIsNotSelected() + // No recommendations showing + composeTestRule.onNode(hasTextExactly(featuredWidgetA.label)).assertIsNotDisplayed() + // Has list of personal apps showing + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists() + // But not the work apps + composeTestRule.onNode(hasText(WORK_TEST_APPS[0].title!!.toString())) + .assertIsNotDisplayed() + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun noWorkProfile() = testScope.runTest { + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS) + widgetsRepository.seedFeaturedWidgets(setOf(featuredWidgetA.id)) + widgetsUsersRepository.seedUserProfiles( + WidgetUserProfiles( + personal = TestUtils.widgetUserProfilePersonal, + work = null + ), + workProfileUser = null + ) + + composeTestRule.setContent { SinglePaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + // Toolbar tabs state shows 2 tabs (featured / browse) + composeTestRule.onNode(hasTextExactly(featuredTabLabel)) + .assertIsSelected() + composeTestRule.onNode(hasTextExactly(browseTabLabel)).assertExists().assertIsNotSelected() + composeTestRule.onNode(hasTextExactly(browseTabLabel)).onSiblings().assertCountEquals(1) + // featured widgets showing + composeTestRule.onNode(hasTextExactly(featuredWidgetA.label)).assertIsDisplayed() + // Widget apps list is not showing. + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertIsNotDisplayed() + } +} diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPaneTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPaneTest.kt new file mode 100644 index 0000000000..f64008ddda --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPaneTest.kt @@ -0,0 +1,261 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing + +import android.platform.test.rule.AllowedDevices +import android.platform.test.rule.DeviceProduct +import android.platform.test.rule.LimitDevicesRule +import androidx.activity.ComponentActivity +import androidx.compose.runtime.Composable +import androidx.compose.ui.semantics.SemanticsProperties +import androidx.compose.ui.semantics.getOrNull +import androidx.compose.ui.test.ExperimentalTestApi +import androidx.compose.ui.test.SemanticsMatcher +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed +import androidx.compose.ui.test.assertIsNotSelected +import androidx.compose.ui.test.assertIsSelected +import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.hasTextExactly +import androidx.compose.ui.test.isSelected +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.performClick +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.TestUtils +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_LABEL +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_LABEL +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.workUser +import com.android.launcher3.widgetpicker.domain.interactor.WidgetAppIconsInteractor +import com.android.launcher3.widgetpicker.domain.interactor.WidgetsInteractor +import com.android.launcher3.widgetpicker.domain.usecase.FilterWidgetsForHostUseCase +import com.android.launcher3.widgetpicker.domain.usecase.GroupWidgetAppsByProfileUseCase +import com.android.launcher3.widgetpicker.repository.FakeWidgetAppIconsRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetUsersRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import com.android.launcher3.widgetpicker.ui.rememberViewModel +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@AllowedDevices(allowed = [DeviceProduct.CF_TABLET]) +class LandingScreenTwoPaneTest { + @get:Rule + val limitDevicesRule = LimitDevicesRule() + @get:Rule + val composeTestRule = createAndroidComposeRule() + + @OptIn(ExperimentalCoroutinesApi::class) + private val testDispatcher = UnconfinedTestDispatcher() + private val testScope = TestScope(testDispatcher) + private val context = InstrumentationRegistry.getInstrumentation().context + + private lateinit var viewModel: LandingScreenViewModel + private val widgetsRepository = FakeWidgetsRepository() + private val widgetAppIconsRepository = FakeWidgetAppIconsRepository() + private val widgetsUsersRepository = FakeWidgetUsersRepository() + + private lateinit var featuredTabLabel: String + private lateinit var browseTabLabel: String + private val featuredWidgetA = PERSONAL_TEST_APPS[0].widgets[0] + private val featuredWidgetB = WORK_TEST_APPS[0].widgets[0] + + @Before + fun setUp() { + viewModel = LandingScreenViewModel( + widgetsInteractor = WidgetsInteractor( + widgetsRepository = widgetsRepository, + widgetUsersRepository = widgetsUsersRepository, + filterWidgetsForHostUseCase = FilterWidgetsForHostUseCase(WidgetHostInfo()), + getWidgetAppsByProfileUseCase = GroupWidgetAppsByProfileUseCase(), + backgroundContext = testDispatcher, + ), + widgetAppIconsInteractor = WidgetAppIconsInteractor( + widgetAppIconsRepository = widgetAppIconsRepository, + widgetsRepository = widgetsRepository, + backgroundContext = testDispatcher + ) + ) + + featuredTabLabel = + context.resources.getString(R.string.featured_widgets_tab_label) + browseTabLabel = + context.resources.getString(R.string.browse_widgets_tab_label) + + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + widgetsRepository.seedFeaturedWidgets(setOf(featuredWidgetA.id, featuredWidgetB.id)) + widgetsUsersRepository.seedUserProfiles( + WidgetUserProfiles( + personal = TestUtils.widgetUserProfilePersonal, + work = TestUtils.widgetUserProfileWork + ), + workProfileUser = workUser + ) + } + + @Composable + private fun TwoPaneTestContent() { + val viewModel = rememberViewModel { viewModel } + + LandingScreen( + isCompact = false, + onEnterSearchMode = {}, + viewModel = viewModel, + ) + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun showsFeaturedSectionByDefault() = testScope.runTest { + composeTestRule.setContent { TwoPaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + // Featured tab as list item + composeTestRule.onNode(hasText(featuredTabLabel)).assertIsSelected() + // And toolbar also simultaneously shows one of the tabs as selected + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().assertIsSelected() + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().assertIsNotSelected() + // Featured Widgets state + composeTestRule.onNode(hasTextExactly(featuredWidgetA.label)).assertExists() + composeTestRule.onNode(hasTextExactly(featuredWidgetB.label)).assertExists() + // List on left showing personal apps + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists().assertIsNotSelected() + } + + @OptIn(ExperimentalCoroutinesApi::class, ExperimentalTestApi::class) + @Test + fun clickingOnWorkTab_updatesAppsListInLeftPane() = testScope.runTest { + composeTestRule.setContent { TwoPaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().assertIsSelected() + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().assertIsNotSelected() + + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().performClick() + runCurrent() + composeTestRule.waitForIdle() + + composeTestRule.waitUntilAtLeastOneExists(hasTextExactly(WORK_LABEL) and isSelected()) + + // Toolbar tabs state + composeTestRule.onNode(hasTextExactly(WORK_LABEL)).assertExists().assertIsSelected() + composeTestRule.onNode(hasTextExactly(PERSONAL_LABEL)).assertExists().assertIsNotSelected() + // Selecting toolbar tabs in 2-pane view doesn't reset what's showing in right pane; one has + // to click on specific app header to see the widgets. + composeTestRule.onNode(hasText(featuredTabLabel)).assertIsSelected() + // No recommendations showing + composeTestRule.onNode(hasText(featuredWidgetA.label)).assertIsDisplayed() + // Has list of work apps showing + composeTestRule.onNode(hasText(WORK_TEST_APPS[0].title!!.toString())) + .assertExists() + .assertIsNotSelected() + // But not the personal apps + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertIsNotDisplayed() + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun selectingAppOnLeft_updatesRightPane() = testScope.runTest { + val appToSelect = PERSONAL_TEST_APPS[1].title!!.toString() + + composeTestRule.setContent { TwoPaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + // Feature tab selected and right pane title indicating the same. + composeTestRule.onNode(hasText(featuredTabLabel)).assertIsSelected() + val rightPaneTitleBefore = context.resources.getString( + R.string.widget_picker_right_pane_accessibility_label, + featuredTabLabel + ) + composeTestRule.onNode(SemanticsMatcher("Right paneTitle before selecting an app on left") { + it.config.getOrNull(SemanticsProperties.PaneTitle) == rightPaneTitleBefore + }).assertExists() + + composeTestRule.onNode(hasText(appToSelect)).assertExists().performClick() + runCurrent() + composeTestRule.waitForIdle() + + // Now app is selected and featured tab is not. + composeTestRule.onNode(hasText(appToSelect)).assertIsSelected() + composeTestRule.onNode(hasText(featuredTabLabel)).assertIsNotSelected() + // widgets for the selected app are showing + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].widgets[0].label)) + .assertIsDisplayed() + val rightPaneTitleAfter = context.resources.getString( + R.string.widget_picker_right_pane_accessibility_label, + appToSelect + ) + composeTestRule.onNode(SemanticsMatcher("Right PaneTitle after clicking on app") { + it.config.getOrNull(SemanticsProperties.PaneTitle) == rightPaneTitleAfter + }).assertExists() + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun noWorkProfile_noFloatingToolbar() = testScope.runTest { + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS) + widgetsRepository.seedFeaturedWidgets(setOf(featuredWidgetA.id)) + widgetsUsersRepository.seedUserProfiles( + profiles = WidgetUserProfiles( + personal = TestUtils.widgetUserProfilePersonal, + work = null + ), + workProfileUser = null + ) + + composeTestRule.setContent { TwoPaneTestContent() } + + runCurrent() + composeTestRule.waitForIdle() + + // Featured list header + composeTestRule.onNode(hasText(featuredTabLabel)) + .assertIsSelected() + // No toolbar i.e. browse tab + composeTestRule.onNode(hasTextExactly(browseTabLabel)).assertDoesNotExist() + // featured widgets showing + composeTestRule.onNode(hasTextExactly(featuredWidgetA.label)) + .assertExists() + .assertIsDisplayed() + // But not other widgets + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].widgets[0].label)) + .assertDoesNotExist() + // Widget apps list shown on left + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertIsDisplayed().assertIsNotSelected() + } +} From df07059bd4775f7261f82b7a824c440b5ea2f658 Mon Sep 17 00:00:00 2001 From: Shamali Patwa Date: Fri, 23 May 2025 12:12:27 -0700 Subject: [PATCH 23/25] Add widget picker search screen. This adds the search screen and view model logic. It uses the same composable structure as the landing screen. Bug: 408283627 Flag: EXEMPT independent module Test: Unit tests Change-Id: Ic83090be21b31a4f1b416284f78d5a05d5cd2cdc --- modules/widgetpicker/Android.bp | 9 + .../ui/components/TitledBottomSheet.kt | 6 + .../ui/components/WidgetsSearchBar.kt | 9 +- .../ui/fullcatalog/FullWidgetsCatalog.kt | 89 +++++++ .../FullWidgetsCatalogViewModel.kt | 72 ++++++ .../screens/search/SearchScreen.kt | 218 ++++++++++++++++++ .../screens/search/SearchScreenViewModel.kt | 155 +++++++++++++ .../screens/search/SearchScreenTest.kt | 212 +++++++++++++++++ 8 files changed, 768 insertions(+), 2 deletions(-) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalog.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalogViewModel.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreen.kt create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenViewModel.kt create mode 100644 modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenTest.kt diff --git a/modules/widgetpicker/Android.bp b/modules/widgetpicker/Android.bp index 9ca26f06b5..379cb1de38 100644 --- a/modules/widgetpicker/Android.bp +++ b/modules/widgetpicker/Android.bp @@ -42,6 +42,10 @@ android_library { static_libs: [ "dagger2", "widget_picker_dagger_annotations", + "widget_picker_data_repositories", + "widget_picker_shared_data_types", + "widget_picker_domain_layer", + "widget_picker_ui", ], } @@ -163,10 +167,15 @@ android_library { min_sdk_version: min_launcher3_sdk_version, srcs: [ "src/com/android/launcher3/widgetpicker/ui/ViewModel.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalog.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalogViewModel.kt", "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreen.kt", "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenSinglePane.kt", "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenTwoPane.kt", "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/landing/LandingScreenViewModel.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreen.kt", + "src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenViewModel.kt", + "src/com/android/launcher3/widgetpicker/ui/WidgetPickerEventListeners.kt", ], static_libs: [ "widget_picker_ui_components", diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/TitledBottomSheet.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/TitledBottomSheet.kt index e690bb88c9..415c796f1d 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/TitledBottomSheet.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/TitledBottomSheet.kt @@ -168,6 +168,12 @@ private object DragHandleDimens { val dragHandleWidth = 32.dp } +/** Default values for the [TitledBottomSheet] component. */ +object TitledBottomSheetDefaults { + /** Animation duration for the bottom sheet to fully expand. */ + const val SLIDE_IN_ANIMATION_DURATION: Long = 400L +} + /** * Describes how should the default height of the bottom sheet look like (excluding the insets such * as status bar). diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetsSearchBar.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetsSearchBar.kt index bd5e097880..1889f4c474 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetsSearchBar.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/components/WidgetsSearchBar.kt @@ -53,6 +53,7 @@ import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -92,6 +93,7 @@ fun WidgetsSearchBar( val interactionSource = remember { MutableInteractionSource() } val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current + val keyboardController = LocalSoftwareKeyboardController.current val exitSearchMode = { onSearch("") @@ -114,7 +116,10 @@ fun WidgetsSearchBar( singleLine = true, cursorBrush = SolidColor(MaterialTheme.colorScheme.primary), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions(onSearch = { onSearch(text) }), + keyboardActions = KeyboardActions(onSearch = { + keyboardController?.hide() + onSearch(text) + }), interactionSource = interactionSource, textStyle = WidgetsSearchBarDefaults.textStyle, decorationBox = @@ -214,7 +219,7 @@ private fun BackButton(onClick: () -> Unit) { IconButton(colors = WidgetsSearchBarDefaults.iconButtonColors, onClick = onClick) { Icon( imageVector = Icons.AutoMirrored.Outlined.ArrowBack, - contentDescription = stringResource(R.string.widget_search_bar_clear_button_label), + contentDescription = stringResource(R.string.widget_search_bar_back_button_label), ) } } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalog.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalog.kt new file mode 100644 index 0000000000..6242a5f1c8 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalog.kt @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog + +import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass +import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import com.android.launcher3.widgetpicker.WidgetPickerEventListeners +import com.android.launcher3.widgetpicker.ui.components.ModalBottomSheetHeightStyle +import com.android.launcher3.widgetpicker.ui.components.TitledBottomSheet +import com.android.launcher3.widgetpicker.ui.components.TitledBottomSheetDefaults +import com.android.launcher3.widgetpicker.ui.fullcatalog.FullWidgetsCatalogViewModel.Screen +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreen +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.search.SearchScreen +import com.android.launcher3.widgetpicker.ui.rememberViewModel +import com.android.launcher3.widgetpicker.ui.windowsizeclass.calculateWindowInfo +import javax.inject.Inject + +/** + * A catalog of all widgets available on device. + * + * When opened, first shows a landing page that comprises of the featured widgets and the list of + * apps hosting widgets. User can enter search mode by tapping the search bar and see matching + * results. + * + */ +class FullWidgetsCatalog @Inject constructor( + private val viewModelFactory: FullWidgetsCatalogViewModel.Factory, +) { + @Composable + fun Content( + eventListeners: WidgetPickerEventListeners, + ) { + val viewModel: FullWidgetsCatalogViewModel = + rememberViewModel( + animationDelay = TitledBottomSheetDefaults.SLIDE_IN_ANIMATION_DURATION + ) { + viewModelFactory.create() + } + val windowInfo = LocalConfiguration.current.calculateWindowInfo() + val isCompactWidth = + windowInfo.windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact + val isCompactHeight = + windowInfo.windowSizeClass.heightSizeClass == WindowHeightSizeClass.Compact + + TitledBottomSheet( + title = viewModel.title.takeIf { !isCompactHeight }, + modifier = Modifier, + description = null, + heightStyle = ModalBottomSheetHeightStyle.FILL_HEIGHT, + showDragHandle = true, + onDismissRequest = { eventListeners.onClose() }, + ) { + when (viewModel.activeScreen) { + Screen.LANDING -> { + LandingScreen( + isCompact = isCompactWidth, + onEnterSearchMode = { viewModel.onActiveScreenChange(Screen.SEARCH) }, + viewModel = viewModel.landingScreenViewModel, + ) + } + + Screen.SEARCH -> { + SearchScreen( + isCompact = isCompactWidth, + onExitSearchMode = { viewModel.onActiveScreenChange(Screen.LANDING) }, + viewModel = viewModel.searchScreenViewModel, + ) + } + } + } + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalogViewModel.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalogViewModel.kt new file mode 100644 index 0000000000..26d57f9d43 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/FullWidgetsCatalogViewModel.kt @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import com.android.launcher3.widgetpicker.WidgetPickerHostInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.ui.ViewModel +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.LandingScreenViewModel +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.search.SearchScreenViewModel +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import kotlinx.coroutines.awaitCancellation +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch + +/** + * Top-level view model for the widget picker view that shows a full catalog of widgets available + * on the device. + */ +class FullWidgetsCatalogViewModel @AssistedInject constructor( + landingScreenViewModelFactory: LandingScreenViewModel.Factory, + searchScreenViewModelFactory: SearchScreenViewModel.Factory, + @WidgetPickerHostInfo private val hostInfo: WidgetHostInfo, +) : ViewModel { + val landingScreenViewModel = landingScreenViewModelFactory.create() + val searchScreenViewModel = searchScreenViewModelFactory.create() + + val title: String? = hostInfo.title + val description: String? = hostInfo.description + var activeScreen by mutableStateOf(Screen.LANDING) + private set + + override suspend fun onInit() { + coroutineScope { + launch { landingScreenViewModel.onInit() } + launch { searchScreenViewModel.onInit() } + + awaitCancellation() + } + } + + fun onActiveScreenChange(screen: Screen) { + activeScreen = screen + } + + @AssistedFactory + interface Factory { + fun create(): FullWidgetsCatalogViewModel + } + + enum class Screen { + LANDING, + SEARCH + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreen.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreen.kt new file mode 100644 index 0000000000..e61d6a24f9 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreen.kt @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.search + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.ui.components.AppHeaderDescriptionStyle +import com.android.launcher3.widgetpicker.ui.components.SinglePaneLayout +import com.android.launcher3.widgetpicker.ui.components.TwoPaneLayout +import com.android.launcher3.widgetpicker.ui.components.WidgetAppHeaderStyle +import com.android.launcher3.widgetpicker.ui.components.WidgetAppsList +import com.android.launcher3.widgetpicker.ui.components.WidgetsGrid +import com.android.launcher3.widgetpicker.ui.components.WidgetsSearchBar +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.AppIconsState +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.PreviewsState + +/** + * Screen showing the search results in the widget picker when browsing the full widget catalog. + */ +@Composable +fun SearchScreen( + isCompact: Boolean, + onExitSearchMode: () -> Unit, + viewModel: SearchScreenViewModel, +) { + SearchScreen( + isCompact = isCompact, + input = viewModel.query, + resultsState = viewModel.resultsState, + selectedWidgetAppId = viewModel.selectedWidgetAppId, + appIconsState = viewModel.appIconsState, + widgetPreviewsState = viewModel.previewsState, + onSearch = viewModel::onQueryChange, + onSelectedWidgetAppToggle = viewModel::onSelectedWidgetAppToggle, + onExitSearchMode = onExitSearchMode, + ) +} + +@Composable +private fun SearchScreen( + isCompact: Boolean, + input: String, + resultsState: SearchResultsState, + selectedWidgetAppId: WidgetAppId?, + appIconsState: AppIconsState, + widgetPreviewsState: PreviewsState, + onSearch: (String) -> Unit, + onSelectedWidgetAppToggle: (id: WidgetAppId) -> Unit, + onExitSearchMode: () -> Unit, +) { + val searchBar: @Composable () -> Unit = { + WidgetsSearchBar( + text = input, + isSearching = true, + onSearch = onSearch, + onToggleSearchMode = { searchModeEnabled -> + if (!searchModeEnabled) { + onExitSearchMode() + } + }, + modifier = Modifier.fillMaxWidth(), + ) + } + if (isCompact) { + SearchScreenSinglePane( + searchBar = searchBar, + resultsState = resultsState, + selectedWidgetAppId = selectedWidgetAppId, + appIconsState = appIconsState, + widgetPreviewsState = widgetPreviewsState, + onSelectedWidgetAppChange = onSelectedWidgetAppToggle + ) + } else { + SearchScreenTwoPane( + searchBar = searchBar, + resultsState = resultsState, + selectedWidgetAppId = selectedWidgetAppId, + appIconsState = appIconsState, + widgetPreviewsState = widgetPreviewsState, + onSelectedWidgetAppChange = onSelectedWidgetAppToggle + ) + } +} + +@Composable +private fun SearchScreenSinglePane( + searchBar: @Composable () -> Unit, + resultsState: SearchResultsState, + selectedWidgetAppId: WidgetAppId?, + appIconsState: AppIconsState, + widgetPreviewsState: PreviewsState, + onSelectedWidgetAppChange: (id: WidgetAppId) -> Unit +) { + SinglePaneLayout( + searchBar = searchBar, + content = { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = resultsState.results, + selectedWidgetAppId = selectedWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.EXPANDABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.COMBINED_WIDGETS_TITLE, + onWidgetAppClick = { widgetApp -> + onSelectedWidgetAppChange(widgetApp.id) + }, + appIcons = appIconsState.icons, + widgetPreviews = widgetPreviewsState.previews + ) + } + } + ) +} + +@Composable +fun SearchScreenTwoPane( + searchBar: @Composable () -> Unit, + resultsState: SearchResultsState, + selectedWidgetAppId: WidgetAppId?, + appIconsState: AppIconsState, + widgetPreviewsState: PreviewsState, + onSelectedWidgetAppChange: (id: WidgetAppId) -> Unit +) { + TwoPaneLayout( + searchBar = searchBar, + leftContent = { + Box(modifier = Modifier.fillMaxSize()) { + WidgetAppsList( + modifier = Modifier.fillMaxSize(), + widgetApps = resultsState.results, + selectedWidgetAppId = selectedWidgetAppId, + widgetAppHeaderStyle = WidgetAppHeaderStyle.CLICKABLE, + headerDescriptionStyle = AppHeaderDescriptionStyle.COMBINED_WIDGETS_TITLE, + appIcons = appIconsState.icons, + widgetPreviews = widgetPreviewsState.previews, + onWidgetAppClick = { widgetApp -> + onSelectedWidgetAppChange(widgetApp.id) + }, + ) + } + }, + rightPaneTitle = rightPaneTitle( + resultsState = resultsState, + selectedWidgetAppId = selectedWidgetAppId, + ), + rightContent = { + selectedWidgetAppId?.let { id -> + val selectedWidgets = + remember(id, resultsState) { + id.let { selectedId -> + resultsState.results.find { + it.id == selectedId + }?.widgetSizeGroups + } ?: listOf() + } + + WidgetsGrid( + modifier = Modifier + .fillMaxWidth() + .wrapContentSize() + .verticalScroll(rememberScrollState()), + showAllWidgetDetails = true, + widgetSizeGroups = selectedWidgets, + previews = widgetPreviewsState.previews, + appIcons = appIconsState.icons + ) + } + }, + ) +} + +/** + * Title for the right pane that is updated when selected tab on left changes. When set, a talkback + * user can use four finger swipe down to switch to right pane. + */ +@Composable +private fun rightPaneTitle( + resultsState: SearchResultsState, + selectedWidgetAppId: WidgetAppId? +): String? { + val selectedAppName: CharSequence? = + selectedWidgetAppId?.let { selectedId -> + resultsState.results.find { it.id == selectedId }?.title + } + + return if (selectedAppName != null) { + stringResource( + R.string.widget_picker_right_pane_accessibility_label, + selectedAppName + ) + } else { + null + } +} diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenViewModel.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenViewModel.kt new file mode 100644 index 0000000000..f2b18bdb29 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenViewModel.kt @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.search + +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshotFlow +import com.android.launcher3.widgetpicker.domain.interactor.WidgetAppIconsInteractor +import com.android.launcher3.widgetpicker.domain.interactor.WidgetsInteractor +import com.android.launcher3.widgetpicker.shared.model.WidgetAppId +import com.android.launcher3.widgetpicker.ui.ViewModel +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.AppIconsState +import com.android.launcher3.widgetpicker.ui.fullcatalog.screens.landing.PreviewsState +import com.android.launcher3.widgetpicker.ui.model.DisplayableWidgetApp +import com.android.launcher3.widgetpicker.ui.model.DisplayableWidgetApp.Companion.getWidgetIdsForApp +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import kotlinx.coroutines.awaitCancellation +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.launch + +/** + * View model for the search screen that allows searching for all widgets in the full catalog view + * of the widget picker. + */ +class SearchScreenViewModel @AssistedInject constructor( + private val widgetsInteractor: WidgetsInteractor, + private val widgetAppIconsInteractor: WidgetAppIconsInteractor +) : ViewModel { + /** Data backing the results (widget apps & their widgets) that match the provided input. */ + var resultsState by mutableStateOf(SearchResultsState()) + private set + + /** Current query that is input in search bar by the user. */ + var query by mutableStateOf("") + private set + + /** Data about all app icons shown on search screen. */ + var appIconsState by mutableStateOf(AppIconsState()) + private set + + /** + * Id of the app that is currently selected / expanded in search results. When null, implies + * none of the apps is expanded. + */ + var selectedWidgetAppId by mutableStateOf(null) + private val _selectedWidgetAppWidgetIds = snapshotFlow { + selectedWidgetAppId?.let { + resultsState.results.getWidgetIdsForApp(it) + } ?: listOf() + } + + /** Preview information about the widgets in the search results. */ + var previewsState by mutableStateOf(PreviewsState()) + private set + + override suspend fun onInit() { + coroutineScope { + launch { initializeSearchResults() } + launch { initAppIcons() } + launch { initialWidgetPreviews() } + } + } + + private suspend fun initializeSearchResults() { + snapshotFlow { query }.collectLatest { newInput -> + if (newInput.isEmpty()) { + resultsState = SearchResultsState() + } else { + widgetsInteractor.searchWidgetApps(query).collectLatest { matchedResults -> + resultsState = SearchResultsState( + results = matchedResults.map { DisplayableWidgetApp.fromWidgetApp(it) } + ) + } + } + } + + awaitCancellation() + } + + private suspend fun initAppIcons() { + widgetAppIconsInteractor.getAllWidgetAppIcons().collect { result -> + appIconsState = AppIconsState(icons = result) + } + + awaitCancellation() + } + + private suspend fun initialWidgetPreviews() { + _selectedWidgetAppWidgetIds.collect { ids -> + previewsState = + PreviewsState( + previewsState.previews + + ids.associateWith { widgetsInteractor.getWidgetPreview(it) }) + } + + awaitCancellation() + } + + /** + * Callback for when user types a search query and its changed. Updates the [query] state + * so that the search results can update as well. + */ + fun onQueryChange(query: String) { + this.query = query + } + + /** + * Callback to handle the visibility toggle of a widget app in search results; e.g. when user + * clicks an app to expand or collapse. + * + * @param id id of the widget app that was tapped; if its same as last id that was tapped, the + * [selectedWidgetAppId] is reset to null (aka toggled); if its different, then the provided id + * is set as the [selectedWidgetAppId]. To clear the [selectedWidgetAppId] invoke this with + * `null` + */ + fun onSelectedWidgetAppToggle(id: WidgetAppId) { + selectedWidgetAppId = if (selectedWidgetAppId != id) { + id + } else { + null + } + } + + /** A factory that should be injected whenever [SearchScreenViewModel] is required. */ + @AssistedFactory + interface Factory { + fun create(): SearchScreenViewModel + } +} + +/** Represents data that backs the list of widget apps (and their widgets) shown in the results. */ +@Stable +@Immutable +data class SearchResultsState( + val results: List = emptyList() +) diff --git a/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenTest.kt b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenTest.kt new file mode 100644 index 0000000000..3e5f332baa --- /dev/null +++ b/modules/widgetpicker/tests/multivalentTests/src/com/android/launcher3/widgetpicker/ui/fullcatalog/screens/search/SearchScreenTest.kt @@ -0,0 +1,212 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker.ui.fullcatalog.screens.search + +import android.platform.test.rule.AllowedDevices +import android.platform.test.rule.DeviceProduct +import android.platform.test.rule.LimitDevicesRule +import androidx.activity.ComponentActivity +import androidx.compose.runtime.Composable +import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onNodeWithContentDescription +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performTextInput +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import com.android.launcher3.widgetpicker.R +import com.android.launcher3.widgetpicker.TestUtils +import com.android.launcher3.widgetpicker.TestUtils.PERSONAL_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.WORK_TEST_APPS +import com.android.launcher3.widgetpicker.TestUtils.workUser +import com.android.launcher3.widgetpicker.domain.interactor.WidgetAppIconsInteractor +import com.android.launcher3.widgetpicker.domain.interactor.WidgetsInteractor +import com.android.launcher3.widgetpicker.domain.usecase.FilterWidgetsForHostUseCase +import com.android.launcher3.widgetpicker.domain.usecase.GroupWidgetAppsByProfileUseCase +import com.android.launcher3.widgetpicker.repository.FakeWidgetAppIconsRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetUsersRepository +import com.android.launcher3.widgetpicker.repository.FakeWidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.shared.model.WidgetUserProfiles +import com.android.launcher3.widgetpicker.ui.rememberViewModel +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runCurrent +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +@AllowedDevices(allowed = [DeviceProduct.CF_TABLET]) +class SearchScreenTest { + @get:Rule + val limitDevicesRule = LimitDevicesRule() + @get:Rule + val composeTestRule = createAndroidComposeRule() + + @OptIn(ExperimentalCoroutinesApi::class) + private val testDispatcher = UnconfinedTestDispatcher() + private val testScope = TestScope(testDispatcher) + private val context = InstrumentationRegistry.getInstrumentation().context + + private lateinit var viewModel: SearchScreenViewModel + private val widgetsRepository = FakeWidgetsRepository() + private val widgetAppIconsRepository = FakeWidgetAppIconsRepository() + private val widgetsUsersRepository = FakeWidgetUsersRepository() + + private lateinit var searchBarHint: String + private lateinit var clearButtonContentDescription: String + + @Before + fun setUp() { + viewModel = SearchScreenViewModel( + widgetsInteractor = WidgetsInteractor( + widgetsRepository = widgetsRepository, + widgetUsersRepository = widgetsUsersRepository, + filterWidgetsForHostUseCase = FilterWidgetsForHostUseCase(WidgetHostInfo()), + getWidgetAppsByProfileUseCase = GroupWidgetAppsByProfileUseCase(), + backgroundContext = testDispatcher, + ), + widgetAppIconsInteractor = WidgetAppIconsInteractor( + widgetAppIconsRepository = widgetAppIconsRepository, + widgetsRepository = widgetsRepository, + backgroundContext = testDispatcher + ), + ) + + searchBarHint = context.applicationContext.resources.getString( + R.string.widgets_search_bar_hint + ) + clearButtonContentDescription = + context.applicationContext.resources.getString(R.string.widget_search_bar_clear_button_label) + widgetsRepository.seedWidgets(PERSONAL_TEST_APPS + WORK_TEST_APPS) + widgetsUsersRepository.seedUserProfiles( + WidgetUserProfiles( + personal = TestUtils.widgetUserProfilePersonal, + work = TestUtils.widgetUserProfileWork + ), + workProfileUser = workUser + ) + } + + @Composable + private fun TestContent(isCompact: Boolean) { + val viewModel = rememberViewModel { viewModel } + + SearchScreen( + isCompact = isCompact, + onExitSearchMode = {}, + viewModel = viewModel, + ) + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun singlePane_showMatchingApps() = testScope.runTest { + composeTestRule.setContent { + TestContent( + isCompact = true + ) + } + + runCurrent() + composeTestRule.waitForIdle() + + val testInputOne = "PersonalWidget" + composeTestRule.onNodeWithText(searchBarHint) + .performTextInput(testInputOne) + + runCurrent() + composeTestRule.waitForIdle() + + // has both apps + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists() + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].title!!.toString())) + .assertExists() + + composeTestRule + .onNodeWithContentDescription(clearButtonContentDescription) + .performClick() + + runCurrent() + composeTestRule.waitForIdle() + + // change query + val testInputTwo = "PersonalWidget1A" + composeTestRule.onNodeWithText(searchBarHint).performTextInput(testInputTwo) + + runCurrent() + composeTestRule.waitForIdle() + + // has only app 1 + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists() + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].title!!.toString())) + .assertDoesNotExist() + } + + @OptIn(ExperimentalCoroutinesApi::class) + @Test + fun twoPane_showMatchingApps() = testScope.runTest { + composeTestRule.setContent { + TestContent( + isCompact = false + ) + } + + runCurrent() + composeTestRule.waitForIdle() + + val testInputOne = "PersonalWidget" + composeTestRule.onNodeWithText(searchBarHint) + .performTextInput(testInputOne) + + runCurrent() + composeTestRule.waitForIdle() + + // has both apps + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists() + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].title!!.toString())) + .assertExists() + + composeTestRule + .onNodeWithContentDescription(clearButtonContentDescription) + .performClick() + + runCurrent() + composeTestRule.waitForIdle() + + // change query + val testInputTwo = "PersonalWidget1A" + composeTestRule.onNodeWithText(searchBarHint).performTextInput(testInputTwo) + + runCurrent() + composeTestRule.waitForIdle() + + // has only app 1 + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[0].title!!.toString())) + .assertExists() + composeTestRule.onNode(hasText(PERSONAL_TEST_APPS[1].title!!.toString())) + .assertDoesNotExist() + } +} From 7de040acac5dc2d5647d164b5c01b2cc1e7f597d Mon Sep 17 00:00:00 2001 From: Shamali Patwa Date: Fri, 23 May 2025 12:08:46 -0700 Subject: [PATCH 24/25] Update widget picker component to define dependencies and provide full catalog for clients to use. Bug: 408283627 Flag: EXEMPT independent module Test: Not applicable. Change-Id: I573036882472c44de7024322a6ed2aa037eab277 --- .../widgetpicker/WidgetPickerComponent.kt | 52 ++++++++++++------- .../ui/WidgetPickerEventListeners.kt | 26 ++++++++++ 2 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/WidgetPickerEventListeners.kt diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerComponent.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerComponent.kt index 05f92cb5f4..b96cb6d101 100644 --- a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerComponent.kt +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/WidgetPickerComponent.kt @@ -16,7 +16,14 @@ package com.android.launcher3.widgetpicker +import com.android.launcher3.widgetpicker.data.repository.WidgetAppIconsRepository +import com.android.launcher3.widgetpicker.data.repository.WidgetUsersRepository +import com.android.launcher3.widgetpicker.data.repository.WidgetsRepository +import com.android.launcher3.widgetpicker.shared.model.WidgetHostInfo +import com.android.launcher3.widgetpicker.ui.fullcatalog.FullWidgetsCatalog +import dagger.BindsInstance import dagger.Subcomponent +import kotlin.coroutines.CoroutineContext /** * A sub-component that apps can include in their dagger module to bootstrap & interact with apis @@ -25,39 +32,44 @@ import dagger.Subcomponent * Steps: * 1. Include this component as a sub-component on your app's main dagger module (and remember to * update Android.bp & gradle files). - * 2. Ensure bindings necessary for repository interfaces used in [WidgetPickerModule] are provided - * in your app. - * 3. Host a singleton class in your app to create an instance of widget picker component on-demand - * e.g. when user wants to open widget picker. + * 2. Host a singleton class in your app to create an instance of widget picker component on-demand + * e.g. when user wants to open widget picker. The component factory takes in a few dependencies + * that should be implemented e.g. the repository implementations. * - * Example for #3. + * Example of using the component and opening the picker. * * ``` * @MyAppSingleton - * public class WidgetPickerProvider { - * private final Provider widgetPickerComponentProvider; - * - * @Inject - * public WidgetPickerProvider(Provider widgetPickerComponentProvider) { - * this.widgetPickerComponentProvider = widgetPickerComponentProvider; - * } - * + * public class WidgetPickerProvider @Inject constructor( + * private val Provider widgetPickerComponentProvider + * ) { * public boolean show(...) { - * WidgetPickerComponent component = widgetPickerComponentProvider.get().build(); - * WidgetPickerUiInteractor interactor = component.getWidgetInteractor(); - * return interactor.show(...); + * WidgetPickerComponent component = widgetPickerComponentProvider.get().build(...); + * FullCatalog catalog = component.getFullWidgetsCatalog(); + * return catalog.show(...); * } * } * ``` */ @WidgetPickerSingleton -@Subcomponent(modules = [WidgetPickerModule::class]) +@Subcomponent interface WidgetPickerComponent { @Subcomponent.Factory interface Factory { - fun build(): WidgetPickerComponent + fun build( + @WidgetPickerRepository @BindsInstance + widgetsRepository: WidgetsRepository, + @WidgetPickerRepository @BindsInstance + widgetUsersRepository: WidgetUsersRepository, + @WidgetPickerRepository @BindsInstance + widgetAppIconsRepository: WidgetAppIconsRepository, + @WidgetPickerHostInfo @BindsInstance + widgetHostInfo: WidgetHostInfo, + @WidgetPickerBackground @BindsInstance + backgroundContext: CoroutineContext + ): WidgetPickerComponent } - // Interactors / APIs available for clients to interact with widget picker will go here. - // e.g. fun getWidgetPickerUiInteractor(): WidgetPickerUiInteractor + /** Provides UI for the catalog of all widgets on device. */ + fun getFullWidgetsCatalog(): FullWidgetsCatalog } diff --git a/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/WidgetPickerEventListeners.kt b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/WidgetPickerEventListeners.kt new file mode 100644 index 0000000000..7773284937 --- /dev/null +++ b/modules/widgetpicker/src/com/android/launcher3/widgetpicker/ui/WidgetPickerEventListeners.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.widgetpicker + +/** + * General interface that clients can implement to listen to events from different types of + * widget picker. + */ +interface WidgetPickerEventListeners { + /** Called when the widget picker is dismissed. */ + fun onClose() +} From 7705e92d93381e386b3dece397f51808d45f12d2 Mon Sep 17 00:00:00 2001 From: "Priyanka Advani (xWF)" Date: Fri, 23 May 2025 13:53:00 -0700 Subject: [PATCH 25/25] Revert "Moving DeviceProfile properties into DeviceProperties da..." Revert submission 33672643-DataDeviceProfile1 Reason for revert: Droidmonitor created revert due to b/419867875. Will be verifying through ABTD before submission. Fix: 419867875 Reverted changes: /q/submissionid:33672643-DataDeviceProfile1 Change-Id: Icb66aefbbcee24e05806b2139923e1f2ea1c65e3 --- .../launcher3/QuickstepTransitionManager.java | 56 ++-- .../KeyboardQuickSwitchController.java | 2 +- .../taskbar/ManageWindowsTaskbarShortcut.kt | 9 +- .../taskbar/NavbarButtonsViewController.java | 14 +- .../taskbar/TaskbarActivityContext.java | 14 +- .../launcher3/taskbar/TaskbarEduTooltip.kt | 2 +- .../taskbar/TaskbarInsetsController.kt | 2 +- .../launcher3/taskbar/TaskbarManagerImpl.java | 10 +- .../taskbar/TaskbarStashController.java | 2 +- .../taskbar/TaskbarStashViaTouchController.kt | 3 +- .../taskbar/TaskbarThresholdUtils.java | 2 +- .../launcher3/taskbar/TaskbarView.java | 2 +- .../taskbar/TaskbarViewController.java | 4 +- .../allapps/TaskbarAllAppsSlideInView.java | 6 +- .../bubbles/BubbleBarSwipeController.kt | 3 +- .../BubbleStashedHandleViewController.java | 2 +- .../customization/TaskbarFeatureEvaluator.kt | 2 +- .../launcher3/taskbar/growth/NudgeView.kt | 2 +- .../navbutton/AbstractNavButtonLayoutter.kt | 2 +- .../navbutton/NavButtonLayoutFactory.kt | 2 +- .../navbutton/PhoneLandscapeNavLayoutter.kt | 2 +- .../navbutton/PhonePortraitNavLayoutter.kt | 12 +- .../taskbar/navbutton/SetupNavLayoutter.kt | 6 +- .../taskbar/navbutton/TaskbarNavLayoutter.kt | 12 +- .../overlay/TaskbarOverlayController.java | 2 +- .../uioverrides/QuickstepLauncher.java | 4 +- .../uioverrides/RecentsViewStateController.kt | 5 +- .../uioverrides/states/AllAppsState.java | 4 +- .../uioverrides/states/OverviewState.java | 10 +- .../QuickstepAtomicAnimationFactory.java | 2 +- .../states/SplitScreenSelectState.java | 2 +- .../NavBarToHomeTouchController.java | 2 +- ...ButtonNavbarToOverviewTouchController.java | 2 +- .../NoButtonQuickSwitchTouchController.java | 4 +- .../QuickSwitchTouchController.java | 2 +- .../TransposedQuickSwitchTouchController.java | 2 +- .../android/quickstep/AbsSwipeUpHandler.java | 26 +- .../quickstep/AspectRatioSystemShortcut.kt | 5 +- .../quickstep/BaseContainerInterface.java | 18 +- .../quickstep/FallbackActivityInterface.java | 4 +- .../quickstep/FallbackSwipeHandler.java | 4 +- .../quickstep/FallbackWindowInterface.java | 4 +- .../quickstep/LauncherActivityInterface.java | 2 +- .../quickstep/LauncherSwipeHandlerV2.java | 2 +- .../quickstep/OverviewCommandHelper.kt | 2 +- .../QuickstepTestInformationHandler.java | 2 +- .../quickstep/SwipeUpAnimationLogic.java | 18 +- .../android/quickstep/TaskOverlayFactory.java | 2 +- .../quickstep/TaskShortcutFactory.java | 6 +- .../com/android/quickstep/TaskViewUtils.java | 2 +- .../quickstep/fallback/RecentsState.java | 2 +- .../window/RecentsWindowSwipeHandler.java | 4 +- .../TaskbarUnstashInputConsumer.java | 24 +- .../quickstep/interaction/AllSetActivity.java | 4 +- .../interaction/EdgeBackGestureHandler.java | 2 +- .../interaction/GestureSandboxActivity.java | 4 +- .../interaction/NavBarGestureHandler.java | 2 +- .../SwipeUpGestureTutorialController.java | 2 +- .../interaction/TutorialController.java | 6 +- .../interaction/TutorialFragment.java | 4 +- .../orientation/LandscapePagedViewHandler.kt | 14 +- .../orientation/PortraitPagedViewHandler.kt | 57 ++-- .../orientation/SeascapePagedViewHandler.kt | 4 +- .../RecentsDeviceProfileRepositoryImpl.kt | 2 +- .../AnimatorControllerWithResistance.java | 4 +- .../LauncherUnfoldAnimationController.java | 8 +- .../util/QuickstepOnboardingPrefs.java | 2 +- .../quickstep/util/RecentsOrientedState.java | 2 +- .../quickstep/util/RectFSpringAnim.java | 8 +- .../util/SplitAnimationController.kt | 27 +- .../util/SplitToWorkspaceController.java | 2 +- .../quickstep/util/TaskViewSimulator.java | 12 +- .../LauncherUnfoldTransitionController.kt | 12 +- .../quickstep/views/AllAppsEduView.java | 4 +- .../quickstep/views/DigitalWellBeingToast.kt | 2 +- .../views/FloatingAppPairBackground.kt | 61 ++--- .../quickstep/views/FloatingTaskView.java | 6 +- .../quickstep/views/OverviewActionsView.java | 8 +- .../quickstep/views/RecentsDismissUtils.kt | 6 +- .../android/quickstep/views/RecentsView.java | 44 +-- .../quickstep/views/RecentsViewUtils.kt | 6 +- .../android/quickstep/views/TaskMenuView.kt | 4 +- .../views/TaskThumbnailViewDeprecated.java | 2 +- .../com/android/quickstep/views/TaskView.kt | 14 +- .../launcher3/taskbar/TaskbarOverflowTest.kt | 5 +- .../navbutton/NavButtonLayoutFactoryTest.kt | 26 +- .../taskbar/rules/TaskbarModeRuleTest.kt | 6 +- src/com/android/launcher3/CellLayout.java | 2 +- src/com/android/launcher3/DeviceProfile.java | 252 ++++++++++-------- src/com/android/launcher3/DropTargetBar.java | 45 ++-- .../launcher3/InvariantDeviceProfile.java | 14 +- src/com/android/launcher3/Launcher.java | 18 +- src/com/android/launcher3/LauncherState.java | 10 +- src/com/android/launcher3/ModelCallbacks.kt | 13 +- src/com/android/launcher3/Workspace.java | 12 +- .../allapps/AllAppsTransitionController.java | 2 +- .../allapps/LauncherAllAppsContainerView.java | 4 +- .../launcher3/allapps/WorkUtilityView.java | 2 +- .../deviceprofile/DeviceProperties.kt | 80 ------ src/com/android/launcher3/folder/Folder.java | 4 +- .../graphics/LauncherPreviewRenderer.java | 14 +- .../graphics/PreviewSurfaceRenderer.java | 2 +- .../launcher3/graphics/SysUiScrim.java | 2 +- .../launcher3/model/WorkspaceItemProcessor.kt | 4 +- .../launcher3/model/data/AppPairInfo.kt | 5 +- .../popup/PopupContainerWithArrow.java | 2 +- .../launcher3/popup/SystemShortcut.java | 3 +- .../launcher3/states/RotationHelper.java | 2 +- .../testing/TestInformationHandler.java | 4 +- .../AbstractStateChangeTouchController.java | 6 +- .../touch/AllAppsSwipeController.java | 11 +- .../launcher3/touch/ItemClickHandler.java | 2 +- .../android/launcher3/util/DimensionUtils.kt | 10 +- .../launcher3/views/AbstractSlideInView.java | 2 +- .../launcher3/views/ActivityContext.java | 6 +- .../android/launcher3/views/ClipIconView.java | 22 +- .../launcher3/views/FloatingIconView.java | 8 +- .../widget/AddItemWidgetsBottomSheet.java | 2 +- .../launcher3/widget/BaseWidgetSheet.java | 6 +- .../widget/LauncherAppWidgetProviderInfo.java | 2 +- .../picker/WidgetRecommendationsView.java | 2 +- .../widget/picker/WidgetsFullSheet.java | 8 +- .../widget/picker/WidgetsTwoPaneSheet.java | 8 +- .../picker/util/WidgetPreviewContainerSize.kt | 6 +- .../uioverrides/states/AllAppsState.java | 6 +- .../util/WidgetPreviewContainerSizesTest.kt | 2 +- .../util/ui/PortraitLandscapeRunner.java | 4 +- 127 files changed, 596 insertions(+), 726 deletions(-) delete mode 100644 src/com/android/launcher3/deviceprofile/DeviceProperties.kt diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 31721370f1..280b9eb23c 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -512,9 +512,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener target = t; break; } - final int widthPx = mDeviceProfile.getDeviceProperties().getWidthPx(); - final int heightPx = mDeviceProfile.getDeviceProperties().getHeightPx(); - if (target == null) return new Rect(0, 0, widthPx, heightPx); + if (target == null) return new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx); final Rect bounds = new Rect(target.screenSpaceBounds); if (target.localBounds != null) { bounds.set(target.localBounds); @@ -524,10 +522,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener if (rotationChange != 0) { if ((rotationChange % 2) == 1) { // undoing rotation, so our "original" parent size is actually flipped - Utilities.rotateBounds(bounds, heightPx, widthPx, + Utilities.rotateBounds(bounds, mDeviceProfile.heightPx, mDeviceProfile.widthPx, 4 - rotationChange); } else { - Utilities.rotateBounds(bounds, widthPx, heightPx, + Utilities.rotateBounds(bounds, mDeviceProfile.widthPx, mDeviceProfile.heightPx, 4 - rotationChange); } } @@ -566,8 +564,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final View appsView = mLauncher.getAppsView(); final float startAlpha = appsView.getAlpha(); final float startScale = SCALE_PROPERTY.get(appsView); - if (mDeviceProfile.getDeviceProperties().isTablet()) { - + if (mDeviceProfile.isTablet) { // AllApps should not fade at all in tablets. alphas = new float[]{1, 1}; } @@ -795,7 +792,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f; - final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() + final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher); final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius; @@ -878,8 +875,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener final int windowCropWidth = crop.width(); final int windowCropHeight = crop.height(); if (rotationChange != 0) { - Utilities.rotateBounds(crop, mDeviceProfile.getDeviceProperties().getWidthPx(), - mDeviceProfile.getDeviceProperties().getHeightPx(), rotationChange); + Utilities.rotateBounds(crop, mDeviceProfile.widthPx, + mDeviceProfile.heightPx, rotationChange); } // Scale the size of the icon to match the size of the window crop. @@ -926,14 +923,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener matrix.setScale(scale, scale); if (rotationChange == 1) { matrix.postTranslate(windowTransY0, - mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth)); + mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth)); } else if (rotationChange == 2) { matrix.postTranslate( - mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth), - mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight)); + mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth), + mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight)); } else if (rotationChange == 3) { matrix.postTranslate( - mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight), + mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight), windowTransX0); } else { matrix.postTranslate(windowTransX0, windowTransY0); @@ -1025,7 +1022,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget); } - final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() + final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher); final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher, v, widgetBackgroundBounds, @@ -1415,9 +1412,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener DeviceProfile dp = mLauncher.getDeviceProfile(); final int halfIconSize = dp.iconSizePx / 2; float primaryDimension = orientationHandler - .getPrimaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx()); + .getPrimaryValue(dp.availableWidthPx, dp.availableHeightPx); float secondaryDimension = orientationHandler - .getSecondaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx()); + .getSecondaryValue(dp.availableWidthPx, dp.availableHeightPx); final float targetX = primaryDimension / 2f; final float targetY = secondaryDimension - dp.hotseatBarSizePx; return new RectF(targetX - halfIconSize, targetY - halfIconSize, @@ -1447,13 +1444,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener // Get floating view and target rect. boolean isInHotseat = false; if (launcherView instanceof LauncherAppWidgetHostView) { - Size windowSize = new Size(mDeviceProfile.getDeviceProperties().getAvailableWidthPx(), - mDeviceProfile.getDeviceProperties().getAvailableHeightPx()); + Size windowSize = new Size(mDeviceProfile.availableWidthPx, + mDeviceProfile.availableHeightPx); int fallbackBackgroundColor = FloatingWidgetView.getDefaultBackgroundColor(mLauncher, runningTaskTarget); floatingWidget = FloatingWidgetView.getFloatingWidgetView(mLauncher, (LauncherAppWidgetHostView) launcherView, targetRect, windowSize, - mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher), + mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher), isTransluscent, fallbackBackgroundColor); } else if (launcherView != null && !RemoveAnimationSettingsTracker.INSTANCE.get( mLauncher).isRemoveAnimationEnabled()) { @@ -1484,7 +1481,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Rect closingWindowStartRect = new Rect(); closingWindowStartRectF.round(closingWindowStartRect); Rect closingWindowOriginalRect = - new Rect(0, 0, mDeviceProfile.getDeviceProperties().getWidthPx(), mDeviceProfile.getDeviceProperties().getHeightPx()); + new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx); if (floatingIconView != null) { anim.addAnimatorListener(floatingIconView); floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged); @@ -1562,7 +1559,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener Rect tmpRect = new Rect(); ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1); int duration = CLOSING_TRANSITION_DURATION_MS; - float windowCornerRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode() + float windowCornerRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher); float startShadowRadius = areAllTargetsTranslucent(appTargets) ? 0 : mMaxShadowRadius; closingAnimator.setDuration(duration); @@ -2252,20 +2249,17 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean toLauncher, RectF resultRect) { final int taskRotation = target.windowConfiguration.getRotation(); final DeviceProfile profile = mLauncher.getDeviceProfile(); - final int rotation = profile.getDeviceProperties().getRotationHint(); - final int widthPx = profile.getDeviceProperties().getWidthPx(); - final int heightPx = profile.getDeviceProperties().getWidthPx(); final int rotationDelta = toLauncher - ? android.util.RotationUtils.deltaRotation(taskRotation, rotation) - : android.util.RotationUtils.deltaRotation(rotation, taskRotation); + ? android.util.RotationUtils.deltaRotation(taskRotation, profile.rotationHint) + : android.util.RotationUtils.deltaRotation(profile.rotationHint, taskRotation); if (rotationDelta != ROTATION_0) { // Get original display size when task is on top but with different rotation - if (rotationDelta % 2 != 0 && toLauncher && (rotation == ROTATION_0 - || rotation == ROTATION_180)) { - mDisplayRect.set(0, 0, heightPx, widthPx); + if (rotationDelta % 2 != 0 && toLauncher && (profile.rotationHint == ROTATION_0 + || profile.rotationHint == ROTATION_180)) { + mDisplayRect.set(0, 0, profile.heightPx, profile.widthPx); } else { - mDisplayRect.set(0, 0, widthPx, heightPx); + mDisplayRect.set(0, 0, profile.widthPx, profile.heightPx); } currentRect.round(mTmpResult); android.util.RotationUtils.rotateBounds(mTmpResult, mDisplayRect, rotationDelta); diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index d4213e59dd..7074a823de 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -503,7 +503,7 @@ public final class KeyboardQuickSwitchController implements boolean isAspectRatioSquare() { return mControllers != null && LayoutUtils.isAspectRatioSquare( - mControllers.taskbarActivityContext.getDeviceProfile().getDeviceProperties().getAspectRatio()); + mControllers.taskbarActivityContext.getDeviceProfile().aspectRatio); } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt index 2d6f1ee5be..bfd93dda31 100644 --- a/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt +++ b/quickstep/src/com/android/launcher3/taskbar/ManageWindowsTaskbarShortcut.kt @@ -225,7 +225,7 @@ class ManageWindowsTaskbarShortcut( // Calculate the Y position to place the carousel above the taskbar menuView.rootView.y = - deviceProfile.deviceProperties.availableHeightPx - + deviceProfile.availableHeightPx - menuView.menuHeight - controllers.taskbarStashController.touchableHeight - margin @@ -234,12 +234,9 @@ class ManageWindowsTaskbarShortcut( // but avoid clashing with the screen edge menuView.rootView.translationX = if (Utilities.isRtl(context.resources)) { - -(deviceProfile.deviceProperties.availableWidthPx - menuView.menuWidth) / 2f + -(deviceProfile.availableWidthPx - menuView.menuWidth) / 2f } else { - val maxX = - deviceProfile.deviceProperties.availableWidthPx - - menuView.menuWidth - - margin + val maxX = deviceProfile.availableWidthPx - menuView.menuWidth - margin minOf(originalView.x, maxX) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 71f93f9eec..77cf3d5503 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -1048,9 +1048,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // If SUW is on a large screen device that is landscape (or has a square aspect // ratio) the back button has to be placed accordingly - if ((deviceProfile.getDeviceProperties().isTablet() && deviceProfile.getDeviceProperties().isLandscape()) - || (deviceProfile.getDeviceProperties().getAspectRatio() > SQUARE_ASPECT_RATIO_BOTTOM_BOUND - && deviceProfile.getDeviceProperties().getAspectRatio() < SQUARE_ASPECT_RATIO_UPPER_BOUND)) { + if ((deviceProfile.isTablet && deviceProfile.isLandscape) + || (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND + && deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) { navButtonsLayoutParams.setMarginStart( resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)); navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize( @@ -1061,7 +1061,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize( R.dimen.taskbar_contextual_button_suw_margin); navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin); - navButtonsLayoutParams.bottomMargin = !deviceProfile.getDeviceProperties().isLandscape() + navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape ? 0 : phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize( R.dimen.taskbar_nav_buttons_size) / 2); @@ -1427,7 +1427,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // If the taskbar is start aligned the navigation bar is aligned to the start or end of // the container, depending on the bubble bar location if (isNavbarOnRight) { - navBarTargetStartX = dp.getDeviceProperties().getWidthPx() - navBarSpacing - mNavButtonContainer.getWidth(); + navBarTargetStartX = dp.widthPx - navBarSpacing - mNavButtonContainer.getWidth(); } else { navBarTargetStartX = navBarSpacing; } @@ -1440,7 +1440,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT if (isNavbarOnRight) { if (mNavButtonsView.isLayoutRtl()) { float taskBarEnd = taskbarBounds.right; - navBarTargetStartX = (dp.getDeviceProperties().getWidthPx() + taskBarEnd - navbarWidth) / 2; + navBarTargetStartX = (dp.widthPx + taskBarEnd - navbarWidth) / 2; } else { navBarTargetStartX = mNavButtonContainer.getLeft(); } @@ -1458,7 +1458,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // screen. Rect transientTaskbarIconLayoutBoundsInParent = mControllers.taskbarViewController .getTransientTaskbarIconLayoutBoundsInParent(); - if (mContext.getDeviceProfile().getDeviceProperties().isPhone() + if (mContext.getDeviceProfile().isPhone || transientTaskbarIconLayoutBoundsInParent.isEmpty() || mNavButtonsView.getWidth() == 0) { return; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index ac05982ccf..26479c1543 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -316,7 +316,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { Optional bubbleControllersOptional = Optional.empty(); BubbleBarController.onTaskbarRecreated(); final boolean deviceBubbleBarEnabled = enableBubbleBarOnPhones() - || (!mDeviceProfile.getDeviceProperties().isPhone() && !mDeviceProfile.isVerticalBarLayout()); + || (!mDeviceProfile.isPhone && !mDeviceProfile.isVerticalBarLayout()); if (BubbleBarController.isBubbleBarEnabled() && deviceBubbleBarEnabled && bubbleBarView != null && isPrimaryDisplay) { Optional bubbleHandleController = Optional.empty(); @@ -398,7 +398,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { onViewCreated(); } - /** Updates {@link deviceprofile} instances for any Taskbar windows. */ + /** Updates {@link DeviceProfile} instances for any Taskbar windows. */ public void updateDeviceProfile(DeviceProfile launcherDp) { applyDeviceProfile(launcherDp); mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp); @@ -591,7 +591,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { */ public boolean isPhoneMode() { return ENABLE_TASKBAR_NAVBAR_UNIFICATION - && mDeviceProfile.getDeviceProperties().isPhone() + && mDeviceProfile.isPhone && !mDeviceProfile.isTaskbarPresent; } @@ -620,11 +620,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext { /** Returns {@code true} iff a tiny version of taskbar is shown on phone. */ public boolean isTinyTaskbar() { - return enableTinyTaskbar() && mDeviceProfile.getDeviceProperties().isPhone() && mDeviceProfile.isTaskbarPresent; + return enableTinyTaskbar() && mDeviceProfile.isPhone && mDeviceProfile.isTaskbarPresent; } public boolean isBubbleBarOnPhone() { - return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.getDeviceProperties().isPhone(); + return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.isPhone; } /** @@ -1310,13 +1310,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { public void setTaskbarWindowSize(int size) { // In landscape phone button nav mode, we should set the task bar width instead of height // because this is the only case in which the nav bar is not on the display bottom. - boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.getDeviceProperties().isLandscape(); + boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.isLandscape; if ((landscapePhoneButtonNav ? mWindowLayoutParams.width : mWindowLayoutParams.height) == size || mIsDestroyed) { return; } if (size == MATCH_PARENT) { - size = mDeviceProfile.getDeviceProperties().getHeightPx(); + size = mDeviceProfile.heightPx; } else { mLastRequestedNonFullscreenSize = size; if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt index f3ea655866..d85dd50bb3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt @@ -86,7 +86,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) if ( measuredHeight + activityContext.deviceProfile.taskbarHeight >= - activityContext.deviceProfile.deviceProperties.availableHeightPx + activityContext.deviceProfile.availableHeightPx ) { updateLayoutParams { width = MATCH_PARENT } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index 21fe03f290..c9e613b913 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -172,7 +172,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas // only add the taskbar touch region if not on home val bottom = windowLayoutParams.height val top = bottom - taskbarTouchableHeight - val right = context.deviceProfile.deviceProperties.widthPx + val right = context.deviceProfile.widthPx defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom)) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java index b55efb7181..1346d4403f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java @@ -196,7 +196,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { new SparseArray<>(); /** DisplayId - {@link ComponentCallbacks} map for Connected Display. */ private final SparseArray mComponentCallbacks = new SparseArray<>(); - /** DisplayId - {@link deviceprofile} map for Connected Display. */ + /** DisplayId - {@link DeviceProfile} map for Connected Display. */ private final SparseArray mExternalDeviceProfiles = new SparseArray<>(); private StatefulActivity mActivity; private RecentsViewContainer mRecentsViewContainer; @@ -1373,7 +1373,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { /** * Creates a {@link TaskbarActivityContext} for the given display and adds it to the map. * - * @param dp The {@link deviceprofile} for the display. + * @param dp The {@link DeviceProfile} for the display. * @param displayId The ID of the display. */ private @Nullable TaskbarActivityContext createTaskbarActivityContext(DeviceProfile dp, @@ -1400,7 +1400,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Creates a {@link deviceprofile} for the given display and adds it to the map. + * Creates a {@link DeviceProfile} for the given display and adds it to the map. * * @param displayId The ID of the display. */ @@ -1425,7 +1425,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Gets a {@link deviceprofile} for the given displayId. + * Gets a {@link DeviceProfile} for the given displayId. * * @param displayId The ID of the display. */ @@ -1447,7 +1447,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { } /** - * Removes the {@link deviceprofile} associated with the given display ID from the map. + * Removes the {@link DeviceProfile} associated with the given display ID from the map. * * @param displayId The ID of the display for which to remove the taskbar. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 2583137a32..1abcaa093a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -1239,7 +1239,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba } // Do not stash if in small screen, with 3 button nav, and in landscape. if (mActivity.isPhoneMode() && mActivity.isThreeButtonNav() - && mActivity.getDeviceProfile().getDeviceProperties().isLandscape()) { + && mActivity.getDeviceProfile().isLandscape) { return false; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt index 7793642eda..cbb69ba7c7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashViaTouchController.kt @@ -68,8 +68,7 @@ class TaskbarStashViaTouchController(val controllers: TaskbarControllers) : Touc ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, activity.resources, ) - gestureHeightYThreshold = - (activity.deviceProfile.deviceProperties.heightPx - gestureHeight).toFloat() + gestureHeightYThreshold = (activity.deviceProfile.heightPx - gestureHeight).toFloat() } private fun createSwipeListener() = diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java index d3d7f5e143..17516f3616 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarThresholdUtils.java @@ -38,7 +38,7 @@ public class TaskbarThresholdUtils { private static int getThreshold(Resources r, DeviceProfile dp, int thresholdDimen, int multiplierDimen) { - float landscapeScreenHeight = dp.getDeviceProperties().isLandscape() ? dp.getDeviceProperties().getHeightPx() : dp.getDeviceProperties().getWidthPx(); + float landscapeScreenHeight = dp.isLandscape ? dp.heightPx : dp.widthPx; float screenPart = (landscapeScreenHeight * SCREEN_UNITS); float defaultDp = dpiFromPx(screenPart, DisplayMetrics.DENSITY_DEVICE_STABLE); float thisDp = dpToPx(defaultDp); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index c6ae854ccf..e4d44c1a84 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -209,7 +209,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar */ private int calculateMaxNumIcons() { DeviceProfile deviceProfile = mActivityContext.getDeviceProfile(); - int availableWidth = deviceProfile.getDeviceProperties().getWidthPx(); + int availableWidth = deviceProfile.widthPx; int defaultEdgeMargin = (int) getResources().getDimension(deviceProfile.inv.inlineNavButtonsEndSpacing); int spaceForBubbleBar = diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 12f5e925ae..98710863dc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -985,7 +985,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar float scaleUp = ((float) launcherDp.iconSizePx) / taskbarDp.taskbarIconSize; int borderSpacing = launcherDp.hotseatBorderSpace; int hotseatCellSize = DeviceProfile.calculateCellWidth( - launcherDp.getDeviceProperties().getAvailableWidthPx() - hotseatPadding.left - hotseatPadding.right, + launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right, borderSpacing, launcherDp.numShownHotseatIcons); @@ -1066,7 +1066,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar if (child == mTaskbarView.getQsb()) { boolean isRtl = Utilities.isRtl(child.getResources()); float hotseatIconCenter = isRtl - ? launcherDp.getDeviceProperties().getWidthPx() - hotseatPadding.right + borderSpacing + ? launcherDp.widthPx - hotseatPadding.right + borderSpacing + launcherDp.hotseatQsbWidth / 2f : hotseatPadding.left - borderSpacing - launcherDp.hotseatQsbWidth / 2f; if (taskbarDp.isQsbInline) { diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 254ba5173b..9e2399e609 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -147,7 +147,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView= top && x >= mStashedHandleBounds.left && x <= mStashedHandleBounds.right; diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt index 10e0cd2ef2..3245c3db27 100644 --- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt +++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt @@ -38,7 +38,7 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext) get() = taskbarActivityContext.isTransientTaskbar val isLandscape: Boolean - get() = taskbarActivityContext.deviceProfile.deviceProperties.isLandscape + get() = taskbarActivityContext.deviceProfile.isLandscape val isTnMinimalState: Boolean get() = taskbarActivityContext.isTaskbarInMinimalState diff --git a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt index 2290192ae7..17ee50e367 100644 --- a/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt +++ b/quickstep/src/com/android/launcher3/taskbar/growth/NudgeView.kt @@ -69,7 +69,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED) if ( measuredHeight + activityContext.deviceProfile.taskbarHeight >= - activityContext.deviceProfile.deviceProperties.availableHeightPx + activityContext.deviceProfile.availableHeightPx ) { updateLayoutParams { width = LayoutParams.MATCH_PARENT } } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt index 918d5cf71e..3712a76eab 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt @@ -90,7 +90,7 @@ abstract class AbstractNavButtonLayoutter( resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin) nearestTouchFrameLayoutParams.marginStart = phoneOrPortraitSetupMargin nearestTouchFrameLayoutParams.bottomMargin = - if (!deviceProfile.deviceProperties.isLandscape) 0 + if (!deviceProfile.isLandscape) 0 else phoneOrPortraitSetupMargin - resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2 diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index 17e63e8bd3..a199dba0bd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -90,7 +90,7 @@ class NavButtonLayoutFactory { ) } isPhoneNavMode -> { - if (!deviceProfile.deviceProperties.isLandscape) { + if (!deviceProfile.isLandscape) { navButtonsView.setIsVertical(false) PhonePortraitNavLayoutter( resources, diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt index 00ba40c7f9..d989f6b534 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt @@ -48,7 +48,7 @@ open class PhoneLandscapeNavLayoutter( ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { - val totalHeight = context.deviceProfile.deviceProperties.heightPx + val totalHeight = context.deviceProfile.heightPx val homeButtonHeight = resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size) val roundedCornerContentMargin = diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt index 833a309e83..5b24ebfe1d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt @@ -34,7 +34,7 @@ class PhonePortraitNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space?, + space: Space? ) : AbstractNavButtonLayoutter( resources, @@ -43,11 +43,11 @@ class PhonePortraitNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space, + space ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { - val totalWidth = context.deviceProfile.deviceProperties.widthPx + val totalWidth = context.deviceProfile.widthPx val homeButtonWidth = resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size) val roundedCornerContentMargin = @@ -63,7 +63,7 @@ class PhonePortraitNavLayoutter( val navContainerParams = FrameLayout.LayoutParams( navButtonContainerWidth.toInt(), - ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT ) navContainerParams.apply { topMargin = 0 @@ -120,14 +120,14 @@ class PhonePortraitNavLayoutter( contextualButtonWidth.toInt(), roundedCornerContentMargin + contentPadding, 0, - Gravity.START, + Gravity.START ) repositionContextualContainer( endContextualContainer, contextualButtonWidth.toInt(), 0, roundedCornerContentMargin + contentPadding, - Gravity.END, + Gravity.END ) startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT) diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt index f558122b3d..99a2382827 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt @@ -78,9 +78,9 @@ class SetupNavLayoutter( // If SUW is on a large screen device that is landscape (or has a square aspect // ratio) the back button has to be placed accordingly if ( - deviceProfile.deviceProperties.isTablet && deviceProfile.deviceProperties.isLandscape || - (deviceProfile.deviceProperties.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND && - deviceProfile.deviceProperties.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND) + deviceProfile.isTablet && deviceProfile.isLandscape || + (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND && + deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND) ) { navButtonsLayoutParams.marginStart = resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin) diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt index bef432e668..a59e8a847b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt @@ -35,7 +35,7 @@ class TaskbarNavLayoutter( startContextualContainer: ViewGroup, imeSwitcher: ImageView?, a11yButton: ImageView?, - space: Space?, + space: Space? ) : AbstractNavButtonLayoutter( resources, @@ -44,7 +44,7 @@ class TaskbarNavLayoutter( startContextualContainer, imeSwitcher, a11yButton, - space, + space ) { override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { @@ -69,7 +69,7 @@ class TaskbarNavLayoutter( val navButtonParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT ) navButtonParams.apply { gravity = Gravity.END or Gravity.CENTER_VERTICAL @@ -101,7 +101,7 @@ class TaskbarNavLayoutter( endContextualContainer.removeAllViews() startContextualContainer.removeAllViews() - if (!context.deviceProfile.deviceProperties.isGestureMode) { + if (!context.deviceProfile.isGestureMode) { val contextualMargin = resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_padding) repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END) @@ -110,7 +110,7 @@ class TaskbarNavLayoutter( WRAP_CONTENT, contextualMargin, contextualMargin, - Gravity.START, + Gravity.START ) if (imeSwitcher != null) { @@ -122,7 +122,7 @@ class TaskbarNavLayoutter( val imeSwitcherButtonParams = FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT ) imeSwitcherButtonParams.apply { marginStart = imeStartMargin diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java index 219c2b01ff..82916031a0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayController.java @@ -189,7 +189,7 @@ public final class TaskbarOverlayController { return mLauncherDeviceProfile; } - /** Updates {@link deviceprofile} instance for Taskbar's overlay window. */ + /** Updates {@link DeviceProfile} instance for Taskbar's overlay window. */ public void updateLauncherDeviceProfile(DeviceProfile dp) { mLauncherDeviceProfile = dp; Optional.ofNullable(mOverlayContext).ifPresent(c -> { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index af83d13e1c..13d6dc43fe 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -515,7 +515,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, } private List> getSplitShortcuts() { - if (!mDeviceProfile.getDeviceProperties().isTablet() || mSplitSelectStateController.isSplitSelectActive()) { + if (!mDeviceProfile.isTablet || mSplitSelectStateController.isSplitSelectActive()) { return Collections.emptyList(); } RecentsView recentsView = getOverviewPanel(); @@ -704,7 +704,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, break; } - if (!getDeviceProfile().getDeviceProperties().isMultiWindowMode()) { + if (!getDeviceProfile().isMultiWindowMode) { list.add(new StatusBarTouchController( this, () -> this.isInState(LauncherState.NORMAL))); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt index 927d94c2f6..9bc1290d36 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.kt @@ -246,10 +246,7 @@ class RecentsViewStateController(private val launcher: QuickstepLauncher) : launcher.deviceProfile, ) - val timings = - AnimUtils.getDeviceOverviewToSplitTimings( - launcher.deviceProfile.getDeviceProperties().isTablet - ) + val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet) if (!goingToOverviewFromWorkspaceContextual) { // This animation is already done for the contextual case, don't redo it recentsView.createSplitSelectInitAnimation( diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index d6b7c3dd74..19e98fafea 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -176,7 +176,7 @@ public class AllAppsState extends LauncherState { } private static boolean isWorkspaceVisible(DeviceProfile deviceProfile) { - return deviceProfile.getDeviceProperties().isTablet() || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur()); + return deviceProfile.isTablet || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur()); } @Override @@ -199,7 +199,7 @@ public class AllAppsState extends LauncherState { @Override public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { DeviceProfile dp = launcher.getDeviceProfile(); - return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape(); + return dp.isPhone && !dp.isLandscape; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index a8be0545ec..4d32f7d690 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -82,7 +82,7 @@ public class OverviewState extends LauncherState { recentsView.getTaskSize(sTempRect); float scale; DeviceProfile deviceProfile = launcher.getDeviceProfile(); - if (deviceProfile.getDeviceProperties().isTwoPanels()) { + if (deviceProfile.isTwoPanels) { // In two panel layout, width does not include both panels or space between them, so // use height instead. We do not use height for handheld, as cell layout can be // shorter than a task and we want the workspace to scale down to task size. @@ -114,9 +114,9 @@ public class OverviewState extends LauncherState { int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS | ADD_DESK_BUTTON; DeviceProfile dp = launcher.getDeviceProfile(); boolean showFloatingSearch; - if (dp.getDeviceProperties().isPhone()) { + if (dp.isPhone) { // Only show search in phone overview in portrait mode. - showFloatingSearch = !dp.getDeviceProperties().isLandscape(); + showFloatingSearch = !dp.isLandscape; } else { // Only show search in tablet overview if taskbar is not visible. showFloatingSearch = !dp.isTaskbarPresent || isTaskbarStashed(launcher); @@ -148,7 +148,7 @@ public class OverviewState extends LauncherState { @Override public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) { DeviceProfile dp = launcher.getDeviceProfile(); - return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape(); + return dp.isPhone && !dp.isLandscape; } @Override @@ -163,7 +163,7 @@ public class OverviewState extends LauncherState { @Override public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) { - return deviceProfile.getDeviceProperties().isTablet(); + return deviceProfile.isTablet; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java index 3a6de197ac..44f8bf1e07 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java @@ -220,7 +220,7 @@ public class QuickstepAtomicAnimationFactory extends } else if (fromState == NORMAL && toState == ALL_APPS) { AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mContainer, config); } else if (fromState == OVERVIEW && toState == OVERVIEW_SPLIT_SELECT) { - SplitAnimationTimings timings = mContainer.getDeviceProfile().getDeviceProperties().isTablet() + SplitAnimationTimings timings = mContainer.getDeviceProfile().isTablet ? SplitAnimationTimings.TABLET_OVERVIEW_TO_SPLIT : SplitAnimationTimings.PHONE_OVERVIEW_TO_SPLIT; config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java b/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java index c2ec17ab3f..2631fbf0b6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/SplitScreenSelectState.java @@ -43,7 +43,7 @@ public class SplitScreenSelectState extends OverviewState { @Override public int getTransitionDuration(ActivityContext context, boolean isToState) { - if (isToState && context.getDeviceProfile().getDeviceProperties().isTablet()) { + if (isToState && context.getDeviceProfile().isTablet) { return SplitAnimationTimings.TABLET_ENTER_DURATION; } else if (isToState) { return SplitAnimationTimings.PHONE_ENTER_DURATION; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java index dce158f63f..38775625b8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java @@ -136,7 +136,7 @@ public class NavBarToHomeTouchController implements TouchController, } private float getShiftRange() { - return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx(); + return mLauncher.getDeviceProfile().heightPx; } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java index 7140d0f010..5a8a3a3406 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java @@ -136,7 +136,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch float progressMultiplier = super.initCurrentAnimation(); if (mToState == HINT_STATE) { // Track the drag across the entire height of the screen. - progressMultiplier = -1f / mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx(); + progressMultiplier = -1f / mLauncher.getDeviceProfile().heightPx; } return progressMultiplier; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 60bd54431f..b3c424f3f0 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -130,13 +130,13 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mLauncher = launcher; mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this); mRecentsView = mLauncher.getOverviewPanel(); - mXRange = mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f; + mXRange = mLauncher.getDeviceProfile().widthPx / 2f; mYRange = LayoutUtils.getShelfTrackingDistance( mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler(), mRecentsView.getContainerInterface()); - mMaxYProgress = mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / mYRange; + mMaxYProgress = mLauncher.getDeviceProfile().heightPx / mYRange; mMotionPauseDetector = new MotionPauseDetector(mLauncher); mMotionPauseMinDisplacement = mLauncher.getResources().getDimension( R.dimen.motion_pause_detector_min_displacement_from_app); diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java index 14896e53c7..f582324f23 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java @@ -161,6 +161,6 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll @Override protected float getShiftRange() { - return mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f; + return mLauncher.getDeviceProfile().widthPx / 2f; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java index e7d2cd23c6..b70cabe76d 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TransposedQuickSwitchTouchController.java @@ -39,6 +39,6 @@ public class TransposedQuickSwitchTouchController extends QuickSwitchTouchContro @Override protected float getShiftRange() { - return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / 2f; + return mLauncher.getDeviceProfile().heightPx / 2f; } } diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 30fc6b5df5..86efe9b7ca 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1024,7 +1024,7 @@ public abstract class AbsSwipeUpHandler< } dp.updateInsets(targets.homeContentInsets); initTransitionEndpoints(dp); - orientationState.setMultiWindowMode(dp.getDeviceProperties().isMultiWindowMode()); + orientationState.setMultiWindowMode(dp.isMultiWindowMode); } // Notify when the animation starts @@ -1539,7 +1539,7 @@ public abstract class AbsSwipeUpHandler< } private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTaskView) { - if (mDp == null || !mDp.getDeviceProperties().isGestureMode()) { + if (mDp == null || !mDp.isGestureMode) { // We probably never received an animation controller, skip logging. return; } @@ -1973,26 +1973,24 @@ public abstract class AbsSwipeUpHandler< private Rect getKeepClearAreaForHotseat() { Rect keepClearArea; - final int heightPx = mDp.getDeviceProperties().getHeightPx(); - final int widthPx = mDp.getDeviceProperties().getWidthPx(); // the keep clear area in global screen coordinates, in pixels - if (mDp.getDeviceProperties().isPhone()) { + if (mDp.isPhone) { if (mDp.isSeascape()) { // in seascape the Hotseat is on the left edge of the screen - keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, heightPx); - } else if (mDp.getDeviceProperties().isLandscape()) { + keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, mDp.heightPx); + } else if (mDp.isLandscape) { // in landscape the Hotseat is on the right edge of the screen - keepClearArea = new Rect(widthPx - mDp.hotseatBarSizePx, 0, - widthPx, heightPx); + keepClearArea = new Rect(mDp.widthPx - mDp.hotseatBarSizePx, 0, + mDp.widthPx, mDp.heightPx); } else { // in portrait mode the Hotseat is at the bottom of the screen - keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx, - widthPx, heightPx); + keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx, + mDp.widthPx, mDp.heightPx); } } else { // large screens have Hotseat always at the bottom of the screen - keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx, - widthPx, heightPx); + keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx, + mDp.widthPx, mDp.heightPx); } return keepClearArea; } @@ -2756,7 +2754,7 @@ public abstract class AbsSwipeUpHandler< // Scaling of RecentsView during quick switch based on amount of recents scroll private float getScaleProgressDueToScroll() { - if (mContainer == null || !mContainer.getDeviceProfile().getDeviceProperties().isTablet() || mRecentsView == null + if (mContainer == null || !mContainer.getDeviceProfile().isTablet || mRecentsView == null || !shouldLinkRecentsViewScroll()) { return 0; } diff --git a/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt index f2242d8d4b..68860ac91b 100644 --- a/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt +++ b/quickstep/src/com/android/quickstep/AspectRatioSystemShortcut.kt @@ -58,7 +58,8 @@ class AspectRatioSystemShortcut( } mTarget.startActivitySafely(view, intent, mItemInfo) - mTarget.statsLogManager + mTarget + .statsLogManager .logger() .withItemInfo(mItemInfo) .log(LauncherEvent.LAUNCHER_ASPECT_RATIO_SETTINGS_SYSTEM_SHORTCUT_TAP) @@ -80,7 +81,7 @@ class AspectRatioSystemShortcut( !universalResizableByDefault() -> null // The option is only shown on sw600dp+ screens (checked by isTablet) - !viewContainer.deviceProfile.deviceProperties.isTablet -> null + !viewContainer.deviceProfile.isTablet -> null else -> { listOf( diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java index cc787ccfc0..52512f1498 100644 --- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java +++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java @@ -253,7 +253,7 @@ public abstract class BaseContainerInterface { * For this state, whether tasks should layout as a grid rather than a list. */ public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) { - return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.getDeviceProperties().isTablet(); + return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.isTablet; } @Override diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java index 289baef349..e55b2eeb68 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowSwipeHandler.java @@ -283,7 +283,7 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler deviceProfile.deviceProperties.heightPx) { + if (outStartRect.left > deviceProfile.heightPx) { outStartRect.offsetTo(0f, outStartRect.top) - } else if (outStartRect.left < -deviceProfile.deviceProperties.heightPx) { + } else if (outStartRect.left < -deviceProfile.heightPx) { outStartRect.offsetTo(0f, outStartRect.top) } } @@ -394,15 +394,15 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { ) { // In fake land/seascape, the placeholder always needs to go to the "top" of the device, // which is the same bounds as 0 rotation. - val width = dp.deviceProperties.widthPx + val width = dp.widthPx val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp) out.set(0, 0, width, placeholderHeight + insetSizeAdjustment) out.inset(placeholderInset, 0) // Adjust the top to account for content off screen. This will help to animate the view in // with rounded corners. - val screenWidth = dp.deviceProperties.widthPx - val screenHeight = dp.deviceProperties.heightPx + val screenWidth = dp.widthPx + val screenHeight = dp.heightPx val totalHeight = (1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset) / screenWidth).toInt() out.top -= totalHeight - placeholderHeight @@ -467,8 +467,8 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { out2: Rect, ) { // In fake land/seascape, the window bounds are always top and bottom half - val screenHeight = dp.deviceProperties.heightPx - val screenWidth = dp.deviceProperties.widthPx + val screenHeight = dp.heightPx + val screenWidth = dp.widthPx out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize) out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight) } diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt index dd22b92d23..4e1b1ad390 100644 --- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt @@ -63,9 +63,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat } override fun fixBoundsForHomeAnimStartRect(outStartRect: RectF, deviceProfile: DeviceProfile) { - if (outStartRect.left > deviceProfile.deviceProperties.widthPx) { + if (outStartRect.left > deviceProfile.widthPx) { outStartRect.offsetTo(0f, outStartRect.top) - } else if (outStartRect.left < -deviceProfile.deviceProperties.widthPx) { + } else if (outStartRect.left < -deviceProfile.widthPx) { outStartRect.offsetTo(0f, outStartRect.top) } } @@ -139,7 +139,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat if (enableOverviewIconMenu()) { x } else { - if (deviceProfile.deviceProperties.isLandscape) { + if (deviceProfile.isLandscape) { (x + taskInsetMargin + (thumbnailView.measuredWidth - thumbnailView.measuredHeight) / 2f) @@ -181,8 +181,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat ) } - (deviceProfile.deviceProperties.isLandscape && - !deviceProfile.deviceProperties.isTablet) -> { + (deviceProfile.isLandscape && !deviceProfile.isTablet) -> { val padding = thumbnailView.resources.getDimensionPixelSize(R.dimen.task_menu_edge_padding) thumbnailView.measuredHeight - (2 * padding) @@ -201,7 +200,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat taskMenuX: Float, taskMenuY: Float, ): Int = - deviceProfile.deviceProperties.heightPx - + deviceProfile.heightPx - deviceProfile.insets.top - taskMenuY.toInt() - deviceProfile.overviewActionsClaimedSpaceBelow @@ -332,11 +331,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat /* -------------------- */ override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int = - dp.deviceProperties.heightPx - rect.bottom + dp.heightPx - rect.bottom override fun getSplitPositionOptions(dp: DeviceProfile): List = when { - dp.deviceProperties.isTablet -> { + dp.isTablet -> { Utilities.getSplitPositionOptions(dp) } @@ -382,8 +381,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat @StagePosition stagePosition: Int, out: Rect, ) { - val screenWidth = dp.deviceProperties.widthPx - val screenHeight = dp.deviceProperties.heightPx + val screenWidth = dp.widthPx + val screenHeight = dp.heightPx val pinToRight = stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight) @@ -467,7 +466,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat */ private fun getPlaceholderSizeAdjustment(dp: DeviceProfile, pinToRight: Boolean): Int { val insetThickness = - if (!dp.deviceProperties.isLandscape) { + if (!dp.isLandscape) { dp.insets.top } else { if (pinToRight) dp.insets.right else dp.insets.left @@ -485,8 +484,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat out.pivotY = splitInstructionsHeight.toFloat() out.rotation = degreesRotated val distanceToEdge = - if (dp.deviceProperties.isPhone) { - if (dp.deviceProperties.isLandscape) { + if (dp.isPhone) { + if (dp.isLandscape) { out.resources.getDimensionPixelSize( R.dimen.split_instructions_bottom_margin_phone_landscape ) @@ -517,8 +516,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat out1: Rect, out2: Rect, ) { - val screenHeight = dp.deviceProperties.heightPx - val screenWidth = dp.deviceProperties.widthPx + val screenHeight = dp.heightPx + val screenWidth = dp.widthPx out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize) out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight) if (!dp.isLeftRightSplit) { @@ -557,11 +556,10 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat val dividerBarPercent = splitInfo.dividerPercent val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight - val scale = - outRect.height().toFloat() / (dp.deviceProperties.availableHeightPx - taskbarHeight) - val topTaskHeight = dp.deviceProperties.availableHeightPx * topLeftTaskPercent + val scale = outRect.height().toFloat() / (dp.availableHeightPx - taskbarHeight) + val topTaskHeight = dp.availableHeightPx * topLeftTaskPercent val scaledTopTaskHeight = topTaskHeight * scale - val dividerHeight = dp.deviceProperties.availableHeightPx * dividerBarPercent + val dividerHeight = dp.availableHeightPx * dividerBarPercent val scaledDividerHeight = dividerHeight * scale if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) { @@ -670,10 +668,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat secondTaskViewSize.y = totalThumbnailHeight } else { val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight - val scale = - totalThumbnailHeight.toFloat() / - (dp.deviceProperties.availableHeightPx - taskbarHeight) - val topTaskHeight = dp.deviceProperties.availableHeightPx * taskPercent + val scale = totalThumbnailHeight.toFloat() / (dp.availableHeightPx - taskbarHeight) + val topTaskHeight = dp.availableHeightPx * taskPercent val finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale).toFloat() val scaledTopTaskHeight = topTaskHeight * scale firstTaskViewSize.x = parentWidth @@ -783,8 +779,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat .toInt() secondaryAppChipView.setSplitTranslationY( (primarySnapshotHeight + - (if (deviceProfile.deviceProperties.isTablet) 0 - else dividerThickness)) + (if (deviceProfile.isTablet) 0 else dividerThickness)) .toFloat() ) } @@ -797,11 +792,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat if (deviceProfile.isSeascape) deviceProfile.insets.right else deviceProfile.insets.left val fullscreenMidpointFromBottom = - ((deviceProfile.deviceProperties.widthPx - fullscreenInsetThickness) / 2) - val midpointFromEndPct = - fullscreenMidpointFromBottom.toFloat() / deviceProfile.deviceProperties.widthPx - val insetPct = - fullscreenInsetThickness.toFloat() / deviceProfile.deviceProperties.widthPx + ((deviceProfile.widthPx - fullscreenInsetThickness) / 2) + val midpointFromEndPct = fullscreenMidpointFromBottom.toFloat() / deviceProfile.widthPx + val insetPct = fullscreenInsetThickness.toFloat() / deviceProfile.widthPx val spaceAboveSnapshots = 0 val overviewThumbnailAreaThickness = groupedTaskViewWidth - spaceAboveSnapshots val bottomToMidpointOffset = @@ -902,9 +895,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat } override fun getDefaultSplitPosition(deviceProfile: DeviceProfile): Int { - check(deviceProfile.deviceProperties.isTablet) { - "Default position available only for large screens" - } + check(deviceProfile.isTablet) { "Default position available only for large screens" } return if (deviceProfile.isLeftRightSplit) { SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT } else { diff --git a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt index 470db5e36a..7db9d30bc5 100644 --- a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt @@ -113,7 +113,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() { deviceProfile: DeviceProfile, taskMenuX: Float, taskMenuY: Float, - ): Int = (deviceProfile.deviceProperties.availableWidthPx - taskInsetMargin - taskMenuX).toInt() + ): Int = (deviceProfile.availableWidthPx - taskInsetMargin - taskMenuX).toInt() override fun setSplitTaskSwipeRect( dp: DeviceProfile, @@ -187,7 +187,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() { } override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int = - dp.deviceProperties.widthPx - rect.right + dp.widthPx - rect.right override fun getSplitPositionOptions(dp: DeviceProfile): List = // Add "right" option which is actually the top diff --git a/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt b/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt index 5397638ce1..8450f09cea 100644 --- a/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt +++ b/quickstep/src/com/android/quickstep/recents/data/RecentsDeviceProfileRepositoryImpl.kt @@ -29,7 +29,7 @@ class RecentsDeviceProfileRepositoryImpl(private val container: RecentsViewConta override fun getRecentsDeviceProfile() = with(container.deviceProfile) { RecentsDeviceProfile( - isLargeScreen = deviceProperties.isTablet, + isLargeScreen = isTablet, canEnterDesktopMode = DesktopModeStatus.canEnterDesktopMode(container.asContext()), ) } diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java index a2e0628da8..37d7030832 100644 --- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java +++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java @@ -183,7 +183,7 @@ public class AnimatorControllerWithResistance { params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR); float prevScaleRate = (fullscreenScale - params.startScale) - / (params.dp.getDeviceProperties().getHeightPx() - startRect.bottom); + / (params.dp.heightPx - startRect.bottom); // This is what the scale would be at the end of the drag if we didn't apply resistance. float endScale = params.startScale - prevScaleRate * distanceToCover; // Create an interpolator that resists the scale so the scale doesn't get smaller than @@ -256,7 +256,7 @@ public class AnimatorControllerWithResistance { this.scaleProperty = scaleProperty; this.translationTarget = translationTarget; this.translationProperty = translationProperty; - if (dp.getDeviceProperties().isTablet()) { + if (dp.isTablet) { resistanceParams = RecentsResistanceParams.FROM_APP_TABLET; } else { resistanceParams = RecentsResistanceParams.FROM_APP; diff --git a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java index fd1fbe6299..4c26761440 100644 --- a/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java +++ b/quickstep/src/com/android/quickstep/util/LauncherUnfoldAnimationController.java @@ -163,7 +163,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL @Override public void onDeviceProfileChanged(DeviceProfile dp) { - if (mIsTablet != null && dp.getDeviceProperties().isTablet() != mIsTablet) { + if (mIsTablet != null && dp.isTablet != mIsTablet) { // We should preemptively start the animation only if: // - We changed to the unfolded screen // - SystemUI IPC connection is alive, so we won't end up in a situation that we won't @@ -173,7 +173,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL // if Launcher was not open during unfold, in this case we receive the configuration // change only after we went back to home screen and we don't want to start the // animation in this case. - if (dp.getDeviceProperties().isTablet() + if (dp.isTablet && SystemUiProxy.INSTANCE.get(mLauncher).isActive() && !mExternalTransitionStatusProvider.hasRun()) { // Preemptively start the unfold animation to make sure that we have drawn @@ -181,12 +181,12 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL preemptivelyStartAnimationOnNextFrame(); } - if (!dp.getDeviceProperties().isTablet()) { + if (!dp.isTablet) { mExternalTransitionStatusProvider.onFolded(); } } - mIsTablet = dp.getDeviceProperties().isTablet(); + mIsTablet = dp.isTablet; } private class QsbAnimationListener implements TransitionProgressListener { diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java index a6da2e9e02..70ef47cc77 100644 --- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java +++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java @@ -82,7 +82,7 @@ public class QuickstepOnboardingPrefs { public void onStateTransitionComplete(LauncherState finalState) { HotseatPredictionController client = launcher.getHotseatPredictionController(); if (mFromAllApps && finalState == NORMAL && client.hasPredictions()) { - if (!launcher.getDeviceProfile().getDeviceProperties().isTablet() + if (!launcher.getDeviceProfile().isTablet && HOTSEAT_DISCOVERY_TIP_COUNT.increment(launcher)) { client.showEdu(); stateManager.removeStateListener(this); diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 51645356b8..079478ccf1 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -175,7 +175,7 @@ public class RecentsOrientedState implements LauncherPrefChangeListener { */ public void setDeviceProfile(DeviceProfile deviceProfile) { boolean oldMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice(); - setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.getDeviceProperties().isTablet()); + setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.isTablet); if (mListenersInitialized) { boolean newMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice(); // If isMultipleOrientationSupportedByDevice is changed, init or destroy listeners diff --git a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java index f56c7a27d5..00b40116f7 100644 --- a/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java +++ b/quickstep/src/com/android/quickstep/util/RectFSpringAnim.java @@ -346,7 +346,7 @@ public class RectFSpringAnim extends ReleaseCheck { // Increase the stiffness for devices where we want the window size to transform // quicker. boolean shouldUseHigherStiffness = profile != null - && (profile.getDeviceProperties().isLandscape() || profile.getDeviceProperties().isTablet()); + && (profile.isLandscape || profile.isTablet); float stiffness = shouldUseHigherStiffness ? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness) : rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness); @@ -549,7 +549,7 @@ public class RectFSpringAnim extends ReleaseCheck { // Increase the stiffness for devices where we want the window size to transform // quicker. boolean shouldUseHigherStiffness = deviceProfile != null - && (deviceProfile.getDeviceProperties().isLandscape() || deviceProfile.getDeviceProperties().isTablet()); + && (deviceProfile.isLandscape || deviceProfile.isTablet); rectStiffness = shouldUseHigherStiffness ? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness) : rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness); @@ -562,11 +562,11 @@ public class RectFSpringAnim extends ReleaseCheck { ? TRACKING_BOTTOM : TRACKING_TOP; } else { - int heightPx = deviceProfile.getDeviceProperties().getHeightPx(); + int heightPx = deviceProfile.heightPx; Rect padding = deviceProfile.workspacePadding; final float topThreshold = heightPx / 3f; - final float bottomThreshold = deviceProfile.getDeviceProperties().getHeightPx() - padding.bottom; + final float bottomThreshold = deviceProfile.heightPx - padding.bottom; if (targetRect.bottom > bottomThreshold) { if (enableScalingRevealHomeAnimation()) { diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index c28e8c224c..d6d265b89d 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -328,16 +328,14 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC // Make the scrim fullscreen val lp = scrim.layoutParams as InsettableFrameLayout.LayoutParams lp.topMargin = 0 - lp.height = dp.deviceProperties.heightPx - lp.width = dp.deviceProperties.widthPx + lp.height = dp.heightPx + lp.width = dp.widthPx scrim.alpha = 0f scrim.setBackgroundColor( container.asContext().resources.getColor(R.color.taskbar_background_dark) ) - val timings = - AnimUtils.getDeviceSplitToConfirmTimings(dp.deviceProperties.isTablet) - as SplitToConfirmTimings + val timings = AnimUtils.getDeviceSplitToConfirmTimings(dp.isTablet) as SplitToConfirmTimings pendingAnimation.setViewAlpha( scrim, 1f, @@ -430,10 +428,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC safeRemoveViewFromDragLayer(container, splitSelectStateController.splitInstructionsView) val splitInstructionsView = SplitInstructionsView.getSplitInstructionsView(container) splitSelectStateController.splitInstructionsView = splitInstructionsView - val timings = - AnimUtils.getDeviceOverviewToSplitTimings( - container.deviceProfile.deviceProperties.isTablet - ) + val timings = AnimUtils.getDeviceOverviewToSplitTimings(container.deviceProfile.isTablet) val anim = PendingAnimation(100 /*duration */) splitInstructionsView.alpha = 0f anim.setViewAlpha( @@ -476,7 +471,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC ) { val stagedTaskView = view as FloatingTaskView - val isTablet: Boolean = container.deviceProfile.deviceProperties.isTablet + val isTablet: Boolean = container.deviceProfile.isTablet val duration = if (isTablet) SplitAnimationTimings.TABLET_CONFIRM_DURATION else SplitAnimationTimings.PHONE_CONFIRM_DURATION @@ -896,7 +891,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC rootCandidate: Change, ): ValueAnimator { val progressUpdater = ValueAnimator.ofFloat(0f, 1f) - val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.deviceProperties.isTablet) + val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.isTablet) progressUpdater.setDuration(timings.getDuration().toLong()) progressUpdater.interpolator = Interpolators.LINEAR @@ -920,8 +915,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mDx = FloatProp( floatingView.startingPosition.left, - dp.deviceProperties.widthPx / 2f - - floatingView.startingPosition.width() / 2f, + dp.widthPx / 2f - floatingView.startingPosition.width() / 2f, Interpolators.clampToProgress( timings.getStagedRectXInterpolator(), timings.stagedRectSlideStartOffset, @@ -931,8 +925,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mDy = FloatProp( floatingView.startingPosition.top, - dp.deviceProperties.heightPx / 2f - - floatingView.startingPosition.height() / 2f, + dp.heightPx / 2f - floatingView.startingPosition.height() / 2f, Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, @@ -942,7 +935,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mScaleX = FloatProp( 1f /* start */, - dp.deviceProperties.widthPx / floatingView.startingPosition.width(), + dp.widthPx / floatingView.startingPosition.width(), Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, @@ -952,7 +945,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC var mScaleY = FloatProp( 1f /* start */, - dp.deviceProperties.heightPx / floatingView.startingPosition.height(), + dp.heightPx / floatingView.startingPosition.height(), Interpolators.clampToProgress( Interpolators.EMPHASIZED, timings.stagedRectSlideStartOffset, diff --git a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java index abd24588d4..d3390b4ed9 100644 --- a/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java +++ b/quickstep/src/com/android/quickstep/util/SplitToWorkspaceController.java @@ -157,7 +157,7 @@ public class SplitToWorkspaceController { private void startWorkspaceAnimation(@NonNull View view, @Nullable Bitmap bitmap, @Nullable Drawable icon) { DeviceProfile dp = mLauncher.getDeviceProfile(); - boolean isTablet = dp.getDeviceProperties().isTablet(); + boolean isTablet = dp.isTablet; SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet); PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration()); diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index b34587c525..7fbc7bd4e0 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -152,7 +152,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mLayoutValid = false; mOrientationState.setDeviceProfile(dp); if (enableGridOnlyOverview()) { - mIsGridTask = dp.getDeviceProperties().isTablet() && !mIsDesktopTask; + mIsGridTask = dp.isTablet && !mIsDesktopTask; } calculateTaskSize(); } @@ -325,7 +325,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { public void addAppToCarouselAnim(PendingAnimation pa, Interpolator interpolator, boolean isHandlingAtomicEvent) { pa.addFloat(fullScreenProgress, AnimatedFloat.VALUE, 1, 0, interpolator); - if (enableGridOnlyOverview() && mDp.getDeviceProperties().isTablet() && !isHandlingAtomicEvent) { + if (enableGridOnlyOverview() && mDp.isTablet && !isHandlingAtomicEvent) { mIsAnimatingToCarousel = true; carouselScale.value = mCarouselTaskSize.width() / (float) mFullTaskSize.width(); } @@ -357,7 +357,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { public RectF getCurrentRect() { RectF result = getCurrentCropRect(); mMatrixTmp.set(mMatrix); - preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(), + preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.widthPx, mDp.heightPx, mMatrixTmp); mMatrixTmp.mapRect(result); return result; @@ -411,11 +411,11 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { * window coordinate space. */ public void applyWindowToHomeRotation(Matrix matrix) { - matrix.postTranslate(mDp.getDeviceProperties().getWindowX(), mDp.getDeviceProperties().getWindowY()); + matrix.postTranslate(mDp.windowX, mDp.windowY); postDisplayRotation(deltaRotation( mOrientationState.getRecentsActivityRotation(), mOrientationState.getDisplayRotation()), - mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(), matrix); + mDp.widthPx, mDp.heightPx, matrix); } /** @@ -450,7 +450,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { boolean isRtlEnabled = !mIsRecentsRtl; mPositionHelper.updateThumbnailMatrix( mThumbnailPosition, mThumbnailData, mTaskRect.width(), mTaskRect.height(), - mDp.getDeviceProperties().isTablet(), mOrientationState.getRecentsActivityRotation(), isRtlEnabled); + mDp.isTablet, mOrientationState.getRecentsActivityRotation(), isRtlEnabled); mPositionHelper.getMatrix().invert(mInversePositionMatrix); if (DEBUG) { Log.d(TAG, " taskRect: " + mTaskRect); diff --git a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt index 6fc450a01b..915c9e5305 100644 --- a/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt +++ b/quickstep/src/com/android/quickstep/util/unfold/LauncherUnfoldTransitionController.kt @@ -56,7 +56,7 @@ class LauncherUnfoldTransitionController( } override fun onDeviceProfileChanged(dp: DeviceProfile) { - if (isTablet != null && dp.getDeviceProperties().isTablet != isTablet) { + if (isTablet != null && dp.isTablet != isTablet) { // We should preemptively start the animation only if: // - We changed to the unfolded screen // - SystemUI IPC connection is alive, so we won't end up in a situation that we won't @@ -66,24 +66,20 @@ class LauncherUnfoldTransitionController( // if Launcher was not open during unfold, in this case we receive the configuration // change only after we went back to home screen and we don't want to start the // animation in this case. - if ( - dp.getDeviceProperties().isTablet && - progressProvider.isActive && - !hasUnfoldTransitionStarted - ) { + if (dp.isTablet && progressProvider.isActive && !hasUnfoldTransitionStarted) { // Preemptively start the unfold animation to make sure that we have drawn // the first frame of the animation before the screen gets unblocked onTransitionStarted() Trace.beginAsyncSection("$TAG#startedPreemptively", 0) timeoutAlarm.setAlarm(PREEMPTIVE_UNFOLD_TIMEOUT_MS) } - if (!dp.getDeviceProperties().isTablet) { + if (!dp.isTablet) { // Reset unfold transition status when folded hasUnfoldTransitionStarted = false } } - isTablet = dp.getDeviceProperties().isTablet + isTablet = dp.isTablet } override fun onTransitionStarted() { diff --git a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java index 166ed7916c..121d8ede11 100644 --- a/quickstep/src/com/android/quickstep/views/AllAppsEduView.java +++ b/quickstep/src/com/android/quickstep/views/AllAppsEduView.java @@ -267,8 +267,8 @@ public class AllAppsEduView extends AbstractFloatingView { DeviceProfile grid = launcher.getDeviceProfile(); DragLayer.LayoutParams lp = new DragLayer.LayoutParams(mWidthPx, mMaxHeightPx); lp.ignoreInsets = true; - lp.leftMargin = (grid.getDeviceProperties().getWidthPx() - mWidthPx) / 2; - lp.topMargin = grid.getDeviceProperties().getHeightPx() - grid.hotseatBarSizePx - mMaxHeightPx; + lp.leftMargin = (grid.widthPx - mWidthPx) / 2; + lp.topMargin = grid.heightPx - grid.hotseatBarSizePx - mMaxHeightPx; setLayoutParams(lp); } diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt index fd5c1336a3..10d4377424 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt @@ -178,7 +178,7 @@ constructor( val splitBounds = splitBounds return when { splitBounds == null || - !recentsViewContainer.deviceProfile.deviceProperties.isTablet || + !recentsViewContainer.deviceProfile.isTablet || taskView.isLargeTile -> SplitBannerConfig.SPLIT_BANNER_FULLSCREEN // For portrait grid only height of task changes, not width. So we keep the text the // same diff --git a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt index 4361a33aa5..6bbd6b2c15 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt +++ b/quickstep/src/com/android/quickstep/views/FloatingAppPairBackground.kt @@ -37,12 +37,12 @@ import com.android.systemui.shared.system.QuickStepContract * increase in size during the animation. */ open class FloatingAppPairBackground( - context: Context, - // the view that we will draw this background on - protected val floatingView: FloatingAppPairView, - private val appIcon1: Drawable, - private val appIcon2: Drawable?, - dividerPos: Int, + context: Context, + // the view that we will draw this background on + protected val floatingView: FloatingAppPairView, + private val appIcon1: Drawable, + private val appIcon2: Drawable?, + dividerPos: Int ) : Drawable() { companion object { // Design specs -- app icons start small and expand during the animation @@ -79,44 +79,41 @@ open class FloatingAppPairBackground( backgroundPaint.color = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0) ta.recycle() // Set up timings and interpolators - val timings = - AnimUtils.getDeviceAppPairLaunchTimings( - container.deviceProfile.deviceProperties.isTablet - ) + val timings = AnimUtils.getDeviceAppPairLaunchTimings(container.deviceProfile.isTablet) expandXInterpolator = Interpolators.clampToProgress( timings.getStagedRectScaleXInterpolator(), timings.stagedRectSlideStartOffset, - timings.stagedRectSlideEndOffset, + timings.stagedRectSlideEndOffset ) expandYInterpolator = Interpolators.clampToProgress( timings.getStagedRectScaleYInterpolator(), timings.stagedRectSlideStartOffset, - timings.stagedRectSlideEndOffset, + timings.stagedRectSlideEndOffset ) cellSplitInterpolator = Interpolators.clampToProgress( timings.cellSplitInterpolator, timings.cellSplitStartOffset, - timings.cellSplitEndOffset, + timings.cellSplitEndOffset ) iconFadeInterpolator = Interpolators.clampToProgress( timings.iconFadeInterpolator, timings.iconFadeStartOffset, - timings.iconFadeEndOffset, + timings.iconFadeEndOffset ) // Find device-specific measurements val resources = context.resources deviceCornerRadius = QuickStepContract.getWindowCornerRadius(context) deviceHalfDividerSize = - resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f + resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f val dividerCenterPos = dividerPos + deviceHalfDividerSize desiredSplitRatio = - if (dp.isLeftRightSplit) dividerCenterPos / dp.deviceProperties.widthPx - else dividerCenterPos / dp.deviceProperties.heightPx + if (dp.isLeftRightSplit) dividerCenterPos / dp.widthPx + else dividerCenterPos / dp.heightPx dividerPaint.color = resources.getColor(R.color.taskbar_background_dark, null /*theme*/) } @@ -160,13 +157,8 @@ open class FloatingAppPairBackground( // The right half of the background image val rightSide = RectF(dividerCenterPos + changingDividerSize, 0f, width, height) // Middle part is for divider background - val middleRect = - RectF( - leftSide.right - deviceHalfDividerSize, - 0f, - rightSide.left + deviceHalfDividerSize, - height, - ) + val middleRect = RectF(leftSide.right - deviceHalfDividerSize, 0f, + rightSide.left + deviceHalfDividerSize, height) // Draw background canvas.drawRect(middleRect, dividerPaint) @@ -182,7 +174,7 @@ open class FloatingAppPairBackground( changingInnerRadiusY, cornerRadiusX, cornerRadiusY, - ), + ) ) drawCustomRoundedRect( canvas, @@ -196,7 +188,7 @@ open class FloatingAppPairBackground( cornerRadiusY, changingInnerRadiusX, changingInnerRadiusY, - ), + ) ) // Calculate changing measurements for icons. @@ -267,13 +259,8 @@ open class FloatingAppPairBackground( // The bottom half of the background image val bottomSide = RectF(0f, dividerCenterPos + changingDividerSize, width, height) // Middle part is for divider background - val middleRect = - RectF( - 0f, - topSide.bottom - deviceHalfDividerSize, - width, - bottomSide.top + deviceHalfDividerSize, - ) + val middleRect = RectF(0f, topSide.bottom - deviceHalfDividerSize, + width, bottomSide.top + deviceHalfDividerSize) // Draw background canvas.drawRect(middleRect, dividerPaint) @@ -288,8 +275,8 @@ open class FloatingAppPairBackground( changingInnerRadiusX, changingInnerRadiusY, changingInnerRadiusX, - changingInnerRadiusY, - ), + changingInnerRadiusY + ) ) drawCustomRoundedRect( canvas, @@ -302,8 +289,8 @@ open class FloatingAppPairBackground( cornerRadiusX, cornerRadiusY, cornerRadiusX, - cornerRadiusY, - ), + cornerRadiusY + ) ) // Calculate changing measurements for icons. diff --git a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java index 72a823efe1..acbb2eccbb 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingTaskView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingTaskView.java @@ -239,7 +239,7 @@ public class FloatingTaskView extends FrameLayout { // Position the floating view exactly on top of the original lp.topMargin = Math.round(pos.top); if (mIsRtl) { - lp.setMarginStart(mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() - Math.round(pos.right)); + lp.setMarginStart(mContainer.getDeviceProfile().widthPx - Math.round(pos.right)); } else { lp.setMarginStart(Math.round(pos.left)); } @@ -256,7 +256,7 @@ public class FloatingTaskView extends FrameLayout { */ public void addStagingAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { - boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet(); + boolean isTablet = mContainer.getDeviceProfile().isTablet; boolean splittingFromOverview = fadeWithThumbnail; SplitAnimationTimings timings; @@ -280,7 +280,7 @@ public class FloatingTaskView extends FrameLayout { public void addConfirmAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) { SplitAnimationTimings timings = - AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); + AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().isTablet); addAnimation(animation, startingBounds, endBounds, fadeWithThumbnail, isStagedTask, timings); diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index 8ac15cb447..efc7eea84d 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -273,7 +273,7 @@ public class OverviewActionsView extends FrameLayo private void updateForIsTablet() { assert mDp != null; // Update flags to see if split button should be hidden. - updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.getDeviceProperties().isTablet()); + updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.isTablet); updateActionButtonsVisibility(); } @@ -282,7 +282,7 @@ public class OverviewActionsView extends FrameLayo return; } boolean showSingleTaskActions = !mIsGroupedTask; - boolean showGroupActions = mIsGroupedTask && mDp.getDeviceProperties().isTablet() && mCanSaveAppPair; + boolean showGroupActions = mIsGroupedTask && mDp.isTablet && mCanSaveAppPair; Log.d(TAG, "updateActionButtonsVisibility() called: showSingleTaskActions = [" + showSingleTaskActions + "], showGroupActions = [" + showGroupActions + "]"); getActionsAlphas().get(INDEX_GROUPED_ALPHA).setValue(showSingleTaskActions ? 1 : 0); @@ -384,12 +384,12 @@ public class OverviewActionsView extends FrameLayo return 0; } - if (mDp.getDeviceProperties().isTablet() && enableGridOnlyOverview()) { + if (mDp.isTablet && enableGridOnlyOverview()) { return mDp.stashedTaskbarHeight; } // Align to bottom of task Rect. - return mDp.getDeviceProperties().getHeightPx() - mTaskSize.bottom - mDp.overviewActionsTopMarginPx + return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx - mDp.overviewActionsHeight; } diff --git a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt index b24b71c395..23b0f6c180 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt @@ -1004,11 +1004,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) { dispatchScrollChanged() updateActionsViewFocusedScroll() if ( - isClearAllHidden && - !(mContainer as ActivityContext) - .getDeviceProfile() - .deviceProperties - .isTablet + isClearAllHidden && !(mContainer as ActivityContext).getDeviceProfile().isTablet ) { actionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false) } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 9c5f604c78..b4c04bbb40 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1475,9 +1475,9 @@ public abstract class RecentsView< for (int i = apps.length - 1; i >= 0; --i) { RemoteAnimationTarget app = apps[i]; - float dx = mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() * (1 - percent) / 2 + float dx = mContainer.getDeviceProfile().widthPx * (1 - percent) / 2 + app.screenSpaceBounds.left * percent; - float dy = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() * (1 - percent) / 2 + float dy = mContainer.getDeviceProfile().heightPx * (1 - percent) / 2 + app.screenSpaceBounds.top * percent; matrix.setScale(percent, percent); matrix.postTranslate(dx, dy); @@ -1714,7 +1714,7 @@ public abstract class RecentsView< @Override protected void onPageBeginTransition() { super.onPageBeginTransition(); - if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { + if (!mContainer.getDeviceProfile().isTablet) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, true); } if (mOverviewStateEnabled) { // only when in overview @@ -1726,7 +1726,7 @@ public abstract class RecentsView< protected void onPageEndTransition() { super.onPageEndTransition(); ActiveGestureProtoLogProxy.logOnPageEndTransition(getNextPage()); - if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { + if (!mContainer.getDeviceProfile().isTablet) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } if (getNextPage() > 0) { @@ -1738,12 +1738,12 @@ public abstract class RecentsView< @Override protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) { DeviceProfile deviceProfile = mContainer.getDeviceProfile(); - if (!deviceProfile.getDeviceProperties().isTablet()) { + if (!deviceProfile.isTablet) { return super.isSignificantMove(absoluteDelta, pageOrientedSize); } return absoluteDelta - > deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; + > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; } @Override @@ -2300,7 +2300,7 @@ public abstract class RecentsView< setOverviewGridEnabled( getStateManager().getState().displayOverviewTasksAsGrid(dp)); if (enableGridOnlyOverview()) { - mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.getDeviceProperties().isTablet()); + mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.isTablet); } setPageSpacing(dp.overviewPageSpacing); @@ -2378,8 +2378,8 @@ public abstract class RecentsView< mTaskHeight = mLastComputedTaskSize.height(); setPadding(mLastComputedTaskSize.left - mInsets.left, mLastComputedTaskSize.top - dp.overviewTaskThumbnailTopMarginPx - mInsets.top, - dp.getDeviceProperties().getWidthPx() - mInsets.right - mLastComputedTaskSize.right, - dp.getDeviceProperties().getHeightPx() - mInsets.bottom - mLastComputedTaskSize.bottom); + dp.widthPx - mInsets.right - mLastComputedTaskSize.right, + dp.heightPx - mInsets.bottom - mLastComputedTaskSize.bottom); mContainerInterface.calculateGridSize(dp, mContainer, mLastComputedGridSize); mContainerInterface.calculateGridTaskSize(mContainer, dp, mLastComputedGridTaskSize, @@ -2461,7 +2461,7 @@ public abstract class RecentsView< */ private float getTaskAlignmentTranslationY() { DeviceProfile deviceProfile = mContainer.getDeviceProfile(); - if (deviceProfile.getDeviceProperties().isTablet()) { + if (deviceProfile.isTablet) { return deviceProfile.overviewRowSpacing; } return deviceProfile.overviewTaskThumbnailTopMarginPx / 2.0f; @@ -2562,7 +2562,7 @@ public abstract class RecentsView< @Override protected int getDestinationPage(int scaledScroll) { - if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { + if (!mContainer.getDeviceProfile().isTablet) { return super.getDestinationPage(scaledScroll); } if (!isPageScrollsInitialized()) { @@ -3491,7 +3491,7 @@ public abstract class RecentsView< int minimumDistance = (mIsRtl ? mLastComputedTaskSize.left - : deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right) + : deviceProfile.widthPx - mLastComputedTaskSize.right) - deviceProfile.overviewGridSideMargin - mPageSpacing + (mTaskWidth - snappedTaskView.getLayoutParams().width) - mClearAllShortTotalWidthTranslation; @@ -3648,7 +3648,7 @@ public abstract class RecentsView< mSplitPlaceholderInset, mContainer.getDeviceProfile(), mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect); SplitAnimationTimings timings = - AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); + AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet); RectF startingTaskRect = new RectF(); safeRemoveDragLayerView(mSplitSelectStateController.getFirstFloatingTaskView()); @@ -3880,7 +3880,7 @@ public abstract class RecentsView< } SplitAnimationTimings splitTimings = - AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet()); + AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet); int distanceFromDismissedTask = 1; int slidingTranslation = 0; @@ -4245,7 +4245,7 @@ public abstract class RecentsView< // Update various scroll-dependent UI. dispatchScrollChanged(); updateActionsViewFocusedScroll(); - if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { + if (!mContainer.getDeviceProfile().isTablet) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } @@ -5131,7 +5131,7 @@ public abstract class RecentsView< if (isTopShift) { distanceToOffscreen = -taskPosition.bottom; } else if (isBottomShift) { - distanceToOffscreen = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() - taskPosition.top; + distanceToOffscreen = mContainer.getDeviceProfile().heightPx - taskPosition.top; } return distanceToOffscreen * offsetProgress; } @@ -5232,7 +5232,7 @@ public abstract class RecentsView< public void handleDesktopTaskInSplitSelectState(PendingAnimation builder, Interpolator deskTopFadeInterPolator) { SplitAnimationTimings timings = AnimUtils.getDeviceOverviewToSplitTimings( - mContainer.getDeviceProfile().getDeviceProperties().isTablet()); + mContainer.getDeviceProfile().isTablet); if (enableLargeDesktopWindowingTile()) { getTaskViews().forEachWithIndexInParent((index, taskView) -> { if (taskView instanceof DesktopTaskView) { @@ -5344,7 +5344,7 @@ public abstract class RecentsView< builder.addOnFrameListener((animator) -> { SplitAnimationTimings splitTimings = AnimUtils.getDeviceOverviewToSplitTimings( - mContainer.getDeviceProfile().getDeviceProperties().isTablet()); + mContainer.getDeviceProfile().isTablet); if (animator.getAnimatedFraction() > splitTimings.getGridSlideStartOffset() && !hasRunDismiss.get()) { mDismissUtils.createTaskDismissSpringAnimation( @@ -5410,7 +5410,7 @@ public abstract class RecentsView< Rect firstTaskStartingBounds = new Rect(); Rect firstTaskEndingBounds = mTempRect; - boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet(); + boolean isTablet = mContainer.getDeviceProfile().isTablet; SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet); PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration()); @@ -5490,7 +5490,7 @@ public abstract class RecentsView< if (mSplitHiddenTaskViewIndex == -1) { return; } - if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) { + if (!mContainer.getDeviceProfile().isTablet) { int pageToSnapTo = mCurrentPage; if (mSplitHiddenTaskViewIndex <= pageToSnapTo) { pageToSnapTo += 1; @@ -5540,11 +5540,11 @@ public abstract class RecentsView< int direction = orientationHandler.getSplitTranslationDirectionFactor( splitPosition, deviceProfile); - if (deviceProfile.getDeviceProperties().isTablet() && deviceProfile.isLeftRightSplit) { + if (deviceProfile.isTablet && deviceProfile.isLeftRightSplit) { // Only shift TaskViews if there is not enough space on the side of // mLastComputedTaskSize to minimize motion. int sideSpace = mIsRtl - ? deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right + ? deviceProfile.widthPx - mLastComputedTaskSize.right : mLastComputedTaskSize.left; int extraSpace = splitPlaceholderSize + mPageSpacing - sideSpace; if (extraSpace <= 0f) { diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt index e46891a3f1..7a53b109c5 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/views/RecentsViewUtils.kt @@ -213,7 +213,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi if (desktopTaskView != null) return recentsView.indexOfChild(desktopTaskView) } val firstTaskViewIndex = recentsView.indexOfChild(getFirstTaskView()) - return if (getDeviceProfile().deviceProperties.isTablet) { + return if (getDeviceProfile().isTablet) { var index = firstTaskViewIndex if (enableLargeDesktopWindowingTile() && runningTaskView !is DesktopTaskView) { // For fullsreen tasks, skip over Desktop tasks in its section @@ -402,7 +402,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi outTopRowRect: Rect, outBottomRowRect: Rect, ) { - if (!getDeviceProfile().deviceProperties.isTablet) { + if (!getDeviceProfile().isTablet) { getRowRect(getFirstTaskView(), getLastTaskView(), outTaskViewRowRect) return } @@ -468,7 +468,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi } fun updateCentralTask() { - val isTablet: Boolean = getDeviceProfile().deviceProperties.isTablet + val isTablet: Boolean = getDeviceProfile().isTablet val actionsViewCanRelateToTaskView = !(isTablet && enableGridOnlyOverview()) val focusedTaskView = recentsView.focusedTaskView val currentPageTaskView = recentsView.currentPageTaskView diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt index 09a358a39d..1d12d119b3 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt @@ -75,7 +75,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : // Spaced claimed below Overview (taskbar and insets) private val taskbarTop by lazy { - recentsViewContainer.deviceProfile.deviceProperties.heightPx - + recentsViewContainer.deviceProfile.heightPx - recentsViewContainer.deviceProfile.overviewActionsClaimedSpaceBelow } private val minMenuTop by lazy { taskContainer.iconView.asView().height.toFloat() } @@ -478,7 +478,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : additionalTranslationX = max( (translationX + width - - (recentsViewContainer.deviceProfile.deviceProperties.widthPx - + (recentsViewContainer.deviceProfile.widthPx - resources.getDimensionPixelSize( R.dimen.task_menu_edge_padding ) * 2)) diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java index 859feb2ec5..74d76e6432 100644 --- a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewDeprecated.java @@ -469,7 +469,7 @@ public class TaskThumbnailViewDeprecated extends View implements ViewPool.Reusab int currentRotation = mTaskView.getOrientedState().getRecentsActivityRotation(); boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL; mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData, - getMeasuredWidth(), getMeasuredHeight(), dp.getDeviceProperties().isTablet(), currentRotation, isRtl); + getMeasuredWidth(), getMeasuredHeight(), dp.isTablet, currentRotation, isRtl); mBitmapShader.setLocalMatrix(mPreviewPositionHelper.getMatrix()); mPaint.setShader(mBitmapShader); diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 8bd64b0e1f..3cefe68f99 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -155,7 +155,7 @@ constructor( val isGridTask: Boolean /** Returns whether the task is part of overview grid and not being focused. */ - get() = container.deviceProfile.getDeviceProperties().isTablet && !isLargeTile + get() = container.deviceProfile.isTablet && !isLargeTile val isRunningTask: Boolean get() = this === recentsView?.runningTaskView @@ -678,7 +678,7 @@ constructor( pivotY = modalPivot.y } else { val thumbnailTopMargin = container.deviceProfile.overviewTaskThumbnailTopMarginPx - if (container.deviceProfile.getDeviceProperties().isTablet) { + if (container.deviceProfile.isTablet) { pivotX = (if (layoutDirection == LAYOUT_DIRECTION_RTL) 0 else right - left).toFloat() pivotY = thumbnailTopMargin.toFloat() @@ -1128,7 +1128,7 @@ constructor( val boxTranslationY: Float val expectedWidth: Int val expectedHeight: Int - if (container.deviceProfile.getDeviceProperties().isTablet) { + if (container.deviceProfile.isTablet) { val boxWidth: Int val boxHeight: Int @@ -1622,9 +1622,7 @@ constructor( // Don't show menu when selecting second split screen app return true } - if ( - !container.deviceProfile.getDeviceProperties().isTablet && !recentsView.isClearAllHidden - ) { + if (!container.deviceProfile.isTablet && !recentsView.isClearAllHidden) { recentsView.snapToPage(recentsView.indexOfChild(this)) return false } @@ -1660,11 +1658,11 @@ constructor( } else { TaskMenuView.showForTask(menuContainer) { recentsView.setTaskBorderEnabled(true) } } - } else if (container.deviceProfile.getDeviceProperties().isTablet) { + } else if (container.deviceProfile.isTablet) { val alignedOptionIndex = if ( recentsView.isOnGridBottomRow(menuContainer.taskView) && - container.deviceProfile.deviceProperties.isLandscape + container.deviceProfile.isLandscape ) { if (enableGridOnlyOverview()) { // With no focused task, there is less available space below the tasks, so diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt index a23ebe9914..c4b27eda22 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -625,8 +625,7 @@ class TaskbarOverflowTest { return getOnUiThread { val iconLayoutBounds = taskbarViewController.transientTaskbarIconLayoutBoundsInParent - val availableWidth = - taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx + val availableWidth = taskbarUnitTestRule.activityContext.deviceProfile.widthPx iconLayoutBounds.left - (availableWidth - iconLayoutBounds.right) < 2 } } @@ -634,7 +633,7 @@ class TaskbarOverflowTest { private val taskbarEndMargin: Int get() { return getOnUiThread { - taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx - + taskbarUnitTestRule.activityContext.deviceProfile.widthPx - taskbarViewController.transientTaskbarIconLayoutBoundsInParent.right } } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt index 579c10f712..c8f79463b1 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactoryTest.kt @@ -14,7 +14,6 @@ import androidx.test.runner.AndroidJUnit4 import com.android.launcher3.DeviceProfile import com.android.launcher3.R import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION -import com.android.launcher3.deviceprofile.DeviceProperties import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS @@ -51,8 +50,6 @@ class NavButtonLayoutFactoryTest { whenever(mockNavLayout.findViewById(R.id.back)).thenReturn(mockBackButton) whenever(mockNavLayout.findViewById(R.id.home)).thenReturn(mockHomeButton) whenever(mockNavLayout.findViewById(R.id.recent_apps)).thenReturn(mockRecentsButton) - val devicePropertiesMock: DeviceProperties = mock() - whenever(mockDeviceProfile.deviceProperties).thenReturn(devicePropertiesMock) // Init top level layout whenever(mockParentButtonContainer.requireViewById(ID_END_NAV_BUTTONS)) @@ -76,7 +73,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is KidsNavLayoutter) } @@ -91,7 +88,7 @@ class NavButtonLayoutFactoryTest { isInSetup = true, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is SetupNavLayoutter) } @@ -106,7 +103,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is TaskbarNavLayoutter) } @@ -120,7 +117,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = false, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) } @@ -134,7 +131,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is PhonePortraitNavLayoutter) } @@ -150,7 +147,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is PhoneLandscapeNavLayoutter) } @@ -166,7 +163,7 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = true, phoneMode = true, - surfaceRotation = ROTATION_270, + surfaceRotation = ROTATION_270 ) assert(layoutter is PhoneSeascapeNavLayoutter) } @@ -181,13 +178,16 @@ class NavButtonLayoutFactoryTest { isInSetup = false, isThreeButtonNav = false, phoneMode = true, - surfaceRotation = surfaceRotation, + surfaceRotation = surfaceRotation ) assert(layoutter is PhoneGestureLayoutter) } private fun setDeviceProfileLandscape() { - whenever(mockDeviceProfile.deviceProperties.isLandscape).thenReturn(true) + // Use reflection to modify landscape field + val landscapeField = mockDeviceProfile.javaClass.getDeclaredField("isLandscape") + landscapeField.isAccessible = true + landscapeField.set(mockDeviceProfile, true) } private fun getLayoutter( @@ -195,7 +195,7 @@ class NavButtonLayoutFactoryTest { isInSetup: Boolean, isThreeButtonNav: Boolean, phoneMode: Boolean, - @Rotation surfaceRotation: Int, + @Rotation surfaceRotation: Int ): NavButtonLayoutFactory.NavButtonLayoutter { return NavButtonLayoutFactory.getUiLayoutter( deviceProfile = mockDeviceProfile, diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt index 6b41475dd6..0dd1324c0f 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRuleTest.kt @@ -50,7 +50,7 @@ class TaskbarModeRuleTest { fun testTaskbarMode_transient_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isTrue() - assertThat(dp.deviceProperties.isGestureMode).isTrue() + assertThat(dp.isGestureMode).isTrue() } @Test @@ -66,7 +66,7 @@ class TaskbarModeRuleTest { fun testTaskbarMode_pinned_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isFalse() - assertThat(dp.deviceProperties.isGestureMode).isTrue() + assertThat(dp.isGestureMode).isTrue() } @Test @@ -83,6 +83,6 @@ class TaskbarModeRuleTest { fun testTaskbarMode_threeButtons_overridesDeviceProfile() { val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context) assertThat(dp.isTransientTaskbar).isFalse() - assertThat(dp.deviceProperties.isGestureMode).isFalse() + assertThat(dp.isGestureMode).isFalse() } } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 4fda8a58c6..74572fc38a 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1052,7 +1052,7 @@ public class CellLayout extends ViewGroup { /** * Returns the amount of space left over after subtracting padding and cells. This space will be * very small, a few pixels at most, and is a result of rounding down when calculating the cell - * width in {@link deviceprofile#calculateCellWidth(int, int, int)}. + * width in {@link DeviceProfile#calculateCellWidth(int, int, int)}. */ public int getUnusedHorizontalSpace() { return getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - (mCountX * mCellWidth) diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 5d51007025..51da925b98 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -56,7 +56,6 @@ import androidx.core.content.res.ResourcesCompat; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.DevicePaddings.DevicePadding; import com.android.launcher3.InvariantDeviceProfile.DisplayOptionSpec; -import com.android.launcher3.deviceprofile.DeviceProperties; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.model.data.ItemInfo; @@ -103,15 +102,31 @@ public class DeviceProfile { private final IconSizeSteps mIconSizeSteps; // Device properties - - private final DeviceProperties mDeviceProperties; - + public final boolean isTablet; + public final boolean isPhone; + public final boolean transposeLayoutWithOrientation; + public final boolean isMultiDisplay; + public final boolean isTwoPanels; public boolean isPredictiveBackSwipe; public final boolean isQsbInline; // Device properties in current orientation + public final boolean isLandscape; + public final boolean isMultiWindowMode; + public final boolean isGestureMode; public final boolean isLeftRightSplit; + + public final int windowX; + public final int windowY; + public final int widthPx; + public final int heightPx; + public final int availableWidthPx; + public final int availableHeightPx; + public final int rotationHint; + + public final float aspectRatio; + private final boolean mIsScalableGrid; private final int mTypeIndex; @@ -312,29 +327,30 @@ public class DeviceProfile { /** Used only as an alternative to mocking when null values cannot be used. */ @VisibleForTesting public DeviceProfile() { - mDeviceProperties = new DeviceProperties( - 0,0, - 0, - 0,0, - 0,0, - 0.0f, - false, - false, - false, - false, - false, - false, - false, - false - ); inv = null; mDisplayOptionSpec = null; mInfo = null; mMetrics = null; mIconSizeSteps = null; + isTablet = false; + isPhone = false; + transposeLayoutWithOrientation = false; + isMultiDisplay = false; + isTwoPanels = false; isPredictiveBackSwipe = false; isQsbInline = false; + isLandscape = false; + isMultiWindowMode = false; + isGestureMode = false; isLeftRightSplit = false; + windowX = 0; + windowY = 0; + widthPx = 0; + heightPx = 0; + availableWidthPx = 0; + availableHeightPx = 0; + rotationHint = 0; + aspectRatio = 1; mIsScalableGrid = false; mTypeIndex = 0; mIsResponsiveGrid = false; @@ -386,15 +402,14 @@ public class DeviceProfile { boolean isTransientTaskbar, DisplayOptionSpec displayOptionSpec) { this.inv = inv; - mDeviceProperties = DeviceProperties.Factory.createDeviceProperties( - info, - windowBounds, - transposeLayoutWithOrientation, - isMultiDisplay, - isMultiWindowMode, - isGestureMode - ); - + this.isLandscape = windowBounds.isLandscape(); + this.isMultiWindowMode = isMultiWindowMode; + this.transposeLayoutWithOrientation = transposeLayoutWithOrientation; + this.isMultiDisplay = isMultiDisplay; + this.isGestureMode = isGestureMode; + windowX = windowBounds.bounds.left; + windowY = windowBounds.bounds.top; + this.rotationHint = windowBounds.rotationHint; mInsets.set(windowBounds.insets); this.mDisplayOptionSpec = displayOptionSpec; @@ -409,15 +424,18 @@ public class DeviceProfile { mIsScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode; // Determine device posture. mInfo = info; + isTablet = info.isTablet(windowBounds); + isPhone = !isTablet; + isTwoPanels = isTablet && isMultiDisplay; boolean taskbarOrBubbleBarOnPhones = enableTinyTaskbar() || (enableBubbleBar() && enableBubbleBarOnPhones()); - isTaskbarPresent = (mDeviceProperties.isTablet() || (taskbarOrBubbleBarOnPhones && isGestureMode)) + isTaskbarPresent = (isTablet || (taskbarOrBubbleBarOnPhones && isGestureMode)) && wmProxy.isTaskbarDrawnInProcess(); // Some more constants. context = getContext(context, info, inv.isFixedLandscape || isVerticalBarLayout() - || (mDeviceProperties.isTablet() && mDeviceProperties.isLandscape()) + || (isTablet && isLandscape) ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT, windowBounds); @@ -426,6 +444,13 @@ public class DeviceProfile { mIconSizeSteps = new IconSizeSteps(res); + // Determine sizes. + widthPx = windowBounds.bounds.width(); + heightPx = windowBounds.bounds.height(); + availableWidthPx = windowBounds.availableSize.x; + availableHeightPx = windowBounds.availableSize.y; + + aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx); mTypeIndex = displayOptionSpec.typeIndex; this.isTransientTaskbar = isTransientTaskbar; @@ -467,13 +492,13 @@ public class DeviceProfile { { // In large screens, in portrait mode, a bottom sheet can appear too elongated, so, we // apply additional padding. - final boolean applyExtraTopPadding = mDeviceProperties.isTablet() - && !mDeviceProperties.isLandscape() - && (mDeviceProperties.getAspectRatio() > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); - final int derivedTopPadding = mDeviceProperties.getHeightPx() / 6; + final boolean applyExtraTopPadding = isTablet + && !isLandscape + && (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING); + final int derivedTopPadding = heightPx / 6; bottomSheetTopPadding = mInsets.top // statusbar height + (applyExtraTopPadding ? derivedTopPadding : 0) - + (mDeviceProperties.isTablet() ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding } bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); @@ -557,9 +582,9 @@ public class DeviceProfile { dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size); // Some foldable portrait modes are too wide in terms of aspect ratio so we need to tweak // the dimensions for edit state. - final boolean shouldApplyWidePortraitDimens = mDeviceProperties.isTablet() - && !mDeviceProperties.isLandscape() - && mDeviceProperties.getAspectRatio() < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE; + final boolean shouldApplyWidePortraitDimens = isTablet + && !isLandscape + && aspectRatio < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE; dropTargetBarTopMarginPx = shouldApplyWidePortraitDimens ? 0 : res.getDimensionPixelSize(R.dimen.drop_target_top_margin); @@ -598,15 +623,15 @@ public class DeviceProfile { int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin); if (mIsResponsiveGrid) { - float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx(); + float responsiveAspectRatio = (float) widthPx / heightPx; HotseatSpecsProvider hotseatSpecsProvider = HotseatSpecsProvider.create(new ResourceHelper(context, displayOptionSpec.hotseatSpecsId)); mResponsiveHotseatSpec = isVerticalBarLayout() ? hotseatSpecsProvider.getCalculatedSpec( - responsiveAspectRatio, DimensionType.WIDTH, mDeviceProperties.getWidthPx()) + responsiveAspectRatio, DimensionType.WIDTH, widthPx) : hotseatSpecsProvider.getCalculatedSpec(responsiveAspectRatio, - DimensionType.HEIGHT, mDeviceProperties.getHeightPx()); + DimensionType.HEIGHT, heightPx); hotseatQsbSpace = mResponsiveHotseatSpec.getHotseatQsbSpace(); hotseatBarBottomSpace = isVerticalBarLayout() ? 0 : mResponsiveHotseatSpec.getEdgePadding(); @@ -617,7 +642,7 @@ public class DeviceProfile { ResponsiveCellSpecsProvider workspaceCellSpecs = ResponsiveCellSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.workspaceCellSpecsId)); mResponsiveWorkspaceCellSpec = workspaceCellSpecs.getCalculatedSpec( - responsiveAspectRatio, mDeviceProperties.getHeightPx()); + responsiveAspectRatio, heightPx); } else { hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics); hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics); @@ -659,7 +684,7 @@ public class DeviceProfile { updateHotseatSizes(pxFromDp(inv.iconSize[mTypeIndex], mMetrics)); } - if (areNavButtonsInline && !mDeviceProperties.isPhone()) { + if (areNavButtonsInline && !isPhone) { inlineNavButtonsEndSpacingPx = res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing); /* 3 nav buttons + Spacing between nav buttons */ @@ -679,12 +704,12 @@ public class DeviceProfile { // for the available height to be correct if (mIsResponsiveGrid) { int availableResponsiveWidth = - mDeviceProperties.getAvailableWidthPx() - (isVerticalBarLayout() ? hotseatBarSizePx : 0); + availableWidthPx - (isVerticalBarLayout() ? hotseatBarSizePx : 0); int numWorkspaceColumns = getPanelCount() * inv.numColumns; // don't use availableHeightPx because it subtracts mInsets.bottom - int availableResponsiveHeight = mDeviceProperties.getHeightPx() - mInsets.top + int availableResponsiveHeight = heightPx - mInsets.top - (isVerticalBarLayout() ? 0 : hotseatBarSizePx); - float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx(); + float responsiveAspectRatio = (float) widthPx / heightPx; ResponsiveSpecsProvider workspaceSpecs = ResponsiveSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.workspaceSpecsId), @@ -698,7 +723,7 @@ public class DeviceProfile { new ResourceHelper(context, displayOptionSpec.allAppsSpecsId), ResponsiveSpecType.AllApps); mResponsiveAllAppsWidthSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, - DimensionType.WIDTH, numShownAllAppsColumns, mDeviceProperties.getAvailableWidthPx(), + DimensionType.WIDTH, numShownAllAppsColumns, availableWidthPx, mResponsiveWorkspaceWidthSpec); if (inv.appListAlignedWithWorkspaceRow >= 0) { allAppsTopPadding += mResponsiveWorkspaceHeightSpec.getStartPaddingPx() @@ -708,7 +733,7 @@ public class DeviceProfile { } mResponsiveAllAppsHeightSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio, DimensionType.HEIGHT, inv.numAllAppsRowsForCellHeightCalculation, - mDeviceProperties.getHeightPx() - allAppsTopPadding, mResponsiveWorkspaceHeightSpec); + heightPx - allAppsTopPadding, mResponsiveWorkspaceHeightSpec); ResponsiveSpecsProvider folderSpecs = ResponsiveSpecsProvider.create( new ResourceHelper(context, displayOptionSpec.folderSpecsId), @@ -760,10 +785,10 @@ public class DeviceProfile { boolean allowLeftRightSplitInPortrait = leftRightSplitPortraitResId > 0 && res.getBoolean(leftRightSplitPortraitResId); - if (allowLeftRightSplitInPortrait && mDeviceProperties.isTablet()) { - isLeftRightSplit = !mDeviceProperties.isLandscape(); + if (allowLeftRightSplitInPortrait && isTablet) { + isLeftRightSplit = !isLandscape; } else { - isLeftRightSplit = mDeviceProperties.isLandscape(); + isLeftRightSplit = isLandscape; } // Calculate all of the remaining variables. @@ -772,7 +797,7 @@ public class DeviceProfile { calculateAndSetWorkspaceVerticalPadding(context, inv, extraSpace); int cellLayoutPadding = - mDeviceProperties.isTwoPanels() ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize( + isTwoPanels ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize( R.dimen.cell_layout_padding); cellLayoutPaddingPx = new Rect(cellLayoutPadding, cellLayoutPadding, cellLayoutPadding, cellLayoutPadding); @@ -795,7 +820,7 @@ public class DeviceProfile { if (shouldShowAllAppsOnSheet()) { allAppsPadding.top = allAppsTopPadding; - allAppsShiftRange = mDeviceProperties.getHeightPx() - allAppsTopPadding + mInsets.top; + allAppsShiftRange = heightPx - allAppsTopPadding + mInsets.top; } else { allAppsPadding.top = 0; allAppsShiftRange = @@ -816,10 +841,6 @@ public class DeviceProfile { mDotRendererAllApps = createDotRenderer(themeManager, allAppsIconSizePx, dotRendererCache); } - public DeviceProperties getDeviceProperties() { - return mDeviceProperties; - } - /** * Takes care of the logic that determines if we show a the QSB inline or not. */ @@ -831,7 +852,7 @@ public class DeviceProfile { // In tablets we inline in both orientations but only if we have enough space in the QSB boolean tabletInlineQsb = inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE]; - boolean canQsbInline = mDeviceProperties.isTwoPanels() ? twoPanelCanInline : tabletInlineQsb; + boolean canQsbInline = isTwoPanels ? twoPanelCanInline : tabletInlineQsb; canQsbInline = canQsbInline && hotseatQsbHeight > 0; return (mIsScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline) @@ -858,7 +879,7 @@ public class DeviceProfile { * reasonable over estimation is fine. */ public int getMaxAllAppsRowCount() { - return (int) (Math.ceil((mDeviceProperties.getAvailableHeightPx() - allAppsPadding.top) + return (int) (Math.ceil((availableHeightPx - allAppsPadding.top) / (float) allAppsCellHeightPx)); } @@ -948,7 +969,7 @@ public class DeviceProfile { updateHotseatWidthAndBorderSpace(inv.numColumns); int numWorkspaceColumns = getPanelCount() * inv.numColumns; - if (mDeviceProperties.isTwoPanels()) { + if (isTwoPanels) { updateHotseatWidthAndBorderSpace(inv.numDatabaseHotseatIcons); // If hotseat doesn't fit with current width, increase column span to fit by multiple // of 2. @@ -978,7 +999,7 @@ public class DeviceProfile { // The side space with inline buttons should be what is defined in InvariantDeviceProfile int sideSpacePx = inlineNavButtonsEndSpacingPx; - int maxHotseatWidthPx = mDeviceProperties.getAvailableWidthPx() - sideSpacePx - hotseatBarEndOffset; + int maxHotseatWidthPx = availableWidthPx - sideSpacePx - hotseatBarEndOffset; int maxHotseatIconsWidthPx = maxHotseatWidthPx - (isQsbInline ? hotseatQsbWidth : 0); hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx, (isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1); @@ -1053,13 +1074,8 @@ public class DeviceProfile { public Builder toBuilder(Context context) { WindowBounds bounds = new WindowBounds( - mDeviceProperties.getWidthPx(), - mDeviceProperties.getHeightPx(), - mDeviceProperties.getAvailableWidthPx(), - mDeviceProperties.getAvailableHeightPx(), - mDeviceProperties.getRotationHint() - ); - bounds.bounds.offsetTo(mDeviceProperties.getWindowX(), mDeviceProperties.getWindowY()); + widthPx, heightPx, availableWidthPx, availableHeightPx, rotationHint); + bounds.bounds.offsetTo(windowX, windowY); bounds.insets.set(mInsets); SparseArray dotRendererCache = new SparseArray<>(); @@ -1068,10 +1084,10 @@ public class DeviceProfile { return inv.newDPBuilder(context, mInfo) .setWindowBounds(bounds) - .setIsMultiDisplay(mDeviceProperties.isMultiDisplay()) - .setMultiWindowMode(mDeviceProperties.isMultiWindowMode()) + .setIsMultiDisplay(isMultiDisplay) + .setMultiWindowMode(isMultiWindowMode) .setDotRendererCache(dotRendererCache) - .setGestureMode(mDeviceProperties.isGestureMode()) + .setGestureMode(isGestureMode) .setDisplayOptionSpec(mDisplayOptionSpec); } @@ -1163,7 +1179,7 @@ public class DeviceProfile { float usedWidth = getCellLayoutWidthSpecification() + (desiredWorkspaceHorizontalMarginPx * 2); // We do not subtract padding here, as we also scale the workspace padding if needed. - scaleX = mDeviceProperties.getAvailableWidthPx() / usedWidth; + scaleX = availableWidthPx / usedWidth; shouldScale = true; } @@ -1328,7 +1344,7 @@ public class DeviceProfile { maxIconTextLineCount = 1; int cellPaddingY = (getCellSize().y - cellHeightPx) / 2; if (iconDrawablePaddingPx > cellPaddingY && !isVerticalLayout - && !mDeviceProperties.isMultiWindowMode()) { + && !isMultiWindowMode) { // Ensures that the label is closer to its corresponding icon. This is not an issue // with vertical bar layout or multi-window mode since the issue is handled // separately with their calls to {@link #adjustToHideWorkspaceLabels}. @@ -1506,11 +1522,11 @@ public class DeviceProfile { private void updateAllAppsContainerWidth() { int cellLayoutHorizontalPadding = (cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2; - if (mDeviceProperties.isTablet()) { + if (isTablet) { int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns) + (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1)) + allAppsPadding.left + allAppsPadding.right; - allAppsLeftRightMargin = Math.max(1, (mDeviceProperties.getAvailableWidthPx() - usedWidth) / 2); + allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2); } else if (!mIsResponsiveGrid) { allAppsPadding.left = allAppsPadding.right = Math.max(0, desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding @@ -1520,7 +1536,7 @@ public class DeviceProfile { /** Whether All Apps should be presented on a bottom sheet. */ public boolean shouldShowAllAppsOnSheet() { - return mDeviceProperties.isTablet() || Flags.allAppsSheetForHandheld(); + return isTablet || Flags.allAppsSheetForHandheld(); } private void setupAllAppsStyle(Context context) { @@ -1547,14 +1563,14 @@ public class DeviceProfile { + ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y) + folderFooterHeightPx + folderContentPaddingTop; - int contentMaxHeight = mDeviceProperties.getAvailableHeightPx() - totalWorkspacePadding.y; + int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y; float scaleY = contentMaxHeight / contentUsedHeight; // Check if the folder fit within the available width. float contentUsedWidth = folderCellWidthPx * numFolderColumns + ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x) + folderContentPaddingLeftRight * 2; - int contentMaxWidth = mDeviceProperties.getAvailableWidthPx() - totalWorkspacePadding.x; + int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x; float scaleX = contentMaxWidth / contentUsedWidth; float scale = Math.min(scaleX, scaleY); @@ -1706,7 +1722,7 @@ public class DeviceProfile { * Gets the number of panels within the workspace. */ public int getPanelCount() { - return mDeviceProperties.isTwoPanels() ? 2 : 1; + return isTwoPanels ? 2 : 1; } /** @@ -1716,7 +1732,7 @@ public class DeviceProfile { private int getVerticalHotseatLastItemBottomOffset(Context context) { Rect hotseatBarPadding = getHotseatLayoutPadding(context); int cellHeight = calculateCellHeight( - mDeviceProperties.getHeightPx() - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace, + heightPx - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace, numShownHotseatIcons); int extraIconEndSpacing = (cellHeight - iconSizePx) / 2; return extraIconEndSpacing + hotseatBarPadding.bottom; @@ -1735,7 +1751,7 @@ public class DeviceProfile { */ public float getCellLayoutSpringLoadShrunkBottom(Context context) { int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx; - return mDeviceProperties.getHeightPx() - (isVerticalBarLayout() + return heightPx - (isVerticalBarLayout() ? getVerticalHotseatLastItemBottomOffset(context) : topOfHotseat); } @@ -1749,7 +1765,7 @@ public class DeviceProfile { scale = Math.min(scale, 1f); // Reduce scale if next pages would not be visible after scaling the workspace. - int workspaceWidth = mDeviceProperties.getAvailableWidthPx(); + int workspaceWidth = availableWidthPx; float scaledWorkspaceWidth = workspaceWidth * scale; float maxAvailableWidth = workspaceWidth - (2 * workspaceSpringLoadedMinNextPageVisiblePx); if (scaledWorkspaceWidth > maxAvailableWidth) { @@ -1765,7 +1781,7 @@ public class DeviceProfile { * layouts have two Cell Layouts per workspace. */ public int getCellLayoutWidth() { - return (mDeviceProperties.getAvailableWidthPx() - getTotalWorkspacePadding().x) / getPanelCount(); + return (availableWidthPx - getTotalWorkspacePadding().x) / getPanelCount(); } /** @@ -1774,7 +1790,7 @@ public class DeviceProfile { *

This is the height of a Workspace, less its vertical padding. */ public int getCellLayoutHeight() { - return mDeviceProperties.getAvailableHeightPx() - getTotalWorkspacePadding().y; + return availableHeightPx - getTotalWorkspacePadding().y; } public Point getTotalWorkspacePadding() { @@ -1939,7 +1955,7 @@ public class DeviceProfile { int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx); int qsbWidth = getAdditionalQsbSpace() + iconExtraSpacePx / 2; - int availableWidthPxForHotseat = mDeviceProperties.getAvailableWidthPx() - Math.abs(workspacePadding.width()) + int availableWidthPxForHotseat = availableWidthPx - Math.abs(workspacePadding.width()) - Math.abs(cellLayoutPaddingPx.width()); int remainingSpaceOnSide = (availableWidthPxForHotseat - hotseatPlusQSBWidth) / 2; @@ -1968,9 +1984,9 @@ public class DeviceProfile { // Hotseat aligns to the left with nav buttons if (hotseatBarEndOffset > 0) { startSpacing = inlineNavButtonsEndSpacingPx; - endSpacing = mDeviceProperties.getAvailableWidthPx() - hotseatWidth - startSpacing + hotseatBorderSpace; + endSpacing = availableWidthPx - hotseatWidth - startSpacing + hotseatBorderSpace; } else { - startSpacing = (mDeviceProperties.getAvailableWidthPx() - hotseatWidth) / 2; + startSpacing = (availableWidthPx - hotseatWidth) / 2; endSpacing = startSpacing; } startSpacing += getAdditionalQsbSpace(); @@ -1988,7 +2004,7 @@ public class DeviceProfile { } else if (mIsScalableGrid) { int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx); - int sideSpacing = (mDeviceProperties.getAvailableWidthPx() - (hotseatQsbWidth + iconExtraSpacePx)) / 2; + int sideSpacing = (availableWidthPx - (hotseatQsbWidth + iconExtraSpacePx)) / 2; hotseatBarPadding.set(sideSpacing, 0, sideSpacing, @@ -1998,8 +2014,8 @@ public class DeviceProfile { // icons in the hotseat are a different size, and so don't line up perfectly. To account // for this, we pad the left and right of the hotseat with half of the difference of a // workspace cell vs a hotseat cell. - float workspaceCellWidth = (float) mDeviceProperties.getWidthPx() / inv.numColumns; - float hotseatCellWidth = (float) mDeviceProperties.getWidthPx() / numShownHotseatIcons; + float workspaceCellWidth = (float) widthPx / inv.numColumns; + float hotseatCellWidth = (float) widthPx / numShownHotseatIcons; int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2); hotseatBarPadding.set( hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left @@ -2024,7 +2040,7 @@ public class DeviceProfile { } int cellWidth = DeviceProfile.calculateCellWidth( - mDeviceProperties.getAvailableWidthPx() - allAppsSpacing, + availableWidthPx - allAppsSpacing, 0 /* borderSpace */, numShownAllAppsColumns); int iconAlignmentMargin = (cellWidth - getIconVisibleSizePx(allAppsIconSizePx)) / 2; @@ -2106,7 +2122,7 @@ public class DeviceProfile { /** Returns whether bubble bar should be aligned with the hotseat. */ public boolean shouldAlignBubbleBarWithHotseat() { - return isQsbInline || mDeviceProperties.isGestureMode(); + return isQsbInline || isGestureMode; } /** @@ -2126,7 +2142,7 @@ public class DeviceProfile { /** Gets the space that the overview actions will take, including bottom margin. */ public int getOverviewActionsClaimedSpace() { - int overviewActionsSpace = mDeviceProperties.isTablet() && enableGridOnlyOverview() + int overviewActionsSpace = isTablet && enableGridOnlyOverview() ? 0 : (overviewActionsTopMarginPx + overviewActionsHeight); return overviewActionsSpace + getOverviewActionsClaimedSpaceBelow(); @@ -2153,15 +2169,15 @@ public class DeviceProfile { // Folders should only appear right of the drop target bar and left of the hotseat return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx, mInsets.top, - mInsets.left + mDeviceProperties.getAvailableWidthPx() - hotseatBarSizePx - edgeMarginPx, - mInsets.top + mDeviceProperties.getAvailableHeightPx()); + mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx, + mInsets.top + availableHeightPx); } else { // Folders should only appear below the drop target bar and above the hotseat int hotseatTop = isTaskbarPresent ? taskbarHeight : hotseatBarSizePx; return new Rect(mInsets.left + edgeMarginPx, mInsets.top + dropTargetBarSizePx + edgeMarginPx, - mInsets.left + mDeviceProperties.getAvailableWidthPx() - edgeMarginPx, - mInsets.top + mDeviceProperties.getAvailableHeightPx() - hotseatTop + mInsets.left + availableWidthPx - edgeMarginPx, + mInsets.top + availableHeightPx - hotseatTop - workspacePageIndicatorHeight - edgeMarginPx); } } @@ -2180,11 +2196,11 @@ public class DeviceProfile { * the hotseat is on the bottom row. */ public boolean isVerticalBarLayout() { - return mDeviceProperties.isLandscape() && mDeviceProperties.getTransposeLayoutWithOrientation(); + return isLandscape && transposeLayoutWithOrientation; } public boolean isSeascape() { - return mDeviceProperties.getRotationHint() == Surface.ROTATION_270 + return rotationHint == Surface.ROTATION_270 && (isVerticalBarLayout() || inv.isFixedLandscape); } @@ -2221,29 +2237,29 @@ public class DeviceProfile { writer.println(prefix + "DeviceProfile:"); writer.println(prefix + "\t1 dp = " + mMetrics.density + " px"); - writer.println(prefix + "\tisTablet:" + mDeviceProperties.isTablet()); - writer.println(prefix + "\tisPhone:" + mDeviceProperties.isPhone()); + writer.println(prefix + "\tisTablet:" + isTablet); + writer.println(prefix + "\tisPhone:" + isPhone); writer.println(prefix + "\ttransposeLayoutWithOrientation:" - + mDeviceProperties.getTransposeLayoutWithOrientation()); - writer.println(prefix + "\tisGestureMode:" + mDeviceProperties.isGestureMode()); + + transposeLayoutWithOrientation); + writer.println(prefix + "\tisGestureMode:" + isGestureMode); - writer.println(prefix + "\tisLandscape:" + mDeviceProperties.isLandscape()); - writer.println(prefix + "\tisMultiWindowMode:" + mDeviceProperties.isMultiWindowMode()); - writer.println(prefix + "\tisTwoPanels:" + mDeviceProperties.isTwoPanels()); + writer.println(prefix + "\tisLandscape:" + isLandscape); + writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode); + writer.println(prefix + "\tisTwoPanels:" + isTwoPanels); writer.println(prefix + "\tisLeftRightSplit:" + isLeftRightSplit); - writer.println(prefix + pxToDpStr("windowX", mDeviceProperties.getWindowX())); - writer.println(prefix + pxToDpStr("windowY", mDeviceProperties.getWindowY())); - writer.println(prefix + pxToDpStr("widthPx", mDeviceProperties.getWidthPx())); - writer.println(prefix + pxToDpStr("heightPx", mDeviceProperties.getHeightPx())); - writer.println(prefix + pxToDpStr("availableWidthPx", mDeviceProperties.getAvailableWidthPx())); - writer.println(prefix + pxToDpStr("availableHeightPx", mDeviceProperties.getAvailableHeightPx())); + writer.println(prefix + pxToDpStr("windowX", windowX)); + writer.println(prefix + pxToDpStr("windowY", windowY)); + writer.println(prefix + pxToDpStr("widthPx", widthPx)); + writer.println(prefix + pxToDpStr("heightPx", heightPx)); + writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx)); + writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx)); writer.println(prefix + pxToDpStr("mInsets.left", mInsets.left)); writer.println(prefix + pxToDpStr("mInsets.top", mInsets.top)); writer.println(prefix + pxToDpStr("mInsets.right", mInsets.right)); writer.println(prefix + pxToDpStr("mInsets.bottom", mInsets.bottom)); - writer.println(prefix + "\taspectRatio:" + mDeviceProperties.getAspectRatio()); + writer.println(prefix + "\taspectRatio:" + aspectRatio); writer.println(prefix + "\tisResponsiveGrid:" + mIsResponsiveGrid); writer.println(prefix + "\tisScalableGrid:" + mIsScalableGrid); @@ -2426,12 +2442,12 @@ public class DeviceProfile { /** Returns a reduced representation of this DeviceProfile. */ public String toSmallString() { - return "isTablet:" + mDeviceProperties.isTablet() + ", " - + "mDeviceProperties.isMultiDisplay():" + mDeviceProperties.isMultiDisplay() + ", " - + "widthPx:" + mDeviceProperties.getWidthPx() + ", " - + "heightPx:" + mDeviceProperties.getHeightPx() + ", " + return "isTablet:" + isTablet + ", " + + "isMultiDisplay:" + isMultiDisplay + ", " + + "widthPx:" + widthPx + ", " + + "heightPx:" + heightPx + ", " + "insets:" + mInsets + ", " - + "rotationHint:" + mDeviceProperties.getRotationHint(); + + "rotationHint:" + rotationHint; } private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) { diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java index 57a924faae..1d5f185635 100644 --- a/src/com/android/launcher3/DropTargetBar.java +++ b/src/com/android/launcher3/DropTargetBar.java @@ -85,9 +85,8 @@ public class DropTargetBar extends FrameLayout @Override public void setInsets(Rect insets) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); - DeviceProfile deviceProfile = mLauncher.getDeviceProfile(); - mIsVertical = deviceProfile.isVerticalBarLayout(); - int widthPx = deviceProfile.getDeviceProperties().getWidthPx(); + DeviceProfile grid = mLauncher.getDeviceProfile(); + mIsVertical = grid.isVerticalBarLayout(); lp.leftMargin = insets.left; lp.topMargin = insets.top; @@ -96,25 +95,25 @@ public class DropTargetBar extends FrameLayout int tooltipLocation = TOOLTIP_DEFAULT; int horizontalMargin; - if (deviceProfile.getDeviceProperties().isTablet()) { + if (grid.isTablet) { // XXX: If the icon size changes across orientations, we will have to take // that into account here too. - horizontalMargin = ((widthPx - 2 * deviceProfile.edgeMarginPx - - (deviceProfile.inv.numColumns * deviceProfile.cellWidthPx)) - / (2 * (deviceProfile.inv.numColumns + 1))) - + deviceProfile.edgeMarginPx; + horizontalMargin = ((grid.widthPx - 2 * grid.edgeMarginPx + - (grid.inv.numColumns * grid.cellWidthPx)) + / (2 * (grid.inv.numColumns + 1))) + + grid.edgeMarginPx; } else { horizontalMargin = getContext().getResources() .getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal); } - lp.topMargin += deviceProfile.dropTargetBarTopMarginPx; - lp.bottomMargin += deviceProfile.dropTargetBarBottomMarginPx; - lp.width = deviceProfile.getDeviceProperties().getAvailableWidthPx() - 2 * horizontalMargin; + lp.topMargin += grid.dropTargetBarTopMarginPx; + lp.bottomMargin += grid.dropTargetBarBottomMarginPx; + lp.width = grid.availableWidthPx - 2 * horizontalMargin; if (mIsVertical) { - lp.leftMargin = (widthPx - lp.width) / 2; - lp.rightMargin = (widthPx - lp.width) / 2; + lp.leftMargin = (grid.widthPx - lp.width) / 2; + lp.rightMargin = (grid.widthPx - lp.width) / 2; } - lp.height = deviceProfile.dropTargetBarSizePx; + lp.height = grid.dropTargetBarSizePx; lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP; DeviceProfile dp = mLauncher.getDeviceProfile(); @@ -122,7 +121,7 @@ public class DropTargetBar extends FrameLayout int verticalPadding = dp.dropTargetVerticalPaddingPx; setLayoutParams(lp); for (ButtonDropTarget button : mDropTargets) { - button.setTextSize(TypedValue.COMPLEX_UNIT_PX, deviceProfile.dropTargetTextSizePx); + button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx); button.setToolTipLocation(tooltipLocation); button.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); @@ -176,15 +175,15 @@ public class DropTargetBar extends FrameLayout // Reset second button padding in case it was previously changed to multi-line text. secondButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); - + int availableWidth; - if (dp.getDeviceProperties().isTwoPanels()) { + if (dp.isTwoPanels) { // Each button for two panel fits to half the width of the screen excluding the // center gap between the buttons. - availableWidth = (dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx) / 2; + availableWidth = (dp.availableWidthPx - dp.dropTargetGapPx) / 2; } else { // Both buttons plus the button gap do not display past the edge of the screen. - availableWidth = dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx; + availableWidth = dp.availableWidthPx - dp.dropTargetGapPx; } int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); @@ -200,7 +199,7 @@ public class DropTargetBar extends FrameLayout } } - if (!dp.getDeviceProperties().isTwoPanels()) { + if (!dp.isTwoPanels) { availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx; widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST); } @@ -240,11 +239,11 @@ public class DropTargetBar extends FrameLayout float scale = dp.getWorkspaceSpringLoadScale(mLauncher); Workspace ws = mLauncher.getWorkspace(); int barCenter; - if (dp.getDeviceProperties().isTwoPanels()) { + if (dp.isTwoPanels) { barCenter = (right - left) / 2; } else { int workspaceCenter = (ws.getLeft() + ws.getRight()) / 2; - int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.getDeviceProperties().getWidthPx() + int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.widthPx - dp.getInsets().right - dp.workspacePadding.right)) / 2; int cellLayoutCenterOffset = (int) ((cellLayoutCenter - workspaceCenter) * scale); barCenter = workspaceCenter + cellLayoutCenterOffset - left; @@ -259,7 +258,7 @@ public class DropTargetBar extends FrameLayout ButtonDropTarget leftButton = mTempTargets[0]; ButtonDropTarget rightButton = mTempTargets[1]; - if (dp.getDeviceProperties().isTwoPanels()) { + if (dp.isTwoPanels) { leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0, barCenter - (buttonGap / 2), leftButton.getMeasuredHeight()); rightButton.layout(barCenter + (buttonGap / 2), 0, diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 76f4eb31e6..f8bf01ddbb 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -207,7 +207,7 @@ public class InvariantDeviceProfile { public @StyleRes int allAppsStyle; /** - * Do not query directly. see {@link deviceprofile#isScalableGrid}. + * Do not query directly. see {@link DeviceProfile#isScalableGrid}. */ protected boolean isScalable; @XmlRes @@ -488,14 +488,14 @@ public class InvariantDeviceProfile { int numMinShownHotseatIconsForTablet = supportedProfiles .stream() - .filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet()) + .filter(deviceProfile -> deviceProfile.isTablet) .mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons) .min() .orElse(0); supportedProfiles .stream() - .filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet()) + .filter(deviceProfile -> deviceProfile.isTablet) .forEach(deviceProfile -> { deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet; deviceProfile.recalculateHotseatWidthAndBorderSpace(); @@ -924,12 +924,12 @@ public class InvariantDeviceProfile { float minDiff = Float.MAX_VALUE; for (DeviceProfile profile : supportedProfiles) { - float diff = Math.abs(profile.getDeviceProperties().getWidthPx() - screenWidth) - + Math.abs(profile.getDeviceProperties().getHeightPx() - screenHeight); + float diff = Math.abs(profile.widthPx - screenWidth) + + Math.abs(profile.heightPx - screenHeight); if (diff < minDiff) { minDiff = diff; bestMatch = profile; - } else if (diff == minDiff && profile.getDeviceProperties().getRotationHint() == rotation) { + } else if (diff == minDiff && profile.rotationHint == rotation) { bestMatch = profile; } } @@ -995,7 +995,7 @@ public class InvariantDeviceProfile { displayInfo.getDeviceType()), isLandscape); } - /** Class to expose properties required for external displays to {@link deviceprofile} */ + /** Class to expose properties required for external displays to {@link DeviceProfile} */ public static final class DisplayOptionSpec { public final int typeIndex; public final int numShownHotseatIcons; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 178630cd0e..3b982debe9 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -677,9 +677,9 @@ public class Launcher extends StatefulActivity // When the flag oneGridSpecs is on we want to disable ALLOW_ROTATION which is replaced // by FIXED_LANDSCAPE_MODE, ALLOW_ROTATION will only be used on Tablets and foldables // afterwards. - if (getDeviceProfile().getDeviceProperties().isPhone()) { + if (getDeviceProfile().isPhone) { LauncherPrefs.get(this).put(LauncherPrefs.ALLOW_ROTATION, false); - } else if (getDeviceProfile().getDeviceProperties().isTablet()) { + } else if (getDeviceProfile().isTablet) { // Tablet do not use fixed landscape mode, make sure it can't be activated by mistake LauncherPrefs.get(this).put(FIXED_LANDSCAPE_MODE, false); } @@ -708,7 +708,7 @@ public class Launcher extends StatefulActivity this, getMultiWindowDisplaySize()); } - if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.getDeviceProperties().isTwoPanels()) { + if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.isTwoPanels) { mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns); } else { mCellPosMapper = new CellPosMapper(mDeviceProfile.isVerticalBarLayout(), @@ -1883,15 +1883,13 @@ public class Launcher extends StatefulActivity public void updateOpenFolderPosition(int[] inOutPosition, Rect bounds, int width, int height) { int left = inOutPosition[0]; int top = inOutPosition[1]; - DeviceProfile deviceProfile = getDeviceProfile(); + DeviceProfile grid = getDeviceProfile(); int distFromEdgeOfScreen = getWorkspace().getPaddingLeft(); - final int availableWidth = deviceProfile.getDeviceProperties().getAvailableWidthPx(); - if (deviceProfile.getDeviceProperties().isPhone() - && (availableWidth - width) < 4 * distFromEdgeOfScreen) { + if (grid.isPhone && (grid.availableWidthPx - width) < 4 * distFromEdgeOfScreen) { // Center the folder if it is very close to being centered anyway, by virtue of // filling the majority of the viewport. ie. remove it from the uncanny valley // of centeredness. - left = (availableWidth - width) / 2; + left = (grid.availableWidthPx - width) / 2; } else if (width >= bounds.width()) { // If the folder doesn't fit within the bounds, center it about the desired bounds left = bounds.left + (bounds.width() - width) / 2; @@ -1902,7 +1900,7 @@ public class Launcher extends StatefulActivity } else { // Folder height is less than page height, so bound it to the absolute open folder // bounds if necessary - Rect folderBounds = deviceProfile.getAbsoluteOpenFolderBounds(); + Rect folderBounds = grid.getAbsoluteOpenFolderBounds(); left = Math.max(folderBounds.left, Math.min(left, folderBounds.right - width)); top = Math.max(folderBounds.top, Math.min(top, folderBounds.bottom - height)); } @@ -2542,7 +2540,7 @@ public class Launcher extends StatefulActivity if (BuildCompat.isAtLeastV() && Flags.enableDesktopWindowingMode() && !Flags.enableDesktopWindowingWallpaperActivity() - && mDeviceProfile.getDeviceProperties().isTablet()) { + && mDeviceProfile.isTablet) { // TODO(b/333533253): Clean up after desktop wallpaper activity flag is rolled out return; } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index fd91b59aa7..9fb3d15a94 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -242,7 +242,7 @@ public abstract class LauncherState implements BaseState { DeviceProfile dp = launcher.getDeviceProfile(); if (dp.isQsbInline) { int marginStart = getFloatingSearchBarRestingMarginStart(launcher); - return dp.getDeviceProperties().getWidthPx() - marginStart - dp.hotseatQsbWidth; + return dp.widthPx - marginStart - dp.hotseatQsbWidth; } boolean isRtl = Utilities.isRtl(launcher.getResources()); @@ -258,7 +258,7 @@ public abstract class LauncherState implements BaseState { public int getVisibleElements(Launcher launcher) { int elements = HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR; // Floating search bar is visible in normal state except in landscape on phones. - if (!(launcher.getDeviceProfile().getDeviceProperties().isPhone() && launcher.getDeviceProfile().getDeviceProperties().isLandscape())) { + if (!(launcher.getDeviceProfile().isPhone && launcher.getDeviceProfile().isLandscape)) { elements |= FLOATING_SEARCH_BAR; } return elements; @@ -346,7 +346,7 @@ public abstract class LauncherState implements BaseState { public final float getDepth(DEVICE_PROFILE_CONTEXT context) { return getDepth(context, - ActivityContext.lookupContext(context).getDeviceProfile().getDeviceProperties().isMultiWindowMode()); + ActivityContext.lookupContext(context).getDeviceProfile().isMultiWindowMode); } /** @@ -390,7 +390,7 @@ public abstract class LauncherState implements BaseState { boolean shouldFadeAdjacentScreens = (this == NORMAL || this == HINT_STATE) && dp.shouldFadeAdjacentWorkspaceScreens(); // Avoid showing adjacent screens behind handheld All Apps sheet. - if (Flags.allAppsSheetForHandheld() && dp.getDeviceProperties().isPhone() && this == ALL_APPS) { + if (Flags.allAppsSheetForHandheld() && dp.isPhone && this == ALL_APPS) { shouldFadeAdjacentScreens = true; } if (!shouldFadeAdjacentScreens) { @@ -410,7 +410,7 @@ public abstract class LauncherState implements BaseState { */ public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) { if (!(this == SPRING_LOADED || this == EDIT_MODE) - || !launcher.getDeviceProfile().getDeviceProperties().isTwoPanels()) { + || !launcher.getDeviceProfile().isTwoPanels) { return DEFAULT_PAGE_TRANSLATION_PROVIDER; } final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f; diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index ba5c0dbf59..407e126215 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -158,7 +158,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true) launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ false, - deviceProfile.deviceProperties.isTwoPanels, + deviceProfile.isTwoPanels, ) launcher.finishBindingItems(pagesBoundFirst) } @@ -270,13 +270,12 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { // in single panel. if (actualIds.contains(firstId)) { result.add(firstId) - if (launcher.deviceProfile.deviceProperties.isTwoPanels && actualIds.contains(pairId)) { + if (launcher.deviceProfile.isTwoPanels && actualIds.contains(pairId)) { result.add(pairId) } } else if ( - LauncherAppState.getIDP(launcher).supportedProfiles.any { - it.deviceProperties.isTwoPanels - } && actualIds.contains(pairId) + LauncherAppState.getIDP(launcher).supportedProfiles.any(DeviceProfile::isTwoPanels) && + actualIds.contains(pairId) ) { // Add the right panel if left panel is hidden when switching display, due to empty // pages being hidden in single panel. @@ -288,7 +287,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { private fun bindScreens(orderedScreenIds: LIntArray) { launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ true, - launcher.deviceProfile.deviceProperties.isTwoPanels, + launcher.deviceProfile.isTwoPanels, ) val firstScreenPosition = 0 if (orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition) { @@ -346,7 +345,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { private fun bindAddScreens(orderedScreenIdsArg: LIntArray) { var orderedScreenIds = orderedScreenIdsArg - if (launcher.deviceProfile.deviceProperties.isTwoPanels) { + if (launcher.deviceProfile.isTwoPanels) { if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds) } else { diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b410c54929..9e07bb74b7 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -534,7 +534,7 @@ public class Workspace extends PagedView } private boolean isTwoPanelEnabled() { - return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.getDeviceProperties().isTwoPanels(); + return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels; } public void deferRemoveExtraEmptyScreen() { @@ -692,7 +692,7 @@ public class Workspace extends PagedView // created CellLayout. DeviceProfile dp = mLauncher.getDeviceProfile(); CellLayout newScreen; - if (FOLDABLE_SINGLE_PAGE.get() && dp.getDeviceProperties().isTwoPanels()) { + if (FOLDABLE_SINGLE_PAGE.get() && dp.isTwoPanels) { newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate( R.layout.workspace_screen_foldable, this, false /* attachToRoot */); } else { @@ -3443,13 +3443,13 @@ public class Workspace extends PagedView @Override public int getExpectedHeight() { return getMeasuredHeight() <= 0 || !mIsLayoutValid - ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : getMeasuredHeight(); + ? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight(); } @Override public int getExpectedWidth() { return getMeasuredWidth() <= 0 || !mIsLayoutValid - ? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() : getMeasuredWidth(); + ? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth(); } @Override @@ -3515,12 +3515,12 @@ public class Workspace extends PagedView @Override protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) { DeviceProfile deviceProfile = mLauncher.getDeviceProfile(); - if (!deviceProfile.getDeviceProperties().isTablet()) { + if (!deviceProfile.isTablet) { return super.isSignificantMove(absoluteDelta, pageOrientedSize); } return absoluteDelta - > deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; + > deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE; } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 2e50bb2618..7224b1cfdf 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -235,7 +235,7 @@ public class AllAppsTransitionController boolean fromBackground = mLauncher.getStateManager().getCurrentStableState() == BACKGROUND_APP; // Allow apps panel to shift the full screen if coming from another app. - float shiftRange = fromBackground ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : mShiftRange; + float shiftRange = fromBackground ? mLauncher.getDeviceProfile().heightPx : mShiftRange; getAppsViewProgressTranslationY().setValue(mProgress * shiftRange); mLauncher.onAllAppsTransition(1 - progress); diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java index 6daba68102..1e0f2892d6 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -99,7 +99,7 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView 0; - mDrawBottomScrim = !dp.isVerticalBarLayout() && !dp.getDeviceProperties().isGestureMode() && !dp.isTaskbarPresent; + mDrawBottomScrim = !dp.isVerticalBarLayout() && !dp.isGestureMode && !dp.isTaskbarPresent; } @Override diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 17807bcab5..0cd8573466 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -689,8 +689,8 @@ class WorkspaceItemProcessor( deviceProfile.getCellSize(cellSize) FileLog.d( TAG, - "DeviceProfile available width: ${deviceProfile.deviceProperties.availableWidthPx}," + - " available height: ${deviceProfile.deviceProperties.availableHeightPx}," + + "DeviceProfile available width: ${deviceProfile.availableWidthPx}," + + " available height: ${deviceProfile.availableHeightPx}," + " cellLayoutBorderSpacePx Horizontal: ${deviceProfile.cellLayoutBorderSpacePx.x}," + " cellLayoutBorderSpacePx Vertical: ${deviceProfile.cellLayoutBorderSpacePx.y}," + " cellSize: $cellSize", diff --git a/src/com/android/launcher3/model/data/AppPairInfo.kt b/src/com/android/launcher3/model/data/AppPairInfo.kt index 486b9958ea..49273fedd3 100644 --- a/src/com/android/launcher3/model/data/AppPairInfo.kt +++ b/src/com/android/launcher3/model/data/AppPairInfo.kt @@ -70,10 +70,7 @@ class AppPairInfo() : CollectionInfo() { /** Checks if member apps are launchable at the current screen size. */ fun isLaunchable(context: Context): Pair { val isTablet = - (ActivityContext.lookupContext(context) as ActivityContext) - .getDeviceProfile() - .deviceProperties - .isTablet + (ActivityContext.lookupContext(context) as ActivityContext).getDeviceProfile().isTablet return Pair( isTablet || !getFirstApp().isNonResizeable, isTablet || !getSecondApp().isNonResizeable, diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 8a277c36dc..9a226df8db 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -413,7 +413,7 @@ public class PopupContainerWithArrow for (int i = deepShortcutCount; i > 0; i--) { currentHeight += mShortcutHeight; // when there is limited vertical screen space, limit total popup rows to fit - if (currentHeight >= mActivityContext.getDeviceProfile().getDeviceProperties().getAvailableHeightPx()) break; + if (currentHeight >= mActivityContext.getDeviceProfile().availableHeightPx) break; DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, mDeepShortcutContainer); v.getLayoutParams().width = mContainerWidth; diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 0b68315a8f..82b6747da7 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -432,8 +432,7 @@ public abstract class SystemShortcut extends ItemInfo // basically is a check for small screens including Foldables when folded. // However, the name is a bit misleading, so considering renaming. WorkspaceItemInfo wsItemInfo = (WorkspaceItemInfo) itemInfo; - if (wsItemInfo.isNonResizeable() - && activity.getDeviceProfile().getDeviceProperties().isPhone()) { + if (wsItemInfo.isNonResizeable() && activity.getDeviceProfile().isPhone) { return null; } } diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java index c37f259422..9376518ddb 100644 --- a/src/com/android/launcher3/states/RotationHelper.java +++ b/src/com/android/launcher3/states/RotationHelper.java @@ -138,7 +138,7 @@ public class RotationHelper implements LauncherPrefChangeListener, @Override public void onDeviceProfileChanged(DeviceProfile dp) { - onIgnoreAutoRotateChanged(dp.getDeviceProperties().isTablet()); + onIgnoreAutoRotateChanged(dp.isTablet); } private void onIgnoreAutoRotateChanged(boolean ignoreAutoRotateSettings) { diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index cb5725e89b..6aa2200969 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -203,7 +203,7 @@ public class TestInformationHandler implements ResourceBasedOverride { return response; case TestProtocol.REQUEST_IS_TABLET: - response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.getDeviceProperties().isTablet()); + response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, mDeviceProfile.isTablet); return response; case TestProtocol.REQUEST_IS_PREDICTIVE_BACK_SWIPE_ENABLED: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, @@ -230,7 +230,7 @@ public class TestInformationHandler implements ResourceBasedOverride { case TestProtocol.REQUEST_IS_TWO_PANELS: response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, - FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.getDeviceProperties().isTwoPanels()); + FOLDABLE_SINGLE_PAGE.get() ? false : mDeviceProfile.isTwoPanels); return response; case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS: diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java index a1fc607b3d..7df47273f6 100644 --- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java +++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java @@ -312,13 +312,13 @@ public abstract class AbstractStateChangeTouchController // snap to top or bottom using the release velocity } else { float successTransitionProgress = SUCCESS_TRANSITION_PROGRESS; - if (mLauncher.getDeviceProfile().getDeviceProperties().isTablet() + if (mLauncher.getDeviceProfile().isTablet && (mToState == ALL_APPS || mFromState == ALL_APPS)) { successTransitionProgress = TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS; - } else if (!mLauncher.getDeviceProfile().getDeviceProperties().isTablet() + } else if (!mLauncher.getDeviceProfile().isTablet && mToState == ALL_APPS && mFromState == NORMAL) { successTransitionProgress = AllAppsSwipeController.ALL_APPS_STATE_TRANSITION_MANUAL; - } else if (!mLauncher.getDeviceProfile().getDeviceProperties().isTablet() + } else if (!mLauncher.getDeviceProfile().isTablet && mToState == NORMAL && mFromState == ALL_APPS) { successTransitionProgress = 1 - AllAppsSwipeController.ALL_APPS_STATE_TRANSITION_MANUAL; diff --git a/src/com/android/launcher3/touch/AllAppsSwipeController.java b/src/com/android/launcher3/touch/AllAppsSwipeController.java index 5fc9560822..3312844954 100644 --- a/src/com/android/launcher3/touch/AllAppsSwipeController.java +++ b/src/com/android/launcher3/touch/AllAppsSwipeController.java @@ -209,10 +209,11 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { if (!config.isUserControlled()) { config.setInterpolator(ANIM_VERTICAL_PROGRESS, EMPHASIZED); } - config.setInterpolator(ANIM_WORKSPACE_SCALE, ALL_APPS_SHEET_DEPTH); - config.setInterpolator(ANIM_HOTSEAT_SCALE, ALL_APPS_SHEET_DEPTH); - config.setInterpolator(ANIM_DEPTH, ALL_APPS_SHEET_DEPTH); - if (!Flags.allAppsBlur() && launcher.getDeviceProfile().getDeviceProperties().isPhone()) { + config.setInterpolator(ANIM_WORKSPACE_SCALE, + Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); + config.setInterpolator(ANIM_HOTSEAT_SCALE, Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); + config.setInterpolator(ANIM_DEPTH, Interpolators.reverse(ALL_APPS_SHEET_DEPTH)); + if (!Flags.allAppsBlur() && launcher.getDeviceProfile().isPhone) { // On phones without blur, reveal the workspace and hotseat when leaving All Apps. config.setInterpolator(ANIM_WORKSPACE_FADE, INSTANT); config.setInterpolator(ANIM_HOTSEAT_FADE, INSTANT); @@ -260,7 +261,7 @@ public class AllAppsSwipeController extends AbstractStateChangeTouchController { config.setInterpolator(ANIM_WORKSPACE_SCALE, ALL_APPS_SHEET_DEPTH); config.setInterpolator(ANIM_HOTSEAT_SCALE, ALL_APPS_SHEET_DEPTH); config.setInterpolator(ANIM_DEPTH, ALL_APPS_SHEET_DEPTH); - if (!Flags.allAppsBlur() && launcher.getDeviceProfile().getDeviceProperties().isPhone()) { + if (!Flags.allAppsBlur() && launcher.getDeviceProfile().isPhone) { // On phones without blur, hide the workspace and hotseat when entering All Apps. config.setInterpolator(ANIM_WORKSPACE_FADE, FINAL_FRAME); config.setInterpolator(ANIM_HOTSEAT_FADE, FINAL_FRAME); diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 1c30338ac1..32aec92f4a 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -160,7 +160,7 @@ public class ItemClickHandler { if (!isApp1Launchable || !isApp2Launchable) { // App pair is unlaunchable due to screen size. boolean isFoldable = InvariantDeviceProfile.INSTANCE.get(launcher) - .supportedProfiles.stream().anyMatch(dp -> dp.getDeviceProperties().isTwoPanels()); + .supportedProfiles.stream().anyMatch(dp -> dp.isTwoPanels); Toast.makeText(launcher, isFoldable ? R.string.app_pair_needs_unfold : R.string.app_pair_unlaunchable_at_screen_size, diff --git a/src/com/android/launcher3/util/DimensionUtils.kt b/src/com/android/launcher3/util/DimensionUtils.kt index 9941b66618..821dda789f 100644 --- a/src/com/android/launcher3/util/DimensionUtils.kt +++ b/src/com/android/launcher3/util/DimensionUtils.kt @@ -29,10 +29,10 @@ object DimensionUtils { */ @JvmStatic fun getTaskbarPhoneDimensions( - deviceProfile: DeviceProfile, - res: Resources, - isPhoneMode: Boolean, - isGestureNav: Boolean, + deviceProfile: DeviceProfile, + res: Resources, + isPhoneMode: Boolean, + isGestureNav: Boolean, ): Point { val p = Point() // Taskbar for large screen @@ -50,7 +50,7 @@ object DimensionUtils { } // Taskbar on phone, portrait - if (!deviceProfile.deviceProperties.isLandscape) { + if (!deviceProfile.isLandscape) { p.x = ViewGroup.LayoutParams.MATCH_PARENT p.y = res.getDimensionPixelSize(R.dimen.taskbar_phone_size) return p diff --git a/src/com/android/launcher3/views/AbstractSlideInView.java b/src/com/android/launcher3/views/AbstractSlideInView.java index 6301e5d132..65d02d0177 100644 --- a/src/com/android/launcher3/views/AbstractSlideInView.java +++ b/src/com/android/launcher3/views/AbstractSlideInView.java @@ -435,7 +435,7 @@ public abstract class AbstractSlideInView @Override public void onDragEnd(float velocity) { - float successfulShiftThreshold = mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() + float successfulShiftThreshold = mActivityContext.getDeviceProfile().isTablet ? TABLET_BOTTOM_SHEET_SUCCESS_TRANSITION_PROGRESS : SUCCESS_TRANSITION_PROGRESS; if ((mSwipeDetector.isFling(velocity) && velocity > 0) || mTranslationShift > successfulShiftThreshold) { diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index 09d083c68d..3c563d935e 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -240,7 +240,7 @@ public interface ActivityContext extends SavedStateRegistryOwner { /** Registered {@link OnDeviceProfileChangeListener} instances. */ List getOnDeviceProfileChangeListeners(); - /** Notifies listeners of a {@link deviceprofile} change. */ + /** Notifies listeners of a {@link DeviceProfile} change. */ default void dispatchDeviceProfileChanged() { DeviceProfile deviceProfile = getDeviceProfile(); List listeners = getOnDeviceProfileChangeListeners(); @@ -249,12 +249,12 @@ public interface ActivityContext extends SavedStateRegistryOwner { } } - /** Register listener for {@link deviceprofile} changes. */ + /** Register listener for {@link DeviceProfile} changes. */ default void addOnDeviceProfileChangeListener(OnDeviceProfileChangeListener listener) { getOnDeviceProfileChangeListeners().add(listener); } - /** Unregister listener for {@link deviceprofile} changes. */ + /** Unregister listener for {@link DeviceProfile} changes. */ default void removeOnDeviceProfileChangeListener(OnDeviceProfileChangeListener listener) { getOnDeviceProfileChangeListeners().remove(listener); } diff --git a/src/com/android/launcher3/views/ClipIconView.java b/src/com/android/launcher3/views/ClipIconView.java index f7fdd613a0..eb25003925 100644 --- a/src/com/android/launcher3/views/ClipIconView.java +++ b/src/com/android/launcher3/views/ClipIconView.java @@ -122,7 +122,7 @@ public class ClipIconView extends View implements ClipPathView { MarginLayoutParams lp = (MarginLayoutParams) container.getLayoutParams(); float dX = mIsRtl - ? rect.left - (dp.getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width) + ? rect.left - (dp.widthPx - lp.getMarginStart() - lp.width) : rect.left - lp.getMarginStart(); float dY = rect.top - lp.topMargin; container.setTranslationX(dX); @@ -164,7 +164,7 @@ public class ClipIconView extends View implements ClipPathView { float shapeRevealProgress = boundToRange(mapToRange(max(shapeProgressStart, progress), shapeProgressStart, 1f, 0, toMax, LINEAR), 0, 1); - if (dp.getDeviceProperties().isLandscape()) { + if (dp.isLandscape) { mOutline.right = (int) (rect.width() / scale); } else { mOutline.bottom = (int) (rect.height() / scale); @@ -188,16 +188,16 @@ public class ClipIconView extends View implements ClipPathView { mRevealAnimator.setCurrentFraction(shapeRevealProgress); } - float drawableScale = (dp.getDeviceProperties().isLandscape() ? mOutline.width() : mOutline.height()) + float drawableScale = (dp.isLandscape ? mOutline.width() : mOutline.height()) / minSize; - setBackgroundDrawableBounds(drawableScale, dp.getDeviceProperties().isLandscape()); + setBackgroundDrawableBounds(drawableScale, dp.isLandscape); // Center align foreground int height = mFinalDrawableBounds.height(); int width = mFinalDrawableBounds.width(); - int diffY = dp.getDeviceProperties().isLandscape() ? 0 + int diffY = dp.isLandscape ? 0 : (int) (((height * drawableScale) - height) / 2); - int diffX = dp.getDeviceProperties().isLandscape() ? (int) (((width * drawableScale) - width) / 2) + int diffX = dp.isLandscape ? (int) (((width * drawableScale) - width) / 2) : 0; sTmpRect.set(mFinalDrawableBounds); sTmpRect.offset(diffX, diffY); @@ -264,14 +264,14 @@ public class ClipIconView extends View implements ClipPathView { Utilities.scaleRectAboutCenter(mStartRevealRect, ICON_VISIBLE_AREA_FACTOR); } - if (dp.getDeviceProperties().isLandscape()) { - lp.width = (int) Math.max(lp.width, lp.height * dp.getDeviceProperties().getAspectRatio()); + if (dp.isLandscape) { + lp.width = (int) Math.max(lp.width, lp.height * dp.aspectRatio); } else { - lp.height = (int) Math.max(lp.height, lp.width * dp.getDeviceProperties().getAspectRatio()); + lp.height = (int) Math.max(lp.height, lp.width * dp.aspectRatio); } int left = mIsRtl - ? dp.getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width + ? dp.widthPx - lp.getMarginStart() - lp.width : lp.leftMargin; layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height); @@ -285,7 +285,7 @@ public class ClipIconView extends View implements ClipPathView { bgDrawableStartScale = scale; mOutline.set(0, 0, lp.width, lp.height); } - setBackgroundDrawableBounds(bgDrawableStartScale, dp.getDeviceProperties().isLandscape()); + setBackgroundDrawableBounds(bgDrawableStartScale, dp.isLandscape); mEndRevealRect.set(0, 0, lp.width, lp.height); setOutlineProvider(new ViewOutlineProvider() { @Override diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index d9d20d54aa..e2b56bef10 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -226,14 +226,14 @@ public class FloatingIconView extends FrameLayout implements // Position the floating view exactly on top of the original lp.topMargin = Math.round(pos.top); if (mIsRtl) { - lp.setMarginStart(Math.round(mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() - pos.right)); + lp.setMarginStart(Math.round(mLauncher.getDeviceProfile().widthPx - pos.right)); } else { lp.setMarginStart(Math.round(pos.left)); } // Set the properties here already to make sure they are available when running the first // animation frame. int left = mIsRtl - ? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() - lp.getMarginStart() - lp.width + ? mLauncher.getDeviceProfile().widthPx - lp.getMarginStart() - lp.width : lp.leftMargin; layout(left, lp.topMargin, left + lp.width, lp.topMargin + lp.height); } @@ -370,8 +370,8 @@ public class FloatingIconView extends FrameLayout implements mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight); - float aspectRatio = mLauncher.getDeviceProfile().getDeviceProperties().getAspectRatio(); - if (dp.getDeviceProperties().isLandscape()) { + float aspectRatio = mLauncher.getDeviceProfile().aspectRatio; + if (dp.isLandscape) { lp.width = (int) Math.max(lp.width, lp.height * aspectRatio); } else { lp.height = (int) Math.max(lp.height, lp.width * aspectRatio); diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java index a6deee5340..5e702aa37f 100644 --- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java @@ -101,7 +101,7 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView 0) { diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index 9a2f096f1f..af31276ff9 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -355,7 +355,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView protected int getInsetsWidth() { int widthUsed; DeviceProfile deviceProfile = mActivityContext.getDeviceProfile(); - if (deviceProfile.getDeviceProperties().isTablet()) { + if (deviceProfile.isTablet) { widthUsed = Math.max(2 * getTabletHorizontalMargin(deviceProfile), 2 * (mInsets.left + mInsets.right)); } else if (mInsets.bottom > 0) { @@ -375,7 +375,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView @Override protected Interpolator getIdleInterpolator() { - return mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() + return mActivityContext.getDeviceProfile().isTablet ? EMPHASIZED : super.getIdleInterpolator(); } @@ -394,7 +394,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView // In light mode, landscape reverses navbar background color. boolean isPhoneLandscape = - !mActivityContext.getDeviceProfile().getDeviceProperties().isTablet() && mInsets.bottom == 0; + !mActivityContext.getDeviceProfile().isTablet && mInsets.bottom == 0; if (!isNavBarDark && isPhoneLandscape) { isNavBarDark = true; } diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java index 7a7f1f2a06..94ae69cccd 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java @@ -114,7 +114,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo impleme // On phones we no longer support regular landscape, only fixed landscape for this // reason we don't need to take regular landscape into account in phones if (Flags.oneGridSpecs() && dp.inv.deviceType == TYPE_PHONE - && dp.inv.isFixedLandscape != dp.getDeviceProperties().isLandscape()) { + && dp.inv.isFixedLandscape != dp.isLandscape) { continue; } diff --git a/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java b/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java index 12ea5064a9..ec916228db 100644 --- a/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java +++ b/src/com/android/launcher3/widget/picker/WidgetRecommendationsView.java @@ -174,7 +174,7 @@ public final class WidgetRecommendationsView extends PagedViewIn case of a single category, no title is displayed for it.

* * @param recommendations a map of widget items per recommendation category - * @param deviceProfile the current {@link deviceprofile} + * @param deviceProfile the current {@link DeviceProfile} * @param availableHeight height in px that can be used to display the recommendations; * recommendations that don't fit in this height won't be shown * @param availableWidth width in px that the recommendations should display in diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 77efe5e495..44c0ebde4b 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -653,11 +653,11 @@ public class WidgetsFullSheet extends BaseWidgetSheet protected float getMaxAvailableHeightForRecommendations() { // There isn't enough space to show recommendations in landscape orientation on phones with // a full sheet design. Tablets use a two pane picker. - if (mDeviceProfile.getDeviceProperties().isLandscape()) { + if (mDeviceProfile.isLandscape) { return 0f; } - return (mDeviceProfile.getDeviceProperties().getHeightPx() - mDeviceProfile.bottomSheetTopPadding) + return (mDeviceProfile.heightPx - mDeviceProfile.bottomSheetTopPadding) * RECOMMENDATION_TABLE_HEIGHT_RATIO; } @@ -775,7 +775,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet } private static int getWidgetSheetId(BaseActivity activity) { - boolean isTwoPane = activity.getDeviceProfile().getDeviceProperties().isTablet(); + boolean isTwoPane = activity.getDeviceProfile().isTablet; return isTwoPane ? R.layout.widgets_two_pane_sheet : R.layout.widgets_full_sheet; } @@ -922,7 +922,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private static boolean shouldRecreateLayout(DeviceProfile oldDp, DeviceProfile newDp) { // When folding/unfolding the foldables, we need to switch between the regular widget picker // and the two pane picker, so we rebuild the picker with the correct layout. - return oldDp.getDeviceProperties().isTwoPanels() != newDp.getDeviceProperties().isTwoPanels(); + return oldDp.isTwoPanels != newDp.isTwoPanels; } /** diff --git a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java index 113d9c0632..9ffaf5100b 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsTwoPaneSheet.java @@ -136,7 +136,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { mWidgetRecommendationsView.initParentViews(mWidgetRecommendationsContainer); mWidgetRecommendationsView.setWidgetCellLongClickListener(this); mWidgetRecommendationsView.setWidgetCellOnClickListener(this); - if (!mDeviceProfile.getDeviceProperties().isTwoPanels()) { + if (!mDeviceProfile.isTwoPanels) { mWidgetRecommendationsView.enableFullPageViewIfLowDensity(); } // To save the currently displayed page, so that, it can be requested when rebinding @@ -242,7 +242,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - if (changed && mDeviceProfile.getDeviceProperties().isTwoPanels()) { + if (changed && mDeviceProfile.isTwoPanels) { LinearLayout layout = mContent.findViewById(R.id.linear_layout_container); FrameLayout leftPane = layout.findViewById(R.id.recycler_view_container); LinearLayout.LayoutParams layoutParams = (LayoutParams) leftPane.getLayoutParams(); @@ -403,7 +403,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { return Float.MAX_VALUE; } - return (mDeviceProfile.getDeviceProperties().getHeightPx() - mDeviceProfile.bottomSheetTopPadding) + return (mDeviceProfile.heightPx - mDeviceProfile.bottomSheetTopPadding) * RECOMMENDATION_SECTION_HEIGHT_RATIO_TWO_PANE; } @@ -412,7 +412,7 @@ public class WidgetsTwoPaneSheet extends WidgetsFullSheet { protected int getAvailableWidthForSuggestions(int pickerAvailableWidth) { int rightPaneWidth = (int) Math.ceil(0.67 * pickerAvailableWidth); - if (mDeviceProfile.getDeviceProperties().isTwoPanels()) { + if (mDeviceProfile.isTwoPanels) { // See onLayout int leftPaneWidth = (int) (0.33 * pickerAvailableWidth); @Px int minLeftPaneWidthPx = Utilities.dpToPx(MINIMUM_WIDTH_LEFT_PANE_FOLDABLE_DP); diff --git a/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt b/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt index 66d8b7c21d..a0414ba136 100644 --- a/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt +++ b/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSize.kt @@ -29,7 +29,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp */ fun forItem(item: WidgetItem, dp: DeviceProfile): WidgetPreviewContainerSize { val sizes = - if (dp.deviceProperties.isTablet && !dp.deviceProperties.isTwoPanels) { + if (dp.isTablet && !dp.isTwoPanels) { TABLET_WIDGET_PREVIEW_SIZES } else { HANDHELD_WIDGET_PREVIEW_SIZES @@ -43,7 +43,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp return findClosestFittingContainer( containerSizes = sizes.toList(), startIndex = index, - item = item, + item = item ) } } @@ -54,7 +54,7 @@ data class WidgetPreviewContainerSize(@JvmField val spanX: Int, @JvmField val sp private fun findClosestFittingContainer( containerSizes: List, startIndex: Int, - item: WidgetItem, + item: WidgetItem ): WidgetPreviewContainerSize { // Checks if it's a smaller container, but close enough to keep the down-scale minimal. fun hasAcceptableSize(currentIndex: Int): Boolean { diff --git a/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java index 4882f83f6e..03a553534f 100644 --- a/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -65,7 +65,7 @@ public class AllAppsState extends LauncherState { @Override public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { - if (launcher.getDeviceProfile().getDeviceProperties().isTablet()) { + if (launcher.getDeviceProfile().isTablet) { return getWorkspaceScaleAndTranslation(launcher); } else { ScaleAndTranslation overviewScaleAndTranslation = LauncherState.OVERVIEW @@ -83,7 +83,7 @@ public class AllAppsState extends LauncherState { return new PageAlphaProvider(DECELERATE) { @Override public float getPageAlpha(int pageIndex) { - return launcher.getDeviceProfile().getDeviceProperties().isTablet() + return launcher.getDeviceProfile().isTablet ? superPageAlphaProvider.getPageAlpha(pageIndex) : 0; } @@ -97,7 +97,7 @@ public class AllAppsState extends LauncherState { @Override public int getWorkspaceScrimColor(Launcher launcher) { - return launcher.getDeviceProfile().getDeviceProperties().isTablet() + return launcher.getDeviceProfile().isTablet ? launcher.getResources().getColor(R.color.widgets_picker_scrim) : Themes.getAttrColor(launcher, R.attr.allAppsScrimColor); } diff --git a/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt b/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt index 65bf6a2006..2452a88b14 100644 --- a/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/widget/picker/util/WidgetPreviewContainerSizesTest.kt @@ -134,7 +134,7 @@ class WidgetPreviewContainerSizesTest { ) private fun getTestSizes(dp: DeviceProfile) = - if (dp.deviceProperties.isTablet && !dp.deviceProperties.isTwoPanels) { + if (dp.isTablet && !dp.isTwoPanels) { TABLET_TEST_SIZES } else { HANDHELD_TEST_SIZES diff --git a/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java b/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java index 9f58ffff5c..e5b45b9277 100644 --- a/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java +++ b/tests/src/com/android/launcher3/util/ui/PortraitLandscapeRunner.java @@ -125,8 +125,8 @@ public class PortraitLandscapeRunner