Revert "Revert "Moving DeviceProfile properties into DevicePrope..."

Revert submission 33716851-revert-33672643-DataDeviceProfile1-XHYRAPLEBK

Reason for revert: Error is fixed

Reverted changes: /q/submissionid:33716851-revert-33672643-DataDeviceProfile1-XHYRAPLEBK

Change-Id: Ib86824134955903c11e51e52dbfd6368aba1cd50
This commit is contained in:
Sebastián Franco
2025-05-23 14:05:01 -07:00
committed by Sebastian Franco
parent 1bec329180
commit e1d31e5406
128 changed files with 727 additions and 597 deletions
@@ -512,7 +512,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
target = t;
break;
}
if (target == null) return new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx);
final int widthPx = mDeviceProfile.getDeviceProperties().getWidthPx();
final int heightPx = mDeviceProfile.getDeviceProperties().getHeightPx();
if (target == null) return new Rect(0, 0, widthPx, heightPx);
final Rect bounds = new Rect(target.screenSpaceBounds);
if (target.localBounds != null) {
bounds.set(target.localBounds);
@@ -522,10 +524,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
if (rotationChange != 0) {
if ((rotationChange % 2) == 1) {
// undoing rotation, so our "original" parent size is actually flipped
Utilities.rotateBounds(bounds, mDeviceProfile.heightPx, mDeviceProfile.widthPx,
Utilities.rotateBounds(bounds, heightPx, widthPx,
4 - rotationChange);
} else {
Utilities.rotateBounds(bounds, mDeviceProfile.widthPx, mDeviceProfile.heightPx,
Utilities.rotateBounds(bounds, widthPx, heightPx,
4 - rotationChange);
}
}
@@ -564,7 +566,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
final View appsView = mLauncher.getAppsView();
final float startAlpha = appsView.getAlpha();
final float startScale = SCALE_PROPERTY.get(appsView);
if (mDeviceProfile.isTablet) {
if (mDeviceProfile.getDeviceProperties().isTablet()) {
// AllApps should not fade at all in tablets.
alphas = new float[]{1, 1};
}
@@ -792,7 +795,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources())
? Math.max(crop.width(), crop.height()) / 2f
: 0f;
final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode()
? 0 : getWindowCornerRadius(mLauncher);
final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius;
@@ -875,8 +878,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
final int windowCropWidth = crop.width();
final int windowCropHeight = crop.height();
if (rotationChange != 0) {
Utilities.rotateBounds(crop, mDeviceProfile.widthPx,
mDeviceProfile.heightPx, rotationChange);
Utilities.rotateBounds(crop, mDeviceProfile.getDeviceProperties().getWidthPx(),
mDeviceProfile.getDeviceProperties().getHeightPx(), rotationChange);
}
// Scale the size of the icon to match the size of the window crop.
@@ -923,14 +926,14 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
matrix.setScale(scale, scale);
if (rotationChange == 1) {
matrix.postTranslate(windowTransY0,
mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth));
mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth));
} else if (rotationChange == 2) {
matrix.postTranslate(
mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth),
mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight));
mDeviceProfile.getDeviceProperties().getWidthPx() - (windowTransX0 + scaledCropWidth),
mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight));
} else if (rotationChange == 3) {
matrix.postTranslate(
mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight),
mDeviceProfile.getDeviceProperties().getHeightPx() - (windowTransY0 + scaledCropHeight),
windowTransX0);
} else {
matrix.postTranslate(windowTransX0, windowTransY0);
@@ -1022,7 +1025,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
FloatingWidgetView.getDefaultBackgroundColor(mLauncher, openingTarget);
}
final float finalWindowRadius = mDeviceProfile.isMultiWindowMode
final float finalWindowRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode()
? 0 : getWindowCornerRadius(mLauncher);
final FloatingWidgetView floatingView = FloatingWidgetView.getFloatingWidgetView(mLauncher,
v, widgetBackgroundBounds,
@@ -1412,9 +1415,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
DeviceProfile dp = mLauncher.getDeviceProfile();
final int halfIconSize = dp.iconSizePx / 2;
float primaryDimension = orientationHandler
.getPrimaryValue(dp.availableWidthPx, dp.availableHeightPx);
.getPrimaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx());
float secondaryDimension = orientationHandler
.getSecondaryValue(dp.availableWidthPx, dp.availableHeightPx);
.getSecondaryValue(dp.getDeviceProperties().getAvailableWidthPx(), dp.getDeviceProperties().getAvailableHeightPx());
final float targetX = primaryDimension / 2f;
final float targetY = secondaryDimension - dp.hotseatBarSizePx;
return new RectF(targetX - halfIconSize, targetY - halfIconSize,
@@ -1444,13 +1447,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
// Get floating view and target rect.
boolean isInHotseat = false;
if (launcherView instanceof LauncherAppWidgetHostView) {
Size windowSize = new Size(mDeviceProfile.availableWidthPx,
mDeviceProfile.availableHeightPx);
Size windowSize = new Size(mDeviceProfile.getDeviceProperties().getAvailableWidthPx(),
mDeviceProfile.getDeviceProperties().getAvailableHeightPx());
int fallbackBackgroundColor =
FloatingWidgetView.getDefaultBackgroundColor(mLauncher, runningTaskTarget);
floatingWidget = FloatingWidgetView.getFloatingWidgetView(mLauncher,
(LauncherAppWidgetHostView) launcherView, targetRect, windowSize,
mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher),
mDeviceProfile.getDeviceProperties().isMultiWindowMode() ? 0 : getWindowCornerRadius(mLauncher),
isTransluscent, fallbackBackgroundColor);
} else if (launcherView != null && !RemoveAnimationSettingsTracker.INSTANCE.get(
mLauncher).isRemoveAnimationEnabled()) {
@@ -1481,7 +1484,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
Rect closingWindowStartRect = new Rect();
closingWindowStartRectF.round(closingWindowStartRect);
Rect closingWindowOriginalRect =
new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx);
new Rect(0, 0, mDeviceProfile.getDeviceProperties().getWidthPx(), mDeviceProfile.getDeviceProperties().getHeightPx());
if (floatingIconView != null) {
anim.addAnimatorListener(floatingIconView);
floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
@@ -1559,7 +1562,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
Rect tmpRect = new Rect();
ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
int duration = CLOSING_TRANSITION_DURATION_MS;
float windowCornerRadius = mDeviceProfile.isMultiWindowMode
float windowCornerRadius = mDeviceProfile.getDeviceProperties().isMultiWindowMode()
? 0 : getWindowCornerRadius(mLauncher);
float startShadowRadius = areAllTargetsTranslucent(appTargets) ? 0 : mMaxShadowRadius;
closingAnimator.setDuration(duration);
@@ -2249,17 +2252,20 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
boolean toLauncher, RectF resultRect) {
final int taskRotation = target.windowConfiguration.getRotation();
final DeviceProfile profile = mLauncher.getDeviceProfile();
final int rotation = profile.getDeviceProperties().getRotationHint();
final int widthPx = profile.getDeviceProperties().getWidthPx();
final int heightPx = profile.getDeviceProperties().getWidthPx();
final int rotationDelta = toLauncher
? android.util.RotationUtils.deltaRotation(taskRotation, profile.rotationHint)
: android.util.RotationUtils.deltaRotation(profile.rotationHint, taskRotation);
? android.util.RotationUtils.deltaRotation(taskRotation, rotation)
: android.util.RotationUtils.deltaRotation(rotation, taskRotation);
if (rotationDelta != ROTATION_0) {
// Get original display size when task is on top but with different rotation
if (rotationDelta % 2 != 0 && toLauncher && (profile.rotationHint == ROTATION_0
|| profile.rotationHint == ROTATION_180)) {
mDisplayRect.set(0, 0, profile.heightPx, profile.widthPx);
if (rotationDelta % 2 != 0 && toLauncher && (rotation == ROTATION_0
|| rotation == ROTATION_180)) {
mDisplayRect.set(0, 0, heightPx, widthPx);
} else {
mDisplayRect.set(0, 0, profile.widthPx, profile.heightPx);
mDisplayRect.set(0, 0, widthPx, heightPx);
}
currentRect.round(mTmpResult);
android.util.RotationUtils.rotateBounds(mTmpResult, mDisplayRect, rotationDelta);
@@ -503,7 +503,7 @@ public final class KeyboardQuickSwitchController implements
boolean isAspectRatioSquare() {
return mControllers != null && LayoutUtils.isAspectRatioSquare(
mControllers.taskbarActivityContext.getDeviceProfile().aspectRatio);
mControllers.taskbarActivityContext.getDeviceProfile().getDeviceProperties().getAspectRatio());
}
}
}
@@ -225,7 +225,7 @@ class ManageWindowsTaskbarShortcut<T>(
// Calculate the Y position to place the carousel above the taskbar
menuView.rootView.y =
deviceProfile.availableHeightPx -
deviceProfile.deviceProperties.availableHeightPx -
menuView.menuHeight -
controllers.taskbarStashController.touchableHeight -
margin
@@ -234,9 +234,12 @@ class ManageWindowsTaskbarShortcut<T>(
// but avoid clashing with the screen edge
menuView.rootView.translationX =
if (Utilities.isRtl(context.resources)) {
-(deviceProfile.availableWidthPx - menuView.menuWidth) / 2f
-(deviceProfile.deviceProperties.availableWidthPx - menuView.menuWidth) / 2f
} else {
val maxX = deviceProfile.availableWidthPx - menuView.menuWidth - margin
val maxX =
deviceProfile.deviceProperties.availableWidthPx -
menuView.menuWidth -
margin
minOf(originalView.x, maxX)
}
}
@@ -1048,9 +1048,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
// If SUW is on a large screen device that is landscape (or has a square aspect
// ratio) the back button has to be placed accordingly
if ((deviceProfile.isTablet && deviceProfile.isLandscape)
|| (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND
&& deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) {
if ((deviceProfile.getDeviceProperties().isTablet() && deviceProfile.getDeviceProperties().isLandscape())
|| (deviceProfile.getDeviceProperties().getAspectRatio() > SQUARE_ASPECT_RATIO_BOTTOM_BOUND
&& deviceProfile.getDeviceProperties().getAspectRatio() < SQUARE_ASPECT_RATIO_UPPER_BOUND)) {
navButtonsLayoutParams.setMarginStart(
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin));
navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize(
@@ -1061,7 +1061,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize(
R.dimen.taskbar_contextual_button_suw_margin);
navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin);
navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape
navButtonsLayoutParams.bottomMargin = !deviceProfile.getDeviceProperties().isLandscape()
? 0
: phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize(
R.dimen.taskbar_nav_buttons_size) / 2);
@@ -1427,7 +1427,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
// If the taskbar is start aligned the navigation bar is aligned to the start or end of
// the container, depending on the bubble bar location
if (isNavbarOnRight) {
navBarTargetStartX = dp.widthPx - navBarSpacing - mNavButtonContainer.getWidth();
navBarTargetStartX = dp.getDeviceProperties().getWidthPx() - navBarSpacing - mNavButtonContainer.getWidth();
} else {
navBarTargetStartX = navBarSpacing;
}
@@ -1440,7 +1440,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
if (isNavbarOnRight) {
if (mNavButtonsView.isLayoutRtl()) {
float taskBarEnd = taskbarBounds.right;
navBarTargetStartX = (dp.widthPx + taskBarEnd - navbarWidth) / 2;
navBarTargetStartX = (dp.getDeviceProperties().getWidthPx() + taskBarEnd - navbarWidth) / 2;
} else {
navBarTargetStartX = mNavButtonContainer.getLeft();
}
@@ -1458,7 +1458,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
// screen.
Rect transientTaskbarIconLayoutBoundsInParent = mControllers.taskbarViewController
.getTransientTaskbarIconLayoutBoundsInParent();
if (mContext.getDeviceProfile().isPhone
if (mContext.getDeviceProfile().getDeviceProperties().isPhone()
|| transientTaskbarIconLayoutBoundsInParent.isEmpty()
|| mNavButtonsView.getWidth() == 0) {
return;
@@ -316,7 +316,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
Optional<BubbleControllers> bubbleControllersOptional = Optional.empty();
BubbleBarController.onTaskbarRecreated();
final boolean deviceBubbleBarEnabled = enableBubbleBarOnPhones()
|| (!mDeviceProfile.isPhone && !mDeviceProfile.isVerticalBarLayout());
|| (!mDeviceProfile.getDeviceProperties().isPhone() && !mDeviceProfile.isVerticalBarLayout());
if (BubbleBarController.isBubbleBarEnabled() && deviceBubbleBarEnabled
&& bubbleBarView != null && isPrimaryDisplay) {
Optional<BubbleStashedHandleViewController> bubbleHandleController = Optional.empty();
@@ -398,7 +398,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
onViewCreated();
}
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
/** Updates {@link deviceprofile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile launcherDp) {
applyDeviceProfile(launcherDp);
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
@@ -591,7 +591,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
*/
public boolean isPhoneMode() {
return ENABLE_TASKBAR_NAVBAR_UNIFICATION
&& mDeviceProfile.isPhone
&& mDeviceProfile.getDeviceProperties().isPhone()
&& !mDeviceProfile.isTaskbarPresent;
}
@@ -620,11 +620,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
/** Returns {@code true} iff a tiny version of taskbar is shown on phone. */
public boolean isTinyTaskbar() {
return enableTinyTaskbar() && mDeviceProfile.isPhone && mDeviceProfile.isTaskbarPresent;
return enableTinyTaskbar() && mDeviceProfile.getDeviceProperties().isPhone() && mDeviceProfile.isTaskbarPresent;
}
public boolean isBubbleBarOnPhone() {
return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.isPhone;
return enableBubbleBarOnPhones() && enableBubbleBar() && mDeviceProfile.getDeviceProperties().isPhone();
}
/**
@@ -1310,13 +1310,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
public void setTaskbarWindowSize(int size) {
// In landscape phone button nav mode, we should set the task bar width instead of height
// because this is the only case in which the nav bar is not on the display bottom.
boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.isLandscape;
boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.getDeviceProperties().isLandscape();
if ((landscapePhoneButtonNav ? mWindowLayoutParams.width : mWindowLayoutParams.height)
== size || mIsDestroyed) {
return;
}
if (size == MATCH_PARENT) {
size = mDeviceProfile.heightPx;
size = mDeviceProfile.getDeviceProperties().getHeightPx();
} else {
mLastRequestedNonFullscreenSize = size;
if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) {
@@ -86,7 +86,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
if (
measuredHeight + activityContext.deviceProfile.taskbarHeight >=
activityContext.deviceProfile.availableHeightPx
activityContext.deviceProfile.deviceProperties.availableHeightPx
) {
updateLayoutParams { width = MATCH_PARENT }
}
@@ -172,7 +172,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
// only add the taskbar touch region if not on home
val bottom = windowLayoutParams.height
val top = bottom - taskbarTouchableHeight
val right = context.deviceProfile.widthPx
val right = context.deviceProfile.deviceProperties.widthPx
defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom))
}
@@ -196,7 +196,7 @@ public class TaskbarManagerImpl implements DisplayDecorationListener {
new SparseArray<>();
/** DisplayId - {@link ComponentCallbacks} map for Connected Display. */
private final SparseArray<ComponentCallbacks> mComponentCallbacks = new SparseArray<>();
/** DisplayId - {@link DeviceProfile} map for Connected Display. */
/** DisplayId - {@link deviceprofile} map for Connected Display. */
private final SparseArray<DeviceProfile> 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.
*/
@@ -1239,7 +1239,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
// Do not stash if in small screen, with 3 button nav, and in landscape.
if (mActivity.isPhoneMode() && mActivity.isThreeButtonNav()
&& mActivity.getDeviceProfile().isLandscape) {
&& mActivity.getDeviceProfile().getDeviceProperties().isLandscape()) {
return false;
}
@@ -68,7 +68,8 @@ class TaskbarStashViaTouchController(val controllers: TaskbarControllers) : Touc
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
activity.resources,
)
gestureHeightYThreshold = (activity.deviceProfile.heightPx - gestureHeight).toFloat()
gestureHeightYThreshold =
(activity.deviceProfile.deviceProperties.heightPx - gestureHeight).toFloat()
}
private fun createSwipeListener() =
@@ -38,7 +38,7 @@ public class TaskbarThresholdUtils {
private static int getThreshold(Resources r, DeviceProfile dp, int thresholdDimen,
int multiplierDimen) {
float landscapeScreenHeight = dp.isLandscape ? dp.heightPx : dp.widthPx;
float landscapeScreenHeight = dp.getDeviceProperties().isLandscape() ? dp.getDeviceProperties().getHeightPx() : dp.getDeviceProperties().getWidthPx();
float screenPart = (landscapeScreenHeight * SCREEN_UNITS);
float defaultDp = dpiFromPx(screenPart, DisplayMetrics.DENSITY_DEVICE_STABLE);
float thisDp = dpToPx(defaultDp);
@@ -209,7 +209,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
*/
private int calculateMaxNumIcons() {
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int availableWidth = deviceProfile.widthPx;
int availableWidth = deviceProfile.getDeviceProperties().getWidthPx();
int defaultEdgeMargin =
(int) getResources().getDimension(deviceProfile.inv.inlineNavButtonsEndSpacing);
int spaceForBubbleBar =
@@ -985,7 +985,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
float scaleUp = ((float) launcherDp.iconSizePx) / taskbarDp.taskbarIconSize;
int borderSpacing = launcherDp.hotseatBorderSpace;
int hotseatCellSize = DeviceProfile.calculateCellWidth(
launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right,
launcherDp.getDeviceProperties().getAvailableWidthPx() - hotseatPadding.left - hotseatPadding.right,
borderSpacing,
launcherDp.numShownHotseatIcons);
@@ -1066,7 +1066,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
if (child == mTaskbarView.getQsb()) {
boolean isRtl = Utilities.isRtl(child.getResources());
float hotseatIconCenter = isRtl
? launcherDp.widthPx - hotseatPadding.right + borderSpacing
? launcherDp.getDeviceProperties().getWidthPx() - hotseatPadding.right + borderSpacing
+ launcherDp.hotseatQsbWidth / 2f
: hotseatPadding.left - borderSpacing - launcherDp.hotseatQsbWidth / 2f;
if (taskbarDp.isQsbInline) {
@@ -147,7 +147,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
protected void onOpenCloseAnimationPending(PendingAnimation animation) {
final boolean isOpening = mToTranslationShift == TRANSLATION_SHIFT_OPENED;
if (mActivityContext.getDeviceProfile().isPhone) {
if (mActivityContext.getDeviceProfile().getDeviceProperties().isPhone()) {
final Interpolator allAppsFadeInterpolator =
isOpening ? ALL_APPS_FADE_MANUAL : Interpolators.reverse(ALL_APPS_FADE_MANUAL);
animation.setViewAlpha(mAppsView, 1 - mToTranslationShift, allAppsFadeInterpolator);
@@ -168,7 +168,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
@Override
protected Interpolator getScrimInterpolator() {
if (mActivityContext.getDeviceProfile().isTablet) {
if (mActivityContext.getDeviceProfile().getDeviceProperties().isTablet()) {
return super.getScrimInterpolator();
}
return mToTranslationShift == TRANSLATION_SHIFT_OPENED
@@ -213,7 +213,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
protected void onFinishInflate() {
super.onFinishInflate();
mAppsView = findViewById(R.id.apps_view);
if (mActivityContext.getDeviceProfile().isPhone) {
if (mActivityContext.getDeviceProfile().getDeviceProperties().isPhone()) {
mAppsView.setAlpha(0);
}
mContent = mAppsView;
@@ -210,7 +210,8 @@ class BubbleBarSwipeController {
resources,
taskbarActivityContext.deviceProfile,
)
maxOverscroll = taskbarActivityContext.deviceProfile.heightPx - unstashThreshold
maxOverscroll =
taskbarActivityContext.deviceProfile.deviceProperties.heightPx - unstashThreshold
}
}
}
@@ -348,7 +348,7 @@ public class BubbleStashedHandleViewController {
// the bounds of the handle only include the visible part, so we check that the Y coordinate
// is anywhere within the stashed height of bubble bar (same as taskbar stashed height).
final int top = mActivity.getDeviceProfile().heightPx - mStashedBubbleBarHeight;
final int top = mActivity.getDeviceProfile().getDeviceProperties().getHeightPx() - mStashedBubbleBarHeight;
final float x = ev.getRawX();
return ev.getRawY() >= top && x >= mStashedHandleBounds.left
&& x <= mStashedHandleBounds.right;
@@ -38,7 +38,7 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext)
get() = taskbarActivityContext.isTransientTaskbar
val isLandscape: Boolean
get() = taskbarActivityContext.deviceProfile.isLandscape
get() = taskbarActivityContext.deviceProfile.deviceProperties.isLandscape
val isTnMinimalState: Boolean
get() = taskbarActivityContext.isTaskbarInMinimalState
@@ -69,7 +69,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
if (
measuredHeight + activityContext.deviceProfile.taskbarHeight >=
activityContext.deviceProfile.availableHeightPx
activityContext.deviceProfile.deviceProperties.availableHeightPx
) {
updateLayoutParams { width = LayoutParams.MATCH_PARENT }
}
@@ -90,7 +90,7 @@ abstract class AbstractNavButtonLayoutter(
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin)
nearestTouchFrameLayoutParams.marginStart = phoneOrPortraitSetupMargin
nearestTouchFrameLayoutParams.bottomMargin =
if (!deviceProfile.isLandscape) 0
if (!deviceProfile.deviceProperties.isLandscape) 0
else
phoneOrPortraitSetupMargin -
resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2
@@ -90,7 +90,7 @@ class NavButtonLayoutFactory {
)
}
isPhoneNavMode -> {
if (!deviceProfile.isLandscape) {
if (!deviceProfile.deviceProperties.isLandscape) {
navButtonsView.setIsVertical(false)
PhonePortraitNavLayoutter(
resources,
@@ -48,7 +48,7 @@ open class PhoneLandscapeNavLayoutter(
) {
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
val totalHeight = context.deviceProfile.heightPx
val totalHeight = context.deviceProfile.deviceProperties.heightPx
val homeButtonHeight =
resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size)
val roundedCornerContentMargin =
@@ -34,7 +34,7 @@ class PhonePortraitNavLayoutter(
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
a11yButton: ImageView?,
space: Space?
space: Space?,
) :
AbstractNavButtonLayoutter(
resources,
@@ -43,11 +43,11 @@ class PhonePortraitNavLayoutter(
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
) {
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
val totalWidth = context.deviceProfile.widthPx
val totalWidth = context.deviceProfile.deviceProperties.widthPx
val homeButtonWidth =
resources.getDimensionPixelSize(R.dimen.taskbar_phone_home_button_size)
val roundedCornerContentMargin =
@@ -63,7 +63,7 @@ class PhonePortraitNavLayoutter(
val navContainerParams =
FrameLayout.LayoutParams(
navButtonContainerWidth.toInt(),
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
)
navContainerParams.apply {
topMargin = 0
@@ -120,14 +120,14 @@ class PhonePortraitNavLayoutter(
contextualButtonWidth.toInt(),
roundedCornerContentMargin + contentPadding,
0,
Gravity.START
Gravity.START,
)
repositionContextualContainer(
endContextualContainer,
contextualButtonWidth.toInt(),
0,
roundedCornerContentMargin + contentPadding,
Gravity.END
Gravity.END,
)
startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT)
@@ -78,9 +78,9 @@ class SetupNavLayoutter(
// If SUW is on a large screen device that is landscape (or has a square aspect
// ratio) the back button has to be placed accordingly
if (
deviceProfile.isTablet && deviceProfile.isLandscape ||
(deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND &&
deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)
deviceProfile.deviceProperties.isTablet && deviceProfile.deviceProperties.isLandscape ||
(deviceProfile.deviceProperties.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND &&
deviceProfile.deviceProperties.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)
) {
navButtonsLayoutParams.marginStart =
resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)
@@ -35,7 +35,7 @@ class TaskbarNavLayoutter(
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
a11yButton: ImageView?,
space: Space?
space: Space?,
) :
AbstractNavButtonLayoutter(
resources,
@@ -44,7 +44,7 @@ class TaskbarNavLayoutter(
startContextualContainer,
imeSwitcher,
a11yButton,
space
space,
) {
override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
@@ -69,7 +69,7 @@ class TaskbarNavLayoutter(
val navButtonParams =
FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
)
navButtonParams.apply {
gravity = Gravity.END or Gravity.CENTER_VERTICAL
@@ -101,7 +101,7 @@ class TaskbarNavLayoutter(
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
if (!context.deviceProfile.isGestureMode) {
if (!context.deviceProfile.deviceProperties.isGestureMode) {
val contextualMargin =
resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_padding)
repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END)
@@ -110,7 +110,7 @@ class TaskbarNavLayoutter(
WRAP_CONTENT,
contextualMargin,
contextualMargin,
Gravity.START
Gravity.START,
)
if (imeSwitcher != null) {
@@ -122,7 +122,7 @@ class TaskbarNavLayoutter(
val imeSwitcherButtonParams =
FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
ViewGroup.LayoutParams.MATCH_PARENT,
)
imeSwitcherButtonParams.apply {
marginStart = imeStartMargin
@@ -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 -> {
@@ -515,7 +515,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
}
private List<SystemShortcut.Factory<QuickstepLauncher>> getSplitShortcuts() {
if (!mDeviceProfile.isTablet || mSplitSelectStateController.isSplitSelectActive()) {
if (!mDeviceProfile.getDeviceProperties().isTablet() || mSplitSelectStateController.isSplitSelectActive()) {
return Collections.emptyList();
}
RecentsView recentsView = getOverviewPanel();
@@ -704,7 +704,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
break;
}
if (!getDeviceProfile().isMultiWindowMode) {
if (!getDeviceProfile().getDeviceProperties().isMultiWindowMode()) {
list.add(new StatusBarTouchController(
this, () -> this.isInState(LauncherState.NORMAL)));
}
@@ -246,7 +246,10 @@ class RecentsViewStateController(private val launcher: QuickstepLauncher) :
launcher.deviceProfile,
)
val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet)
val timings =
AnimUtils.getDeviceOverviewToSplitTimings(
launcher.deviceProfile.getDeviceProperties().isTablet
)
if (!goingToOverviewFromWorkspaceContextual) {
// This animation is already done for the contextual case, don't redo it
recentsView.createSplitSelectInitAnimation(
@@ -176,7 +176,7 @@ public class AllAppsState extends LauncherState {
}
private static boolean isWorkspaceVisible(DeviceProfile deviceProfile) {
return deviceProfile.isTablet || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur());
return deviceProfile.getDeviceProperties().isTablet() || (Flags.allAppsSheetForHandheld() && Flags.allAppsBlur());
}
@Override
@@ -199,7 +199,7 @@ public class AllAppsState extends LauncherState {
@Override
public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) {
DeviceProfile dp = launcher.getDeviceProfile();
return dp.isPhone && !dp.isLandscape;
return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape();
}
@Override
@@ -82,7 +82,7 @@ public class OverviewState extends LauncherState {
recentsView.getTaskSize(sTempRect);
float scale;
DeviceProfile deviceProfile = launcher.getDeviceProfile();
if (deviceProfile.isTwoPanels) {
if (deviceProfile.getDeviceProperties().isTwoPanels()) {
// In two panel layout, width does not include both panels or space between them, so
// use height instead. We do not use height for handheld, as cell layout can be
// shorter than a task and we want the workspace to scale down to task size.
@@ -114,9 +114,9 @@ public class OverviewState extends LauncherState {
int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS | ADD_DESK_BUTTON;
DeviceProfile dp = launcher.getDeviceProfile();
boolean showFloatingSearch;
if (dp.isPhone) {
if (dp.getDeviceProperties().isPhone()) {
// Only show search in phone overview in portrait mode.
showFloatingSearch = !dp.isLandscape;
showFloatingSearch = !dp.getDeviceProperties().isLandscape();
} else {
// Only show search in tablet overview if taskbar is not visible.
showFloatingSearch = !dp.isTaskbarPresent || isTaskbarStashed(launcher);
@@ -148,7 +148,7 @@ public class OverviewState extends LauncherState {
@Override
public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) {
DeviceProfile dp = launcher.getDeviceProfile();
return dp.isPhone && !dp.isLandscape;
return dp.getDeviceProperties().isPhone() && !dp.getDeviceProperties().isLandscape();
}
@Override
@@ -163,7 +163,7 @@ public class OverviewState extends LauncherState {
@Override
public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
return deviceProfile.isTablet;
return deviceProfile.getDeviceProperties().isTablet();
}
@Override
@@ -220,7 +220,7 @@ public class QuickstepAtomicAnimationFactory extends
} else if (fromState == NORMAL && toState == ALL_APPS) {
AllAppsSwipeController.applyNormalToAllAppsAnimConfig(mContainer, config);
} else if (fromState == OVERVIEW && toState == OVERVIEW_SPLIT_SELECT) {
SplitAnimationTimings timings = mContainer.getDeviceProfile().isTablet
SplitAnimationTimings timings = mContainer.getDeviceProfile().getDeviceProperties().isTablet()
? SplitAnimationTimings.TABLET_OVERVIEW_TO_SPLIT
: SplitAnimationTimings.PHONE_OVERVIEW_TO_SPLIT;
config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR,
@@ -43,7 +43,7 @@ public class SplitScreenSelectState extends OverviewState {
@Override
public int getTransitionDuration(ActivityContext context, boolean isToState) {
if (isToState && context.getDeviceProfile().isTablet) {
if (isToState && context.getDeviceProfile().getDeviceProperties().isTablet()) {
return SplitAnimationTimings.TABLET_ENTER_DURATION;
} else if (isToState) {
return SplitAnimationTimings.PHONE_ENTER_DURATION;
@@ -136,7 +136,7 @@ public class NavBarToHomeTouchController implements TouchController,
}
private float getShiftRange() {
return mLauncher.getDeviceProfile().heightPx;
return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx();
}
@Override
@@ -136,7 +136,7 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
float progressMultiplier = super.initCurrentAnimation();
if (mToState == HINT_STATE) {
// Track the drag across the entire height of the screen.
progressMultiplier = -1f / mLauncher.getDeviceProfile().heightPx;
progressMultiplier = -1f / mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx();
}
return progressMultiplier;
}
@@ -130,13 +130,13 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
mLauncher = launcher;
mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this);
mRecentsView = mLauncher.getOverviewPanel();
mXRange = mLauncher.getDeviceProfile().widthPx / 2f;
mXRange = mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f;
mYRange = LayoutUtils.getShelfTrackingDistance(
mLauncher,
mLauncher.getDeviceProfile(),
mRecentsView.getPagedOrientationHandler(),
mRecentsView.getContainerInterface());
mMaxYProgress = mLauncher.getDeviceProfile().heightPx / mYRange;
mMaxYProgress = mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / mYRange;
mMotionPauseDetector = new MotionPauseDetector(mLauncher);
mMotionPauseMinDisplacement = mLauncher.getResources().getDimension(
R.dimen.motion_pause_detector_min_displacement_from_app);
@@ -161,6 +161,6 @@ public class QuickSwitchTouchController extends AbstractStateChangeTouchControll
@Override
protected float getShiftRange() {
return mLauncher.getDeviceProfile().widthPx / 2f;
return mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() / 2f;
}
}
@@ -39,6 +39,6 @@ public class TransposedQuickSwitchTouchController extends QuickSwitchTouchContro
@Override
protected float getShiftRange() {
return mLauncher.getDeviceProfile().heightPx / 2f;
return mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() / 2f;
}
}
@@ -1024,7 +1024,7 @@ public abstract class AbsSwipeUpHandler<
}
dp.updateInsets(targets.homeContentInsets);
initTransitionEndpoints(dp);
orientationState.setMultiWindowMode(dp.isMultiWindowMode);
orientationState.setMultiWindowMode(dp.getDeviceProperties().isMultiWindowMode());
}
// Notify when the animation starts
@@ -1539,7 +1539,7 @@ public abstract class AbsSwipeUpHandler<
}
private void doLogGesture(GestureEndTarget endTarget, @Nullable TaskView targetTaskView) {
if (mDp == null || !mDp.isGestureMode) {
if (mDp == null || !mDp.getDeviceProperties().isGestureMode()) {
// We probably never received an animation controller, skip logging.
return;
}
@@ -1973,24 +1973,26 @@ public abstract class AbsSwipeUpHandler<
private Rect getKeepClearAreaForHotseat() {
Rect keepClearArea;
final int heightPx = mDp.getDeviceProperties().getHeightPx();
final int widthPx = mDp.getDeviceProperties().getWidthPx();
// the keep clear area in global screen coordinates, in pixels
if (mDp.isPhone) {
if (mDp.getDeviceProperties().isPhone()) {
if (mDp.isSeascape()) {
// in seascape the Hotseat is on the left edge of the screen
keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, mDp.heightPx);
} else if (mDp.isLandscape) {
keepClearArea = new Rect(0, 0, mDp.hotseatBarSizePx, heightPx);
} else if (mDp.getDeviceProperties().isLandscape()) {
// in landscape the Hotseat is on the right edge of the screen
keepClearArea = new Rect(mDp.widthPx - mDp.hotseatBarSizePx, 0,
mDp.widthPx, mDp.heightPx);
keepClearArea = new Rect(widthPx - mDp.hotseatBarSizePx, 0,
widthPx, heightPx);
} else {
// in portrait mode the Hotseat is at the bottom of the screen
keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx,
mDp.widthPx, mDp.heightPx);
keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx,
widthPx, heightPx);
}
} else {
// large screens have Hotseat always at the bottom of the screen
keepClearArea = new Rect(0, mDp.heightPx - mDp.hotseatBarSizePx,
mDp.widthPx, mDp.heightPx);
keepClearArea = new Rect(0, heightPx - mDp.hotseatBarSizePx,
widthPx, heightPx);
}
return keepClearArea;
}
@@ -2754,7 +2756,7 @@ public abstract class AbsSwipeUpHandler<
// Scaling of RecentsView during quick switch based on amount of recents scroll
private float getScaleProgressDueToScroll() {
if (mContainer == null || !mContainer.getDeviceProfile().isTablet || mRecentsView == null
if (mContainer == null || !mContainer.getDeviceProfile().getDeviceProperties().isTablet() || mRecentsView == null
|| !shouldLinkRecentsViewScroll()) {
return 0;
}
@@ -58,8 +58,7 @@ class AspectRatioSystemShortcut(
}
mTarget.startActivitySafely(view, intent, mItemInfo)
mTarget
.statsLogManager
mTarget.statsLogManager
.logger()
.withItemInfo(mItemInfo)
.log(LauncherEvent.LAUNCHER_ASPECT_RATIO_SETTINGS_SYSTEM_SHORTCUT_TAP)
@@ -81,7 +80,7 @@ class AspectRatioSystemShortcut(
!universalResizableByDefault() -> null
// The option is only shown on sw600dp+ screens (checked by isTablet)
!viewContainer.deviceProfile.isTablet -> null
!viewContainer.deviceProfile.deviceProperties.isTablet -> null
else -> {
listOf(
@@ -253,7 +253,7 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect,
RecentsPagedOrientationHandler orientationHandler) {
if (dp.isTablet) {
if (dp.getDeviceProperties().isTablet()) {
calculateLargeTileSize(context, dp, outRect);
} else {
Resources res = context.getResources();
@@ -286,7 +286,7 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity,
Rect outRect, RecentsPagedOrientationHandler orientationHandler) {
Rect potentialTaskRect = new Rect(0, 0, dp.widthPx, dp.heightPx);
Rect potentialTaskRect = new Rect(0, 0, dp.getDeviceProperties().getWidthPx(), dp.getDeviceProperties().getHeightPx());
Rect insets;
if (orientationHandler.isLayoutNaturalToLauncher()) {
@@ -349,9 +349,9 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
* Gets the dimension of the task in the current system state.
*/
public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
out.x = dp.widthPx;
out.y = dp.heightPx;
if (dp.isTablet && !DisplayController.isTransientTaskbar(context)) {
out.x = dp.getDeviceProperties().getWidthPx();
out.y = dp.getDeviceProperties().getHeightPx();
if (dp.getDeviceProperties().isTablet() && !DisplayController.isTransientTaskbar(context)) {
out.y -= dp.taskbarHeight;
}
}
@@ -365,7 +365,7 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
int bottomMargin = dp.getOverviewActionsClaimedSpace();
int sideMargin = dp.overviewGridSideMargin;
outRect.set(0, 0, dp.widthPx, dp.heightPx);
outRect.set(0, 0, dp.getDeviceProperties().getWidthPx(), dp.getDeviceProperties().getHeightPx());
outRect.inset(Math.max(insets.left, sideMargin), insets.top + topMargin,
Math.max(insets.right, sideMargin), Math.max(insets.bottom, bottomMargin));
}
@@ -398,15 +398,15 @@ public abstract class BaseContainerInterface<STATE_TYPE extends BaseState<STATE_
public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect,
RecentsPagedOrientationHandler orientationHandler) {
calculateTaskSize(context, dp, outRect, orientationHandler);
boolean isGridOnlyOverview = dp.isTablet && enableGridOnlyOverview();
boolean isGridOnlyOverview = dp.getDeviceProperties().isTablet() && enableGridOnlyOverview();
int claimedSpaceBelow = isGridOnlyOverview
? dp.overviewActionsTopMarginPx + dp.overviewActionsHeight + dp.stashedTaskbarHeight
: (dp.heightPx - outRect.bottom - dp.getInsets().bottom);
: (dp.getDeviceProperties().getHeightPx() - outRect.bottom - dp.getInsets().bottom);
int minimumHorizontalPadding = 0;
if (!isGridOnlyOverview) {
float maxScale = context.getResources().getFloat(R.dimen.overview_modal_max_scale);
minimumHorizontalPadding =
Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2);
Math.round((dp.getDeviceProperties().getAvailableWidthPx() - outRect.width() * maxScale) / 2);
}
calculateTaskSizeInternal(
context,
@@ -63,9 +63,9 @@ public final class FallbackActivityInterface extends
RecentsPagedOrientationHandler orientationHandler) {
calculateTaskSize(context, dp, outRect, orientationHandler);
if (dp.isVerticalBarLayout() && DisplayController.getNavigationMode(context) != NO_BUTTON) {
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
return dp.isSeascape() ? outRect.left : (dp.getDeviceProperties().getWidthPx() - outRect.right);
} else {
return dp.heightPx - outRect.bottom;
return dp.getDeviceProperties().getHeightPx() - outRect.bottom;
}
}
@@ -233,7 +233,7 @@ public class FallbackSwipeHandler extends
@Override
public AnimatorPlaybackController createActivityAnimationToHome() {
// copied from {@link LauncherSwipeHandlerV2.LauncherHomeAnimationFactory}
long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx);
long accuracy = 2 * Math.max(mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx());
return mContainer.getStateManager().createAnimationToNewWorkspace(
RecentsState.HOME, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS);
}
@@ -342,7 +342,7 @@ public class FallbackSwipeHandler extends
.setStartValue(mVerticalShiftForScale.value)
.setEndValue(0)
.setStartVelocity(-velocity / mTransitionDragLength)
.setMinimumVisibleChange(1f / mDp.heightPx)
.setMinimumVisibleChange(1f / mDp.getDeviceProperties().getHeightPx())
.setDampingRatio(0.6f)
.setStiffness(800)
.build(mVerticalShiftForScale, AnimatedFloat.VALUE)
@@ -77,9 +77,9 @@ public final class FallbackWindowInterface extends BaseWindowInterface {
RecentsPagedOrientationHandler orientationHandler) {
calculateTaskSize(context, dp, outRect, orientationHandler);
if (dp.isVerticalBarLayout() && DisplayController.getNavigationMode(context) != NO_BUTTON) {
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
return dp.isSeascape() ? outRect.left : (dp.getDeviceProperties().getWidthPx() - outRect.right);
} else {
return dp.heightPx - outRect.bottom;
return dp.getDeviceProperties().getHeightPx() - outRect.bottom;
}
}
@@ -74,7 +74,7 @@ public final class LauncherActivityInterface extends
calculateTaskSize(context, dp, outRect, orientationHandler);
if (dp.isVerticalBarLayout()
&& DisplayController.getNavigationMode(context) != NavigationMode.NO_BUTTON) {
return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
return dp.isSeascape() ? outRect.left : (dp.getDeviceProperties().getWidthPx() - outRect.right);
} else {
return LayoutUtils.getShelfTrackingDistance(context, dp, orientationHandler, this);
}
@@ -366,7 +366,7 @@ public class LauncherSwipeHandlerV2 extends AbsSwipeUpHandler<
public AnimatorPlaybackController createActivityAnimationToHome() {
// Return an empty APC here since we have an non-user controlled animation
// to home.
long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx);
long accuracy = 2 * Math.max(mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx());
return mContainer.getStateManager().createAnimationToNewWorkspace(
NORMAL, accuracy, StateAnimationConfig.SKIP_ALL_ANIMATIONS);
}
@@ -539,7 +539,7 @@ constructor(
private fun shouldShowAltTabKqs(deviceProfile: DeviceProfile?, displayId: Int): Boolean =
// Alt+Tab KQS is always shown on tablets (large screen devices).
deviceProfile?.isTablet == true ||
deviceProfile?.deviceProperties?.isTablet == true ||
// For small screen devices, it's only shown on connected displays.
displayId != DEFAULT_DISPLAY
@@ -74,7 +74,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
}
case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
final float swipeHeight = mDeviceProfile.heightPx / 2f;
final float swipeHeight = mDeviceProfile.getDeviceProperties().getHeightPx() / 2f;
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
return response;
}
@@ -113,7 +113,7 @@ public abstract class SwipeUpAnimationLogic implements
.getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT,
mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState()
.getOrientationHandler());
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
mDragLengthFactor = (float) dp.getDeviceProperties().getHeightPx() / mTransitionDragLength;
for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
PendingAnimation pendingAnimation = new PendingAnimation(mTransitionDragLength * 2);
@@ -186,10 +186,14 @@ public abstract class SwipeUpAnimationLogic implements
PagedOrientationHandler orientationHandler = getOrientationHandler();
DeviceProfile dp = mDp;
final int halfIconSize = dp.iconSizePx / 2;
float primaryDimension = orientationHandler
.getPrimaryValue(dp.availableWidthPx, dp.availableHeightPx);
float secondaryDimension = orientationHandler
.getSecondaryValue(dp.availableWidthPx, dp.availableHeightPx);
float primaryDimension = orientationHandler.getPrimaryValue(
dp.getDeviceProperties().getAvailableWidthPx(),
dp.getDeviceProperties().getAvailableHeightPx()
);
float secondaryDimension = orientationHandler.getSecondaryValue(
dp.getDeviceProperties().getAvailableWidthPx(),
dp.getDeviceProperties().getAvailableHeightPx()
);
final float targetX = primaryDimension / 2f;
final float targetY = secondaryDimension - dp.hotseatBarSizePx;
// Fallback to animate to center of screen.
@@ -260,7 +264,7 @@ public abstract class SwipeUpAnimationLogic implements
}
public boolean isPortrait() {
return !mDp.isLandscape && !mDp.isSeascape();
return !mDp.getDeviceProperties().isLandscape() && !mDp.isSeascape();
}
}
@@ -450,7 +454,7 @@ public abstract class SwipeUpAnimationLogic implements
// to end up offscreen.
mRunningTaskViewScrollOffset = factory.isRtl()
? (Math.min(0, -invariantStartRect.right))
: (Math.max(0, mDp.widthPx - invariantStartRect.left));
: (Math.max(0, mDp.getDeviceProperties().getWidthPx() - invariantStartRect.left));
}
@Override
@@ -349,7 +349,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
RecentsViewContainer container = containerFromContext(
getTaskView().getContext());
int bottomInset = container.getDeviceProfile().isTablet
int bottomInset = container.getDeviceProfile().getDeviceProperties().isTablet()
? Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom) : 0;
return Insets.of(0, 0, 0, bottomInset);
}
@@ -342,7 +342,7 @@ public interface TaskShortcutFactory {
!deviceProfile.isTaskbarPresent && recentsView.getTaskViewCount() < 2;
boolean isTaskSplitNotSupported = !task.isDockable ||
(intentFlags & FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0;
boolean hideForExistingMultiWindow = container.getDeviceProfile().isMultiWindowMode;
boolean hideForExistingMultiWindow = container.getDeviceProfile().getDeviceProperties().isMultiWindowMode();
if (notEnoughTasksToSplit || isTaskSplitNotSupported || hideForExistingMultiWindow) {
return null;
@@ -365,7 +365,7 @@ public interface TaskShortcutFactory {
DeviceProfile deviceProfile = container.getDeviceProfile();
final TaskView taskView = taskContainer.getTaskView();
final RecentsView recentsView = taskView.getRecentsView();
boolean isLargeTile = deviceProfile.isTablet && taskView.isLargeTile();
boolean isLargeTile = deviceProfile.getDeviceProperties().isTablet() && taskView.isLargeTile();
boolean isInExpectedScrollPosition =
recentsView.isTaskInExpectedScrollPosition(taskView);
boolean shouldShowActionsButtonInstead =
@@ -521,7 +521,7 @@ public interface TaskShortcutFactory {
// Modal only works with grid size tiles with enableGridOnlyOverview enabled on
// tablets / foldables. With enableGridOnlyOverview off, for large tiles it works,
// but the tile needs to be in the center of Recents / Overview.
boolean isTablet = container.getDeviceProfile().isTablet;
boolean isTablet = container.getDeviceProfile().getDeviceProperties().isTablet();
RecentsView recentsView = container.getOverviewPanel();
boolean isLargeTileInCenterOfOverview = taskContainer.getTaskView().isLargeTile()
&& recentsView.isFocusedTaskInExpectedScrollPosition();
@@ -226,7 +226,7 @@ public final class TaskViewUtils {
T container = RecentsViewContainer.containerFromContext(context);
DeviceProfile dp = container.getDeviceProfile();
boolean showAsGrid = dp.isTablet;
boolean showAsGrid = dp.getDeviceProperties().isTablet();
boolean parallaxCenterAndAdjacentTask =
!showAsGrid && taskIndex != recentsView.getCurrentPage();
int scrollOffset = recentsView.getScrollOffset(taskIndex);
@@ -178,7 +178,7 @@ public class RecentsState implements BaseState<RecentsState> {
* For this state, whether tasks should layout as a grid rather than a list.
*/
public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.isTablet;
return hasFlag(FLAG_SHOW_AS_GRID) && deviceProfile.getDeviceProperties().isTablet();
}
@Override
@@ -283,7 +283,7 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler<RecentsWindowMa
@Override
public AnimatorPlaybackController createActivityAnimationToHome() {
// copied from {@link LauncherSwipeHandlerV2.LauncherHomeAnimationFactory}
long accuracy = 2 * Math.max(mDp.widthPx, mDp.heightPx);
long accuracy = 2 * Math.max(mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx());
return mRecentsWindowManager
.getStateManager()
.createAnimationToNewWorkspace(
@@ -359,7 +359,7 @@ public class RecentsWindowSwipeHandler extends AbsSwipeUpHandler<RecentsWindowMa
.setStartValue(mVerticalShiftForScale.value)
.setEndValue(0)
.setStartVelocity(-velocity / mTransitionDragLength)
.setMinimumVisibleChange(1f / mDp.heightPx)
.setMinimumVisibleChange(1f / mDp.getDeviceProperties().getHeightPx())
.setDampingRatio(0.6f)
.setStiffness(800)
.build(mVerticalShiftForScale, AnimatedFloat.VALUE)
@@ -123,7 +123,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
pinnedTaskbarWithAutoStashing ? 0 : TaskbarThresholdUtils.getFromNavThreshold(res,
taskbarActivityContext.getDeviceProfile());
mTaskbarNavThresholdY = taskbarActivityContext.getDeviceProfile().heightPx
mTaskbarNavThresholdY = taskbarActivityContext.getDeviceProfile().getDeviceProperties().getHeightPx()
- mTaskbarNavThreshold;
mIsTaskbarAllAppsOpen = mTaskbarActivityContext.isTaskbarAllAppsOpen();
@@ -302,10 +302,10 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
private void updateHoveredTaskbarState(int x, int y) {
DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
mBottomEdgeBounds.set(
(dp.widthPx - (int) mUnstashArea) / 2,
dp.heightPx - mStashedTaskbarBottomEdge,
(int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
dp.heightPx);
(dp.getDeviceProperties().getWidthPx() - (int) mUnstashArea) / 2,
dp.getDeviceProperties().getHeightPx() - mStashedTaskbarBottomEdge,
(int) (((dp.getDeviceProperties().getWidthPx() - mUnstashArea) / 2) + mUnstashArea),
dp.getDeviceProperties().getHeightPx());
if (mBottomEdgeBounds.contains(x, y)) {
// start a single unstash timeout if hovering bottom edge under the hinted taskbar.
@@ -330,9 +330,9 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
mBottomEdgeBounds.set(
0,
dp.heightPx - mBottomScreenEdge,
dp.widthPx,
dp.heightPx);
dp.getDeviceProperties().getHeightPx() - mBottomScreenEdge,
dp.getDeviceProperties().getWidthPx(),
dp.getDeviceProperties().getHeightPx());
if (cursorHotCorner() && mDisplayManager != null) {
Display display = mDisplayManager.getDisplay(displayId);
@@ -371,10 +371,10 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
}
DeviceProfile dp = mTaskbarActivityContext.getDeviceProfile();
mStashedTaskbarHandleBounds.set(
(dp.widthPx - (int) mUnstashArea) / 2,
dp.heightPx - dp.stashedTaskbarHeight,
(int) (((dp.widthPx - mUnstashArea) / 2) + mUnstashArea),
dp.heightPx);
(dp.getDeviceProperties().getWidthPx() - (int) mUnstashArea) / 2,
dp.getDeviceProperties().getHeightPx() - dp.stashedTaskbarHeight,
(int) (((dp.getDeviceProperties().getWidthPx() - mUnstashArea) / 2) + mUnstashArea),
dp.getDeviceProperties().getHeightPx());
return mStashedTaskbarHandleBounds.contains(x, y);
}
@@ -215,7 +215,7 @@ public class AllSetActivity extends Activity {
maybeResumeOrPauseBackgroundAnimation();
});
setUpBackgroundAnimation(getDP().isTablet);
setUpBackgroundAnimation(getDP().getDeviceProperties().isTablet());
getIDP().addOnChangeListener(mOnIDPChangeListener);
OverviewComponentObserver.INSTANCE.get(this)
@@ -239,7 +239,7 @@ public class AllSetActivity extends Activity {
private void updateHint() {
mHintView.setText(
getDP().isGestureMode ? R.string.allset_hint : R.string.allset_button_hint);
getDP().getDeviceProperties().isGestureMode() ? R.string.allset_hint : R.string.allset_button_hint);
}
private void runOnUiHelperThread(Runnable runnable) {
@@ -118,7 +118,7 @@ public class EdgeBackGestureHandler implements OnTouchListener {
// Add a nav bar panel window.
mEdgeBackPanel = new EdgeBackGesturePanel(mContext, parent, createLayoutParams());
mEdgeBackPanel.setBackCallback(mBackCallback);
mDisplaySize.set(mDeviceProfile.widthPx, mDeviceProfile.heightPx);
mDisplaySize.set(mDeviceProfile.getDeviceProperties().getWidthPx(), mDeviceProfile.getDeviceProperties().getHeightPx());
mEdgeBackPanel.setDisplaySize(mDisplaySize);
}
}
@@ -151,9 +151,9 @@ public class GestureSandboxActivity extends FragmentActivity {
private void correctUserOrientation() {
DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.get(
getApplicationContext()).getDeviceProfile(this);
if (deviceProfile.isTablet) {
if (deviceProfile.getDeviceProperties().isTablet()) {
// The tutorial will work in either orientation if the height and width are similar
boolean showRotationPrompt = !LayoutUtils.isAspectRatioSquare(deviceProfile.aspectRatio)
boolean showRotationPrompt = !LayoutUtils.isAspectRatioSquare(deviceProfile.getDeviceProperties().getAspectRatio())
&& getResources().getConfiguration().orientation
== ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
@@ -60,7 +60,7 @@ public class NavBarGestureHandler implements OnTouchListener,
NavBarGestureHandler(Context context, DeviceProfile deviceProfile) {
mContext = context;
mDisplaySize.set(deviceProfile.widthPx, deviceProfile.heightPx);
mDisplaySize.set(deviceProfile.getDeviceProperties().getWidthPx(), deviceProfile.getDeviceProperties().getHeightPx());
mSwipeUpTouchTracker = new TriggerSwipeUpTouchTracker(
context,
/* disableHorizontalSwipe= */ true,
@@ -330,7 +330,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
void initDp(DeviceProfile dp) {
initTransitionEndpoints(dp);
mRemoteTargetHandles[0].getTaskViewSimulator().setPreviewBounds(
new Rect(0, 0, dp.widthPx, dp.heightPx), dp.getInsets());
new Rect(0, 0, dp.getDeviceProperties().getWidthPx(), dp.getDeviceProperties().getHeightPx()), dp.getInsets());
}
@Override
@@ -157,8 +157,8 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mAnimatedGestureDemonstration = rootView.findViewById(
R.id.gesture_demonstration_animations);
mExitingAppView = rootView.findViewById(R.id.exiting_app_back);
mScreenWidth = mTutorialFragment.getDeviceProfile().widthPx;
mScreenHeight = mTutorialFragment.getDeviceProfile().heightPx;
mScreenWidth = mTutorialFragment.getDeviceProfile().getDeviceProperties().getWidthPx();
mScreenHeight = mTutorialFragment.getDeviceProfile().getDeviceProperties().getHeightPx();
mExitingAppMargin = mContext.getResources().getDimensionPixelSize(
R.dimen.gesture_tutorial_back_gesture_exiting_app_margin);
mExitingAppStartingCornerRadius = QuickStepContract.getWindowCornerRadius(mContext);
@@ -655,7 +655,7 @@ abstract class TutorialController implements BackGestureAttemptCallback,
if (!mTutorialFragment.isLargeScreen()) {
DeviceProfile dp = mTutorialFragment.getDeviceProfile();
hotseatLayoutParams.addRule(dp.isLandscape
hotseatLayoutParams.addRule(dp.getDeviceProperties().isLandscape()
? (dp.isSeascape()
? RelativeLayout.ALIGN_PARENT_START
: RelativeLayout.ALIGN_PARENT_END)
@@ -183,8 +183,8 @@ abstract class TutorialFragment extends GestureSandboxFragment implements OnTouc
mDeviceProfile = InvariantDeviceProfile.INSTANCE.get(getContext())
.getDeviceProfile(getContext());
mIsLargeScreen = mDeviceProfile.isTablet;
mIsFoldable = mDeviceProfile.isTwoPanels;
mIsLargeScreen = mDeviceProfile.getDeviceProperties().isTablet();
mIsFoldable = mDeviceProfile.getDeviceProperties().isTwoPanels();
if (mOnAttachedToWindowPendingCreate) {
mOnAttachedToWindowPendingCreate = false;
@@ -84,9 +84,9 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler {
override fun fixBoundsForHomeAnimStartRect(outStartRect: RectF, deviceProfile: DeviceProfile) {
// We don't need to check the "top" value here because the startRect is in the orientation
// of the app, not of the fixed portrait launcher.
if (outStartRect.left > deviceProfile.heightPx) {
if (outStartRect.left > deviceProfile.deviceProperties.heightPx) {
outStartRect.offsetTo(0f, outStartRect.top)
} else if (outStartRect.left < -deviceProfile.heightPx) {
} else if (outStartRect.left < -deviceProfile.deviceProperties.heightPx) {
outStartRect.offsetTo(0f, outStartRect.top)
}
}
@@ -394,15 +394,15 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler {
) {
// In fake land/seascape, the placeholder always needs to go to the "top" of the device,
// which is the same bounds as 0 rotation.
val width = dp.widthPx
val width = dp.deviceProperties.widthPx
val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp)
out.set(0, 0, width, placeholderHeight + insetSizeAdjustment)
out.inset(placeholderInset, 0)
// Adjust the top to account for content off screen. This will help to animate the view in
// with rounded corners.
val screenWidth = dp.widthPx
val screenHeight = dp.heightPx
val screenWidth = dp.deviceProperties.widthPx
val screenHeight = dp.deviceProperties.heightPx
val totalHeight =
(1.0f * screenHeight / 2 * (screenWidth - 2 * placeholderInset) / screenWidth).toInt()
out.top -= totalHeight - placeholderHeight
@@ -467,8 +467,8 @@ open class LandscapePagedViewHandler : RecentsPagedOrientationHandler {
out2: Rect,
) {
// In fake land/seascape, the window bounds are always top and bottom half
val screenHeight = dp.heightPx
val screenWidth = dp.widthPx
val screenHeight = dp.deviceProperties.heightPx
val screenWidth = dp.deviceProperties.widthPx
out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize)
out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight)
}
@@ -63,9 +63,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
}
override fun fixBoundsForHomeAnimStartRect(outStartRect: RectF, deviceProfile: DeviceProfile) {
if (outStartRect.left > deviceProfile.widthPx) {
if (outStartRect.left > deviceProfile.deviceProperties.widthPx) {
outStartRect.offsetTo(0f, outStartRect.top)
} else if (outStartRect.left < -deviceProfile.widthPx) {
} else if (outStartRect.left < -deviceProfile.deviceProperties.widthPx) {
outStartRect.offsetTo(0f, outStartRect.top)
}
}
@@ -139,7 +139,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
if (enableOverviewIconMenu()) {
x
} else {
if (deviceProfile.isLandscape) {
if (deviceProfile.deviceProperties.isLandscape) {
(x +
taskInsetMargin +
(thumbnailView.measuredWidth - thumbnailView.measuredHeight) / 2f)
@@ -181,7 +181,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
)
}
(deviceProfile.isLandscape && !deviceProfile.isTablet) -> {
(deviceProfile.deviceProperties.isLandscape &&
!deviceProfile.deviceProperties.isTablet) -> {
val padding =
thumbnailView.resources.getDimensionPixelSize(R.dimen.task_menu_edge_padding)
thumbnailView.measuredHeight - (2 * padding)
@@ -200,7 +201,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
taskMenuX: Float,
taskMenuY: Float,
): Int =
deviceProfile.heightPx -
deviceProfile.deviceProperties.heightPx -
deviceProfile.insets.top -
taskMenuY.toInt() -
deviceProfile.overviewActionsClaimedSpaceBelow
@@ -331,11 +332,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
/* -------------------- */
override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int =
dp.heightPx - rect.bottom
dp.deviceProperties.heightPx - rect.bottom
override fun getSplitPositionOptions(dp: DeviceProfile): List<SplitPositionOption> =
when {
dp.isTablet -> {
dp.deviceProperties.isTablet -> {
Utilities.getSplitPositionOptions(dp)
}
@@ -381,8 +382,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
@StagePosition stagePosition: Int,
out: Rect,
) {
val screenWidth = dp.widthPx
val screenHeight = dp.heightPx
val screenWidth = dp.deviceProperties.widthPx
val screenHeight = dp.deviceProperties.heightPx
val pinToRight = stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT
val insetSizeAdjustment = getPlaceholderSizeAdjustment(dp, pinToRight)
@@ -466,7 +467,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
*/
private fun getPlaceholderSizeAdjustment(dp: DeviceProfile, pinToRight: Boolean): Int {
val insetThickness =
if (!dp.isLandscape) {
if (!dp.deviceProperties.isLandscape) {
dp.insets.top
} else {
if (pinToRight) dp.insets.right else dp.insets.left
@@ -484,8 +485,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
out.pivotY = splitInstructionsHeight.toFloat()
out.rotation = degreesRotated
val distanceToEdge =
if (dp.isPhone) {
if (dp.isLandscape) {
if (dp.deviceProperties.isPhone) {
if (dp.deviceProperties.isLandscape) {
out.resources.getDimensionPixelSize(
R.dimen.split_instructions_bottom_margin_phone_landscape
)
@@ -516,8 +517,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
out1: Rect,
out2: Rect,
) {
val screenHeight = dp.heightPx
val screenWidth = dp.widthPx
val screenHeight = dp.deviceProperties.heightPx
val screenWidth = dp.deviceProperties.widthPx
out1.set(0, 0, screenWidth, screenHeight / 2 - splitDividerSize)
out2.set(0, screenHeight / 2 + splitDividerSize, screenWidth, screenHeight)
if (!dp.isLeftRightSplit) {
@@ -556,10 +557,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
val dividerBarPercent = splitInfo.dividerPercent
val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight
val scale = outRect.height().toFloat() / (dp.availableHeightPx - taskbarHeight)
val topTaskHeight = dp.availableHeightPx * topLeftTaskPercent
val scale =
outRect.height().toFloat() / (dp.deviceProperties.availableHeightPx - taskbarHeight)
val topTaskHeight = dp.deviceProperties.availableHeightPx * topLeftTaskPercent
val scaledTopTaskHeight = topTaskHeight * scale
val dividerHeight = dp.availableHeightPx * dividerBarPercent
val dividerHeight = dp.deviceProperties.availableHeightPx * dividerBarPercent
val scaledDividerHeight = dividerHeight * scale
if (desiredStagePosition == SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT) {
@@ -668,8 +670,10 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
secondTaskViewSize.y = totalThumbnailHeight
} else {
val taskbarHeight = if (dp.isTransientTaskbar) 0 else dp.taskbarHeight
val scale = totalThumbnailHeight.toFloat() / (dp.availableHeightPx - taskbarHeight)
val topTaskHeight = dp.availableHeightPx * taskPercent
val scale =
totalThumbnailHeight.toFloat() /
(dp.deviceProperties.availableHeightPx - taskbarHeight)
val topTaskHeight = dp.deviceProperties.availableHeightPx * taskPercent
val finalDividerHeight = Math.round(totalThumbnailHeight * dividerScale).toFloat()
val scaledTopTaskHeight = topTaskHeight * scale
firstTaskViewSize.x = parentWidth
@@ -779,7 +783,8 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
.toInt()
secondaryAppChipView.setSplitTranslationY(
(primarySnapshotHeight +
(if (deviceProfile.isTablet) 0 else dividerThickness))
(if (deviceProfile.deviceProperties.isTablet) 0
else dividerThickness))
.toFloat()
)
}
@@ -792,9 +797,11 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
if (deviceProfile.isSeascape) deviceProfile.insets.right
else deviceProfile.insets.left
val fullscreenMidpointFromBottom =
((deviceProfile.widthPx - fullscreenInsetThickness) / 2)
val midpointFromEndPct = fullscreenMidpointFromBottom.toFloat() / deviceProfile.widthPx
val insetPct = fullscreenInsetThickness.toFloat() / deviceProfile.widthPx
((deviceProfile.deviceProperties.widthPx - fullscreenInsetThickness) / 2)
val midpointFromEndPct =
fullscreenMidpointFromBottom.toFloat() / deviceProfile.deviceProperties.widthPx
val insetPct =
fullscreenInsetThickness.toFloat() / deviceProfile.deviceProperties.widthPx
val spaceAboveSnapshots = 0
val overviewThumbnailAreaThickness = groupedTaskViewWidth - spaceAboveSnapshots
val bottomToMidpointOffset =
@@ -895,7 +902,9 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat
}
override fun getDefaultSplitPosition(deviceProfile: DeviceProfile): Int {
check(deviceProfile.isTablet) { "Default position available only for large screens" }
check(deviceProfile.deviceProperties.isTablet) {
"Default position available only for large screens"
}
return if (deviceProfile.isLeftRightSplit) {
SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT
} else {
@@ -113,7 +113,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() {
deviceProfile: DeviceProfile,
taskMenuX: Float,
taskMenuY: Float,
): Int = (deviceProfile.availableWidthPx - taskInsetMargin - taskMenuX).toInt()
): Int = (deviceProfile.deviceProperties.availableWidthPx - taskInsetMargin - taskMenuX).toInt()
override fun setSplitTaskSwipeRect(
dp: DeviceProfile,
@@ -187,7 +187,7 @@ class SeascapePagedViewHandler : LandscapePagedViewHandler() {
}
override fun getDistanceToBottomOfRect(dp: DeviceProfile, rect: Rect): Int =
dp.widthPx - rect.right
dp.deviceProperties.widthPx - rect.right
override fun getSplitPositionOptions(dp: DeviceProfile): List<SplitPositionOption> =
// Add "right" option which is actually the top
@@ -29,7 +29,7 @@ class RecentsDeviceProfileRepositoryImpl(private val container: RecentsViewConta
override fun getRecentsDeviceProfile() =
with(container.deviceProfile) {
RecentsDeviceProfile(
isLargeScreen = isTablet,
isLargeScreen = deviceProperties.isTablet,
canEnterDesktopMode = DesktopModeStatus.canEnterDesktopMode(container.asContext()),
)
}
@@ -183,7 +183,7 @@ public class AnimatorControllerWithResistance {
params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR);
float prevScaleRate = (fullscreenScale - params.startScale)
/ (params.dp.heightPx - startRect.bottom);
/ (params.dp.getDeviceProperties().getHeightPx() - startRect.bottom);
// This is what the scale would be at the end of the drag if we didn't apply resistance.
float endScale = params.startScale - prevScaleRate * distanceToCover;
// Create an interpolator that resists the scale so the scale doesn't get smaller than
@@ -256,7 +256,7 @@ public class AnimatorControllerWithResistance {
this.scaleProperty = scaleProperty;
this.translationTarget = translationTarget;
this.translationProperty = translationProperty;
if (dp.isTablet) {
if (dp.getDeviceProperties().isTablet()) {
resistanceParams = RecentsResistanceParams.FROM_APP_TABLET;
} else {
resistanceParams = RecentsResistanceParams.FROM_APP;
@@ -163,7 +163,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL
@Override
public void onDeviceProfileChanged(DeviceProfile dp) {
if (mIsTablet != null && dp.isTablet != mIsTablet) {
if (mIsTablet != null && dp.getDeviceProperties().isTablet() != mIsTablet) {
// We should preemptively start the animation only if:
// - We changed to the unfolded screen
// - SystemUI IPC connection is alive, so we won't end up in a situation that we won't
@@ -173,7 +173,7 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL
// if Launcher was not open during unfold, in this case we receive the configuration
// change only after we went back to home screen and we don't want to start the
// animation in this case.
if (dp.isTablet
if (dp.getDeviceProperties().isTablet()
&& SystemUiProxy.INSTANCE.get(mLauncher).isActive()
&& !mExternalTransitionStatusProvider.hasRun()) {
// Preemptively start the unfold animation to make sure that we have drawn
@@ -181,12 +181,12 @@ public class LauncherUnfoldAnimationController implements OnDeviceProfileChangeL
preemptivelyStartAnimationOnNextFrame();
}
if (!dp.isTablet) {
if (!dp.getDeviceProperties().isTablet()) {
mExternalTransitionStatusProvider.onFolded();
}
}
mIsTablet = dp.isTablet;
mIsTablet = dp.getDeviceProperties().isTablet();
}
private class QsbAnimationListener implements TransitionProgressListener {
@@ -82,7 +82,7 @@ public class QuickstepOnboardingPrefs {
public void onStateTransitionComplete(LauncherState finalState) {
HotseatPredictionController client = launcher.getHotseatPredictionController();
if (mFromAllApps && finalState == NORMAL && client.hasPredictions()) {
if (!launcher.getDeviceProfile().isTablet
if (!launcher.getDeviceProfile().getDeviceProperties().isTablet()
&& HOTSEAT_DISCOVERY_TIP_COUNT.increment(launcher)) {
client.showEdu();
stateManager.removeStateListener(this);
@@ -175,7 +175,7 @@ public class RecentsOrientedState implements LauncherPrefChangeListener {
*/
public void setDeviceProfile(DeviceProfile deviceProfile) {
boolean oldMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice();
setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.isTablet);
setFlag(FLAG_MULTIPLE_ORIENTATION_SUPPORTED_BY_DENSITY, !deviceProfile.getDeviceProperties().isTablet());
if (mListenersInitialized) {
boolean newMultipleOrientationsSupported = isMultipleOrientationSupportedByDevice();
// If isMultipleOrientationSupportedByDevice is changed, init or destroy listeners
@@ -346,7 +346,7 @@ public class RectFSpringAnim extends ReleaseCheck {
// Increase the stiffness for devices where we want the window size to transform
// quicker.
boolean shouldUseHigherStiffness = profile != null
&& (profile.isLandscape || profile.isTablet);
&& (profile.getDeviceProperties().isLandscape() || profile.getDeviceProperties().isTablet());
float stiffness = shouldUseHigherStiffness
? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness)
: rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness);
@@ -549,7 +549,7 @@ public class RectFSpringAnim extends ReleaseCheck {
// Increase the stiffness for devices where we want the window size to transform
// quicker.
boolean shouldUseHigherStiffness = deviceProfile != null
&& (deviceProfile.isLandscape || deviceProfile.isTablet);
&& (deviceProfile.getDeviceProperties().isLandscape() || deviceProfile.getDeviceProperties().isTablet());
rectStiffness = shouldUseHigherStiffness
? rp.getFloat(R.dimen.swipe_up_rect_scale_higher_stiffness)
: rp.getFloat(R.dimen.swipe_up_rect_scale_stiffness);
@@ -562,11 +562,11 @@ public class RectFSpringAnim extends ReleaseCheck {
? TRACKING_BOTTOM
: TRACKING_TOP;
} else {
int heightPx = deviceProfile.heightPx;
int heightPx = deviceProfile.getDeviceProperties().getHeightPx();
Rect padding = deviceProfile.workspacePadding;
final float topThreshold = heightPx / 3f;
final float bottomThreshold = deviceProfile.heightPx - padding.bottom;
final float bottomThreshold = deviceProfile.getDeviceProperties().getHeightPx() - padding.bottom;
if (targetRect.bottom > bottomThreshold) {
if (enableScalingRevealHomeAnimation()) {
@@ -328,14 +328,16 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
// Make the scrim fullscreen
val lp = scrim.layoutParams as InsettableFrameLayout.LayoutParams
lp.topMargin = 0
lp.height = dp.heightPx
lp.width = dp.widthPx
lp.height = dp.deviceProperties.heightPx
lp.width = dp.deviceProperties.widthPx
scrim.alpha = 0f
scrim.setBackgroundColor(
container.asContext().resources.getColor(R.color.taskbar_background_dark)
)
val timings = AnimUtils.getDeviceSplitToConfirmTimings(dp.isTablet) as SplitToConfirmTimings
val timings =
AnimUtils.getDeviceSplitToConfirmTimings(dp.deviceProperties.isTablet)
as SplitToConfirmTimings
pendingAnimation.setViewAlpha(
scrim,
1f,
@@ -428,7 +430,10 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
safeRemoveViewFromDragLayer(container, splitSelectStateController.splitInstructionsView)
val splitInstructionsView = SplitInstructionsView.getSplitInstructionsView(container)
splitSelectStateController.splitInstructionsView = splitInstructionsView
val timings = AnimUtils.getDeviceOverviewToSplitTimings(container.deviceProfile.isTablet)
val timings =
AnimUtils.getDeviceOverviewToSplitTimings(
container.deviceProfile.deviceProperties.isTablet
)
val anim = PendingAnimation(100 /*duration */)
splitInstructionsView.alpha = 0f
anim.setViewAlpha(
@@ -471,7 +476,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
) {
val stagedTaskView = view as FloatingTaskView
val isTablet: Boolean = container.deviceProfile.isTablet
val isTablet: Boolean = container.deviceProfile.deviceProperties.isTablet
val duration =
if (isTablet) SplitAnimationTimings.TABLET_CONFIRM_DURATION
else SplitAnimationTimings.PHONE_CONFIRM_DURATION
@@ -891,7 +896,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
rootCandidate: Change,
): ValueAnimator {
val progressUpdater = ValueAnimator.ofFloat(0f, 1f)
val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.isTablet)
val timings = AnimUtils.getDeviceAppPairLaunchTimings(dp.deviceProperties.isTablet)
progressUpdater.setDuration(timings.getDuration().toLong())
progressUpdater.interpolator = Interpolators.LINEAR
@@ -915,7 +920,8 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
var mDx =
FloatProp(
floatingView.startingPosition.left,
dp.widthPx / 2f - floatingView.startingPosition.width() / 2f,
dp.deviceProperties.widthPx / 2f -
floatingView.startingPosition.width() / 2f,
Interpolators.clampToProgress(
timings.getStagedRectXInterpolator(),
timings.stagedRectSlideStartOffset,
@@ -925,7 +931,8 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
var mDy =
FloatProp(
floatingView.startingPosition.top,
dp.heightPx / 2f - floatingView.startingPosition.height() / 2f,
dp.deviceProperties.heightPx / 2f -
floatingView.startingPosition.height() / 2f,
Interpolators.clampToProgress(
Interpolators.EMPHASIZED,
timings.stagedRectSlideStartOffset,
@@ -935,7 +942,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
var mScaleX =
FloatProp(
1f /* start */,
dp.widthPx / floatingView.startingPosition.width(),
dp.deviceProperties.widthPx / floatingView.startingPosition.width(),
Interpolators.clampToProgress(
Interpolators.EMPHASIZED,
timings.stagedRectSlideStartOffset,
@@ -945,7 +952,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC
var mScaleY =
FloatProp(
1f /* start */,
dp.heightPx / floatingView.startingPosition.height(),
dp.deviceProperties.heightPx / floatingView.startingPosition.height(),
Interpolators.clampToProgress(
Interpolators.EMPHASIZED,
timings.stagedRectSlideStartOffset,
@@ -157,7 +157,7 @@ public class SplitToWorkspaceController {
private void startWorkspaceAnimation(@NonNull View view, @Nullable Bitmap bitmap,
@Nullable Drawable icon) {
DeviceProfile dp = mLauncher.getDeviceProfile();
boolean isTablet = dp.isTablet;
boolean isTablet = dp.getDeviceProperties().isTablet();
SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet);
PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration());
@@ -152,7 +152,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
mLayoutValid = false;
mOrientationState.setDeviceProfile(dp);
if (enableGridOnlyOverview()) {
mIsGridTask = dp.isTablet && !mIsDesktopTask;
mIsGridTask = dp.getDeviceProperties().isTablet() && !mIsDesktopTask;
}
calculateTaskSize();
}
@@ -325,7 +325,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
public void addAppToCarouselAnim(PendingAnimation pa, Interpolator interpolator,
boolean isHandlingAtomicEvent) {
pa.addFloat(fullScreenProgress, AnimatedFloat.VALUE, 1, 0, interpolator);
if (enableGridOnlyOverview() && mDp.isTablet && !isHandlingAtomicEvent) {
if (enableGridOnlyOverview() && mDp.getDeviceProperties().isTablet() && !isHandlingAtomicEvent) {
mIsAnimatingToCarousel = true;
carouselScale.value = mCarouselTaskSize.width() / (float) mFullTaskSize.width();
}
@@ -357,7 +357,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
public RectF getCurrentRect() {
RectF result = getCurrentCropRect();
mMatrixTmp.set(mMatrix);
preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.widthPx, mDp.heightPx,
preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(),
mMatrixTmp);
mMatrixTmp.mapRect(result);
return result;
@@ -411,11 +411,11 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
* window coordinate space.
*/
public void applyWindowToHomeRotation(Matrix matrix) {
matrix.postTranslate(mDp.windowX, mDp.windowY);
matrix.postTranslate(mDp.getDeviceProperties().getWindowX(), mDp.getDeviceProperties().getWindowY());
postDisplayRotation(deltaRotation(
mOrientationState.getRecentsActivityRotation(),
mOrientationState.getDisplayRotation()),
mDp.widthPx, mDp.heightPx, matrix);
mDp.getDeviceProperties().getWidthPx(), mDp.getDeviceProperties().getHeightPx(), matrix);
}
/**
@@ -450,7 +450,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
boolean isRtlEnabled = !mIsRecentsRtl;
mPositionHelper.updateThumbnailMatrix(
mThumbnailPosition, mThumbnailData, mTaskRect.width(), mTaskRect.height(),
mDp.isTablet, mOrientationState.getRecentsActivityRotation(), isRtlEnabled);
mDp.getDeviceProperties().isTablet(), mOrientationState.getRecentsActivityRotation(), isRtlEnabled);
mPositionHelper.getMatrix().invert(mInversePositionMatrix);
if (DEBUG) {
Log.d(TAG, " taskRect: " + mTaskRect);
@@ -56,7 +56,7 @@ class LauncherUnfoldTransitionController(
}
override fun onDeviceProfileChanged(dp: DeviceProfile) {
if (isTablet != null && dp.isTablet != isTablet) {
if (isTablet != null && dp.getDeviceProperties().isTablet != isTablet) {
// We should preemptively start the animation only if:
// - We changed to the unfolded screen
// - SystemUI IPC connection is alive, so we won't end up in a situation that we won't
@@ -66,20 +66,24 @@ class LauncherUnfoldTransitionController(
// if Launcher was not open during unfold, in this case we receive the configuration
// change only after we went back to home screen and we don't want to start the
// animation in this case.
if (dp.isTablet && progressProvider.isActive && !hasUnfoldTransitionStarted) {
if (
dp.getDeviceProperties().isTablet &&
progressProvider.isActive &&
!hasUnfoldTransitionStarted
) {
// Preemptively start the unfold animation to make sure that we have drawn
// the first frame of the animation before the screen gets unblocked
onTransitionStarted()
Trace.beginAsyncSection("$TAG#startedPreemptively", 0)
timeoutAlarm.setAlarm(PREEMPTIVE_UNFOLD_TIMEOUT_MS)
}
if (!dp.isTablet) {
if (!dp.getDeviceProperties().isTablet) {
// Reset unfold transition status when folded
hasUnfoldTransitionStarted = false
}
}
isTablet = dp.isTablet
isTablet = dp.getDeviceProperties().isTablet
}
override fun onTransitionStarted() {
@@ -267,8 +267,8 @@ public class AllAppsEduView extends AbstractFloatingView {
DeviceProfile grid = launcher.getDeviceProfile();
DragLayer.LayoutParams lp = new DragLayer.LayoutParams(mWidthPx, mMaxHeightPx);
lp.ignoreInsets = true;
lp.leftMargin = (grid.widthPx - mWidthPx) / 2;
lp.topMargin = grid.heightPx - grid.hotseatBarSizePx - mMaxHeightPx;
lp.leftMargin = (grid.getDeviceProperties().getWidthPx() - mWidthPx) / 2;
lp.topMargin = grid.getDeviceProperties().getHeightPx() - grid.hotseatBarSizePx - mMaxHeightPx;
setLayoutParams(lp);
}
@@ -178,7 +178,7 @@ constructor(
val splitBounds = splitBounds
return when {
splitBounds == null ||
!recentsViewContainer.deviceProfile.isTablet ||
!recentsViewContainer.deviceProfile.deviceProperties.isTablet ||
taskView.isLargeTile -> SplitBannerConfig.SPLIT_BANNER_FULLSCREEN
// For portrait grid only height of task changes, not width. So we keep the text the
// same
@@ -37,12 +37,12 @@ import com.android.systemui.shared.system.QuickStepContract
* increase in size during the animation.
*/
open class FloatingAppPairBackground(
context: Context,
// the view that we will draw this background on
protected val floatingView: FloatingAppPairView,
private val appIcon1: Drawable,
private val appIcon2: Drawable?,
dividerPos: Int
context: Context,
// the view that we will draw this background on
protected val floatingView: FloatingAppPairView,
private val appIcon1: Drawable,
private val appIcon2: Drawable?,
dividerPos: Int,
) : Drawable() {
companion object {
// Design specs -- app icons start small and expand during the animation
@@ -79,41 +79,44 @@ open class FloatingAppPairBackground(
backgroundPaint.color = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0)
ta.recycle()
// Set up timings and interpolators
val timings = AnimUtils.getDeviceAppPairLaunchTimings(container.deviceProfile.isTablet)
val timings =
AnimUtils.getDeviceAppPairLaunchTimings(
container.deviceProfile.deviceProperties.isTablet
)
expandXInterpolator =
Interpolators.clampToProgress(
timings.getStagedRectScaleXInterpolator(),
timings.stagedRectSlideStartOffset,
timings.stagedRectSlideEndOffset
timings.stagedRectSlideEndOffset,
)
expandYInterpolator =
Interpolators.clampToProgress(
timings.getStagedRectScaleYInterpolator(),
timings.stagedRectSlideStartOffset,
timings.stagedRectSlideEndOffset
timings.stagedRectSlideEndOffset,
)
cellSplitInterpolator =
Interpolators.clampToProgress(
timings.cellSplitInterpolator,
timings.cellSplitStartOffset,
timings.cellSplitEndOffset
timings.cellSplitEndOffset,
)
iconFadeInterpolator =
Interpolators.clampToProgress(
timings.iconFadeInterpolator,
timings.iconFadeStartOffset,
timings.iconFadeEndOffset
timings.iconFadeEndOffset,
)
// Find device-specific measurements
val resources = context.resources
deviceCornerRadius = QuickStepContract.getWindowCornerRadius(context)
deviceHalfDividerSize =
resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f
resources.getDimensionPixelSize(R.dimen.multi_window_task_divider_size) / 2f
val dividerCenterPos = dividerPos + deviceHalfDividerSize
desiredSplitRatio =
if (dp.isLeftRightSplit) dividerCenterPos / dp.widthPx
else dividerCenterPos / dp.heightPx
if (dp.isLeftRightSplit) dividerCenterPos / dp.deviceProperties.widthPx
else dividerCenterPos / dp.deviceProperties.heightPx
dividerPaint.color = resources.getColor(R.color.taskbar_background_dark, null /*theme*/)
}
@@ -157,8 +160,13 @@ open class FloatingAppPairBackground(
// The right half of the background image
val rightSide = RectF(dividerCenterPos + changingDividerSize, 0f, width, height)
// Middle part is for divider background
val middleRect = RectF(leftSide.right - deviceHalfDividerSize, 0f,
rightSide.left + deviceHalfDividerSize, height)
val middleRect =
RectF(
leftSide.right - deviceHalfDividerSize,
0f,
rightSide.left + deviceHalfDividerSize,
height,
)
// Draw background
canvas.drawRect(middleRect, dividerPaint)
@@ -174,7 +182,7 @@ open class FloatingAppPairBackground(
changingInnerRadiusY,
cornerRadiusX,
cornerRadiusY,
)
),
)
drawCustomRoundedRect(
canvas,
@@ -188,7 +196,7 @@ open class FloatingAppPairBackground(
cornerRadiusY,
changingInnerRadiusX,
changingInnerRadiusY,
)
),
)
// Calculate changing measurements for icons.
@@ -259,8 +267,13 @@ open class FloatingAppPairBackground(
// The bottom half of the background image
val bottomSide = RectF(0f, dividerCenterPos + changingDividerSize, width, height)
// Middle part is for divider background
val middleRect = RectF(0f, topSide.bottom - deviceHalfDividerSize,
width, bottomSide.top + deviceHalfDividerSize)
val middleRect =
RectF(
0f,
topSide.bottom - deviceHalfDividerSize,
width,
bottomSide.top + deviceHalfDividerSize,
)
// Draw background
canvas.drawRect(middleRect, dividerPaint)
@@ -275,8 +288,8 @@ open class FloatingAppPairBackground(
changingInnerRadiusX,
changingInnerRadiusY,
changingInnerRadiusX,
changingInnerRadiusY
)
changingInnerRadiusY,
),
)
drawCustomRoundedRect(
canvas,
@@ -289,8 +302,8 @@ open class FloatingAppPairBackground(
cornerRadiusX,
cornerRadiusY,
cornerRadiusX,
cornerRadiusY
)
cornerRadiusY,
),
)
// Calculate changing measurements for icons.
@@ -239,7 +239,7 @@ public class FloatingTaskView extends FrameLayout {
// Position the floating view exactly on top of the original
lp.topMargin = Math.round(pos.top);
if (mIsRtl) {
lp.setMarginStart(mContainer.getDeviceProfile().widthPx - Math.round(pos.right));
lp.setMarginStart(mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() - Math.round(pos.right));
} else {
lp.setMarginStart(Math.round(pos.left));
}
@@ -256,7 +256,7 @@ public class FloatingTaskView extends FrameLayout {
*/
public void addStagingAnimation(PendingAnimation animation, RectF startingBounds,
Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) {
boolean isTablet = mContainer.getDeviceProfile().isTablet;
boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet();
boolean splittingFromOverview = fadeWithThumbnail;
SplitAnimationTimings timings;
@@ -280,7 +280,7 @@ public class FloatingTaskView extends FrameLayout {
public void addConfirmAnimation(PendingAnimation animation, RectF startingBounds,
Rect endBounds, boolean fadeWithThumbnail, boolean isStagedTask) {
SplitAnimationTimings timings =
AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().isTablet);
AnimUtils.getDeviceSplitToConfirmTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet());
addAnimation(animation, startingBounds, endBounds, fadeWithThumbnail, isStagedTask,
timings);
@@ -273,7 +273,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
private void updateForIsTablet() {
assert mDp != null;
// Update flags to see if split button should be hidden.
updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.isTablet);
updateSplitButtonHiddenFlags(FLAG_SMALL_SCREEN_HIDE_SPLIT, !mDp.getDeviceProperties().isTablet());
updateActionButtonsVisibility();
}
@@ -282,7 +282,7 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
return;
}
boolean showSingleTaskActions = !mIsGroupedTask;
boolean showGroupActions = mIsGroupedTask && mDp.isTablet && mCanSaveAppPair;
boolean showGroupActions = mIsGroupedTask && mDp.getDeviceProperties().isTablet() && mCanSaveAppPair;
Log.d(TAG, "updateActionButtonsVisibility() called: showSingleTaskActions = ["
+ showSingleTaskActions + "], showGroupActions = [" + showGroupActions + "]");
getActionsAlphas().get(INDEX_GROUPED_ALPHA).setValue(showSingleTaskActions ? 1 : 0);
@@ -384,12 +384,12 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
return 0;
}
if (mDp.isTablet && enableGridOnlyOverview()) {
if (mDp.getDeviceProperties().isTablet() && enableGridOnlyOverview()) {
return mDp.stashedTaskbarHeight;
}
// Align to bottom of task Rect.
return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx
return mDp.getDeviceProperties().getHeightPx() - mTaskSize.bottom - mDp.overviewActionsTopMarginPx
- mDp.overviewActionsHeight;
}
@@ -1076,7 +1076,11 @@ constructor(
dispatchScrollChanged()
updateActionsViewFocusedScroll()
if (
isClearAllHidden && !(mContainer as ActivityContext).getDeviceProfile().isTablet
isClearAllHidden &&
!(mContainer as ActivityContext)
.getDeviceProfile()
.deviceProperties
.isTablet
) {
actionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false)
}
@@ -1477,9 +1477,9 @@ public abstract class RecentsView<
for (int i = apps.length - 1; i >= 0; --i) {
RemoteAnimationTarget app = apps[i];
float dx = mContainer.getDeviceProfile().widthPx * (1 - percent) / 2
float dx = mContainer.getDeviceProfile().getDeviceProperties().getWidthPx() * (1 - percent) / 2
+ app.screenSpaceBounds.left * percent;
float dy = mContainer.getDeviceProfile().heightPx * (1 - percent) / 2
float dy = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() * (1 - percent) / 2
+ app.screenSpaceBounds.top * percent;
matrix.setScale(percent, percent);
matrix.postTranslate(dx, dy);
@@ -1716,7 +1716,7 @@ public abstract class RecentsView<
@Override
protected void onPageBeginTransition() {
super.onPageBeginTransition();
if (!mContainer.getDeviceProfile().isTablet) {
if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, true);
}
if (mOverviewStateEnabled) { // only when in overview
@@ -1728,7 +1728,7 @@ public abstract class RecentsView<
protected void onPageEndTransition() {
super.onPageEndTransition();
ActiveGestureProtoLogProxy.logOnPageEndTransition(getNextPage());
if (!mContainer.getDeviceProfile().isTablet) {
if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false);
}
if (getNextPage() > 0) {
@@ -1740,12 +1740,12 @@ public abstract class RecentsView<
@Override
protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
DeviceProfile deviceProfile = mContainer.getDeviceProfile();
if (!deviceProfile.isTablet) {
if (!deviceProfile.getDeviceProperties().isTablet()) {
return super.isSignificantMove(absoluteDelta, pageOrientedSize);
}
return absoluteDelta
> deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
> deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
}
@Override
@@ -2302,7 +2302,7 @@ public abstract class RecentsView<
setOverviewGridEnabled(
getStateManager().getState().displayOverviewTasksAsGrid(dp));
if (enableGridOnlyOverview()) {
mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.isTablet);
mActionsView.updateHiddenFlags(HIDDEN_ACTIONS_IN_MENU, dp.getDeviceProperties().isTablet());
}
setPageSpacing(dp.overviewPageSpacing);
@@ -2380,8 +2380,8 @@ public abstract class RecentsView<
mTaskHeight = mLastComputedTaskSize.height();
setPadding(mLastComputedTaskSize.left - mInsets.left,
mLastComputedTaskSize.top - dp.overviewTaskThumbnailTopMarginPx - mInsets.top,
dp.widthPx - mInsets.right - mLastComputedTaskSize.right,
dp.heightPx - mInsets.bottom - mLastComputedTaskSize.bottom);
dp.getDeviceProperties().getWidthPx() - mInsets.right - mLastComputedTaskSize.right,
dp.getDeviceProperties().getHeightPx() - mInsets.bottom - mLastComputedTaskSize.bottom);
mContainerInterface.calculateGridSize(dp, mContainer, mLastComputedGridSize);
mContainerInterface.calculateGridTaskSize(mContainer, dp, mLastComputedGridTaskSize,
@@ -2463,7 +2463,7 @@ public abstract class RecentsView<
*/
private float getTaskAlignmentTranslationY() {
DeviceProfile deviceProfile = mContainer.getDeviceProfile();
if (deviceProfile.isTablet) {
if (deviceProfile.getDeviceProperties().isTablet()) {
return deviceProfile.overviewRowSpacing;
}
return deviceProfile.overviewTaskThumbnailTopMarginPx / 2.0f;
@@ -2564,7 +2564,7 @@ public abstract class RecentsView<
@Override
protected int getDestinationPage(int scaledScroll) {
if (!mContainer.getDeviceProfile().isTablet) {
if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) {
return super.getDestinationPage(scaledScroll);
}
if (!isPageScrollsInitialized()) {
@@ -3493,7 +3493,7 @@ public abstract class RecentsView<
int minimumDistance =
(mIsRtl
? mLastComputedTaskSize.left
: deviceProfile.widthPx - mLastComputedTaskSize.right)
: deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right)
- deviceProfile.overviewGridSideMargin - mPageSpacing
+ (mTaskWidth - snappedTaskView.getLayoutParams().width)
- mClearAllShortTotalWidthTranslation;
@@ -3650,7 +3650,7 @@ public abstract class RecentsView<
mSplitPlaceholderInset, mContainer.getDeviceProfile(),
mSplitSelectStateController.getActiveSplitStagePosition(), mTempRect);
SplitAnimationTimings timings =
AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet);
AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet());
RectF startingTaskRect = new RectF();
safeRemoveDragLayerView(mSplitSelectStateController.getFirstFloatingTaskView());
@@ -3882,7 +3882,7 @@ public abstract class RecentsView<
}
SplitAnimationTimings splitTimings =
AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().isTablet);
AnimUtils.getDeviceOverviewToSplitTimings(mContainer.getDeviceProfile().getDeviceProperties().isTablet());
int distanceFromDismissedTask = 1;
int slidingTranslation = 0;
@@ -4247,7 +4247,7 @@ public abstract class RecentsView<
// Update various scroll-dependent UI.
dispatchScrollChanged();
updateActionsViewFocusedScroll();
if (!mContainer.getDeviceProfile().isTablet) {
if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING,
false);
}
@@ -5137,7 +5137,7 @@ public abstract class RecentsView<
if (isTopShift) {
distanceToOffscreen = -taskPosition.bottom;
} else if (isBottomShift) {
distanceToOffscreen = mContainer.getDeviceProfile().heightPx - taskPosition.top;
distanceToOffscreen = mContainer.getDeviceProfile().getDeviceProperties().getHeightPx() - taskPosition.top;
}
return distanceToOffscreen * offsetProgress;
}
@@ -5238,7 +5238,7 @@ public abstract class RecentsView<
public void handleDesktopTaskInSplitSelectState(PendingAnimation builder,
Interpolator deskTopFadeInterPolator) {
SplitAnimationTimings timings = AnimUtils.getDeviceOverviewToSplitTimings(
mContainer.getDeviceProfile().isTablet);
mContainer.getDeviceProfile().getDeviceProperties().isTablet());
if (enableLargeDesktopWindowingTile()) {
getTaskViews().forEachWithIndexInParent((index, taskView) -> {
if (taskView instanceof DesktopTaskView) {
@@ -5350,7 +5350,7 @@ public abstract class RecentsView<
builder.addOnFrameListener((animator) -> {
SplitAnimationTimings splitTimings =
AnimUtils.getDeviceOverviewToSplitTimings(
mContainer.getDeviceProfile().isTablet);
mContainer.getDeviceProfile().getDeviceProperties().isTablet());
if (animator.getAnimatedFraction() > splitTimings.getGridSlideStartOffset()
&& !hasRunDismiss.get()) {
mDismissUtils.createTaskDismissSpringAnimation(
@@ -5416,7 +5416,7 @@ public abstract class RecentsView<
Rect firstTaskStartingBounds = new Rect();
Rect firstTaskEndingBounds = mTempRect;
boolean isTablet = mContainer.getDeviceProfile().isTablet;
boolean isTablet = mContainer.getDeviceProfile().getDeviceProperties().isTablet();
SplitAnimationTimings timings = AnimUtils.getDeviceSplitToConfirmTimings(isTablet);
PendingAnimation pendingAnimation = new PendingAnimation(timings.getDuration());
@@ -5496,7 +5496,7 @@ public abstract class RecentsView<
if (mSplitHiddenTaskViewIndex == -1) {
return;
}
if (!mContainer.getDeviceProfile().isTablet) {
if (!mContainer.getDeviceProfile().getDeviceProperties().isTablet()) {
int pageToSnapTo = mCurrentPage;
if (mSplitHiddenTaskViewIndex <= pageToSnapTo) {
pageToSnapTo += 1;
@@ -5546,11 +5546,11 @@ public abstract class RecentsView<
int direction = orientationHandler.getSplitTranslationDirectionFactor(
splitPosition, deviceProfile);
if (deviceProfile.isTablet && deviceProfile.isLeftRightSplit) {
if (deviceProfile.getDeviceProperties().isTablet() && deviceProfile.isLeftRightSplit) {
// Only shift TaskViews if there is not enough space on the side of
// mLastComputedTaskSize to minimize motion.
int sideSpace = mIsRtl
? deviceProfile.widthPx - mLastComputedTaskSize.right
? deviceProfile.getDeviceProperties().getWidthPx() - mLastComputedTaskSize.right
: mLastComputedTaskSize.left;
int extraSpace = splitPlaceholderSize + mPageSpacing - sideSpace;
if (extraSpace <= 0f) {
@@ -213,7 +213,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi
if (desktopTaskView != null) return recentsView.indexOfChild(desktopTaskView)
}
val firstTaskViewIndex = recentsView.indexOfChild(getFirstTaskView())
return if (getDeviceProfile().isTablet) {
return if (getDeviceProfile().deviceProperties.isTablet) {
var index = firstTaskViewIndex
if (enableLargeDesktopWindowingTile() && runningTaskView !is DesktopTaskView) {
// For fullsreen tasks, skip over Desktop tasks in its section
@@ -402,7 +402,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi
outTopRowRect: Rect,
outBottomRowRect: Rect,
) {
if (!getDeviceProfile().isTablet) {
if (!getDeviceProfile().deviceProperties.isTablet) {
getRowRect(getFirstTaskView(), getLastTaskView(), outTaskViewRowRect)
return
}
@@ -468,7 +468,7 @@ class RecentsViewUtils(private val recentsView: RecentsView<*, *>) : DesktopVisi
}
fun updateCentralTask() {
val isTablet: Boolean = getDeviceProfile().isTablet
val isTablet: Boolean = getDeviceProfile().deviceProperties.isTablet
val actionsViewCanRelateToTaskView = !(isTablet && enableGridOnlyOverview())
val focusedTaskView = recentsView.focusedTaskView
val currentPageTaskView = recentsView.currentPageTaskView
@@ -75,7 +75,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) :
// Spaced claimed below Overview (taskbar and insets)
private val taskbarTop by lazy {
recentsViewContainer.deviceProfile.heightPx -
recentsViewContainer.deviceProfile.deviceProperties.heightPx -
recentsViewContainer.deviceProfile.overviewActionsClaimedSpaceBelow
}
private val minMenuTop by lazy { taskContainer.iconView.asView().height.toFloat() }
@@ -478,7 +478,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) :
additionalTranslationX =
max(
(translationX + width -
(recentsViewContainer.deviceProfile.widthPx -
(recentsViewContainer.deviceProfile.deviceProperties.widthPx -
resources.getDimensionPixelSize(
R.dimen.task_menu_edge_padding
) * 2))
@@ -469,7 +469,7 @@ public class TaskThumbnailViewDeprecated extends View implements ViewPool.Reusab
int currentRotation = mTaskView.getOrientedState().getRecentsActivityRotation();
boolean isRtl = getLayoutDirection() == LAYOUT_DIRECTION_RTL;
mPreviewPositionHelper.updateThumbnailMatrix(mPreviewRect, mThumbnailData,
getMeasuredWidth(), getMeasuredHeight(), dp.isTablet, currentRotation, isRtl);
getMeasuredWidth(), getMeasuredHeight(), dp.getDeviceProperties().isTablet(), currentRotation, isRtl);
mBitmapShader.setLocalMatrix(mPreviewPositionHelper.getMatrix());
mPaint.setShader(mBitmapShader);
@@ -155,7 +155,7 @@ constructor(
val isGridTask: Boolean
/** Returns whether the task is part of overview grid and not being focused. */
get() = container.deviceProfile.isTablet && !isLargeTile
get() = container.deviceProfile.getDeviceProperties().isTablet && !isLargeTile
val isRunningTask: Boolean
get() = this === recentsView?.runningTaskView
@@ -678,7 +678,7 @@ constructor(
pivotY = modalPivot.y
} else {
val thumbnailTopMargin = container.deviceProfile.overviewTaskThumbnailTopMarginPx
if (container.deviceProfile.isTablet) {
if (container.deviceProfile.getDeviceProperties().isTablet) {
pivotX =
(if (layoutDirection == LAYOUT_DIRECTION_RTL) 0 else right - left).toFloat()
pivotY = thumbnailTopMargin.toFloat()
@@ -1128,7 +1128,7 @@ constructor(
val boxTranslationY: Float
val expectedWidth: Int
val expectedHeight: Int
if (container.deviceProfile.isTablet) {
if (container.deviceProfile.getDeviceProperties().isTablet) {
val boxWidth: Int
val boxHeight: Int
@@ -1622,7 +1622,9 @@ constructor(
// Don't show menu when selecting second split screen app
return true
}
if (!container.deviceProfile.isTablet && !recentsView.isClearAllHidden) {
if (
!container.deviceProfile.getDeviceProperties().isTablet && !recentsView.isClearAllHidden
) {
recentsView.snapToPage(recentsView.indexOfChild(this))
return false
}
@@ -1658,11 +1660,11 @@ constructor(
} else {
TaskMenuView.showForTask(menuContainer) { recentsView.setTaskBorderEnabled(true) }
}
} else if (container.deviceProfile.isTablet) {
} else if (container.deviceProfile.getDeviceProperties().isTablet) {
val alignedOptionIndex =
if (
recentsView.isOnGridBottomRow(menuContainer.taskView) &&
container.deviceProfile.isLandscape
container.deviceProfile.deviceProperties.isLandscape
) {
if (enableGridOnlyOverview()) {
// With no focused task, there is less available space below the tasks, so
@@ -625,7 +625,8 @@ class TaskbarOverflowTest {
return getOnUiThread {
val iconLayoutBounds =
taskbarViewController.transientTaskbarIconLayoutBoundsInParent
val availableWidth = taskbarUnitTestRule.activityContext.deviceProfile.widthPx
val availableWidth =
taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx
iconLayoutBounds.left - (availableWidth - iconLayoutBounds.right) < 2
}
}
@@ -633,7 +634,7 @@ class TaskbarOverflowTest {
private val taskbarEndMargin: Int
get() {
return getOnUiThread {
taskbarUnitTestRule.activityContext.deviceProfile.widthPx -
taskbarUnitTestRule.activityContext.deviceProfile.deviceProperties.widthPx -
taskbarViewController.transientTaskbarIconLayoutBoundsInParent.right
}
}
@@ -14,6 +14,7 @@ import androidx.test.runner.AndroidJUnit4
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION
import com.android.launcher3.deviceprofile.DeviceProperties
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_CONTEXTUAL_BUTTONS
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_END_NAV_BUTTONS
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.ID_START_CONTEXTUAL_BUTTONS
@@ -50,6 +51,8 @@ class NavButtonLayoutFactoryTest {
whenever(mockNavLayout.findViewById<View>(R.id.back)).thenReturn(mockBackButton)
whenever(mockNavLayout.findViewById<View>(R.id.home)).thenReturn(mockHomeButton)
whenever(mockNavLayout.findViewById<View>(R.id.recent_apps)).thenReturn(mockRecentsButton)
val devicePropertiesMock: DeviceProperties = mock()
whenever(mockDeviceProfile.deviceProperties).thenReturn(devicePropertiesMock)
// Init top level layout
whenever(mockParentButtonContainer.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS))
@@ -73,7 +76,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = false,
phoneMode = false,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is KidsNavLayoutter)
}
@@ -88,7 +91,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = true,
isThreeButtonNav = false,
phoneMode = false,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is SetupNavLayoutter)
}
@@ -103,7 +106,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = false,
phoneMode = false,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is TaskbarNavLayoutter)
}
@@ -117,7 +120,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = false,
phoneMode = false,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
}
@@ -131,7 +134,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = true,
phoneMode = true,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is PhonePortraitNavLayoutter)
}
@@ -147,7 +150,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = true,
phoneMode = true,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is PhoneLandscapeNavLayoutter)
}
@@ -163,7 +166,7 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = true,
phoneMode = true,
surfaceRotation = ROTATION_270
surfaceRotation = ROTATION_270,
)
assert(layoutter is PhoneSeascapeNavLayoutter)
}
@@ -178,16 +181,13 @@ class NavButtonLayoutFactoryTest {
isInSetup = false,
isThreeButtonNav = false,
phoneMode = true,
surfaceRotation = surfaceRotation
surfaceRotation = surfaceRotation,
)
assert(layoutter is PhoneGestureLayoutter)
}
private fun setDeviceProfileLandscape() {
// Use reflection to modify landscape field
val landscapeField = mockDeviceProfile.javaClass.getDeclaredField("isLandscape")
landscapeField.isAccessible = true
landscapeField.set(mockDeviceProfile, true)
whenever(mockDeviceProfile.deviceProperties.isLandscape).thenReturn(true)
}
private fun getLayoutter(
@@ -195,7 +195,7 @@ class NavButtonLayoutFactoryTest {
isInSetup: Boolean,
isThreeButtonNav: Boolean,
phoneMode: Boolean,
@Rotation surfaceRotation: Int
@Rotation surfaceRotation: Int,
): NavButtonLayoutFactory.NavButtonLayoutter {
return NavButtonLayoutFactory.getUiLayoutter(
deviceProfile = mockDeviceProfile,
@@ -50,7 +50,7 @@ class TaskbarModeRuleTest {
fun testTaskbarMode_transient_overridesDeviceProfile() {
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
assertThat(dp.isTransientTaskbar).isTrue()
assertThat(dp.isGestureMode).isTrue()
assertThat(dp.deviceProperties.isGestureMode).isTrue()
}
@Test
@@ -66,7 +66,7 @@ class TaskbarModeRuleTest {
fun testTaskbarMode_pinned_overridesDeviceProfile() {
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
assertThat(dp.isTransientTaskbar).isFalse()
assertThat(dp.isGestureMode).isTrue()
assertThat(dp.deviceProperties.isGestureMode).isTrue()
}
@Test
@@ -83,6 +83,6 @@ class TaskbarModeRuleTest {
fun testTaskbarMode_threeButtons_overridesDeviceProfile() {
val dp = InvariantDeviceProfile.INSTANCE.get(context).getDeviceProfile(context)
assertThat(dp.isTransientTaskbar).isFalse()
assertThat(dp.isGestureMode).isFalse()
assertThat(dp.deviceProperties.isGestureMode).isFalse()
}
}
+1 -1
View File
@@ -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)
+118 -134
View File
@@ -56,6 +56,7 @@ import androidx.core.content.res.ResourcesCompat;
import com.android.launcher3.CellLayout.ContainerType;
import com.android.launcher3.DevicePaddings.DevicePadding;
import com.android.launcher3.InvariantDeviceProfile.DisplayOptionSpec;
import com.android.launcher3.deviceprofile.DeviceProperties;
import com.android.launcher3.graphics.ThemeManager;
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.model.data.ItemInfo;
@@ -102,31 +103,15 @@ public class DeviceProfile {
private final IconSizeSteps mIconSizeSteps;
// Device properties
public final boolean isTablet;
public final boolean isPhone;
public final boolean transposeLayoutWithOrientation;
public final boolean isMultiDisplay;
public final boolean isTwoPanels;
private final DeviceProperties mDeviceProperties;
public boolean isPredictiveBackSwipe;
public final boolean isQsbInline;
// Device properties in current orientation
public final boolean isLandscape;
public final boolean isMultiWindowMode;
public final boolean isGestureMode;
public final boolean isLeftRightSplit;
public final int windowX;
public final int windowY;
public final int widthPx;
public final int heightPx;
public final int availableWidthPx;
public final int availableHeightPx;
public final int rotationHint;
public final float aspectRatio;
private final boolean mIsScalableGrid;
private final int mTypeIndex;
@@ -327,30 +312,29 @@ public class DeviceProfile {
/** Used only as an alternative to mocking when null values cannot be used. */
@VisibleForTesting
public DeviceProfile() {
mDeviceProperties = new DeviceProperties(
0,0,
0,
0,0,
0,0,
0.0f,
false,
false,
false,
false,
false,
false,
false,
false
);
inv = null;
mDisplayOptionSpec = null;
mInfo = null;
mMetrics = null;
mIconSizeSteps = null;
isTablet = false;
isPhone = false;
transposeLayoutWithOrientation = false;
isMultiDisplay = false;
isTwoPanels = false;
isPredictiveBackSwipe = false;
isQsbInline = false;
isLandscape = false;
isMultiWindowMode = false;
isGestureMode = false;
isLeftRightSplit = false;
windowX = 0;
windowY = 0;
widthPx = 0;
heightPx = 0;
availableWidthPx = 0;
availableHeightPx = 0;
rotationHint = 0;
aspectRatio = 1;
mIsScalableGrid = false;
mTypeIndex = 0;
mIsResponsiveGrid = false;
@@ -402,14 +386,15 @@ public class DeviceProfile {
boolean isTransientTaskbar, DisplayOptionSpec displayOptionSpec) {
this.inv = inv;
this.isLandscape = windowBounds.isLandscape();
this.isMultiWindowMode = isMultiWindowMode;
this.transposeLayoutWithOrientation = transposeLayoutWithOrientation;
this.isMultiDisplay = isMultiDisplay;
this.isGestureMode = isGestureMode;
windowX = windowBounds.bounds.left;
windowY = windowBounds.bounds.top;
this.rotationHint = windowBounds.rotationHint;
mDeviceProperties = DeviceProperties.Factory.createDeviceProperties(
info,
windowBounds,
transposeLayoutWithOrientation,
isMultiDisplay,
isMultiWindowMode,
isGestureMode
);
mInsets.set(windowBounds.insets);
this.mDisplayOptionSpec = displayOptionSpec;
@@ -424,18 +409,15 @@ public class DeviceProfile {
mIsScalableGrid = inv.isScalable && !isVerticalBarLayout() && !isMultiWindowMode;
// Determine device posture.
mInfo = info;
isTablet = info.isTablet(windowBounds);
isPhone = !isTablet;
isTwoPanels = isTablet && isMultiDisplay;
boolean taskbarOrBubbleBarOnPhones = enableTinyTaskbar()
|| (enableBubbleBar() && enableBubbleBarOnPhones());
isTaskbarPresent = (isTablet || (taskbarOrBubbleBarOnPhones && isGestureMode))
isTaskbarPresent = (mDeviceProperties.isTablet() || (taskbarOrBubbleBarOnPhones && isGestureMode))
&& wmProxy.isTaskbarDrawnInProcess();
// Some more constants.
context = getContext(context, info, inv.isFixedLandscape
|| isVerticalBarLayout()
|| (isTablet && isLandscape)
|| (mDeviceProperties.isTablet() && mDeviceProperties.isLandscape())
? Configuration.ORIENTATION_LANDSCAPE
: Configuration.ORIENTATION_PORTRAIT,
windowBounds);
@@ -444,13 +426,6 @@ public class DeviceProfile {
mIconSizeSteps = new IconSizeSteps(res);
// Determine sizes.
widthPx = windowBounds.bounds.width();
heightPx = windowBounds.bounds.height();
availableWidthPx = windowBounds.availableSize.x;
availableHeightPx = windowBounds.availableSize.y;
aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
mTypeIndex = displayOptionSpec.typeIndex;
this.isTransientTaskbar = isTransientTaskbar;
@@ -492,13 +467,13 @@ public class DeviceProfile {
{
// In large screens, in portrait mode, a bottom sheet can appear too elongated, so, we
// apply additional padding.
final boolean applyExtraTopPadding = isTablet
&& !isLandscape
&& (aspectRatio > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING);
final int derivedTopPadding = heightPx / 6;
final boolean applyExtraTopPadding = mDeviceProperties.isTablet()
&& !mDeviceProperties.isLandscape()
&& (mDeviceProperties.getAspectRatio() > MIN_ASPECT_RATIO_FOR_EXTRA_TOP_PADDING);
final int derivedTopPadding = mDeviceProperties.getHeightPx() / 6;
bottomSheetTopPadding = mInsets.top // statusbar height
+ (applyExtraTopPadding ? derivedTopPadding : 0)
+ (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
+ (mDeviceProperties.isTablet() ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding
}
bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration);
@@ -582,9 +557,9 @@ public class DeviceProfile {
dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
// Some foldable portrait modes are too wide in terms of aspect ratio so we need to tweak
// the dimensions for edit state.
final boolean shouldApplyWidePortraitDimens = isTablet
&& !isLandscape
&& aspectRatio < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE;
final boolean shouldApplyWidePortraitDimens = mDeviceProperties.isTablet()
&& !mDeviceProperties.isLandscape()
&& mDeviceProperties.getAspectRatio() < MAX_ASPECT_RATIO_FOR_ALTERNATE_EDIT_STATE;
dropTargetBarTopMarginPx = shouldApplyWidePortraitDimens
? 0
: res.getDimensionPixelSize(R.dimen.drop_target_top_margin);
@@ -623,15 +598,15 @@ public class DeviceProfile {
int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin);
if (mIsResponsiveGrid) {
float responsiveAspectRatio = (float) widthPx / heightPx;
float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx();
HotseatSpecsProvider hotseatSpecsProvider =
HotseatSpecsProvider.create(new ResourceHelper(context,
displayOptionSpec.hotseatSpecsId));
mResponsiveHotseatSpec =
isVerticalBarLayout() ? hotseatSpecsProvider.getCalculatedSpec(
responsiveAspectRatio, DimensionType.WIDTH, widthPx)
responsiveAspectRatio, DimensionType.WIDTH, mDeviceProperties.getWidthPx())
: hotseatSpecsProvider.getCalculatedSpec(responsiveAspectRatio,
DimensionType.HEIGHT, heightPx);
DimensionType.HEIGHT, mDeviceProperties.getHeightPx());
hotseatQsbSpace = mResponsiveHotseatSpec.getHotseatQsbSpace();
hotseatBarBottomSpace =
isVerticalBarLayout() ? 0 : mResponsiveHotseatSpec.getEdgePadding();
@@ -642,7 +617,7 @@ public class DeviceProfile {
ResponsiveCellSpecsProvider workspaceCellSpecs = ResponsiveCellSpecsProvider.create(
new ResourceHelper(context, displayOptionSpec.workspaceCellSpecsId));
mResponsiveWorkspaceCellSpec = workspaceCellSpecs.getCalculatedSpec(
responsiveAspectRatio, heightPx);
responsiveAspectRatio, mDeviceProperties.getHeightPx());
} else {
hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics);
hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
@@ -684,7 +659,7 @@ public class DeviceProfile {
updateHotseatSizes(pxFromDp(inv.iconSize[mTypeIndex], mMetrics));
}
if (areNavButtonsInline && !isPhone) {
if (areNavButtonsInline && !mDeviceProperties.isPhone()) {
inlineNavButtonsEndSpacingPx =
res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing);
/* 3 nav buttons + Spacing between nav buttons */
@@ -704,12 +679,12 @@ public class DeviceProfile {
// for the available height to be correct
if (mIsResponsiveGrid) {
int availableResponsiveWidth =
availableWidthPx - (isVerticalBarLayout() ? hotseatBarSizePx : 0);
mDeviceProperties.getAvailableWidthPx() - (isVerticalBarLayout() ? hotseatBarSizePx : 0);
int numWorkspaceColumns = getPanelCount() * inv.numColumns;
// don't use availableHeightPx because it subtracts mInsets.bottom
int availableResponsiveHeight = heightPx - mInsets.top
int availableResponsiveHeight = mDeviceProperties.getHeightPx() - mInsets.top
- (isVerticalBarLayout() ? 0 : hotseatBarSizePx);
float responsiveAspectRatio = (float) widthPx / heightPx;
float responsiveAspectRatio = (float) mDeviceProperties.getWidthPx() / mDeviceProperties.getHeightPx();
ResponsiveSpecsProvider workspaceSpecs = ResponsiveSpecsProvider.create(
new ResourceHelper(context, displayOptionSpec.workspaceSpecsId),
@@ -723,7 +698,7 @@ public class DeviceProfile {
new ResourceHelper(context, displayOptionSpec.allAppsSpecsId),
ResponsiveSpecType.AllApps);
mResponsiveAllAppsWidthSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio,
DimensionType.WIDTH, numShownAllAppsColumns, availableWidthPx,
DimensionType.WIDTH, numShownAllAppsColumns, mDeviceProperties.getAvailableWidthPx(),
mResponsiveWorkspaceWidthSpec);
if (inv.appListAlignedWithWorkspaceRow >= 0) {
allAppsTopPadding += mResponsiveWorkspaceHeightSpec.getStartPaddingPx()
@@ -733,7 +708,7 @@ public class DeviceProfile {
}
mResponsiveAllAppsHeightSpec = allAppsSpecs.getCalculatedSpec(responsiveAspectRatio,
DimensionType.HEIGHT, inv.numAllAppsRowsForCellHeightCalculation,
heightPx - allAppsTopPadding, mResponsiveWorkspaceHeightSpec);
mDeviceProperties.getHeightPx() - allAppsTopPadding, mResponsiveWorkspaceHeightSpec);
ResponsiveSpecsProvider folderSpecs = ResponsiveSpecsProvider.create(
new ResourceHelper(context, displayOptionSpec.folderSpecsId),
@@ -785,10 +760,10 @@ public class DeviceProfile {
boolean allowLeftRightSplitInPortrait =
leftRightSplitPortraitResId > 0
&& res.getBoolean(leftRightSplitPortraitResId);
if (allowLeftRightSplitInPortrait && isTablet) {
isLeftRightSplit = !isLandscape;
if (allowLeftRightSplitInPortrait && mDeviceProperties.isTablet()) {
isLeftRightSplit = !mDeviceProperties.isLandscape();
} else {
isLeftRightSplit = isLandscape;
isLeftRightSplit = mDeviceProperties.isLandscape();
}
// Calculate all of the remaining variables.
@@ -797,7 +772,7 @@ public class DeviceProfile {
calculateAndSetWorkspaceVerticalPadding(context, inv, extraSpace);
int cellLayoutPadding =
isTwoPanels ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize(
mDeviceProperties.isTwoPanels() ? cellLayoutBorderSpacePx.x / 2 : res.getDimensionPixelSize(
R.dimen.cell_layout_padding);
cellLayoutPaddingPx = new Rect(cellLayoutPadding, cellLayoutPadding, cellLayoutPadding,
cellLayoutPadding);
@@ -820,7 +795,7 @@ public class DeviceProfile {
if (shouldShowAllAppsOnSheet()) {
allAppsPadding.top = allAppsTopPadding;
allAppsShiftRange = heightPx - allAppsTopPadding + mInsets.top;
allAppsShiftRange = mDeviceProperties.getHeightPx() - allAppsTopPadding + mInsets.top;
} else {
allAppsPadding.top = 0;
allAppsShiftRange =
@@ -841,6 +816,10 @@ public class DeviceProfile {
mDotRendererAllApps = createDotRenderer(themeManager, allAppsIconSizePx, dotRendererCache);
}
public DeviceProperties getDeviceProperties() {
return mDeviceProperties;
}
/**
* Takes care of the logic that determines if we show a the QSB inline or not.
*/
@@ -852,7 +831,7 @@ public class DeviceProfile {
// In tablets we inline in both orientations but only if we have enough space in the QSB
boolean tabletInlineQsb = inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE];
boolean canQsbInline = isTwoPanels ? twoPanelCanInline : tabletInlineQsb;
boolean canQsbInline = mDeviceProperties.isTwoPanels() ? twoPanelCanInline : tabletInlineQsb;
canQsbInline = canQsbInline && hotseatQsbHeight > 0;
return (mIsScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline)
@@ -879,7 +858,7 @@ public class DeviceProfile {
* reasonable over estimation is fine.
*/
public int getMaxAllAppsRowCount() {
return (int) (Math.ceil((availableHeightPx - allAppsPadding.top)
return (int) (Math.ceil((mDeviceProperties.getAvailableHeightPx() - allAppsPadding.top)
/ (float) allAppsCellHeightPx));
}
@@ -969,7 +948,7 @@ public class DeviceProfile {
updateHotseatWidthAndBorderSpace(inv.numColumns);
int numWorkspaceColumns = getPanelCount() * inv.numColumns;
if (isTwoPanels) {
if (mDeviceProperties.isTwoPanels()) {
updateHotseatWidthAndBorderSpace(inv.numDatabaseHotseatIcons);
// If hotseat doesn't fit with current width, increase column span to fit by multiple
// of 2.
@@ -999,7 +978,7 @@ public class DeviceProfile {
// The side space with inline buttons should be what is defined in InvariantDeviceProfile
int sideSpacePx = inlineNavButtonsEndSpacingPx;
int maxHotseatWidthPx = availableWidthPx - sideSpacePx - hotseatBarEndOffset;
int maxHotseatWidthPx = mDeviceProperties.getAvailableWidthPx() - sideSpacePx - hotseatBarEndOffset;
int maxHotseatIconsWidthPx = maxHotseatWidthPx - (isQsbInline ? hotseatQsbWidth : 0);
hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx,
(isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
@@ -1074,8 +1053,13 @@ public class DeviceProfile {
public Builder toBuilder(Context context) {
WindowBounds bounds = new WindowBounds(
widthPx, heightPx, availableWidthPx, availableHeightPx, rotationHint);
bounds.bounds.offsetTo(windowX, windowY);
mDeviceProperties.getWidthPx(),
mDeviceProperties.getHeightPx(),
mDeviceProperties.getAvailableWidthPx(),
mDeviceProperties.getAvailableHeightPx(),
mDeviceProperties.getRotationHint()
);
bounds.bounds.offsetTo(mDeviceProperties.getWindowX(), mDeviceProperties.getWindowY());
bounds.insets.set(mInsets);
SparseArray<DotRenderer> dotRendererCache = new SparseArray<>();
@@ -1084,10 +1068,10 @@ public class DeviceProfile {
return inv.newDPBuilder(context, mInfo)
.setWindowBounds(bounds)
.setIsMultiDisplay(isMultiDisplay)
.setMultiWindowMode(isMultiWindowMode)
.setIsMultiDisplay(mDeviceProperties.isMultiDisplay())
.setMultiWindowMode(mDeviceProperties.isMultiWindowMode())
.setDotRendererCache(dotRendererCache)
.setGestureMode(isGestureMode)
.setGestureMode(mDeviceProperties.isGestureMode())
.setDisplayOptionSpec(mDisplayOptionSpec);
}
@@ -1179,7 +1163,7 @@ public class DeviceProfile {
float usedWidth =
getCellLayoutWidthSpecification() + (desiredWorkspaceHorizontalMarginPx * 2);
// We do not subtract padding here, as we also scale the workspace padding if needed.
scaleX = availableWidthPx / usedWidth;
scaleX = mDeviceProperties.getAvailableWidthPx() / usedWidth;
shouldScale = true;
}
@@ -1344,7 +1328,7 @@ public class DeviceProfile {
maxIconTextLineCount = 1;
int cellPaddingY = (getCellSize().y - cellHeightPx) / 2;
if (iconDrawablePaddingPx > cellPaddingY && !isVerticalLayout
&& !isMultiWindowMode) {
&& !mDeviceProperties.isMultiWindowMode()) {
// Ensures that the label is closer to its corresponding icon. This is not an issue
// with vertical bar layout or multi-window mode since the issue is handled
// separately with their calls to {@link #adjustToHideWorkspaceLabels}.
@@ -1522,11 +1506,11 @@ public class DeviceProfile {
private void updateAllAppsContainerWidth() {
int cellLayoutHorizontalPadding =
(cellLayoutPaddingPx.left + cellLayoutPaddingPx.right) / 2;
if (isTablet) {
if (mDeviceProperties.isTablet()) {
int usedWidth = (allAppsCellWidthPx * numShownAllAppsColumns)
+ (allAppsBorderSpacePx.x * (numShownAllAppsColumns - 1))
+ allAppsPadding.left + allAppsPadding.right;
allAppsLeftRightMargin = Math.max(1, (availableWidthPx - usedWidth) / 2);
allAppsLeftRightMargin = Math.max(1, (mDeviceProperties.getAvailableWidthPx() - usedWidth) / 2);
} else if (!mIsResponsiveGrid) {
allAppsPadding.left = allAppsPadding.right =
Math.max(0, desiredWorkspaceHorizontalMarginPx + cellLayoutHorizontalPadding
@@ -1536,7 +1520,7 @@ public class DeviceProfile {
/** Whether All Apps should be presented on a bottom sheet. */
public boolean shouldShowAllAppsOnSheet() {
return isTablet || Flags.allAppsSheetForHandheld();
return mDeviceProperties.isTablet() || Flags.allAppsSheetForHandheld();
}
private void setupAllAppsStyle(Context context) {
@@ -1563,14 +1547,14 @@ public class DeviceProfile {
+ ((numFolderRows - 1) * folderCellLayoutBorderSpacePx.y)
+ folderFooterHeightPx
+ folderContentPaddingTop;
int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y;
int contentMaxHeight = mDeviceProperties.getAvailableHeightPx() - totalWorkspacePadding.y;
float scaleY = contentMaxHeight / contentUsedHeight;
// Check if the folder fit within the available width.
float contentUsedWidth = folderCellWidthPx * numFolderColumns
+ ((numFolderColumns - 1) * folderCellLayoutBorderSpacePx.x)
+ folderContentPaddingLeftRight * 2;
int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x;
int contentMaxWidth = mDeviceProperties.getAvailableWidthPx() - totalWorkspacePadding.x;
float scaleX = contentMaxWidth / contentUsedWidth;
float scale = Math.min(scaleX, scaleY);
@@ -1722,7 +1706,7 @@ public class DeviceProfile {
* Gets the number of panels within the workspace.
*/
public int getPanelCount() {
return isTwoPanels ? 2 : 1;
return mDeviceProperties.isTwoPanels() ? 2 : 1;
}
/**
@@ -1732,7 +1716,7 @@ public class DeviceProfile {
private int getVerticalHotseatLastItemBottomOffset(Context context) {
Rect hotseatBarPadding = getHotseatLayoutPadding(context);
int cellHeight = calculateCellHeight(
heightPx - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace,
mDeviceProperties.getHeightPx() - hotseatBarPadding.top - hotseatBarPadding.bottom, hotseatBorderSpace,
numShownHotseatIcons);
int extraIconEndSpacing = (cellHeight - iconSizePx) / 2;
return extraIconEndSpacing + hotseatBarPadding.bottom;
@@ -1751,7 +1735,7 @@ public class DeviceProfile {
*/
public float getCellLayoutSpringLoadShrunkBottom(Context context) {
int topOfHotseat = hotseatBarSizePx + springLoadedHotseatBarTopMarginPx;
return heightPx - (isVerticalBarLayout()
return mDeviceProperties.getHeightPx() - (isVerticalBarLayout()
? getVerticalHotseatLastItemBottomOffset(context) : topOfHotseat);
}
@@ -1765,7 +1749,7 @@ public class DeviceProfile {
scale = Math.min(scale, 1f);
// Reduce scale if next pages would not be visible after scaling the workspace.
int workspaceWidth = availableWidthPx;
int workspaceWidth = mDeviceProperties.getAvailableWidthPx();
float scaledWorkspaceWidth = workspaceWidth * scale;
float maxAvailableWidth = workspaceWidth - (2 * workspaceSpringLoadedMinNextPageVisiblePx);
if (scaledWorkspaceWidth > maxAvailableWidth) {
@@ -1781,7 +1765,7 @@ public class DeviceProfile {
* layouts have two Cell Layouts per workspace.
*/
public int getCellLayoutWidth() {
return (availableWidthPx - getTotalWorkspacePadding().x) / getPanelCount();
return (mDeviceProperties.getAvailableWidthPx() - getTotalWorkspacePadding().x) / getPanelCount();
}
/**
@@ -1790,7 +1774,7 @@ public class DeviceProfile {
* <p>This is the height of a Workspace, less its vertical padding.
*/
public int getCellLayoutHeight() {
return availableHeightPx - getTotalWorkspacePadding().y;
return mDeviceProperties.getAvailableHeightPx() - getTotalWorkspacePadding().y;
}
public Point getTotalWorkspacePadding() {
@@ -1955,7 +1939,7 @@ public class DeviceProfile {
int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
int qsbWidth = getAdditionalQsbSpace() + iconExtraSpacePx / 2;
int availableWidthPxForHotseat = availableWidthPx - Math.abs(workspacePadding.width())
int availableWidthPxForHotseat = mDeviceProperties.getAvailableWidthPx() - Math.abs(workspacePadding.width())
- Math.abs(cellLayoutPaddingPx.width());
int remainingSpaceOnSide = (availableWidthPxForHotseat - hotseatPlusQSBWidth) / 2;
@@ -1984,9 +1968,9 @@ public class DeviceProfile {
// Hotseat aligns to the left with nav buttons
if (hotseatBarEndOffset > 0) {
startSpacing = inlineNavButtonsEndSpacingPx;
endSpacing = availableWidthPx - hotseatWidth - startSpacing + hotseatBorderSpace;
endSpacing = mDeviceProperties.getAvailableWidthPx() - hotseatWidth - startSpacing + hotseatBorderSpace;
} else {
startSpacing = (availableWidthPx - hotseatWidth) / 2;
startSpacing = (mDeviceProperties.getAvailableWidthPx() - hotseatWidth) / 2;
endSpacing = startSpacing;
}
startSpacing += getAdditionalQsbSpace();
@@ -2004,7 +1988,7 @@ public class DeviceProfile {
} else if (mIsScalableGrid) {
int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
int sideSpacing = (availableWidthPx - (hotseatQsbWidth + iconExtraSpacePx)) / 2;
int sideSpacing = (mDeviceProperties.getAvailableWidthPx() - (hotseatQsbWidth + iconExtraSpacePx)) / 2;
hotseatBarPadding.set(sideSpacing,
0,
sideSpacing,
@@ -2014,8 +1998,8 @@ public class DeviceProfile {
// icons in the hotseat are a different size, and so don't line up perfectly. To account
// for this, we pad the left and right of the hotseat with half of the difference of a
// workspace cell vs a hotseat cell.
float workspaceCellWidth = (float) widthPx / inv.numColumns;
float hotseatCellWidth = (float) widthPx / numShownHotseatIcons;
float workspaceCellWidth = (float) mDeviceProperties.getWidthPx() / inv.numColumns;
float hotseatCellWidth = (float) mDeviceProperties.getWidthPx() / numShownHotseatIcons;
int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
hotseatBarPadding.set(
hotseatAdjustment + workspacePadding.left + cellLayoutPaddingPx.left
@@ -2040,7 +2024,7 @@ public class DeviceProfile {
}
int cellWidth = DeviceProfile.calculateCellWidth(
availableWidthPx - allAppsSpacing,
mDeviceProperties.getAvailableWidthPx() - allAppsSpacing,
0 /* borderSpace */,
numShownAllAppsColumns);
int iconAlignmentMargin = (cellWidth - getIconVisibleSizePx(allAppsIconSizePx)) / 2;
@@ -2122,7 +2106,7 @@ public class DeviceProfile {
/** Returns whether bubble bar should be aligned with the hotseat. */
public boolean shouldAlignBubbleBarWithHotseat() {
return isQsbInline || isGestureMode;
return isQsbInline || mDeviceProperties.isGestureMode();
}
/**
@@ -2142,7 +2126,7 @@ public class DeviceProfile {
/** Gets the space that the overview actions will take, including bottom margin. */
public int getOverviewActionsClaimedSpace() {
int overviewActionsSpace = isTablet && enableGridOnlyOverview()
int overviewActionsSpace = mDeviceProperties.isTablet() && enableGridOnlyOverview()
? 0
: (overviewActionsTopMarginPx + overviewActionsHeight);
return overviewActionsSpace + getOverviewActionsClaimedSpaceBelow();
@@ -2169,15 +2153,15 @@ public class DeviceProfile {
// Folders should only appear right of the drop target bar and left of the hotseat
return new Rect(mInsets.left + dropTargetBarSizePx + edgeMarginPx,
mInsets.top,
mInsets.left + availableWidthPx - hotseatBarSizePx - edgeMarginPx,
mInsets.top + availableHeightPx);
mInsets.left + mDeviceProperties.getAvailableWidthPx() - hotseatBarSizePx - edgeMarginPx,
mInsets.top + mDeviceProperties.getAvailableHeightPx());
} else {
// Folders should only appear below the drop target bar and above the hotseat
int hotseatTop = isTaskbarPresent ? taskbarHeight : hotseatBarSizePx;
return new Rect(mInsets.left + edgeMarginPx,
mInsets.top + dropTargetBarSizePx + edgeMarginPx,
mInsets.left + availableWidthPx - edgeMarginPx,
mInsets.top + availableHeightPx - hotseatTop
mInsets.left + mDeviceProperties.getAvailableWidthPx() - edgeMarginPx,
mInsets.top + mDeviceProperties.getAvailableHeightPx() - hotseatTop
- workspacePageIndicatorHeight - edgeMarginPx);
}
}
@@ -2196,11 +2180,11 @@ public class DeviceProfile {
* the hotseat is on the bottom row.
*/
public boolean isVerticalBarLayout() {
return isLandscape && transposeLayoutWithOrientation;
return mDeviceProperties.isLandscape() && mDeviceProperties.getTransposeLayoutWithOrientation();
}
public boolean isSeascape() {
return rotationHint == Surface.ROTATION_270
return mDeviceProperties.getRotationHint() == Surface.ROTATION_270
&& (isVerticalBarLayout() || inv.isFixedLandscape);
}
@@ -2237,29 +2221,29 @@ public class DeviceProfile {
writer.println(prefix + "DeviceProfile:");
writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
writer.println(prefix + "\tisTablet:" + isTablet);
writer.println(prefix + "\tisPhone:" + isPhone);
writer.println(prefix + "\tisTablet:" + mDeviceProperties.isTablet());
writer.println(prefix + "\tisPhone:" + mDeviceProperties.isPhone());
writer.println(prefix + "\ttransposeLayoutWithOrientation:"
+ transposeLayoutWithOrientation);
writer.println(prefix + "\tisGestureMode:" + isGestureMode);
+ mDeviceProperties.getTransposeLayoutWithOrientation());
writer.println(prefix + "\tisGestureMode:" + mDeviceProperties.isGestureMode());
writer.println(prefix + "\tisLandscape:" + isLandscape);
writer.println(prefix + "\tisMultiWindowMode:" + isMultiWindowMode);
writer.println(prefix + "\tisTwoPanels:" + isTwoPanels);
writer.println(prefix + "\tisLandscape:" + mDeviceProperties.isLandscape());
writer.println(prefix + "\tisMultiWindowMode:" + mDeviceProperties.isMultiWindowMode());
writer.println(prefix + "\tisTwoPanels:" + mDeviceProperties.isTwoPanels());
writer.println(prefix + "\tisLeftRightSplit:" + isLeftRightSplit);
writer.println(prefix + pxToDpStr("windowX", windowX));
writer.println(prefix + pxToDpStr("windowY", windowY));
writer.println(prefix + pxToDpStr("widthPx", widthPx));
writer.println(prefix + pxToDpStr("heightPx", heightPx));
writer.println(prefix + pxToDpStr("availableWidthPx", availableWidthPx));
writer.println(prefix + pxToDpStr("availableHeightPx", availableHeightPx));
writer.println(prefix + pxToDpStr("windowX", mDeviceProperties.getWindowX()));
writer.println(prefix + pxToDpStr("windowY", mDeviceProperties.getWindowY()));
writer.println(prefix + pxToDpStr("widthPx", mDeviceProperties.getWidthPx()));
writer.println(prefix + pxToDpStr("heightPx", mDeviceProperties.getHeightPx()));
writer.println(prefix + pxToDpStr("availableWidthPx", mDeviceProperties.getAvailableWidthPx()));
writer.println(prefix + pxToDpStr("availableHeightPx", mDeviceProperties.getAvailableHeightPx()));
writer.println(prefix + pxToDpStr("mInsets.left", mInsets.left));
writer.println(prefix + pxToDpStr("mInsets.top", mInsets.top));
writer.println(prefix + pxToDpStr("mInsets.right", mInsets.right));
writer.println(prefix + pxToDpStr("mInsets.bottom", mInsets.bottom));
writer.println(prefix + "\taspectRatio:" + aspectRatio);
writer.println(prefix + "\taspectRatio:" + mDeviceProperties.getAspectRatio());
writer.println(prefix + "\tisResponsiveGrid:" + mIsResponsiveGrid);
writer.println(prefix + "\tisScalableGrid:" + mIsScalableGrid);
@@ -2442,12 +2426,12 @@ public class DeviceProfile {
/** Returns a reduced representation of this DeviceProfile. */
public String toSmallString() {
return "isTablet:" + isTablet + ", "
+ "isMultiDisplay:" + isMultiDisplay + ", "
+ "widthPx:" + widthPx + ", "
+ "heightPx:" + heightPx + ", "
return "isTablet:" + mDeviceProperties.isTablet() + ", "
+ "mDeviceProperties.isMultiDisplay():" + mDeviceProperties.isMultiDisplay() + ", "
+ "widthPx:" + mDeviceProperties.getWidthPx() + ", "
+ "heightPx:" + mDeviceProperties.getHeightPx() + ", "
+ "insets:" + mInsets + ", "
+ "rotationHint:" + rotationHint;
+ "rotationHint:" + mDeviceProperties.getRotationHint();
}
private static Context getContext(Context c, Info info, int orientation, WindowBounds bounds) {
+23 -22
View File
@@ -85,8 +85,9 @@ public class DropTargetBar extends FrameLayout
@Override
public void setInsets(Rect insets) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
DeviceProfile grid = mLauncher.getDeviceProfile();
mIsVertical = grid.isVerticalBarLayout();
DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
mIsVertical = deviceProfile.isVerticalBarLayout();
int widthPx = deviceProfile.getDeviceProperties().getWidthPx();
lp.leftMargin = insets.left;
lp.topMargin = insets.top;
@@ -95,25 +96,25 @@ public class DropTargetBar extends FrameLayout
int tooltipLocation = TOOLTIP_DEFAULT;
int horizontalMargin;
if (grid.isTablet) {
if (deviceProfile.getDeviceProperties().isTablet()) {
// XXX: If the icon size changes across orientations, we will have to take
// that into account here too.
horizontalMargin = ((grid.widthPx - 2 * grid.edgeMarginPx
- (grid.inv.numColumns * grid.cellWidthPx))
/ (2 * (grid.inv.numColumns + 1)))
+ grid.edgeMarginPx;
horizontalMargin = ((widthPx - 2 * deviceProfile.edgeMarginPx
- (deviceProfile.inv.numColumns * deviceProfile.cellWidthPx))
/ (2 * (deviceProfile.inv.numColumns + 1)))
+ deviceProfile.edgeMarginPx;
} else {
horizontalMargin = getContext().getResources()
.getDimensionPixelSize(R.dimen.drop_target_bar_margin_horizontal);
}
lp.topMargin += grid.dropTargetBarTopMarginPx;
lp.bottomMargin += grid.dropTargetBarBottomMarginPx;
lp.width = grid.availableWidthPx - 2 * horizontalMargin;
lp.topMargin += deviceProfile.dropTargetBarTopMarginPx;
lp.bottomMargin += deviceProfile.dropTargetBarBottomMarginPx;
lp.width = deviceProfile.getDeviceProperties().getAvailableWidthPx() - 2 * horizontalMargin;
if (mIsVertical) {
lp.leftMargin = (grid.widthPx - lp.width) / 2;
lp.rightMargin = (grid.widthPx - lp.width) / 2;
lp.leftMargin = (widthPx - lp.width) / 2;
lp.rightMargin = (widthPx - lp.width) / 2;
}
lp.height = grid.dropTargetBarSizePx;
lp.height = deviceProfile.dropTargetBarSizePx;
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
DeviceProfile dp = mLauncher.getDeviceProfile();
@@ -121,7 +122,7 @@ public class DropTargetBar extends FrameLayout
int verticalPadding = dp.dropTargetVerticalPaddingPx;
setLayoutParams(lp);
for (ButtonDropTarget button : mDropTargets) {
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.dropTargetTextSizePx);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, deviceProfile.dropTargetTextSizePx);
button.setToolTipLocation(tooltipLocation);
button.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
verticalPadding);
@@ -175,15 +176,15 @@ public class DropTargetBar extends FrameLayout
// Reset second button padding in case it was previously changed to multi-line text.
secondButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
verticalPadding);
int availableWidth;
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
// Each button for two panel fits to half the width of the screen excluding the
// center gap between the buttons.
availableWidth = (dp.availableWidthPx - dp.dropTargetGapPx) / 2;
availableWidth = (dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx) / 2;
} else {
// Both buttons plus the button gap do not display past the edge of the screen.
availableWidth = dp.availableWidthPx - dp.dropTargetGapPx;
availableWidth = dp.getDeviceProperties().getAvailableWidthPx() - dp.dropTargetGapPx;
}
int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
@@ -199,7 +200,7 @@ public class DropTargetBar extends FrameLayout
}
}
if (!dp.isTwoPanels) {
if (!dp.getDeviceProperties().isTwoPanels()) {
availableWidth -= firstButton.getMeasuredWidth() + dp.dropTargetGapPx;
widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
}
@@ -239,11 +240,11 @@ public class DropTargetBar extends FrameLayout
float scale = dp.getWorkspaceSpringLoadScale(mLauncher);
Workspace<?> ws = mLauncher.getWorkspace();
int barCenter;
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
barCenter = (right - left) / 2;
} else {
int workspaceCenter = (ws.getLeft() + ws.getRight()) / 2;
int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.widthPx
int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.getDeviceProperties().getWidthPx()
- dp.getInsets().right - dp.workspacePadding.right)) / 2;
int cellLayoutCenterOffset = (int) ((cellLayoutCenter - workspaceCenter) * scale);
barCenter = workspaceCenter + cellLayoutCenterOffset - left;
@@ -258,7 +259,7 @@ public class DropTargetBar extends FrameLayout
ButtonDropTarget leftButton = mTempTargets[0];
ButtonDropTarget rightButton = mTempTargets[1];
if (dp.isTwoPanels) {
if (dp.getDeviceProperties().isTwoPanels()) {
leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
rightButton.layout(barCenter + (buttonGap / 2), 0,
@@ -207,7 +207,7 @@ public class InvariantDeviceProfile {
public @StyleRes int allAppsStyle;
/**
* Do not query directly. see {@link DeviceProfile#isScalableGrid}.
* Do not query directly. see {@link deviceprofile#isScalableGrid}.
*/
protected boolean isScalable;
@XmlRes
@@ -488,14 +488,14 @@ public class InvariantDeviceProfile {
int numMinShownHotseatIconsForTablet = supportedProfiles
.stream()
.filter(deviceProfile -> deviceProfile.isTablet)
.filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet())
.mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons)
.min()
.orElse(0);
supportedProfiles
.stream()
.filter(deviceProfile -> deviceProfile.isTablet)
.filter(deviceProfile -> deviceProfile.getDeviceProperties().isTablet())
.forEach(deviceProfile -> {
deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet;
deviceProfile.recalculateHotseatWidthAndBorderSpace();
@@ -924,12 +924,12 @@ public class InvariantDeviceProfile {
float minDiff = Float.MAX_VALUE;
for (DeviceProfile profile : supportedProfiles) {
float diff = Math.abs(profile.widthPx - screenWidth)
+ Math.abs(profile.heightPx - screenHeight);
float diff = Math.abs(profile.getDeviceProperties().getWidthPx() - screenWidth)
+ Math.abs(profile.getDeviceProperties().getHeightPx() - screenHeight);
if (diff < minDiff) {
minDiff = diff;
bestMatch = profile;
} else if (diff == minDiff && profile.rotationHint == rotation) {
} else if (diff == minDiff && profile.getDeviceProperties().getRotationHint() == rotation) {
bestMatch = profile;
}
}
@@ -995,7 +995,7 @@ public class InvariantDeviceProfile {
displayInfo.getDeviceType()), isLandscape);
}
/** Class to expose properties required for external displays to {@link DeviceProfile} */
/** Class to expose properties required for external displays to {@link deviceprofile} */
public static final class DisplayOptionSpec {
public final int typeIndex;
public final int numShownHotseatIcons;
+10 -8
View File
@@ -677,9 +677,9 @@ public class Launcher extends StatefulActivity<LauncherState>
// When the flag oneGridSpecs is on we want to disable ALLOW_ROTATION which is replaced
// by FIXED_LANDSCAPE_MODE, ALLOW_ROTATION will only be used on Tablets and foldables
// afterwards.
if (getDeviceProfile().isPhone) {
if (getDeviceProfile().getDeviceProperties().isPhone()) {
LauncherPrefs.get(this).put(LauncherPrefs.ALLOW_ROTATION, false);
} else if (getDeviceProfile().isTablet) {
} else if (getDeviceProfile().getDeviceProperties().isTablet()) {
// Tablet do not use fixed landscape mode, make sure it can't be activated by mistake
LauncherPrefs.get(this).put(FIXED_LANDSCAPE_MODE, false);
}
@@ -708,7 +708,7 @@ public class Launcher extends StatefulActivity<LauncherState>
this, getMultiWindowDisplaySize());
}
if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.isTwoPanels) {
if (FOLDABLE_SINGLE_PAGE.get() && mDeviceProfile.getDeviceProperties().isTwoPanels()) {
mCellPosMapper = new TwoPanelCellPosMapper(mDeviceProfile.inv.numColumns);
} else {
mCellPosMapper = new CellPosMapper(mDeviceProfile.isVerticalBarLayout(),
@@ -1883,13 +1883,15 @@ public class Launcher extends StatefulActivity<LauncherState>
public void updateOpenFolderPosition(int[] inOutPosition, Rect bounds, int width, int height) {
int left = inOutPosition[0];
int top = inOutPosition[1];
DeviceProfile grid = getDeviceProfile();
DeviceProfile deviceProfile = getDeviceProfile();
int distFromEdgeOfScreen = getWorkspace().getPaddingLeft();
if (grid.isPhone && (grid.availableWidthPx - width) < 4 * distFromEdgeOfScreen) {
final int availableWidth = deviceProfile.getDeviceProperties().getAvailableWidthPx();
if (deviceProfile.getDeviceProperties().isPhone()
&& (availableWidth - width) < 4 * distFromEdgeOfScreen) {
// Center the folder if it is very close to being centered anyway, by virtue of
// filling the majority of the viewport. ie. remove it from the uncanny valley
// of centeredness.
left = (grid.availableWidthPx - width) / 2;
left = (availableWidth - width) / 2;
} else if (width >= bounds.width()) {
// If the folder doesn't fit within the bounds, center it about the desired bounds
left = bounds.left + (bounds.width() - width) / 2;
@@ -1900,7 +1902,7 @@ public class Launcher extends StatefulActivity<LauncherState>
} else {
// Folder height is less than page height, so bound it to the absolute open folder
// bounds if necessary
Rect folderBounds = grid.getAbsoluteOpenFolderBounds();
Rect folderBounds = deviceProfile.getAbsoluteOpenFolderBounds();
left = Math.max(folderBounds.left, Math.min(left, folderBounds.right - width));
top = Math.max(folderBounds.top, Math.min(top, folderBounds.bottom - height));
}
@@ -2540,7 +2542,7 @@ public class Launcher extends StatefulActivity<LauncherState>
if (BuildCompat.isAtLeastV()
&& Flags.enableDesktopWindowingMode()
&& !Flags.enableDesktopWindowingWallpaperActivity()
&& mDeviceProfile.isTablet) {
&& mDeviceProfile.getDeviceProperties().isTablet()) {
// TODO(b/333533253): Clean up after desktop wallpaper activity flag is rolled out
return;
}
+5 -5
View File
@@ -242,7 +242,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
DeviceProfile dp = launcher.getDeviceProfile();
if (dp.isQsbInline) {
int marginStart = getFloatingSearchBarRestingMarginStart(launcher);
return dp.widthPx - marginStart - dp.hotseatQsbWidth;
return dp.getDeviceProperties().getWidthPx() - marginStart - dp.hotseatQsbWidth;
}
boolean isRtl = Utilities.isRtl(launcher.getResources());
@@ -258,7 +258,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
public int getVisibleElements(Launcher launcher) {
int elements = HOTSEAT_ICONS | WORKSPACE_PAGE_INDICATOR | VERTICAL_SWIPE_INDICATOR;
// Floating search bar is visible in normal state except in landscape on phones.
if (!(launcher.getDeviceProfile().isPhone && launcher.getDeviceProfile().isLandscape)) {
if (!(launcher.getDeviceProfile().getDeviceProperties().isPhone() && launcher.getDeviceProfile().getDeviceProperties().isLandscape())) {
elements |= FLOATING_SEARCH_BAR;
}
return elements;
@@ -346,7 +346,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
public final <DEVICE_PROFILE_CONTEXT extends Context & ActivityContext>
float getDepth(DEVICE_PROFILE_CONTEXT context) {
return getDepth(context,
ActivityContext.lookupContext(context).getDeviceProfile().isMultiWindowMode);
ActivityContext.lookupContext(context).getDeviceProfile().getDeviceProperties().isMultiWindowMode());
}
/**
@@ -390,7 +390,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
boolean shouldFadeAdjacentScreens = (this == NORMAL || this == HINT_STATE)
&& dp.shouldFadeAdjacentWorkspaceScreens();
// Avoid showing adjacent screens behind handheld All Apps sheet.
if (Flags.allAppsSheetForHandheld() && dp.isPhone && this == ALL_APPS) {
if (Flags.allAppsSheetForHandheld() && dp.getDeviceProperties().isPhone() && this == ALL_APPS) {
shouldFadeAdjacentScreens = true;
}
if (!shouldFadeAdjacentScreens) {
@@ -410,7 +410,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
*/
public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) {
if (!(this == SPRING_LOADED || this == EDIT_MODE)
|| !launcher.getDeviceProfile().isTwoPanels) {
|| !launcher.getDeviceProfile().getDeviceProperties().isTwoPanels()) {
return DEFAULT_PAGE_TRANSLATION_PROVIDER;
}
final float quarterPageSpacing = launcher.getWorkspace().getPageSpacing() / 4f;
+7 -6
View File
@@ -158,7 +158,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true)
launcher.workspace.pageIndicator.setPauseScroll(
/*pause=*/ false,
deviceProfile.isTwoPanels,
deviceProfile.deviceProperties.isTwoPanels,
)
launcher.finishBindingItems(pagesBoundFirst)
}
@@ -270,12 +270,13 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
// in single panel.
if (actualIds.contains(firstId)) {
result.add(firstId)
if (launcher.deviceProfile.isTwoPanels && actualIds.contains(pairId)) {
if (launcher.deviceProfile.deviceProperties.isTwoPanels && actualIds.contains(pairId)) {
result.add(pairId)
}
} else if (
LauncherAppState.getIDP(launcher).supportedProfiles.any(DeviceProfile::isTwoPanels) &&
actualIds.contains(pairId)
LauncherAppState.getIDP(launcher).supportedProfiles.any {
it.deviceProperties.isTwoPanels
} && actualIds.contains(pairId)
) {
// Add the right panel if left panel is hidden when switching display, due to empty
// pages being hidden in single panel.
@@ -287,7 +288,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
private fun bindScreens(orderedScreenIds: LIntArray) {
launcher.workspace.pageIndicator.setPauseScroll(
/*pause=*/ true,
launcher.deviceProfile.isTwoPanels,
launcher.deviceProfile.deviceProperties.isTwoPanels,
)
val firstScreenPosition = 0
if (orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition) {
@@ -345,7 +346,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
private fun bindAddScreens(orderedScreenIdsArg: LIntArray) {
var orderedScreenIds = orderedScreenIdsArg
if (launcher.deviceProfile.isTwoPanels) {
if (launcher.deviceProfile.deviceProperties.isTwoPanels) {
if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) {
orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds)
} else {
+6 -6
View File
@@ -534,7 +534,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
}
private boolean isTwoPanelEnabled() {
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels;
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.getDeviceProperties().isTwoPanels();
}
public void deferRemoveExtraEmptyScreen() {
@@ -692,7 +692,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// created CellLayout.
DeviceProfile dp = mLauncher.getDeviceProfile();
CellLayout newScreen;
if (FOLDABLE_SINGLE_PAGE.get() && dp.isTwoPanels) {
if (FOLDABLE_SINGLE_PAGE.get() && dp.getDeviceProperties().isTwoPanels()) {
newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen_foldable, this, false /* attachToRoot */);
} else {
@@ -3443,13 +3443,13 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
public int getExpectedHeight() {
return getMeasuredHeight() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight();
? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : getMeasuredHeight();
}
@Override
public int getExpectedWidth() {
return getMeasuredWidth() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth();
? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() : getMeasuredWidth();
}
@Override
@@ -3515,12 +3515,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
if (!deviceProfile.isTablet) {
if (!deviceProfile.getDeviceProperties().isTablet()) {
return super.isSignificantMove(absoluteDelta, pageOrientedSize);
}
return absoluteDelta
> deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
> deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
}
@Override
@@ -1211,7 +1211,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
// Ignore left/right insets on tablet because we are already centered in-screen.
if (grid.isTablet) {
if (grid.getDeviceProperties().isTablet()) {
mlp.leftMargin = mlp.rightMargin = 0;
} else {
mlp.leftMargin = insets.left;
@@ -235,7 +235,7 @@ public class AllAppsTransitionController
boolean fromBackground =
mLauncher.getStateManager().getCurrentStableState() == BACKGROUND_APP;
// Allow apps panel to shift the full screen if coming from another app.
float shiftRange = fromBackground ? mLauncher.getDeviceProfile().heightPx : mShiftRange;
float shiftRange = fromBackground ? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : mShiftRange;
getAppsViewProgressTranslationY().setValue(mProgress * shiftRange);
mLauncher.onAllAppsTransition(1 - progress);
@@ -99,7 +99,7 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
// Special case to not expand the search bar when exiting All Apps on phones.
if (stateManager.getCurrentStableState() == LauncherState.ALL_APPS
&& mActivityContext.getDeviceProfile().isPhone) {
&& mActivityContext.getDeviceProfile().getDeviceProperties().isPhone()) {
return LauncherState.ALL_APPS.getFloatingSearchBarRestingMarginStart(mActivityContext);
}
@@ -121,7 +121,7 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView<L
// Special case to not expand the search bar when exiting All Apps on phones.
if (stateManager.getCurrentStableState() == LauncherState.ALL_APPS
&& mActivityContext.getDeviceProfile().isPhone) {
&& mActivityContext.getDeviceProfile().getDeviceProperties().isPhone()) {
return LauncherState.ALL_APPS.getFloatingSearchBarRestingMarginEnd(mActivityContext);
}
@@ -165,7 +165,7 @@ public class WorkUtilityView extends LinearLayout implements Insettable,
bottomMargin += dp.hotseatQsbHeight;
}
if (!dp.isGestureMode && dp.isTaskbarPresent) {
if (!dp.getDeviceProperties().isGestureMode() && dp.isTaskbarPresent) {
bottomMargin += dp.taskbarHeight;
}
@@ -0,0 +1,80 @@
/*
* Copyright (C) 2025 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.deviceprofile
import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.WindowBounds
import kotlin.math.max
import kotlin.math.min
data class DeviceProperties(
val windowX: Int,
val windowY: Int,
val rotationHint: Int,
val widthPx: Int,
val heightPx: Int,
val availableWidthPx: Int,
val availableHeightPx: Int,
val aspectRatio: Float,
val isTablet: Boolean,
val isPhone: Boolean,
val transposeLayoutWithOrientation: Boolean,
val isMultiDisplay: Boolean,
val isTwoPanels: Boolean,
val isLandscape: Boolean,
val isMultiWindowMode: Boolean,
val isGestureMode: Boolean,
) {
companion object Factory {
// b/419264328 adding here all the improvements/cleanup for this class
fun createDeviceProperties(
info: DisplayController.Info,
windowBounds: WindowBounds,
transposeLayoutWithOrientation: Boolean,
isMultiDisplay: Boolean,
isMultiWindowMode: Boolean,
isGestureMode: Boolean,
): DeviceProperties {
val isTablet = info.isTablet(windowBounds)
val windowX = windowBounds.bounds.left
val windowY = windowBounds.bounds.top
val rotationHint = windowBounds.rotationHint
val widthPx = windowBounds.bounds.width()
val heightPx = windowBounds.bounds.height()
val availableWidthPx = windowBounds.availableSize.x
val availableHeightPx = windowBounds.availableSize.y
return DeviceProperties(
windowX = windowX,
windowY = windowY,
rotationHint = rotationHint,
widthPx = widthPx,
heightPx = heightPx,
availableWidthPx = availableWidthPx,
availableHeightPx = availableHeightPx,
aspectRatio = max(widthPx, heightPx).toFloat() / min(widthPx, heightPx).toFloat(),
isTablet = isTablet,
isPhone = !isTablet,
transposeLayoutWithOrientation = transposeLayoutWithOrientation,
isMultiDisplay = isMultiDisplay,
isTwoPanels = isTablet && isMultiDisplay,
isLandscape = windowBounds.isLandscape,
isMultiWindowMode = isMultiWindowMode,
isGestureMode = isGestureMode,
)
}
}
}

Some files were not shown because too many files have changed in this diff Show More