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