Merge "Moving rearrangementExists to ReorderLogic since it's only used there" into main
diff --git a/aconfig/launcher.aconfig b/aconfig/launcher.aconfig
index 5689c8a..760d8ac 100644
--- a/aconfig/launcher.aconfig
+++ b/aconfig/launcher.aconfig
@@ -69,3 +69,10 @@
description: "Enables initiating split from a fullscreen app using keyboard shortcuts"
bug: "270394122"
}
+
+flag {
+ name: "enable_launcher_br_metrics"
+ namespace: "launcher"
+ description: "Enables logging of Launcher restore metrics to the Backup & Restore team"
+ bug: "307527314"
+}
diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
index c4375d3..29b24b7 100644
--- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
+++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
@@ -16,8 +16,6 @@
package com.android.launcher3.testing;
-import static com.android.launcher3.testing.shared.TestProtocol.WORKSPACE_LONG_PRESS;
-import static com.android.launcher3.testing.shared.TestProtocol.testLogD;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -137,12 +135,10 @@
}
case TestProtocol.REQUEST_ENABLE_DEBUG_TRACING:
- testLogD(WORKSPACE_LONG_PRESS, "enablingDebugTracing");
TestProtocol.sDebugTracing = true;
return response;
case TestProtocol.REQUEST_DISABLE_DEBUG_TRACING:
- testLogD(WORKSPACE_LONG_PRESS, "disablingDebugTracing");
TestProtocol.sDebugTracing = false;
return response;
diff --git a/quickstep/res/layout/icon_app_chip_view.xml b/quickstep/res/layout/icon_app_chip_view.xml
index fa9fd2b..b7acb70 100644
--- a/quickstep/res/layout/icon_app_chip_view.xml
+++ b/quickstep/res/layout/icon_app_chip_view.xml
@@ -60,9 +60,8 @@
android:maxLines="1"
android:ellipsize="end"
android:textAlignment="viewStart"
- android:textColor="?androidprv:attr/materialColorOnSurface"
- android:textSize="@dimen/task_thumbnail_icon_menu_text_size"
- android:importantForAccessibility="no" />
+ android:importantForAccessibility="no"
+ style="@style/IconAppChipMenuTextStyle" />
<TextView
android:id="@+id/icon_text_expanded"
@@ -72,9 +71,8 @@
android:maxLines="1"
android:ellipsize="end"
android:textAlignment="viewStart"
- android:textColor="?androidprv:attr/materialColorOnSurface"
- android:textSize="@dimen/task_thumbnail_icon_menu_text_size"
- android:importantForAccessibility="no" />
+ android:importantForAccessibility="no"
+ style="@style/IconAppChipMenuTextStyle" />
<ImageView
android:id="@+id/icon_arrow"
diff --git a/quickstep/res/layout/split_instructions_view.xml b/quickstep/res/layout/split_instructions_view.xml
index c663bf4..0bbbfd5 100644
--- a/quickstep/res/layout/split_instructions_view.xml
+++ b/quickstep/res/layout/split_instructions_view.xml
@@ -30,9 +30,15 @@
android:id="@+id/split_instructions_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
- android:gravity="center"
android:textColor="?androidprv:attr/textColorOnAccent"
- android:drawableEnd="@drawable/ic_split_exit"
- android:drawablePadding="@dimen/split_instructions_drawable_padding"
android:text="@string/toast_split_select_app" />
+
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/split_instructions_text_cancel"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textColor="?androidprv:attr/textColorOnAccent"
+ android:layout_marginStart="@dimen/split_instructions_start_margin_cancel"
+ android:text="@string/toast_split_select_app_cancel"
+ android:visibility="gone"/>
</com.android.quickstep.views.SplitInstructionsView>
\ No newline at end of file
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 295074a..4867eba 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -55,7 +55,7 @@
<!-- The max width of the icon menu text -->
<dimen name="task_thumbnail_icon_menu_text_max_width">118dp</dimen>
<!-- The size of the icon menu text -->
- <dimen name="task_thumbnail_icon_menu_text_size">16sp</dimen>
+ <dimen name="task_thumbnail_icon_menu_text_size">14sp</dimen>
<!-- The max width of the thumbnail icon menu background -->
<dimen name="task_thumbnail_icon_menu_background_max_width">164dp</dimen>
<!-- The height of the thumbnail icon menu -->
@@ -73,9 +73,9 @@
<!-- The margin at the start of the task icon menu -->
<dimen name="task_thumbnail_icon_menu_start_margin">12dp</dimen>
<!-- The margin at the top of the task icon menu -->
- <dimen name="task_thumbnail_icon_menu_top_margin">6dp</dimen>
- <!-- The margin at the top of the task icon menu when expanded -->
- <dimen name="task_thumbnail_icon_menu_top_margin_expanded">4dp</dimen>
+ <dimen name="task_thumbnail_icon_menu_top_margin">12dp</dimen>
+ <!-- The gap at the top of the task icon menu when expanded -->
+ <dimen name="task_thumbnail_icon_menu_expanded_gap">6dp</dimen>
<!-- The margin at the start of the task icon view in the icon menu -->
<dimen name="task_thumbnail_icon_view_start_margin">6dp</dimen>
<!-- The space around the task icon arrow within the icon menu -->
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 3dade66..077b233 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -230,6 +230,7 @@
<string name="action_split">Split</string>
<!-- Label for toast with instructions for split screen selection mode. [CHAR_LIMIT=50] -->
<string name="toast_split_select_app">Tap another app to use split screen</string>
+ <string name="toast_split_select_app_cancel"><b>Cancel</b></string>
<string name="toast_split_select_cont_desc">Exit split screen selection</string>
<!-- Label for toast when app selected for split isn't supported. [CHAR_LIMIT=50] -->
<string name="toast_split_app_unsupported">Choose another app to use split screen</string>
diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml
index fc03704..ae62c26 100644
--- a/quickstep/res/values/styles.xml
+++ b/quickstep/res/values/styles.xml
@@ -303,4 +303,12 @@
<item name="arrowTipBackground">?androidprv:attr/materialColorSurfaceContainer</item>
<item name="arrowTipTextColor">?androidprv:attr/materialColorOnSurface</item>
</style>
+
+ <style name="IconAppChipMenuTextStyle">
+ <item name="android:fontFamily">google-sans-text-medium</item>
+ <item name="android:textSize">@dimen/task_thumbnail_icon_menu_text_size</item>
+ <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item>
+ <item name="android:letterSpacing">0.025</item>
+ <item name="android:lineHeight">20sp</item>
+ </style>
</resources>
diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
index e77d2c6..d6ab54e 100644
--- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java
@@ -239,7 +239,7 @@
|| Global.getFloat(mLauncher.getContentResolver(),
Global.TRANSITION_ANIMATION_SCALE, 1f) > 0;
}
- };;
+ };
private DeviceProfile mDeviceProfile;
@@ -329,7 +329,7 @@
ItemInfo tag = (ItemInfo) v.getTag();
if (tag != null && tag.shouldUseBackgroundAnimation()) {
ContainerAnimationRunner containerAnimationRunner = ContainerAnimationRunner.from(
- v, mLauncher, mStartingWindowListener, onEndCallback);
+ v, mLauncher, mStartingWindowListener, onEndCallback);
if (containerAnimationRunner != null) {
mAppLaunchRunner = containerAnimationRunner;
}
@@ -491,9 +491,9 @@
/**
* Content is everything on screen except the background and the floating view (if any).
*
- * @param isAppOpening True when this is called when an app is opening.
- * False when this is called when an app is closing.
- * @param startDelay Start delay duration.
+ * @param isAppOpening True when this is called when an app is opening.
+ * False when this is called when an app is closing.
+ * @param startDelay Start delay duration.
* @param skipAllAppsScale True if we want to avoid scaling All Apps
*/
private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening,
@@ -1060,7 +1060,7 @@
LaunchDepthController depthController = new LaunchDepthController(mLauncher);
ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController.stateDepth,
MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher))
- .setDuration(APP_LAUNCH_DURATION);
+ .setDuration(APP_LAUNCH_DURATION);
if (allowBlurringLauncher) {
// Create a temporary effect layer, that lives on top of launcher, so we can apply
@@ -1309,7 +1309,7 @@
return null;
}
- final ComponentName[] taskInfoActivities = new ComponentName[] {
+ final ComponentName[] taskInfoActivities = new ComponentName[]{
runningTaskTarget.taskInfo.baseActivity,
runningTaskTarget.taskInfo.origActivity,
runningTaskTarget.taskInfo.realActivity,
@@ -1355,7 +1355,7 @@
.getPrimaryValue(dp.availableWidthPx, dp.availableHeightPx);
float secondaryDimension = orientationHandler
.getSecondaryValue(dp.availableWidthPx, dp.availableHeightPx);
- final float targetX = primaryDimension / 2f;
+ final float targetX = primaryDimension / 2f;
final float targetY = secondaryDimension - dp.hotseatBarSizePx;
return new RectF(targetX - halfIconSize, targetY - halfIconSize,
targetX + halfIconSize, targetY + halfIconSize);
@@ -1366,7 +1366,7 @@
*/
protected RectFSpringAnim getClosingWindowAnimators(AnimatorSet animation,
RemoteAnimationTarget[] targets, View launcherView, PointF velocityPxPerS,
- RectF closingWindowStartRect, float startWindowCornerRadius) {
+ RectF closingWindowStartRectF, float startWindowCornerRadius) {
FloatingIconView floatingIconView = null;
FloatingWidgetView floatingWidget = null;
RectF targetRect = new RectF();
@@ -1406,14 +1406,16 @@
boolean useTaskbarHotseatParams = mDeviceProfile.isTaskbarPresent && isInHotseat;
RectFSpringAnim anim = new RectFSpringAnim(useTaskbarHotseatParams
- ? new TaskbarHotseatSpringConfig(mLauncher, closingWindowStartRect, targetRect)
- : new DefaultSpringConfig(mLauncher, mDeviceProfile, closingWindowStartRect,
+ ? new TaskbarHotseatSpringConfig(mLauncher, closingWindowStartRectF, targetRect)
+ : new DefaultSpringConfig(mLauncher, mDeviceProfile, closingWindowStartRectF,
targetRect));
// Hook up floating views to the closing window animators.
// note the coordinate of closingWindowStartRect is based on launcher
- Rect windowTargetBounds = new Rect();
- closingWindowStartRect.round(windowTargetBounds);
+ Rect closingWindowStartRect = new Rect();
+ closingWindowStartRectF.round(closingWindowStartRect);
+ Rect closingWindowOriginalRect =
+ new Rect(0, 0, mDeviceProfile.widthPx, mDeviceProfile.heightPx);
if (floatingIconView != null) {
anim.addAnimatorListener(floatingIconView);
floatingIconView.setOnTargetChangeListener(anim::onTargetPositionChanged);
@@ -1425,7 +1427,7 @@
final float windowAlphaThreshold = 1f - SHAPE_PROGRESS_DURATION;
RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect,
- windowTargetBounds, startWindowCornerRadius) {
+ closingWindowStartRect, closingWindowOriginalRect, startWindowCornerRadius) {
@Override
public void onUpdate(RectF currentRectF, float progress) {
finalFloatingIconView.update(1f, currentRectF, progress, windowAlphaThreshold,
@@ -1443,7 +1445,7 @@
final float floatingWidgetAlpha = isTransluscent ? 0 : 1;
FloatingWidgetView finalFloatingWidget = floatingWidget;
RectFSpringAnim.OnUpdateListener runner = new SpringAnimRunner(targets, targetRect,
- windowTargetBounds, startWindowCornerRadius) {
+ closingWindowStartRect, closingWindowOriginalRect, startWindowCornerRadius) {
@Override
public void onUpdate(RectF currentRectF, float progress) {
final float fallbackBackgroundAlpha =
@@ -1461,7 +1463,8 @@
// If no floating icon or widget is present, animate the to the default window
// target rect.
anim.addOnUpdateListener(new SpringAnimRunner(
- targets, targetRect, windowTargetBounds, startWindowCornerRadius));
+ targets, targetRect, closingWindowStartRect, closingWindowOriginalRect,
+ startWindowCornerRadius));
}
// Use a fixed velocity to start the animation.
@@ -1647,7 +1650,7 @@
// is initialized.
if (launcherIsForceInvisibleOrOpening) {
addCujInstrumentation(anim, playFallBackAnimation
- ? CUJ_APP_CLOSE_TO_HOME_FALLBACK : CUJ_APP_CLOSE_TO_HOME);
+ ? CUJ_APP_CLOSE_TO_HOME_FALLBACK : CUJ_APP_CLOSE_TO_HOME);
// Only register the content animation for cancellation when state changes
mLauncher.getStateManager().setCurrentAnimation(anim);
@@ -1961,6 +1964,7 @@
/**
* Transfer the rectangle to another coordinate if needed.
+ *
* @param toLauncher which one is the anchor of this transfer, if true then transfer from
* animation target to launcher, false transfer from launcher to animation
* target.
@@ -2016,27 +2020,45 @@
private final float mStartRadius;
private final float mEndRadius;
private final SurfaceTransactionApplier mSurfaceApplier;
- private final Rect mWindowTargetBounds = new Rect();
+ private final Rect mWindowStartBounds = new Rect();
+ private final Rect mWindowOriginalBounds = new Rect();
private final Rect mTmpRect = new Rect();
+ /**
+ * Constructor for SpringAnimRunner
+ *
+ * @param appTargets the list of opening/closing apps
+ * @param targetRect target rectangle
+ * @param closingWindowStartRect start position of the window when the spring animation
+ * is started. In the predictive back to home case this
+ * will be smaller than closingWindowOriginalRect because
+ * the window is already scaled by the user gesture
+ * @param closingWindowOriginalRect Original unscaled window rect
+ * @param startWindowCornerRadius corner radius of window at the start position
+ */
SpringAnimRunner(RemoteAnimationTarget[] appTargets, RectF targetRect,
- Rect windowTargetBounds, float startWindowCornerRadius) {
+ Rect closingWindowStartRect, Rect closingWindowOriginalRect,
+ float startWindowCornerRadius) {
mAppTargets = appTargets;
mStartRadius = startWindowCornerRadius;
mEndRadius = Math.max(1, targetRect.width()) / 2f;
mSurfaceApplier = new SurfaceTransactionApplier(mDragLayer);
- mWindowTargetBounds.set(windowTargetBounds);
+ mWindowStartBounds.set(closingWindowStartRect);
+ mWindowOriginalBounds.set(closingWindowOriginalRect);
// transfer the coordinate based on animation target.
if (mAppTargets != null) {
for (RemoteAnimationTarget t : mAppTargets) {
if (t.mode == MODE_CLOSING) {
- final RectF targetBounds = new RectF(mWindowTargetBounds);
+ final RectF transferRect = new RectF(mWindowStartBounds);
final RectF result = new RectF();
- transferRectToTargetCoordinate(
- t, targetBounds, false, result);
- result.round(mWindowTargetBounds);
+ transferRectToTargetCoordinate(t, transferRect, false, result);
+ result.round(mWindowStartBounds);
+
+ transferRect.set(closingWindowOriginalRect);
+ transferRectToTargetCoordinate(t, transferRect, false, result);
+ result.round(mWindowOriginalBounds);
break;
}
}
@@ -2061,7 +2083,6 @@
}
if (target.mode == MODE_CLOSING) {
- final RectF before = new RectF(currentRectF);
transferRectToTargetCoordinate(target, currentRectF, false, currentRectF);
currentRectF.round(mCurrentRect);
@@ -2069,20 +2090,21 @@
final float scale;
// We need to infer the crop (we crop the window to match the currentRectF).
- if (mWindowTargetBounds.height() > mWindowTargetBounds.width()) {
- scale = Math.min(1f, currentRectF.width() / mWindowTargetBounds.width());
+ if (mWindowStartBounds.height() > mWindowStartBounds.width()) {
+ scale = Math.min(1f, currentRectF.width() / mWindowOriginalBounds.width());
int unscaledHeight = (int) (mCurrentRect.height() * (1f / scale));
- int croppedHeight = mWindowTargetBounds.height() - unscaledHeight;
- mTmpRect.set(0, 0, mWindowTargetBounds.width(),
- mWindowTargetBounds.height() - croppedHeight);
+ int croppedHeight = mWindowStartBounds.height() - unscaledHeight;
+ mTmpRect.set(0, 0, mWindowOriginalBounds.width(),
+ mWindowStartBounds.height() - croppedHeight);
} else {
- scale = Math.min(1f, currentRectF.height() / mWindowTargetBounds.height());
+ scale = Math.min(1f, currentRectF.height()
+ / mWindowOriginalBounds.height());
int unscaledWidth = (int) (mCurrentRect.width() * (1f / scale));
- int croppedWidth = mWindowTargetBounds.width() - unscaledWidth;
- mTmpRect.set(0, 0, mWindowTargetBounds.width() - croppedWidth,
- mWindowTargetBounds.height());
+ int croppedWidth = mWindowStartBounds.width() - unscaledWidth;
+ mTmpRect.set(0, 0, mWindowStartBounds.width() - croppedWidth,
+ mWindowOriginalBounds.height());
}
// Match size and position of currentRect.
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 0ef4541..3514447 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -26,6 +26,7 @@
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.SYSUI_SURFACE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.TaskbarManager.isPhoneButtonNavMode;
+import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
@@ -380,10 +381,12 @@
int navButtonSize = mContext.getResources().getDimensionPixelSize(
R.dimen.taskbar_nav_buttons_size);
boolean isRtl = Utilities.isRtl(mContext.getResources());
- mPropertyHolders.add(new StatePropertyHolder(
- mBackButton, flags -> (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0
- || (flags & FLAG_KEYGUARD_VISIBLE) != 0,
- VIEW_TRANSLATE_X, navButtonSize * (isRtl ? -2 : 2), 0));
+ if (!isPhoneMode(mContext.getDeviceProfile())) {
+ mPropertyHolders.add(new StatePropertyHolder(
+ mBackButton, flags -> (flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0
+ || (flags & FLAG_KEYGUARD_VISIBLE) != 0,
+ VIEW_TRANSLATE_X, navButtonSize * (isRtl ? -2 : 2), 0));
+ }
// home button
mHomeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, navContainer,
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
index d29f8ea..ea3411b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
@@ -251,5 +251,5 @@
return
}
- LottieAnimationColorUtils.updateColors(this, DARK_TO_LIGHT_COLORS, context.theme)
+ LottieAnimationColorUtils.updateToColorResources(this, DARK_TO_LIGHT_COLORS, context.theme)
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 165ed80..5b0c8c3 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -480,7 +480,11 @@
@Override
public void onDestroy() {
- mAppTransitionManager.onActivityDestroyed();
+ if (mAppTransitionManager != null) {
+ mAppTransitionManager.onActivityDestroyed();
+ }
+ mAppTransitionManager = null;
+
if (mUnfoldTransitionProgressProvider != null) {
SystemUiProxy.INSTANCE.get(this).setUnfoldAnimationListener(null);
mUnfoldTransitionProgressProvider.destroy();
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 8313e09..d7ff59e 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -855,7 +855,9 @@
if (windowInsets.isVisible(WindowInsets.Type.ime())) {
return result;
}
- buildAnimationController();
+ if (mGestureState.getEndTarget() == null) {
+ buildAnimationController();
+ }
// Reapply the current shift to ensure it takes new insets into account, e.g. when long
// pressing to stash taskbar without moving the finger.
onCurrentShiftUpdated();
@@ -1223,12 +1225,12 @@
: null;
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("calculateEndTarget: velocities=(x=")
- .append(Float.toString(dpiFromPx(velocityPxPerMs.x)))
+ .append(dpiFromPx(velocityPxPerMs.x))
.append("dp/ms, y=")
- .append(Float.toString(dpiFromPx(velocityPxPerMs.y)))
+ .append(dpiFromPx(velocityPxPerMs.y))
.append("dp/ms), angle=")
- .append(Double.toString(Math.toDegrees(Math.atan2(
- -velocityPxPerMs.y, velocityPxPerMs.x)))), gestureEvent);
+ .append(Math.toDegrees(Math.atan2(
+ -velocityPxPerMs.y, velocityPxPerMs.x))), gestureEvent);
if (mGestureState.isHandlingAtomicEvent()) {
// Button mode, this is only used to go to recents.
diff --git a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
index 406e9f4..27b3126 100644
--- a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
+++ b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java
@@ -487,10 +487,14 @@
tryFinishBackAnimation();
}
});
+ if (mScrimLayer == null) {
+ // Scrim hasn't been attached yet. Let's attach it.
+ addScrimLayer();
+ }
mScrimAlphaAnimator = new ValueAnimator().ofFloat(1, 0);
mScrimAlphaAnimator.addUpdateListener(animation -> {
float value = (Float) animation.getAnimatedValue();
- if (mScrimLayer.isValid()) {
+ if (mScrimLayer != null && mScrimLayer.isValid()) {
mTransaction.setAlpha(mScrimLayer, value * mScrimAlpha);
mTransaction.apply();
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 0bc44e1..8e03a91 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -34,6 +34,7 @@
import android.util.Log;
import android.view.RemoteAnimationTarget;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
@@ -102,7 +103,7 @@
* Starts a new recents animation for the activity with the given {@param intent}.
*/
@UiThread
- public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState,
+ public RecentsAnimationCallbacks startRecentsAnimation(@NonNull GestureState gestureState,
Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
ActiveGestureLog.INSTANCE.addLog(
/* event= */ "startRecentsAnimation",
@@ -163,6 +164,7 @@
// other apps need to keep visible so finish the animating state after the
// enter animation of overview is done. Then 3p launcher can be stopped.
mLastGestureState.runOnceAtState(STATE_END_TARGET_ANIMATION_FINISHED, () -> {
+ if (mLastGestureState != gestureState) return;
// Only finish if the end target is RECENTS. Otherwise, if the target is
// NEW_TASK, startActivityFromRecents will be skipped.
if (mLastGestureState.getEndTarget() == RECENTS) {
diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.java b/quickstep/src/com/android/quickstep/TaskIconCache.java
index 20a751b..1b3f598 100644
--- a/quickstep/src/com/android/quickstep/TaskIconCache.java
+++ b/quickstep/src/com/android/quickstep/TaskIconCache.java
@@ -31,7 +31,6 @@
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.SparseArray;
-import android.view.accessibility.AccessibilityManager;
import androidx.annotation.WorkerThread;
@@ -45,6 +44,7 @@
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
import com.android.launcher3.util.DisplayController.Info;
+import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.Preconditions;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.TaskKeyLruCache;
@@ -62,7 +62,6 @@
public class TaskIconCache implements DisplayInfoChangeListener {
private final Executor mBgExecutor;
- private final AccessibilityManager mAccessibilityManager;
private final Context mContext;
private final TaskKeyLruCache<TaskCacheEntry> mIconCache;
@@ -79,7 +78,6 @@
public TaskIconCache(Context context, Executor bgExecutor, IconProvider iconProvider) {
mContext = context;
mBgExecutor = bgExecutor;
- mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
mIconProvider = iconProvider;
Resources res = context.getResources();
@@ -238,14 +236,11 @@
if ((index = mDefaultIcons.indexOfKey(userId)) >= 0) {
return mDefaultIcons.valueAt(index).newIcon(mContext);
} else {
- try (BaseIconFactory li = getIconFactory()) {
- BitmapInfo info = mDefaultIconBase.withFlags(
- li.getBitmapFlagOp(new IconOptions()
- .setUser(UserCache.INSTANCE.get(mContext)
- .getUserInfo(UserHandle.of(userId)))));
- mDefaultIcons.put(userId, info);
- return info.newIcon(mContext);
- }
+ BitmapInfo info = mDefaultIconBase.withFlags(
+ UserCache.INSTANCE.get(mContext).getUserInfo(UserHandle.of(userId))
+ .applyBitmapInfoFlags(FlagOp.NO_OP));
+ mDefaultIcons.put(userId, info);
+ return info.newIcon(mContext);
}
}
}
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index 95ce406..35fa539 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -238,6 +238,12 @@
if (toState == MODAL_TASK) {
setOverviewSelectEnabled(true);
}
+
+ // Set border after select mode changes to avoid showing border during state transition
+ if (!toState.overviewUi() || toState == MODAL_TASK) {
+ setTaskBorderEnabled(false);
+ }
+
setFreezeViewVisibility(true);
}
@@ -253,6 +259,11 @@
if (finalState != MODAL_TASK) {
setOverviewSelectEnabled(false);
}
+
+ if (finalState.overviewUi() && finalState != MODAL_TASK) {
+ setTaskBorderEnabled(true);
+ }
+
if (finalState != OVERVIEW_SPLIT_SELECT) {
if (FeatureFlags.enableSplitContextually()) {
mSplitSelectStateController.resetState();
diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
index fce188f..1bec970 100644
--- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
+++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java
@@ -184,7 +184,7 @@
mAnimatedBackground.setAnimation(resources.openRawResource(R.raw.all_set_page_bg),
null);
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToColorResources(
mAnimatedBackground,
Map.of(LOTTIE_PRIMARY_COLOR_TOKEN, R.color.all_set_bg_primary,
LOTTIE_TERTIARY_COLOR_TOKEN, R.color.all_set_bg_tertiary),
diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
index 631cff7..404bca9 100644
--- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java
@@ -41,13 +41,13 @@
super(fragment, tutorialType);
// Set the Lottie animation colors specifically for the Back gesture
if (ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mAnimatedGestureDemonstration,
Map.of(".onSurfaceBack", fragment.mRootView.mColorOnSurfaceBack,
".surfaceBack", fragment.mRootView.mColorSurfaceBack,
".secondaryBack", fragment.mRootView.mColorSecondaryBack));
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mCheckmarkAnimation,
Map.of(".checkmark",
Utilities.isDarkTheme(mContext)
diff --git a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
index daac99b..df552cf 100644
--- a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java
@@ -38,13 +38,13 @@
// Set the Lottie animation colors specifically for the Home gesture
if (ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mAnimatedGestureDemonstration,
Map.of(".onSurfaceHome", fragment.mRootView.mColorOnSurfaceHome,
".surfaceHome", fragment.mRootView.mColorSurfaceHome,
".secondaryHome", fragment.mRootView.mColorSecondaryHome));
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mCheckmarkAnimation,
Map.of(".checkmark",
Utilities.isDarkTheme(mContext)
diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
index afdc1e5..65f3a01 100644
--- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
+++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java
@@ -53,13 +53,13 @@
// Set the Lottie animation colors specifically for the Overview gesture
if (ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mAnimatedGestureDemonstration,
Map.of(".onSurfaceOverview", fragment.mRootView.mColorOnSurfaceOverview,
".surfaceOverview", fragment.mRootView.mColorSurfaceOverview,
".secondaryOverview", fragment.mRootView.mColorSecondaryOverview));
- LottieAnimationColorUtils.updateColors(
+ LottieAnimationColorUtils.updateToArgbColors(
mCheckmarkAnimation,
Map.of(".checkmark",
Utilities.isDarkTheme(mContext)
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index ac6c274..2aa9240 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -32,6 +32,7 @@
import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGED__DST_STATE__OVERVIEW;
import android.content.Context;
+import android.text.TextUtils;
import android.util.Log;
import android.util.StatsEvent;
import android.view.View;
@@ -227,6 +228,7 @@
private Optional<Integer> mCardinality = Optional.empty();
private int mInputType = SysUiStatsLog.LAUNCHER_UICHANGED__INPUT_TYPE__UNKNOWN;
private Optional<Integer> mFeatures = Optional.empty();
+ private Optional<String> mPackageName = Optional.empty();
StatsCompatLogger(Context context, ActivityContext activityContext) {
mContext = context;
@@ -332,6 +334,12 @@
}
@Override
+ public StatsLogger withPackageName(@Nullable String packageName) {
+ mPackageName = Optional.ofNullable(packageName);
+ return this;
+ }
+
+ @Override
public void log(EventEnum event) {
if (!Utilities.ATLEAST_R) {
return;
@@ -431,6 +439,7 @@
int srcState = mSrcState;
int dstState = mDstState;
int inputType = mInputType;
+ String packageName = mPackageName.orElseGet(() -> getPackageName(atomInfo));
if (IS_VERBOSE) {
String name = (event instanceof Enum) ? ((Enum) event).name() :
event.getId() + "";
@@ -448,6 +457,9 @@
if (atomInfo.hasContainerInfo()) {
logStringBuilder.append("\n").append(atomInfo);
}
+ if (!TextUtils.isEmpty(packageName)) {
+ logStringBuilder.append(String.format("\nPackage name: %s", packageName));
+ }
Log.d(TAG, logStringBuilder.toString());
}
@@ -472,7 +484,7 @@
atomInfo.getItemCase().getNumber() /* target_id */,
instanceId.getId() /* instance_id TODO */,
0 /* uid TODO */,
- getPackageName(atomInfo) /* package_name */,
+ packageName /* package_name */,
getComponentName(atomInfo) /* component_name */,
getGridX(atomInfo, false) /* grid_x */,
getGridY(atomInfo, false) /* grid_y */,
diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
index 6f4b6cb..278ca56 100644
--- a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
+++ b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java
@@ -18,6 +18,8 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.android.launcher3.util.Preconditions;
+
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -43,14 +45,6 @@
*/
public static final String INTENT_EXTRA_LOG_TRACE_ID = "INTENT_EXTRA_LOG_TRACE_ID";
- private static final int TYPE_ONE_OFF = 0;
- private static final int TYPE_FLOAT = 1;
- private static final int TYPE_INTEGER = 2;
- private static final int TYPE_BOOL_TRUE = 3;
- private static final int TYPE_BOOL_FALSE = 4;
- private static final int TYPE_COMPOUND_STRING = 5;
- private static final int TYPE_GESTURE_EVENT = 6;
-
private final EventLog[] logs;
private int nextIndex;
private int mCurrentLogId = 100;
@@ -67,9 +61,12 @@
* execution.
*/
public void trackEvent(@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- addLog(TYPE_GESTURE_EVENT, "", 0, CompoundString.NO_OP, gestureEvent);
+ addLog(CompoundString.NO_OP, gestureEvent);
}
+ /**
+ * Adds a log to be printed at log-dump-time.
+ */
public void addLog(String event) {
addLog(event, null);
}
@@ -82,54 +79,35 @@
addLog(event, extras, null);
}
- public void addLog(CompoundString compoundString) {
- if (compoundString == CompoundString.NO_OP) return;
- addLog(TYPE_COMPOUND_STRING, "", 0, compoundString, null);
- }
-
- public void addLog(
- CompoundString compoundString,
- @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- if (compoundString == CompoundString.NO_OP) {
- trackEvent(gestureEvent);
- return;
- }
- addLog(TYPE_COMPOUND_STRING, "", 0, compoundString, gestureEvent);
- }
-
/**
- * Adds a log and track the associated event for error detection.
+ * Adds a log to be printed at log-dump-time and track the associated event for error detection.
*
* @param gestureEvent GestureEvent representing the event being logged.
*/
public void addLog(
String event, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- addLog(TYPE_ONE_OFF, event, 0, CompoundString.NO_OP, gestureEvent);
+ addLog(new CompoundString(event), gestureEvent);
}
public void addLog(
String event,
int extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- addLog(TYPE_INTEGER, event, extras, CompoundString.NO_OP, gestureEvent);
+ addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
public void addLog(
String event,
boolean extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- addLog(
- extras ? TYPE_BOOL_TRUE : TYPE_BOOL_FALSE,
- event,
- 0,
- CompoundString.NO_OP,
- gestureEvent);
+ addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
- private void addLog(
- int type,
- String event,
- float extras,
+ public void addLog(CompoundString compoundString) {
+ addLog(compoundString, null);
+ }
+
+ public void addLog(
CompoundString compoundString,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
EventLog lastEventLog = logs[(nextIndex + logs.length - 1) % logs.length];
@@ -137,7 +115,7 @@
EventLog eventLog = new EventLog(mCurrentLogId, mIsFullyGesturalNavMode);
EventEntry eventEntry = new EventEntry();
- eventEntry.update(type, event, extras, compoundString, gestureEvent);
+ eventEntry.update(compoundString, gestureEvent);
eventLog.eventEntries.add(eventEntry);
logs[nextIndex] = eventLog;
nextIndex = (nextIndex + 1) % logs.length;
@@ -146,17 +124,17 @@
// Update the last EventLog
List<EventEntry> lastEventEntries = lastEventLog.eventEntries;
- EventEntry lastEntry = lastEventEntries.size() > 0
+ EventEntry lastEntry = !lastEventEntries.isEmpty()
? lastEventEntries.get(lastEventEntries.size() - 1) : null;
// Update the last EventEntry if it's a duplicate
- if (isEntrySame(lastEntry, type, event, extras, compoundString, gestureEvent)) {
+ if (isEntrySame(lastEntry, compoundString, gestureEvent)) {
lastEntry.duplicateCount++;
return;
}
EventEntry eventEntry = new EventEntry();
- eventEntry.update(type, event, extras, compoundString, gestureEvent);
+ eventEntry.update(compoundString, gestureEvent);
lastEventEntries.add(eventEntry);
}
@@ -181,30 +159,14 @@
writer.println(prefix + "\tLogs for logId: " + eventLog.logId);
for (EventEntry eventEntry : eventLog.eventEntries) {
+ if (eventEntry.mCompoundString.mIsNoOp) {
+ continue;
+ }
date.setTime(eventEntry.time);
- StringBuilder msg = new StringBuilder(prefix + "\t\t").append(sdf.format(date))
- .append(eventEntry.event);
- switch (eventEntry.type) {
- case TYPE_BOOL_FALSE:
- msg.append(": false");
- break;
- case TYPE_BOOL_TRUE:
- msg.append(": true");
- break;
- case TYPE_FLOAT:
- msg.append(": ").append(eventEntry.extras);
- break;
- case TYPE_INTEGER:
- msg.append(": ").append((int) eventEntry.extras);
- break;
- case TYPE_COMPOUND_STRING:
- msg.append(eventEntry.mCompoundString);
- break;
- case TYPE_GESTURE_EVENT:
- continue;
- default: // fall out
- }
+ StringBuilder msg = new StringBuilder(prefix + "\t\t")
+ .append(sdf.format(date))
+ .append(eventEntry.mCompoundString);
if (eventEntry.duplicateCount > 0) {
msg.append(" & ").append(eventEntry.duplicateCount).append(" similar events");
}
@@ -232,15 +194,9 @@
private boolean isEntrySame(
EventEntry entry,
- int type,
- String event,
- float extras,
CompoundString compoundString,
ActiveGestureErrorDetector.GestureEvent gestureEvent) {
return entry != null
- && entry.type == type
- && entry.event.equals(event)
- && Float.compare(entry.extras, extras) == 0
&& entry.mCompoundString.equals(compoundString)
&& entry.gestureEvent == gestureEvent;
}
@@ -248,9 +204,6 @@
/** A single event entry. */
protected static class EventEntry {
- private int type;
- private String event;
- private float extras;
@NonNull private CompoundString mCompoundString;
private ActiveGestureErrorDetector.GestureEvent gestureEvent;
private long time;
@@ -264,14 +217,8 @@
}
private void update(
- int type,
- String event,
- float extras,
@NonNull CompoundString compoundString,
ActiveGestureErrorDetector.GestureEvent gestureEvent) {
- this.type = type;
- this.event = event;
- this.extras = extras;
this.mCompoundString = compoundString;
this.gestureEvent = gestureEvent;
time = System.currentTimeMillis();
@@ -302,6 +249,7 @@
public static final CompoundString NO_OP = new CompoundString();
private final List<String> mSubstrings;
+ private final List<Object> mArgs;
private final boolean mIsNoOp;
@@ -313,10 +261,12 @@
mIsNoOp = substring == null;
if (mIsNoOp) {
mSubstrings = null;
+ mArgs = null;
return;
}
mSubstrings = new ArrayList<>();
mSubstrings.add(substring);
+ mArgs = new ArrayList<>();
}
public CompoundString append(CompoundString substring) {
@@ -338,19 +288,41 @@
}
public CompoundString append(int num) {
- if (mIsNoOp) {
- return this;
- }
- mSubstrings.add(Integer.toString(num));
+ mArgs.add(num);
- return this;
+ return append("%d");
+ }
+
+ public CompoundString append(float num) {
+ mArgs.add(num);
+
+ return append("%.2f");
+ }
+
+ public CompoundString append(double num) {
+ mArgs.add(num);
+
+ return append("%.2f");
+ }
+
+ public CompoundString append(boolean bool) {
+ mArgs.add(bool);
+
+ return append("%b");
+ }
+
+ public Object[] getArgs() {
+ return mArgs.toArray();
}
@Override
public String toString() {
- if (mIsNoOp) {
- return "ERROR: cannot use No-Op compound string";
- }
+ return String.format(toUnformattedString(), getArgs());
+ }
+
+ public String toUnformattedString() {
+ Preconditions.assertTrue(!mIsNoOp);
+
StringBuilder sb = new StringBuilder();
for (String substring : mSubstrings) {
sb.append(substring);
diff --git a/quickstep/src/com/android/quickstep/util/LottieAnimationColorUtils.java b/quickstep/src/com/android/quickstep/util/LottieAnimationColorUtils.java
index f98b04b..8833b46 100644
--- a/quickstep/src/com/android/quickstep/util/LottieAnimationColorUtils.java
+++ b/quickstep/src/com/android/quickstep/util/LottieAnimationColorUtils.java
@@ -17,13 +17,11 @@
import static com.airbnb.lottie.LottieProperty.COLOR_FILTER;
-import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.model.KeyPath;
@@ -40,51 +38,39 @@
/**
* Updates the given Lottie animation's tokenized colors according to the given mapping.
* <p>
- * Use this method signature only when {@code tokenToColorCodeMap} maps to packed ARBG color
- * integers.
- * <p>
* @param animationView {@link LottieAnimationView} whose animation's colors need to be updated
- * @param tokenToColorCodeMap A mapping from the color tokens used in the Lottie file used in
+ * @param tokenToArgbColorMap A mapping from the color tokens used in the Lottie file used in
* {@code animationView} to packed ARBG color integers.
*/
- public static void updateColors(
+ public static void updateToArgbColors(
@NonNull LottieAnimationView animationView,
- @NonNull Map<String, Integer> tokenToColorCodeMap) {
- updateColors(animationView, tokenToColorCodeMap, null);
- }
-
- /**
- * Updates the given Lottie animation's tokenized colors according to the given mapping.
- * <p>
- * Use this method signature with a non-null theme only when {@code tokenToColorCodeMap} maps
- * to color resource references.
- * <p>
- * @param animationView {@link LottieAnimationView} whose animation's colors need to be updated
- * @param tokenToColorCodeMap A mapping from the color tokens used in the Lottie file used in
- * {@code animationView} to packed ARBG color integers or color
- * resource references.
- * @param theme {@link Theme} to be used when resolving color resource references. {@code null}
- * iff {@code tokenToColorCodeMap} maps to packed ARBG color integers.
- */
- public static void updateColors(
- @NonNull LottieAnimationView animationView,
- @NonNull Map<String, Integer> tokenToColorCodeMap,
- @Nullable Theme theme) {
- Resources resources = animationView.getResources();
- final Map<String, Integer> tokenToColorMap = theme == null
- // tokenToColorCodeMap maps directly to ARBG values
- ? tokenToColorCodeMap
- // tokenToColorCodeMap maps to color references, build a mapping to resolved colors
- : tokenToColorCodeMap.keySet().stream().collect(Collectors.toMap(
- Function.identity(),
- token -> resources.getColor(tokenToColorCodeMap.get(token), theme)));
-
+ @NonNull Map<String, Integer> tokenToArgbColorMap) {
animationView.addLottieOnCompositionLoadedListener(
- composition -> tokenToColorMap.forEach(
+ composition -> tokenToArgbColorMap.forEach(
(token, color) -> animationView.addValueCallback(
new KeyPath("**", token, "**"),
COLOR_FILTER,
frameInfo -> new PorterDuffColorFilter(
color, PorterDuff.Mode.SRC_ATOP))));
}
+
+ /**
+ * Updates the given Lottie animation's tokenized colors according to the given mapping.
+ * <p>
+ * @param animationView {@link LottieAnimationView} whose animation's colors need to be updated
+ * @param tokenToColorResourceMap A mapping from the color tokens used in the Lottie file used
+ * in {@code animationView} to color resource references.
+ * @param theme {@link Theme} to be used when resolving color resource references.
+ */
+ public static void updateToColorResources(
+ @NonNull LottieAnimationView animationView,
+ @NonNull Map<String, Integer> tokenToColorResourceMap,
+ @NonNull Theme theme) {
+ updateToArgbColors(
+ animationView,
+ tokenToColorResourceMap.keySet().stream().collect(Collectors.toMap(
+ Function.identity(),
+ token -> animationView.getResources().getColor(
+ tokenToColorResourceMap.get(token), theme))));
+ }
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
index 6ee65d4..b7c6bf5 100644
--- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
+++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt
@@ -252,6 +252,7 @@
splitSelectStateController.splitInstructionsView = splitInstructionsView
val timings = AnimUtils.getDeviceOverviewToSplitTimings(launcher.deviceProfile.isTablet)
val anim = PendingAnimation(100 /*duration */)
+ splitInstructionsView.alpha = 0f
anim.setViewAlpha(splitInstructionsView, 1f,
Interpolators.clampToProgress(Interpolators.LINEAR,
timings.instructionsContainerFadeInStartOffset,
diff --git a/quickstep/src/com/android/quickstep/util/TaskKeyByLastActiveTimeCache.java b/quickstep/src/com/android/quickstep/util/TaskKeyByLastActiveTimeCache.java
index 79ca076..21c9e09 100644
--- a/quickstep/src/com/android/quickstep/util/TaskKeyByLastActiveTimeCache.java
+++ b/quickstep/src/com/android/quickstep/util/TaskKeyByLastActiveTimeCache.java
@@ -44,7 +44,7 @@
private final PriorityQueue<Task.TaskKey> mQueue;
public TaskKeyByLastActiveTimeCache(int maxSize) {
- mMap = new HashMap(maxSize);
+ mMap = new HashMap(0);
mQueue = new PriorityQueue<>(Comparator.comparingLong(t -> t.lastActiveTime));
mMaxSize = new AtomicInteger(maxSize);
}
@@ -106,7 +106,8 @@
}
/**
- * Adds an entry to the cache, optionally evicting the last accessed entry
+ * Adds an entry to the cache, optionally evicting the last accessed entry excluding the newly
+ * added entry
*/
@Override
public final synchronized void put(Task.TaskKey key, V value) {
@@ -117,9 +118,9 @@
mQueue.remove(entry.mKey);
}
+ removeExcessIfNeeded(mMaxSize.get() - 1);
mMap.put(key.id, new Entry<>(key, value));
mQueue.add(key);
- removeExcessIfNeeded();
} else {
Log.e(TAG, "Unexpected null key or value: " + key + ", " + value);
}
@@ -143,11 +144,11 @@
@Override
public synchronized void updateCacheSizeAndRemoveExcess(int cacheSize) {
mMaxSize.compareAndSet(mMaxSize.get(), cacheSize);
- removeExcessIfNeeded();
+ removeExcessIfNeeded(mMaxSize.get());
}
- private synchronized void removeExcessIfNeeded() {
- while (mQueue.size() > mMaxSize.get() && !mQueue.isEmpty()) {
+ private synchronized void removeExcessIfNeeded(int maxSize) {
+ while (mQueue.size() > maxSize && !mQueue.isEmpty()) {
Task.TaskKey key = mQueue.poll();
mMap.remove(key.id);
}
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index b542909..5b5d0de 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -145,6 +145,12 @@
if (toState == OVERVIEW_MODAL_TASK) {
setOverviewSelectEnabled(true);
}
+
+ // Set border after select mode changes to avoid showing border during state transition
+ if (!toState.overviewUi || toState == OVERVIEW_MODAL_TASK) {
+ setTaskBorderEnabled(false);
+ }
+
setFreezeViewVisibility(true);
if (mActivity.getDesktopVisibilityController() != null) {
mActivity.getDesktopVisibilityController().onLauncherStateChanged(toState);
@@ -165,6 +171,10 @@
setOverviewSelectEnabled(false);
}
+ if (finalState.overviewUi && finalState != OVERVIEW_MODAL_TASK) {
+ setTaskBorderEnabled(true);
+ }
+
if (isOverlayEnabled) {
runActionOnRemoteHandles(remoteTargetHandle ->
remoteTargetHandle.getTaskViewSimulator().setDrawsBelowRecents(true));
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f55dce9..22a5064 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1410,6 +1410,17 @@
}
/**
+ * Enable or disable showing border on hover and focus change on task views
+ */
+ public void setTaskBorderEnabled(boolean enabled) {
+ int taskCount = getTaskViewCount();
+ for (int i = 0; i < taskCount; i++) {
+ TaskView taskView = requireTaskViewAt(i);
+ taskView.setBorderEnabled(enabled);
+ }
+ }
+
+ /**
* Whether the Clear All button is hidden or fully visible. Used to determine if center
* displayed page is a task or the Clear All button.
*
diff --git a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java
index e8f06ee..8bc85cf 100644
--- a/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java
+++ b/quickstep/src/com/android/quickstep/views/SplitInstructionsView.java
@@ -17,14 +17,12 @@
package com.android.quickstep.views;
import android.content.Context;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.FloatProperty;
-import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
-import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
@@ -41,9 +39,11 @@
*
* Appears and disappears concurrently with a FloatingTaskView.
*/
-public class SplitInstructionsView extends FrameLayout {
+public class SplitInstructionsView extends LinearLayout {
private final StatefulActivity mLauncher;
- private AppCompatTextView mTextView;
+ private AppCompatTextView mInstructionTextView;
+ /** Only used if {@link com.android.wm.shell.FeatureFlags#enableSplitContextual()} is true. */
+ private AppCompatTextView mCancelTextView;
public static final FloatProperty<SplitInstructionsView> UNFOLD =
new FloatProperty<SplitInstructionsView>("SplitInstructionsUnfold") {
@@ -97,22 +97,13 @@
}
private void init() {
- mTextView = findViewById(R.id.split_instructions_text);
+ mInstructionTextView = findViewById(R.id.split_instructions_text);
+ mCancelTextView = findViewById(R.id.split_instructions_text_cancel);
- if (!FeatureFlags.enableSplitContextually()) {
- mTextView.setCompoundDrawables(null, null, null, null);
- return;
+ if (FeatureFlags.enableSplitContextually()) {
+ mCancelTextView.setVisibility(VISIBLE);
+ mCancelTextView.setOnClickListener((v) -> exitSplitSelection());
}
-
- mTextView.setOnTouchListener((v, event) -> {
- if (isTouchInsideRightCompoundDrawable(event)) {
- if (event.getAction() == MotionEvent.ACTION_UP) {
- exitSplitSelection();
- }
- return true;
- }
- return false;
- });
}
private void exitSplitSelection() {
@@ -121,20 +112,6 @@
mLauncher.getStateManager().goToState(LauncherState.NORMAL);
}
- private boolean isTouchInsideRightCompoundDrawable(MotionEvent event) {
- // Get the right compound drawable of the TextView.
- Drawable rightDrawable = mTextView.getCompoundDrawablesRelative()[2];
-
- // Check if the touch event intersects with the drawable's bounds.
- if (rightDrawable != null) {
- // We can get away w/o caring about the Y bounds since it's such a small view, if it's
- // above/below the drawable just assume they meant to touch it. ¯\_(ツ)_/¯
- return event.getX() >= (mTextView.getWidth() - rightDrawable.getBounds().width());
- } else {
- return false;
- }
- }
-
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
@@ -172,6 +149,6 @@
}
public AppCompatTextView getTextView() {
- return mTextView;
+ return mInstructionTextView;
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 0c816b8..cf89d2e 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -311,14 +311,14 @@
- mActivity.getDeviceProfile().getOverviewActionsClaimedSpaceBelow();
float midpoint = (taskBottom + taskbarTop) / 2f;
additionalTranslationY = -Math.max(menuBottom - midpoint, 0);
- } else {
- // Animate the menu to leave a small margin at the top of the task.
- additionalTranslationY = getResources().getDimensionPixelSize(
- R.dimen.task_thumbnail_icon_menu_top_margin_expanded);
}
+ // Translate the menu to account for the expansion of the app chip menu as well.
+ float expandOffsetTranslationY = getResources().getDimensionPixelSize(
+ R.dimen.task_thumbnail_icon_menu_expanded_gap);
ObjectAnimator translationYAnim = ObjectAnimator.ofFloat(this, TRANSLATION_Y,
closing ? mMenuTranslationYBeforeOpen
- : mMenuTranslationYBeforeOpen + additionalTranslationY);
+ : mMenuTranslationYBeforeOpen + additionalTranslationY
+ + expandOffsetTranslationY);
translationYAnim.setInterpolator(EMPHASIZED);
ObjectAnimator menuTranslationYAnim = ObjectAnimator.ofFloat(
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 49eda8f..af4f402 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -408,6 +408,7 @@
new TaskIdAttributeContainer[2];
private boolean mShowScreenshot;
+ private boolean mBorderEnabled;
// The current background requests to load the task thumbnail and icon
@Nullable
@@ -439,8 +440,15 @@
this(context, attrs, defStyleAttr, 0);
}
- public TaskView(
- Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ public TaskView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ this(context, attrs, defStyleAttr, defStyleRes, null, null);
+ }
+
+ @VisibleForTesting
+ public TaskView(Context context, @Nullable AttributeSet attrs, int defStyleAttr,
+ int defStyleRes, BorderAnimator focusBorderAnimator,
+ BorderAnimator hoverBorderAnimator) {
super(context, attrs, defStyleAttr, defStyleRes);
mActivity = StatefulActivity.fromContext(context);
setOnClickListener(this::onClick);
@@ -457,28 +465,35 @@
TypedArray styledAttrs = context.obtainStyledAttributes(
attrs, R.styleable.TaskView, defStyleAttr, defStyleRes);
- mFocusBorderAnimator = keyboardFocusHighlightEnabled
- ? BorderAnimator.createSimpleBorderAnimator(
- /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
- /* borderWidthPx= */ context.getResources().getDimensionPixelSize(
- R.dimen.keyboard_quick_switch_border_width),
- /* boundsBuilder= */ this::updateBorderBounds,
- /* targetView= */ this,
- /* borderColor= */ styledAttrs.getColor(
- R.styleable.TaskView_focusBorderColor, DEFAULT_BORDER_COLOR))
- : null;
+ if (focusBorderAnimator != null) {
+ mFocusBorderAnimator = focusBorderAnimator;
+ } else {
+ mFocusBorderAnimator = keyboardFocusHighlightEnabled
+ ? BorderAnimator.createSimpleBorderAnimator(
+ /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
+ /* borderWidthPx= */ context.getResources().getDimensionPixelSize(
+ R.dimen.keyboard_quick_switch_border_width),
+ /* boundsBuilder= */ this::updateBorderBounds,
+ /* targetView= */ this,
+ /* borderColor= */ styledAttrs.getColor(
+ R.styleable.TaskView_focusBorderColor, DEFAULT_BORDER_COLOR))
+ : null;
+ }
- mHoverBorderAnimator = cursorHoverStatesEnabled
- ? BorderAnimator.createSimpleBorderAnimator(
- /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
- /* borderWidthPx= */ context.getResources().getDimensionPixelSize(
- R.dimen.task_hover_border_width),
- /* boundsBuilder= */ this::updateBorderBounds,
- /* targetView= */ this,
- /* borderColor= */ styledAttrs.getColor(
- R.styleable.TaskView_hoverBorderColor, DEFAULT_BORDER_COLOR))
- : null;
-
+ if (hoverBorderAnimator != null) {
+ mHoverBorderAnimator = hoverBorderAnimator;
+ } else {
+ mHoverBorderAnimator = cursorHoverStatesEnabled
+ ? BorderAnimator.createSimpleBorderAnimator(
+ /* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,
+ /* borderWidthPx= */ context.getResources().getDimensionPixelSize(
+ R.dimen.task_hover_border_width),
+ /* boundsBuilder= */ this::updateBorderBounds,
+ /* targetView= */ this,
+ /* borderColor= */ styledAttrs.getColor(
+ R.styleable.TaskView_hoverBorderColor, DEFAULT_BORDER_COLOR))
+ : null;
+ }
styledAttrs.recycle();
}
@@ -538,24 +553,25 @@
}
@Override
- protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
+ @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
+ public void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
- if (mFocusBorderAnimator != null) {
+ if (mFocusBorderAnimator != null && mBorderEnabled) {
mFocusBorderAnimator.setBorderVisibility(gainFocus, /* animated= */ true);
}
}
@Override
public boolean onHoverEvent(MotionEvent event) {
- if (mHoverBorderAnimator != null) {
+ if (mHoverBorderAnimator != null && mBorderEnabled) {
switch (event.getAction()) {
case MotionEvent.ACTION_HOVER_ENTER:
- mHoverBorderAnimator.setBorderVisibility(
- /* visible= */ true, /* animated= */ true);
+ mHoverBorderAnimator.setBorderVisibility(/* visible= */ true, /* animated= */
+ true);
break;
case MotionEvent.ACTION_HOVER_EXIT:
- mHoverBorderAnimator.setBorderVisibility(
- /* visible= */ false, /* animated= */ true);
+ mHoverBorderAnimator.setBorderVisibility(/* visible= */ false, /* animated= */
+ true);
break;
default:
break;
@@ -564,6 +580,24 @@
return super.onHoverEvent(event);
}
+ /**
+ * Enable or disable showing border on hover and focus change
+ */
+ public void setBorderEnabled(boolean enabled) {
+ mBorderEnabled = enabled;
+ // Set the animation correctly in case it misses the hover/focus event during state
+ // transition
+ if (mHoverBorderAnimator != null) {
+ mHoverBorderAnimator.setBorderVisibility(/* visible= */
+ enabled && isHovered(), /* animated= */ true);
+ }
+
+ if (mFocusBorderAnimator != null) {
+ mFocusBorderAnimator.setBorderVisibility(/* visible= */
+ enabled && isFocused(), /* animated= */true);
+ }
+ }
+
@Override
public boolean onInterceptHoverEvent(MotionEvent event) {
if (enableCursorHoverStates()) {
@@ -1327,6 +1361,7 @@
mSnapshotView.setThumbnail(mTask, null);
setOverlayEnabled(false);
onTaskListVisibilityChanged(false);
+ mBorderEnabled = false;
}
public float getTaskCornerRadius() {
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
index ba9ae67..fc757b4 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractTaplTestsTaskbar.java
@@ -25,7 +25,6 @@
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.ui.AbstractLauncherUiTest;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.TestUtil;
@@ -55,7 +54,7 @@
"com.google.android.apps.nexuslauncher.tests",
"com.android.launcher3.testcomponent.BaseTestingActivity");
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, layoutBuilder);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
startAppFast(CALCULATOR_APP_PACKAGE);
mLauncher.enableBlockTimeout(true);
mLauncher.showTaskbarIfHidden();
diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
index a89eab5..85440e9 100644
--- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
+++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
@@ -22,7 +22,7 @@
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
-import com.android.launcher3.ui.TaplTestsLauncher3;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.rule.TestStabilityRule.Stability;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
@@ -40,7 +40,7 @@
@Before
public void setUp() throws Exception {
super.setUp();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
// b/143488140
mLauncher.goHome();
// Start an activity where the gestures start.
@@ -49,6 +49,8 @@
@Test
@NavigationModeSwitch
+ // Stress tests are long. We permanently demote them from presubmit to match the presubmit SLO.
+ @Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT)
public void testStressPressHome() {
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
// Destroy Launcher activity.
@@ -61,7 +63,8 @@
@Test
@NavigationModeSwitch
- @Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/187761685
+ // Stress tests are long. We permanently demote them from presubmit to match the presubmit SLO.
+ @Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT)
public void testStressSwipeToOverview() {
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
// Destroy Launcher activity.
diff --git a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
index c4c95bc..3f806d1 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplOverviewIconTest.java
@@ -15,7 +15,7 @@
*/
package com.android.quickstep;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
index 74f37a4..829e54b 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsKeyboardQuickSwitch.java
@@ -22,7 +22,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.tapl.KeyboardQuickSwitch;
-import com.android.launcher3.ui.TaplTestsLauncher3;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import org.junit.Assume;
import org.junit.Test;
@@ -56,7 +56,7 @@
public void setUp() throws Exception {
Assume.assumeTrue(mLauncher.isTablet());
super.setUp();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
startAppFast(CALCULATOR_APP_PACKAGE);
startTestActivity(2);
}
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index 8e142c3..b3cc215 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -45,8 +45,8 @@
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.OverviewActions;
import com.android.launcher3.tapl.OverviewTask;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
import com.android.launcher3.util.rule.TestStabilityRule;
@@ -72,7 +72,7 @@
@Before
public void setUp() throws Exception {
super.setUp();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
executeOnLauncher(launcher -> {
RecentsView recentsView = launcher.getOverviewPanel();
recentsView.getPagedViewOrientedState().forceAllowRotationForTesting(true);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
index 234fe63..1e33635 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsSplitscreen.java
@@ -32,15 +32,14 @@
import com.android.launcher3.tapl.Overview;
import com.android.launcher3.tapl.Taskbar;
import com.android.launcher3.tapl.TaskbarAppIcon;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.rule.TestStabilityRule;
import com.android.quickstep.TaskbarModeSwitchRule.TaskbarModeSwitch;
import com.android.wm.shell.Flags;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,7 +57,7 @@
@Before
public void setUp() throws Exception {
super.setUp();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
if (mLauncher.isTablet()) {
mLauncher.enableBlockTimeout(true);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java
index 907dbcc..0eec8b7 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTrackpad.java
@@ -19,7 +19,6 @@
import static com.android.quickstep.NavigationModeSwitchRule.Mode.ZERO_BUTTON;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
@@ -32,8 +31,8 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.tapl.LauncherInstrumentation.TrackpadGestureType;
import com.android.launcher3.tapl.Workspace;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import org.junit.After;
@@ -51,7 +50,7 @@
@Before
public void setUp() throws Exception {
super.setUp();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
}
@After
diff --git a/quickstep/tests/src/com/android/quickstep/TaskViewTest.java b/quickstep/tests/src/com/android/quickstep/TaskViewTest.java
new file mode 100644
index 0000000..d744194
--- /dev/null
+++ b/quickstep/tests/src/com/android/quickstep/TaskViewTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.quickstep;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.pm.ApplicationInfo;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Rect;
+import android.util.DisplayMetrics;
+import android.view.MotionEvent;
+
+import androidx.test.filters.SmallTest;
+
+import com.android.launcher3.statemanager.StatefulActivity;
+import com.android.quickstep.util.BorderAnimator;
+import com.android.quickstep.views.TaskView;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@SmallTest
+public class TaskViewTest {
+
+ @Mock
+ private StatefulActivity mContext;
+ @Mock
+ private Resources mResource;
+ @Mock
+ private BorderAnimator mHoverAnimator;
+ @Mock
+ private BorderAnimator mFocusAnimator;
+ private TaskView mTaskView;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ when(mResource.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
+ when(mResource.getConfiguration()).thenReturn(new Configuration());
+
+ when(mContext.getResources()).thenReturn(mResource);
+ when(mContext.getTheme()).thenReturn(mock(Resources.Theme.class));
+ when(mContext.getApplicationInfo()).thenReturn(mock(ApplicationInfo.class));
+ when(mContext.obtainStyledAttributes(any(), any(), anyInt(), anyInt())).thenReturn(
+ mock(TypedArray.class));
+
+ mTaskView = new TaskView(mContext, null, 0, 0, mFocusAnimator, mHoverAnimator);
+ }
+
+ @Test
+ public void notShowBorderOnBorderDisabled() {
+ mTaskView.setBorderEnabled(/* enabled= */ false);
+ MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_ENTER, 0.0f, 0.0f, 0);
+ mTaskView.onHoverEvent(MotionEvent.obtain(event));
+ verify(mHoverAnimator, never()).setBorderVisibility(/* visible= */ true, /* animated= */
+ true);
+
+ mTaskView.onFocusChanged(false, 0, new Rect());
+ verify(mFocusAnimator, never()).setBorderVisibility(/* visible= */ true, /* animated= */
+ true);
+ }
+
+ @Test
+ public void showBorderOnBorderEnabled() {
+ mTaskView.setBorderEnabled(/* enabled= */ true);
+ MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_ENTER, 0.0f, 0.0f, 0);
+ mTaskView.onHoverEvent(MotionEvent.obtain(event));
+ verify(mHoverAnimator, times(1)).setBorderVisibility(/* visible= */ true, /* animated= */
+ true);
+ mTaskView.onFocusChanged(true, 0, new Rect());
+ verify(mFocusAnimator, times(1)).setBorderVisibility(/* visible= */ true, /* animated= */
+ true);
+ }
+
+ @Test
+ public void hideBorderOnBorderDisabled() {
+ mTaskView.setBorderEnabled(/* enabled= */ false);
+ verify(mHoverAnimator, times(1)).setBorderVisibility(/* visible= */ false, /* animated= */
+ true);
+ verify(mFocusAnimator, times(1)).setBorderVisibility(/* visible= */ false, /* animated= */
+ true);
+ }
+
+ @Test
+ public void notShowBorderByDefault() {
+ MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_ENTER, 0.0f, 0.0f, 0);
+ mTaskView.onHoverEvent(MotionEvent.obtain(event));
+ verify(mHoverAnimator, never()).setBorderVisibility(/* visible= */ false, /* animated= */
+ true);
+ mTaskView.onFocusChanged(true, 0, new Rect());
+ verify(mHoverAnimator, never()).setBorderVisibility(/* visible= */ false, /* animated= */
+ true);
+ }
+}
diff --git a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
index 8cc8487..2318f54 100644
--- a/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
+++ b/quickstep/tests/src/com/android/quickstep/ViewInflationDuringSwipeUp.java
@@ -56,7 +56,7 @@
import com.android.launcher3.testcomponent.ListViewService;
import com.android.launcher3.testcomponent.ListViewService.SimpleViewsFactory;
import com.android.launcher3.testcomponent.TestCommandReceiver;
-import com.android.launcher3.ui.TaplTestsLauncher3;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.TestViewHelpers;
import com.android.launcher3.util.Executors;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
@@ -102,7 +102,7 @@
// is started only after starting another app.
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
mModel = LauncherAppState.getInstance(mTargetContext).getModel();
Executors.MODEL_EXECUTOR.submit(mModel.getModelDbController()::createEmptyDB).get();
diff --git a/res/drawable/ic_drag_handle.xml b/res/drawable/ic_drag_handle.xml
deleted file mode 100644
index 9db75f4..0000000
--- a/res/drawable/ic_drag_handle.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/deep_shortcut_drag_handle_size"
- android:height="@dimen/deep_shortcut_drag_handle_size"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0"
- android:tint="?android:attr/textColorPrimary" >
-
- <path
- android:pathData="M20,9H4v2h16V9z M4,15h16v-2H4V15z"
- android:fillColor="@android:color/white" />
-</vector>
\ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 20e7089..8d84c90 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -164,7 +164,19 @@
<!-- numFolderRows & numFolderColumns defaults to numRows & numColumns, if not specified -->
<attr name="numFolderRows" format="integer" />
+ <!-- defaults to numFolderRows, if not specified -->
+ <attr name="numFolderRowsLandscape" format="integer" />
+ <!-- defaults to numFolderRows, if not specified -->
+ <attr name="numFolderRowsTwoPanelLandscape" format="integer" />
+ <!-- defaults to numFolderRows, if not specified -->
+ <attr name="numFolderRowsTwoPanelPortrait" format="integer" />
<attr name="numFolderColumns" format="integer" />
+ <!-- defaults to numFolderColumns, if not specified -->
+ <attr name="numFolderColumnsLandscape" format="integer" />
+ <!-- defaults to numFolderColumns, if not specified -->
+ <attr name="numFolderColumnsTwoPanelLandscape" format="integer" />
+ <!-- defaults to numFolderColumns, if not specified -->
+ <attr name="numFolderColumnsTwoPanelPortrait" format="integer" />
<!-- Support attributes in FolderStyle -->
<attr name="folderStyle" format="reference" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 6c9a238..137ffe8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -290,7 +290,6 @@
<dimen name="popup_single_item_radius">100dp</dimen>
<dimen name="popup_smaller_radius">4dp</dimen>
<dimen name="deep_shortcut_drawable_padding">16dp</dimen>
- <dimen name="deep_shortcut_drag_handle_size">16dp</dimen>
<dimen name="popup_padding_start">10dp</dimen>
<dimen name="popup_padding_end">14dp</dimen>
<dimen name="popup_vertical_padding">4dp</dimen>
@@ -430,6 +429,7 @@
<dimen name="split_instructions_drawable_padding">10dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_landscape">24dp</dimen>
<dimen name="split_instructions_bottom_margin_phone_portrait">60dp</dimen>
+ <dimen name="split_instructions_start_margin_cancel">8dp</dimen>
<!-- Workspace grid visualization parameters -->
<dimen name="grid_visualization_rounding_radius">28dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 7ca8b82..f277926 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -439,8 +439,8 @@
}
folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale);
- numFolderRows = inv.numFolderRows;
- numFolderColumns = inv.numFolderColumns;
+ numFolderRows = inv.numFolderRows[mTypeIndex];
+ numFolderColumns = inv.numFolderColumns[mTypeIndex];
if (mIsScalableGrid && inv.folderStyle != INVALID_RESOURCE_HANDLE) {
TypedArray folderStyle = context.obtainStyledAttributes(inv.folderStyle,
@@ -1002,6 +1002,9 @@
iconCenterVertically = mIsScalableGrid || mIsResponsiveGrid;
if (mIsResponsiveGrid) {
+ iconSizePx = mResponsiveWorkspaceCellSpec.getIconSize();
+ iconTextSizePx = mResponsiveWorkspaceCellSpec.getIconTextSize();
+ mIconDrawablePaddingOriginalPx = mResponsiveWorkspaceCellSpec.getIconDrawablePadding();
updateIconSize(1f, res);
updateWorkspacePadding();
return 0;
@@ -1096,10 +1099,6 @@
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
if (mIsResponsiveGrid) {
- iconSizePx = mResponsiveWorkspaceCellSpec.getIconSize();
- iconTextSizePx = mResponsiveWorkspaceCellSpec.getIconTextSize();
- mIconDrawablePaddingOriginalPx = mResponsiveWorkspaceCellSpec.getIconDrawablePadding();
-
cellWidthPx = mResponsiveWorkspaceWidthSpec.getCellSizePx();
cellHeightPx = mResponsiveWorkspaceHeightSpec.getCellSizePx();
diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java
index 01e65ae..a13dcc1 100644
--- a/src/com/android/launcher3/FastScrollRecyclerView.java
+++ b/src/com/android/launcher3/FastScrollRecyclerView.java
@@ -27,6 +27,7 @@
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.app.animation.Interpolators;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.views.RecyclerViewFastScroller;
@@ -194,12 +195,13 @@
}
/**
- * Scrolls this recycler view to the bottom.
+ * Scrolls this recycler view to the bottom with easing and duration.
*/
- public void scrollToBottom() {
+ public void scrollToBottomWithMotion() {
if (mScrollbar != null) {
mScrollbar.reattachThumbToScroll();
}
- smoothScrollToPosition(getAdapter().getItemCount() - 1);
+ // Emphasized interpolators with 500ms duration
+ smoothScrollBy(0, getAvailableScrollHeight(), Interpolators.EMPHASIZED, 500);
}
}
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 567d0c5..dfbbcaa 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -122,8 +122,8 @@
/**
* Number of icons per row and column in the folder.
*/
- public int numFolderRows;
- public int numFolderColumns;
+ public int[] numFolderRows;
+ public int[] numFolderColumns;
public float[] iconSize;
public float[] iconTextSize;
public int iconBitmapSize;
@@ -810,8 +810,8 @@
public final int numSearchContainerColumns;
public final int deviceCategory;
- private final int numFolderRows;
- private final int numFolderColumns;
+ private final int[] numFolderRows = new int[COUNT_SIZES];
+ private final int[] numFolderColumns = new int[COUNT_SIZES];
private final @StyleRes int folderStyle;
private final @StyleRes int cellStyle;
@@ -888,11 +888,39 @@
a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing,
R.dimen.taskbar_button_margin_default);
- numFolderRows = a.getInt(
+ numFolderRows[INDEX_DEFAULT] = a.getInt(
R.styleable.GridDisplayOption_numFolderRows, numRows);
- numFolderColumns = a.getInt(
+ numFolderColumns[INDEX_DEFAULT] = a.getInt(
R.styleable.GridDisplayOption_numFolderColumns, numColumns);
+ if (FeatureFlags.enableResponsiveWorkspace()) {
+ numFolderRows[INDEX_LANDSCAPE] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderRowsLandscape,
+ numFolderRows[INDEX_DEFAULT]);
+ numFolderColumns[INDEX_LANDSCAPE] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderColumnsLandscape,
+ numFolderColumns[INDEX_DEFAULT]);
+ numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderRowsTwoPanelPortrait,
+ numFolderRows[INDEX_DEFAULT]);
+ numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderColumnsTwoPanelPortrait,
+ numFolderColumns[INDEX_DEFAULT]);
+ numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderRowsTwoPanelLandscape,
+ numFolderRows[INDEX_DEFAULT]);
+ numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = a.getInt(
+ R.styleable.GridDisplayOption_numFolderColumnsTwoPanelLandscape,
+ numFolderColumns[INDEX_DEFAULT]);
+ } else {
+ numFolderRows[INDEX_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
+ numFolderColumns[INDEX_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
+ numFolderRows[INDEX_TWO_PANEL_PORTRAIT] = numFolderRows[INDEX_DEFAULT];
+ numFolderColumns[INDEX_TWO_PANEL_PORTRAIT] = numFolderColumns[INDEX_DEFAULT];
+ numFolderRows[INDEX_TWO_PANEL_LANDSCAPE] = numFolderRows[INDEX_DEFAULT];
+ numFolderColumns[INDEX_TWO_PANEL_LANDSCAPE] = numFolderColumns[INDEX_DEFAULT];
+ }
+
folderStyle = a.getResourceId(R.styleable.GridDisplayOption_folderStyle,
INVALID_RESOURCE_HANDLE);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 0099806..9f7575d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -528,6 +528,7 @@
mAppWidgetManager = new WidgetManagerHelper(this);
mAppWidgetHolder = createAppWidgetHolder();
mAppWidgetHolder.startListening();
+ mAppWidgetHolder.addProviderChangeListener(() -> refreshAndBindWidgetsForPackageUser(null));
mPopupDataProvider = new PopupDataProvider(this::updateNotificationDots);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 8ba6d2c..3f1ccb9 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -79,7 +79,6 @@
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import com.android.launcher3.graphics.TintedDrawableSpan;
-import com.android.launcher3.icons.BaseIconFactory;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.icons.ShortcutCachingLogic;
@@ -91,6 +90,7 @@
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.testing.shared.ResourceUtils;
+import com.android.launcher3.util.FlagOp;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.Themes;
@@ -676,12 +676,11 @@
}
if (badge == null) {
- try (LauncherIcons li = LauncherIcons.obtain(context)) {
- badge = BitmapInfo.LOW_RES_INFO.withFlags(
- li.getBitmapFlagOp(new BaseIconFactory.IconOptions().setUser(
- UserCache.INSTANCE.get(context).getUserInfo(info.user))))
- .getBadgeDrawable(context, useTheme);
- }
+ badge = BitmapInfo.LOW_RES_INFO.withFlags(
+ UserCache.INSTANCE.get(context)
+ .getUserInfo(info.user)
+ .applyBitmapInfoFlags(FlagOp.NO_OP))
+ .getBadgeDrawable(context, useTheme);
if (badge == null) {
badge = new ColorDrawable(Color.TRANSPARENT);
}
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index c9e5b1e..e5a223a 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -515,7 +515,7 @@
// Switch to the main tab
switchToTab(ActivityAllAppsContainerView.AdapterHolder.MAIN);
// Scroll to bottom
- getActiveRecyclerView().scrollToBottom();
+ getActiveRecyclerView().scrollToBottomWithMotion();
});
}
diff --git a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
index b7d8093..7deb653 100644
--- a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
+++ b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
@@ -38,8 +38,8 @@
mSeam = new View(cellLayout.getContext());
}
- private ItemConfiguration removeSeamFromSolution(
- ItemConfiguration solution) {
+ public ItemConfiguration removeSeamFromSolution(ItemConfiguration solution) {
+ solution.map.remove(mSeam);
solution.map.forEach((view, cell) -> cell.cellX =
cell.cellX > mCellLayout.getCountX() / 2 ? cell.cellX - 1 : cell.cellX);
solution.cellX =
@@ -48,9 +48,8 @@
}
@Override
- public ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY,
- int minSpanX, int minSpanY,
- int spanX, int spanY) {
+ public ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX,
+ int minSpanY, int spanX, int spanY) {
return removeSeamFromSolution(simulateSeam(
() -> super.closestEmptySpaceReorder(pixelX, pixelY, minSpanX, minSpanY, spanX,
spanY)));
diff --git a/src/com/android/launcher3/celllayout/ReorderAlgorithm.java b/src/com/android/launcher3/celllayout/ReorderAlgorithm.java
index 535dfe5..d098eba 100644
--- a/src/com/android/launcher3/celllayout/ReorderAlgorithm.java
+++ b/src/com/android/launcher3/celllayout/ReorderAlgorithm.java
@@ -66,6 +66,14 @@
public ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
ItemConfiguration solution) {
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY,
+ direction, dragView, decX, solution);
+ }
+
+
+ private ItemConfiguration findReorderSolutionRecursive(int pixelX, int pixelY,
+ int minSpanX, int minSpanY, int spanX, int spanY, int[] direction, View dragView,
+ boolean decX, ItemConfiguration solution) {
// Copy the current state into the solution. This solution will be manipulated as necessary.
mCellLayout.copyCurrentStateToSolution(solution);
// Copy the current occupied array into the temporary occupied array. This array will be
@@ -87,11 +95,11 @@
// We try shrinking the widget down to size in an alternating pattern, shrink 1 in
// x, then 1 in y etc.
if (spanX > minSpanX && (minSpanY == spanY || decX)) {
- return findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX - 1, spanY,
- direction, dragView, false, solution);
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX - 1,
+ spanY, direction, dragView, false, solution);
} else if (spanY > minSpanY) {
- return findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY - 1,
- direction, dragView, true, solution);
+ return findReorderSolutionRecursive(pixelX, pixelY, minSpanX, minSpanY, spanX,
+ spanY - 1, direction, dragView, true, solution);
}
solution.isSolution = false;
} else {
@@ -264,8 +272,7 @@
mCellLayout.getDirectionVectorForDrop(pixelX, pixelY, spanX, spanY, dragView,
mCellLayout.mDirectionVector);
- ItemConfiguration dropInPlaceSolution = dropInPlaceSolution(pixelX, pixelY,
- spanX, spanY,
+ ItemConfiguration dropInPlaceSolution = dropInPlaceSolution(pixelX, pixelY, spanX, spanY,
dragView);
// Find a solution involving pushing / displacing any items in the way
@@ -274,8 +281,8 @@
new ItemConfiguration());
// We attempt the approach which doesn't shuffle views at all
- ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(
- pixelX, pixelY, minSpanX, minSpanY, spanX, spanY);
+ ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(pixelX, pixelY, minSpanX,
+ minSpanY, spanX, spanY);
// If the reorder solution requires resizing (shrinking) the item being dropped, we instead
// favor a solution in which the item is not resized, but
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 14d1683..2a64eea 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -198,7 +198,7 @@
"Enables generating the reorder using a set of parameters");
public static final BooleanFlag ENABLE_NO_LONG_PRESS_DRAG = getDebugFlag(299748096,
- "ENABLE_NO_LONG_PRESS_DRAG", DISABLED,
+ "ENABLE_NO_LONG_PRESS_DRAG", ENABLED,
"Don't trigger the drag if we are still under long press");
// TODO(Block 12): Clean up flags
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index 5f73ced..9980218 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -860,6 +860,13 @@
}
/**
+ * Set the package name of the log message.
+ */
+ default StatsLogger withPackageName(@Nullable String packageName) {
+ return this;
+ }
+
+ /**
* Builds the final message and logs it as {@link EventEnum}.
*/
default void log(EventEnum event) {
diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java
index 9a0a6eb..4f2d398 100644
--- a/src/com/android/launcher3/model/PackageUpdatedTask.java
+++ b/src/com/android/launcher3/model/PackageUpdatedTask.java
@@ -34,7 +34,6 @@
import androidx.annotation.NonNull;
import com.android.launcher3.Flags;
-import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
@@ -136,14 +135,6 @@
iconCache.updateIconsForPkg(packages[i], mUser);
activitiesLists.put(
packages[i], appsList.updatePackage(context, packages[i], mUser));
-
- // The update may have changed which shortcuts/widgets are available.
- // Refresh the widgets for the package if we have an activity running.
- Launcher launcher = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
- if (launcher != null) {
- launcher.refreshAndBindWidgetsForPackageUser(
- new PackageUserKey(packages[i], mUser));
- }
}
}
// Since package was just updated, the target must be available now.
diff --git a/src/com/android/launcher3/responsive/HotseatSpecsProvider.kt b/src/com/android/launcher3/responsive/HotseatSpecsProvider.kt
index 8e3a5b4..ebbff51 100644
--- a/src/com/android/launcher3/responsive/HotseatSpecsProvider.kt
+++ b/src/com/android/launcher3/responsive/HotseatSpecsProvider.kt
@@ -26,6 +26,7 @@
class HotseatSpecsProvider(groupOfSpecs: List<ResponsiveSpecGroup<HotseatSpec>>) {
private val groupOfSpecs: List<ResponsiveSpecGroup<HotseatSpec>>
+
init {
this.groupOfSpecs = groupOfSpecs.sortedBy { it.aspectRatio }
}
@@ -90,13 +91,18 @@
fun isValid(): Boolean {
if (maxAvailableSize <= 0) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - maxAvailableSize <= 0")
+ logError("The property maxAvailableSize must be higher than 0.")
return false
}
// All specs need to be individually valid
if (!allSpecsAreValid()) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - !allSpecsAreValid()")
+ logError("One or more specs are invalid!")
+ return false
+ }
+
+ if (!isValidFixedSize()) {
+ logError("The total Fixed Size used must be lower or equal to $maxAvailableSize.")
return false
}
@@ -110,6 +116,13 @@
edgePadding.onlyFixedSize()
}
+ private fun isValidFixedSize() =
+ hotseatQsbSpace.fixedSize + edgePadding.fixedSize <= maxAvailableSize
+
+ private fun logError(message: String) {
+ Log.e(LOG_TAG, "${this::class.simpleName}#isValid - $message - $this")
+ }
+
companion object {
private const val LOG_TAG = "HotseatSpec"
}
diff --git a/src/com/android/launcher3/responsive/ResponsiveCellSpecsProvider.kt b/src/com/android/launcher3/responsive/ResponsiveCellSpecsProvider.kt
index affca60..a4b25e5 100644
--- a/src/com/android/launcher3/responsive/ResponsiveCellSpecsProvider.kt
+++ b/src/com/android/launcher3/responsive/ResponsiveCellSpecsProvider.kt
@@ -107,25 +107,39 @@
fun isValid(): Boolean {
if (maxAvailableSize <= 0) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - maxAvailableSize <= 0")
+ logError("The property maxAvailableSize must be higher than 0.")
return false
}
// All specs need to be individually valid
if (!allSpecsAreValid()) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - !allSpecsAreValid()")
+ logError("Specs must be either Fixed Size or Match Workspace!")
+ return false
+ }
+
+ if (!isValidFixedSize()) {
+ logError("The total Fixed Size used must be lower or equal to $maxAvailableSize.")
return false
}
return true
}
+ private fun isValidFixedSize(): Boolean {
+ val totalSize = iconSize.fixedSize + iconTextSize.fixedSize + iconDrawablePadding.fixedSize
+ return totalSize <= maxAvailableSize
+ }
+
private fun allSpecsAreValid(): Boolean {
return (iconSize.fixedSize > 0f || iconSize.matchWorkspace) &&
(iconTextSize.fixedSize >= 0f || iconTextSize.matchWorkspace) &&
(iconDrawablePadding.fixedSize >= 0f || iconDrawablePadding.matchWorkspace)
}
+ private fun logError(message: String) {
+ Log.e(LOG_TAG, "${this::class.simpleName}#isValid - $message - $this")
+ }
+
companion object {
private const val LOG_TAG = "CellSpec"
}
diff --git a/src/com/android/launcher3/responsive/ResponsiveSpec.kt b/src/com/android/launcher3/responsive/ResponsiveSpec.kt
index 32dedfb..b0e1b27 100644
--- a/src/com/android/launcher3/responsive/ResponsiveSpec.kt
+++ b/src/com/android/launcher3/responsive/ResponsiveSpec.kt
@@ -90,18 +90,33 @@
gutter.matchWorkspace ||
cellSize.matchWorkspace)
) {
- Log.e(LOG_TAG, "WorkspaceSpec#isValid - workspace shouldn't contain matchWorkspace!")
+ logError("Workspace spec provided must not have any match workspace value.")
return false
}
if (maxAvailableSize <= 0) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - maxAvailableSize <= 0")
+ logError("The property maxAvailableSize must be higher than 0.")
return false
}
// All specs need to be individually valid
if (!allSpecsAreValid()) {
- Log.e(LOG_TAG, "${this::class.simpleName}#isValid - !allSpecsAreValid()")
+ logError("One or more specs are invalid!")
+ return false
+ }
+
+ if (!isValidRemainderSpace()) {
+ logError("The total Remainder Space used must be lower or equal to 100%.")
+ return false
+ }
+
+ if (!isValidAvailableSpace()) {
+ logError("The total Available Space used must be lower or equal to 100%.")
+ return false
+ }
+
+ if (!isValidFixedSize()) {
+ logError("The total Fixed Size used must be lower or equal to $maxAvailableSize.")
return false
}
@@ -115,6 +130,32 @@
cellSize.isValid()
}
+ private fun isValidRemainderSpace(): Boolean {
+ // TODO(b/313621277): This validation must be update do accept only 0 or 1 instead of <= 1f.
+ return startPadding.ofRemainderSpace +
+ endPadding.ofRemainderSpace +
+ gutter.ofRemainderSpace +
+ cellSize.ofRemainderSpace <= 1f
+ }
+
+ private fun isValidAvailableSpace(): Boolean {
+ return startPadding.ofAvailableSpace +
+ endPadding.ofAvailableSpace +
+ gutter.ofAvailableSpace +
+ cellSize.ofAvailableSpace < 1f
+ }
+
+ private fun isValidFixedSize(): Boolean {
+ return startPadding.fixedSize +
+ endPadding.fixedSize +
+ gutter.fixedSize +
+ cellSize.fixedSize <= maxAvailableSize
+ }
+
+ private fun logError(message: String) {
+ Log.e(LOG_TAG, "${this::class.simpleName}#isValid - $message - $this")
+ }
+
enum class DimensionType {
HEIGHT,
WIDTH
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
index ad3f8df..ded2cee 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
@@ -17,13 +17,11 @@
package com.android.launcher3.shortcuts;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.widget.Toast;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
@@ -33,11 +31,6 @@
* A {@link BubbleTextView} that has the shortcut icon on the left and drag handle on the right.
*/
public class DeepShortcutTextView extends BubbleTextView {
- private final Rect mDragHandleBounds = new Rect();
- private final int mDragHandleWidth;
- private boolean mShowInstructionToast = false;
-
- private Toast mInstructionToast;
private boolean mShowLoadingState;
private Drawable mLoadingStatePlaceholder;
@@ -53,23 +46,12 @@
public DeepShortcutTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- Resources resources = getResources();
- mDragHandleWidth = resources.getDimensionPixelSize(R.dimen.popup_padding_end)
- + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drag_handle_size)
- + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drawable_padding) / 2;
showLoadingState(true);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- mDragHandleBounds.set(0, 0, mDragHandleWidth, getMeasuredHeight());
- if (!Utilities.isRtl(getResources())) {
- mDragHandleBounds.offset(getMeasuredWidth() - mDragHandleBounds.width(), 0);
- }
-
setLoadingBounds();
}
@@ -80,10 +62,10 @@
mLoadingStateBounds.set(
0,
0,
- getMeasuredWidth() - mDragHandleWidth - getPaddingStart(),
+ getMeasuredWidth() - getPaddingEnd() - getPaddingStart(),
mLoadingStatePlaceholder.getIntrinsicHeight());
mLoadingStateBounds.offset(
- Utilities.isRtl(getResources()) ? mDragHandleWidth : getPaddingStart(),
+ Utilities.isRtl(getResources()) ? getPaddingEnd() : getPaddingStart(),
(int) ((getMeasuredHeight() - mLoadingStatePlaceholder.getIntrinsicHeight())
/ 2.0f)
);
@@ -106,23 +88,11 @@
@Override
protected boolean shouldIgnoreTouchDown(float x, float y) {
- // Show toast if user touches the drag handle (long clicks still start the drag).
- mShowInstructionToast = mDragHandleBounds.contains((int) x, (int) y);
-
// assume the whole view as clickable
return false;
}
@Override
- public boolean performClick() {
- if (mShowInstructionToast) {
- showToast();
- return true;
- }
- return super.performClick();
- }
-
- @Override
public void onDraw(Canvas canvas) {
if (!mShowLoadingState) {
super.onDraw(canvas);
@@ -155,15 +125,4 @@
invalidate();
}
-
- private void showToast() {
- if (mInstructionToast != null) {
- mInstructionToast.cancel();
- }
- CharSequence msg = Utilities.wrapForTts(
- getContext().getText(R.string.long_press_shortcut_to_add),
- getContext().getString(R.string.long_accessible_way_to_add_shortcut));
- mInstructionToast = Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT);
- mInstructionToast.show();
- }
}
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index db32829..3bce377 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -61,7 +61,10 @@
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.views.FloatingIconView;
+import com.android.launcher3.views.Snackbar;
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
+import com.android.launcher3.widget.PendingAddShortcutInfo;
+import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.PendingAppWidgetHostView;
import com.android.launcher3.widget.WidgetAddFlowHandler;
import com.android.launcher3.widget.WidgetManagerHelper;
@@ -107,6 +110,16 @@
}
} else if (tag instanceof ItemClickProxy) {
((ItemClickProxy) tag).onItemClicked(v);
+ } else if (tag instanceof PendingAddShortcutInfo) {
+ CharSequence msg = Utilities.wrapForTts(
+ launcher.getText(R.string.long_press_shortcut_to_add),
+ launcher.getString(R.string.long_accessible_way_to_add_shortcut));
+ Snackbar.show(launcher, msg, null);
+ } else if (tag instanceof PendingAddWidgetInfo) {
+ CharSequence msg = Utilities.wrapForTts(
+ launcher.getText(R.string.long_press_widget_to_add),
+ launcher.getString(R.string.long_accessible_way_to_add));
+ Snackbar.show(launcher, msg, null);
}
}
diff --git a/src/com/android/launcher3/touch/ItemLongClickListener.java b/src/com/android/launcher3/touch/ItemLongClickListener.java
index 96cc412..9e7d4dc 100644
--- a/src/com/android/launcher3/touch/ItemLongClickListener.java
+++ b/src/com/android/launcher3/touch/ItemLongClickListener.java
@@ -24,9 +24,12 @@
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_ITEM_LONG_PRESSED;
+import android.graphics.Point;
+import android.graphics.Rect;
import android.view.View;
import android.view.View.OnLongClickListener;
+import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.Launcher;
import com.android.launcher3.celllayout.CellInfo;
@@ -40,6 +43,10 @@
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.views.BubbleTextHolder;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
+import com.android.launcher3.widget.NavigableAppWidgetHostView;
+import com.android.launcher3.widget.PendingItemDragHelper;
+import com.android.launcher3.widget.WidgetCell;
+import com.android.launcher3.widget.WidgetImageView;
/**
* Class to handle long-clicks on workspace items and start drag as a result.
@@ -91,7 +98,46 @@
launcher.getWorkspace().startDrag(longClickCellInfo, dragOptions);
}
+ private static boolean onWidgetItemLongClick(WidgetCell v) {
+ // Get the widget preview as the drag representation
+ WidgetImageView image = v.getWidgetView();
+ Launcher launcher = Launcher.getLauncher(v.getContext());
+ DragSource dragSource = (target, dragObject, success) -> { };
+
+ // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
+ // we abort the drag.
+ if (image.getDrawable() == null && v.getAppWidgetHostViewPreview() == null) {
+ return false;
+ }
+
+ PendingItemDragHelper dragHelper = new PendingItemDragHelper(v);
+ // RemoteViews are being rendered in AppWidgetHostView in WidgetCell. And thus, the scale of
+ // RemoteViews is equivalent to the AppWidgetHostView scale.
+ dragHelper.setRemoteViewsPreview(v.getRemoteViewsPreview(), v.getAppWidgetHostViewScale());
+ dragHelper.setAppWidgetHostViewPreview(v.getAppWidgetHostViewPreview());
+
+ if (image.getDrawable() != null) {
+ int[] loc = new int[2];
+ launcher.getDragLayer().getLocationInDragLayer(image, loc);
+
+ dragHelper.startDrag(image.getBitmapBounds(), image.getDrawable().getIntrinsicWidth(),
+ image.getWidth(), new Point(loc[0], loc[1]), dragSource, new DragOptions());
+ } else {
+ NavigableAppWidgetHostView preview = v.getAppWidgetHostViewPreview();
+ int[] loc = new int[2];
+ launcher.getDragLayer().getLocationInDragLayer(preview, loc);
+ Rect r = new Rect();
+ preview.getWorkspaceVisualDragBounds(r);
+ dragHelper.startDrag(r, preview.getMeasuredWidth(), preview.getMeasuredWidth(),
+ new Point(loc[0], loc[1]), dragSource, new DragOptions());
+ }
+ return true;
+ }
+
private static boolean onAllAppsItemLongClick(View view) {
+ if (view instanceof WidgetCell wc) {
+ return onWidgetItemLongClick(wc);
+ }
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onAllAppsItemLongClick");
view.cancelLongPress();
View v = (view instanceof BubbleTextHolder)
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index a005c60..5b6c9e0 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -25,11 +25,9 @@
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_CLOSE_TAP_OUTSIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_LONGPRESS;
-import static com.android.launcher3.testing.shared.TestProtocol.WORKSPACE_LONG_PRESS;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.util.Log;
import android.view.GestureDetector;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
@@ -41,7 +39,6 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
-import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
@@ -112,10 +109,6 @@
mTouchDownPoint.set(ev.getX(), ev.getY());
// Mouse right button's ACTION_DOWN should immediately show menu
if (TouchUtil.isMouseRightClickDownOrMove(ev)) {
- if (Utilities.isRunningInTestHarness()) {
- Log.d(WORKSPACE_LONG_PRESS, "longPress from mouseHandling timeout: +"
- + ViewConfiguration.getLongPressTimeout());
- }
maybeShowMenu();
return true;
}
@@ -199,10 +192,6 @@
@Override
public void onLongPress(MotionEvent event) {
- if (Utilities.isRunningInTestHarness()) {
- Log.d(WORKSPACE_LONG_PRESS, "longPress from gestureHandler timeout: " +
- ViewConfiguration.getLongPressTimeout());
- }
maybeShowMenu();
}
diff --git a/src/com/android/launcher3/util/Preconditions.java b/src/com/android/launcher3/util/Preconditions.java
index 63d56e4..0e5ab9a 100644
--- a/src/com/android/launcher3/util/Preconditions.java
+++ b/src/com/android/launcher3/util/Preconditions.java
@@ -51,6 +51,12 @@
}
}
+ public static void assertTrue(boolean condition) {
+ if (FeatureFlags.IS_STUDIO_BUILD && !condition) {
+ throw new IllegalStateException();
+ }
+ }
+
private static boolean isSameLooper(Looper looper) {
return Looper.myLooper() == looper;
}
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index 20bcc3c..bef84f7 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -53,6 +53,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.view.WindowInsetsCompat;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
@@ -315,6 +316,25 @@
}
/**
+ * Returns if the software keyboard is hidden. Hardware keyboards do not display on screen by
+ * default.
+ */
+ default boolean isSoftwareKeyboardHidden() {
+ if (isHardwareKeyboard()) {
+ return true;
+ } else {
+ View dragLayer = getDragLayer();
+ WindowInsets insets = dragLayer.getRootWindowInsets();
+ if (insets == null) {
+ return false;
+ }
+ WindowInsetsCompat insetsCompat =
+ WindowInsetsCompat.toWindowInsetsCompat(insets, dragLayer);
+ return !insetsCompat.isVisible(WindowInsetsCompat.Type.ime());
+ }
+ }
+
+ /**
* Sends a pending intent animating from a view.
*
* @param v View to animate.
diff --git a/src/com/android/launcher3/views/Snackbar.java b/src/com/android/launcher3/views/Snackbar.java
index 99040ff..54aa6e4 100644
--- a/src/com/android/launcher3/views/Snackbar.java
+++ b/src/com/android/launcher3/views/Snackbar.java
@@ -66,8 +66,8 @@
}
/** Show a snackbar with just a label. */
- public static <T extends Context & ActivityContext> void show(T activity, String labelString,
- Runnable onDismissed) {
+ public static void show(
+ ActivityContext activity, CharSequence labelString, Runnable onDismissed) {
show(activity, labelString, NO_ID, onDismissed, null);
}
@@ -76,21 +76,21 @@
int actionStringResId, Runnable onDismissed, @Nullable Runnable onActionClicked) {
show(
activity,
- activity.getResources().getString(labelStringResId),
+ activity.getResources().getText(labelStringResId),
actionStringResId,
onDismissed,
onActionClicked);
}
/** Show a snackbar with a label and action. */
- public static <T extends Context & ActivityContext> void show(T activity, String labelString,
+ public static void show(ActivityContext activity, CharSequence labelString,
int actionStringResId, Runnable onDismissed, @Nullable Runnable onActionClicked) {
closeOpenViews(activity, true, TYPE_SNACKBAR);
- Snackbar snackbar = new Snackbar(activity, null);
+ Snackbar snackbar = new Snackbar((Context) activity, null);
// Set some properties here since inflated xml only contains the children.
snackbar.setOrientation(HORIZONTAL);
snackbar.setGravity(Gravity.CENTER_VERTICAL);
- Resources res = activity.getResources();
+ Resources res = snackbar.getResources();
snackbar.setElevation(res.getDimension(R.dimen.snackbar_elevation));
int padding = res.getDimensionPixelSize(R.dimen.snackbar_padding);
snackbar.setPadding(padding, padding, padding, padding);
@@ -143,7 +143,8 @@
actionView.setVisibility(GONE);
}
- int totalContentWidth = (int) (labelView.getPaint().measureText(labelString) + actionWidth)
+ int totalContentWidth = (int) (labelView.getPaint().measureText(labelString.toString())
+ + actionWidth)
+ labelView.getPaddingRight() + labelView.getPaddingLeft()
+ padding * 2;
if (totalContentWidth > params.width) {
@@ -177,7 +178,7 @@
.setDuration(SHOW_DURATION_MS)
.setInterpolator(Interpolators.ACCELERATE_DECELERATE)
.start();
- int timeout = AccessibilityManagerCompat.getRecommendedTimeoutMillis(activity,
+ int timeout = AccessibilityManagerCompat.getRecommendedTimeoutMillis(snackbar.getContext(),
TIMEOUT_DURATION_MS, FLAG_CONTENT_TEXT | FLAG_CONTENT_CONTROLS);
snackbar.postDelayed(() -> snackbar.close(true), timeout);
}
diff --git a/src/com/android/launcher3/views/WidgetsEduView.java b/src/com/android/launcher3/views/WidgetsEduView.java
index e70b1cb..40c6115 100644
--- a/src/com/android/launcher3/views/WidgetsEduView.java
+++ b/src/com/android/launcher3/views/WidgetsEduView.java
@@ -20,15 +20,15 @@
import android.util.AttributeSet;
import android.view.LayoutInflater;
+import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Insettable;
-import com.android.launcher3.Launcher;
import com.android.launcher3.R;
/**
* Education view about widgets.
*/
-public class WidgetsEduView extends AbstractSlideInView<Launcher> implements Insettable {
+public class WidgetsEduView extends AbstractSlideInView<BaseActivity> implements Insettable {
private static final int DEFAULT_CLOSE_DURATION = 200;
@@ -124,10 +124,10 @@
}
/** Shows widget education dialog. */
- public static WidgetsEduView showEducationDialog(Launcher launcher) {
- LayoutInflater layoutInflater = LayoutInflater.from(launcher);
+ public static WidgetsEduView showEducationDialog(BaseActivity activity) {
+ LayoutInflater layoutInflater = LayoutInflater.from(activity);
WidgetsEduView v = (WidgetsEduView) layoutInflater.inflate(
- R.layout.widgets_edu, launcher.getDragLayer(), false);
+ R.layout.widgets_edu, activity.getDragLayer(), false);
v.show();
return v;
}
diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java
index fc9c774..5ec1022 100644
--- a/src/com/android/launcher3/widget/BaseWidgetSheet.java
+++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
@@ -29,47 +28,39 @@
import android.view.View.OnLongClickListener;
import android.view.WindowInsets;
import android.view.animation.Interpolator;
-import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.core.view.ViewCompat;
+import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
-import com.android.launcher3.DragSource;
-import com.android.launcher3.DropTarget.DragObject;
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
-import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.window.WindowManagerProxy;
import com.android.launcher3.views.AbstractSlideInView;
-import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.ArrowTipView;
/**
* Base class for various widgets popup
*/
-public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
- implements OnClickListener, OnLongClickListener, DragSource,
+public abstract class BaseWidgetSheet extends AbstractSlideInView<BaseActivity>
+ implements OnClickListener, OnLongClickListener,
PopupDataProvider.PopupDataChangeListener, Insettable, OnDeviceProfileChangeListener {
/** The default number of cells that can fit horizontally in a widget sheet. */
public static final int DEFAULT_MAX_HORIZONTAL_SPANS = 4;
protected final Rect mInsets = new Rect();
- /* Touch handling related member variables. */
- private Toast mWidgetInstructionToast;
-
@Px protected int mContentHorizontalMargin;
@Px protected int mWidgetCellHorizontalPadding;
@@ -118,32 +109,30 @@
@Override
public final void onClick(View v) {
- Object tag = null;
if (v instanceof WidgetCell) {
- tag = v.getTag();
- } else if (v.getParent() instanceof WidgetCell) {
- tag = ((WidgetCell) v.getParent()).getTag();
+ mActivityContext.getItemOnClickListener().onClick(v);
+ } else if (v.getParent() instanceof WidgetCell wc) {
+ mActivityContext.getItemOnClickListener().onClick(wc);
}
- if (tag instanceof PendingAddShortcutInfo) {
- mWidgetInstructionToast = showShortcutToast(getContext(), mWidgetInstructionToast);
- } else {
- mWidgetInstructionToast = showWidgetToast(getContext(), mWidgetInstructionToast);
- }
-
}
@Override
public boolean onLongClick(View v) {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Widgets.onLongClick");
v.cancelLongPress();
- if (!ItemLongClickListener.canStartDrag(mActivityContext)) return false;
+ boolean result;
if (v instanceof WidgetCell) {
- return beginDraggingWidget((WidgetCell) v);
- } else if (v.getParent() instanceof WidgetCell) {
- return beginDraggingWidget((WidgetCell) v.getParent());
+ result = mActivityContext.getAllAppsItemLongClickListener().onLongClick(v);
+ } else if (v.getParent() instanceof WidgetCell wc) {
+ result = mActivityContext.getAllAppsItemLongClickListener().onLongClick(wc);
+ } else {
+ return true;
}
- return true;
+ if (result) {
+ close(true);
+ }
+ return result;
}
@Override
@@ -212,55 +201,12 @@
MeasureSpec.getSize(heightMeasureSpec));
}
- private boolean beginDraggingWidget(WidgetCell v) {
- // Get the widget preview as the drag representation
- WidgetImageView image = v.getWidgetView();
-
- // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
- // we abort the drag.
- if (image.getDrawable() == null && v.getAppWidgetHostViewPreview() == null) {
- return false;
- }
-
- PendingItemDragHelper dragHelper = new PendingItemDragHelper(v);
- // RemoteViews are being rendered in AppWidgetHostView in WidgetCell. And thus, the scale of
- // RemoteViews is equivalent to the AppWidgetHostView scale.
- dragHelper.setRemoteViewsPreview(v.getRemoteViewsPreview(), v.getAppWidgetHostViewScale());
- dragHelper.setAppWidgetHostViewPreview(v.getAppWidgetHostViewPreview());
-
- if (image.getDrawable() != null) {
- int[] loc = new int[2];
- getPopupContainer().getLocationInDragLayer(image, loc);
-
- dragHelper.startDrag(image.getBitmapBounds(), image.getDrawable().getIntrinsicWidth(),
- image.getWidth(), new Point(loc[0], loc[1]), this, new DragOptions());
- } else {
- NavigableAppWidgetHostView preview = v.getAppWidgetHostViewPreview();
- int[] loc = new int[2];
- getPopupContainer().getLocationInDragLayer(preview, loc);
- Rect r = new Rect();
- preview.getWorkspaceVisualDragBounds(r);
- dragHelper.startDrag(r, preview.getMeasuredWidth(), preview.getMeasuredWidth(),
- new Point(loc[0], loc[1]), this, new DragOptions());
- }
- close(true);
- return true;
- }
-
@Override
protected Interpolator getIdleInterpolator() {
return mActivityContext.getDeviceProfile().isTablet
? EMPHASIZED : super.getIdleInterpolator();
}
- //
- // Drag related handling methods that implement {@link DragSource} interface.
- //
-
- @Override
- public void onDropCompleted(View target, DragObject d, boolean success) { }
-
-
protected void onCloseComplete() {
super.onCloseComplete();
clearNavBarColor();
@@ -282,40 +228,6 @@
return mActivityContext.getSystemUiController();
}
- /**
- * Show Widget tap toast prompting user to drag instead
- */
- public static Toast showWidgetToast(Context context, Toast toast) {
- // Let the user know that they have to long press to add a widget
- if (toast != null) {
- toast.cancel();
- }
-
- CharSequence msg = Utilities.wrapForTts(
- context.getText(R.string.long_press_widget_to_add),
- context.getString(R.string.long_accessible_way_to_add));
- toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
- toast.show();
- return toast;
- }
-
- /**
- * Show shortcut tap toast prompting user to drag instead.
- */
- private static Toast showShortcutToast(Context context, Toast toast) {
- // Let the user know that they have to long press to add a widget
- if (toast != null) {
- toast.cancel();
- }
-
- CharSequence msg = Utilities.wrapForTts(
- context.getText(R.string.long_press_shortcut_to_add),
- context.getString(R.string.long_accessible_way_to_add_shortcut));
- toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
- toast.show();
- return toast;
- }
-
/** Shows education tip on top center of {@code view} if view is laid out. */
@Nullable
protected ArrowTipView showEducationTipOnViewIfPossible(@Nullable View view) {
@@ -344,7 +256,8 @@
@Override
protected void setTranslationShift(float translationShift) {
super.setTranslationShift(translationShift);
- Launcher launcher = ActivityContext.lookupContext(getContext());
- launcher.onWidgetsTransition(1 - translationShift);
+ if (mActivityContext instanceof Launcher ls) {
+ ls.onWidgetsTransition(1 - translationShift);
+ }
}
}
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index af77d03..953ecda 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -55,8 +55,9 @@
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.RecyclerView;
+import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -72,7 +73,6 @@
import com.android.launcher3.views.StickyHeaderLayout;
import com.android.launcher3.views.WidgetsEduView;
import com.android.launcher3.widget.BaseWidgetSheet;
-import com.android.launcher3.widget.LauncherWidgetHolder.ProviderChangedListener;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.picker.search.SearchModeListener;
import com.android.launcher3.widget.picker.search.WidgetsSearchBar;
@@ -89,7 +89,7 @@
* Popup for showing the full list of available widgets
*/
public class WidgetsFullSheet extends BaseWidgetSheet
- implements ProviderChangedListener, OnActivePageChangedListener,
+ implements OnActivePageChangedListener,
WidgetsRecyclerView.HeaderViewDimensionsProvider, SearchModeListener {
private static final long FADE_IN_DURATION = 150;
@@ -166,7 +166,7 @@
private boolean mIsInSearchMode;
private boolean mIsNoWidgetsViewNeeded;
@Px private int mMaxSpanPerRow;
- private DeviceProfile mDeviceProfile;
+ private final DeviceProfile mDeviceProfile;
private int mOrientation;
@@ -181,7 +181,7 @@
public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- mDeviceProfile = Launcher.getLauncher(context).getDeviceProfile();
+ mDeviceProfile = mActivityContext.getDeviceProfile();
mHasWorkProfile = context.getSystemService(LauncherApps.class).getProfiles().size() > 1;
mOrientation = context.getResources().getConfiguration().orientation;
mAdapters.put(AdapterHolder.PRIMARY, new AdapterHolder(AdapterHolder.PRIMARY));
@@ -353,15 +353,14 @@
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- mActivityContext.getAppWidgetHolder().addProviderChangeListener(this);
- notifyWidgetProvidersChanged();
+ LauncherAppState.getInstance(mActivityContext).getModel()
+ .refreshAndBindWidgetsAndShortcuts(null);
onRecommendedWidgetsBound();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- mActivityContext.getAppWidgetHolder().removeProviderChangeListener(this);
mAdapters.get(AdapterHolder.PRIMARY).mWidgetsRecyclerView
.removeOnAttachStateChangeListener(mBindScrollbarInSearchMode);
if (mHasWorkProfile) {
@@ -482,11 +481,6 @@
}
@Override
- public void notifyWidgetProvidersChanged() {
- mActivityContext.refreshAndBindWidgetsForPackageUser(null);
- }
-
- @Override
public void onWidgetsBound() {
if (mIsInSearchMode) {
return;
@@ -682,22 +676,22 @@
}
/** Shows the {@link WidgetsFullSheet} on the launcher. */
- public static WidgetsFullSheet show(Launcher launcher, boolean animate) {
- boolean isTwoPane = launcher.getDeviceProfile().isTablet
- && launcher.getDeviceProfile().isLandscape
- && (!launcher.getDeviceProfile().isTwoPanels
+ public static WidgetsFullSheet show(BaseActivity activity, boolean animate) {
+ boolean isTwoPane = activity.getDeviceProfile().isTablet
+ && activity.getDeviceProfile().isLandscape
+ && (!activity.getDeviceProfile().isTwoPanels
|| FeatureFlags.UNFOLDED_WIDGET_PICKER.get());
WidgetsFullSheet sheet;
if (isTwoPane) {
- sheet = (WidgetsTwoPaneSheet) launcher.getLayoutInflater().inflate(
+ sheet = (WidgetsTwoPaneSheet) activity.getLayoutInflater().inflate(
R.layout.widgets_two_pane_sheet,
- launcher.getDragLayer(),
+ activity.getDragLayer(),
false);
} else {
- sheet = (WidgetsFullSheet) launcher.getLayoutInflater().inflate(
+ sheet = (WidgetsFullSheet) activity.getLayoutInflater().inflate(
R.layout.widgets_full_sheet,
- launcher.getDragLayer(),
+ activity.getDragLayer(),
false);
}
@@ -754,7 +748,7 @@
/** Gets the {@link WidgetsRecyclerView} which shows all widgets in {@link WidgetsFullSheet}. */
@VisibleForTesting
- public static WidgetsRecyclerView getWidgetsView(Launcher launcher) {
+ public static WidgetsRecyclerView getWidgetsView(BaseActivity launcher) {
return launcher.findViewById(R.id.primary_widgets_list_view);
}
@@ -803,7 +797,7 @@
mOrientation = newConfig.orientation;
if (mDeviceProfile.isTablet && !mDeviceProfile.isTwoPanels) {
handleClose(false);
- show(Launcher.getLauncher(getContext()), false);
+ show(BaseActivity.fromContext(getContext()), false);
} else {
reset();
}
diff --git a/tests/res/xml/invalid_cell_specs_3.xml b/tests/res/xml/invalid_cell_specs_3.xml
new file mode 100644
index 0000000..8f8e42b
--- /dev/null
+++ b/tests/res/xml/invalid_cell_specs_3.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+<!-- invalid: total fixedSize > maxAvailableSize -->
+<cellSpecs xmlns:launcher="http://schemas.android.com/apk/res-auto">
+ <!-- portrait -->
+ <specs launcher:maxAspectRatio="1.0">
+ <cellSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <iconDrawablePadding launcher:ofAvailableSpace="0.0125" />
+ <iconSize launcher:fixedSize="48dp" />
+ <iconTextSize launcher:fixedSize="12sp" />
+ </cellSpec>
+ </specs>
+ <!-- landscape -->
+ <specs launcher:maxAspectRatio="10">
+ <cellSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <iconDrawablePadding launcher:fixedSize="9999dp" />
+ <iconSize launcher:ofAvailableSpace="0.0125" />
+ <iconTextSize launcher:fixedSize="1dp" />
+ </cellSpec>
+ </specs>
+</cellSpecs>
\ No newline at end of file
diff --git a/tests/res/xml/invalid_hotseat_file_case_2.xml b/tests/res/xml/invalid_hotseat_file_case_2.xml
new file mode 100644
index 0000000..fbf40ef
--- /dev/null
+++ b/tests/res/xml/invalid_hotseat_file_case_2.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+<!-- invalid: total fixed size > maxAvailableSize -->
+<hotseatSpecs xmlns:launcher="http://schemas.android.com/apk/res-auto">
+ <specs launcher:maxAspectRatio="10">
+ <hotseatSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="847dp">
+ <hotseatQsbSpace launcher:fixedSize="845dp" />
+ <edgePadding launcher:fixedSize="36dp" />
+ </hotseatSpec>
+
+ <hotseatSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <hotseatQsbSpace launcher:fixedSize="36dp" />
+ <edgePadding launcher:fixedSize="36dp" />
+ </hotseatSpec>
+ </specs>
+</hotseatSpecs>
\ No newline at end of file
diff --git a/tests/res/xml/invalid_responsive_spec_4.xml b/tests/res/xml/invalid_responsive_spec_4.xml
new file mode 100644
index 0000000..e9d510e
--- /dev/null
+++ b/tests/res/xml/invalid_responsive_spec_4.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+<!-- invalid file - remainder space > 1 (it must be lower or equal 1) -->
+<workspaceSpecs xmlns:launcher="http://schemas.android.com/apk/res-auto">
+ <specs launcher:maxAspectRatio="10">
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="34dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="371dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="24dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="716dp">
+ <startPadding launcher:fixedSize="16dp" />
+ <endPadding launcher:fixedSize="64dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="36dp" />
+ <endPadding launcher:fixedSize="80dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="602dp">
+ <startPadding launcher:ofRemainderSpace=".5" />
+ <endPadding launcher:ofRemainderSpace=".5" />
+ <gutter launcher:ofRemainderSpace="0.01" />
+ <cellSize launcher:fixedSize="80dp" />
+ </workspaceSpec>
+ </specs>
+
+ <!-- specs from land/handheld_workspace_spec_4x4.xml -->
+ <specs launcher:maxAspectRatio="12">
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="2dp" />
+ <endPadding launcher:fixedSize="2dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="1dp" />
+ <endPadding launcher:fixedSize="1dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+
+ <specs launcher:maxAspectRatio="1.05">
+ <!-- 584 grid height + 28 remainder space -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="612dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="8dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <!-- 584 grid height -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="584dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="32dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofAvailableSpace="0.15808" />
+ </workspaceSpec>
+
+ <!-- Width spec is always the same -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="22dp" />
+ <endPadding launcher:fixedSize="22dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+</workspaceSpecs>
diff --git a/tests/res/xml/invalid_responsive_spec_5.xml b/tests/res/xml/invalid_responsive_spec_5.xml
new file mode 100644
index 0000000..584df35
--- /dev/null
+++ b/tests/res/xml/invalid_responsive_spec_5.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+<!-- invalid file - available space > 1 (it must be lower or equal 1) -->
+<workspaceSpecs xmlns:launcher="http://schemas.android.com/apk/res-auto">
+ <specs launcher:maxAspectRatio="10">
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="34dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="371dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="24dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="716dp">
+ <startPadding launcher:fixedSize="16dp" />
+ <endPadding launcher:fixedSize="64dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="36dp" />
+ <endPadding launcher:fixedSize="80dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="602dp">
+ <startPadding launcher:ofAvailableSpace=".5" />
+ <endPadding launcher:ofAvailableSpace=".5" />
+ <gutter launcher:ofAvailableSpace="0.01" />
+ <cellSize launcher:fixedSize="80dp" />
+ </workspaceSpec>
+ </specs>
+
+ <!-- specs from land/handheld_workspace_spec_4x4.xml -->
+ <specs launcher:maxAspectRatio="12">
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="2dp" />
+ <endPadding launcher:fixedSize="2dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="1dp" />
+ <endPadding launcher:fixedSize="1dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+
+ <specs launcher:maxAspectRatio="1.05">
+ <!-- 584 grid height + 28 remainder space -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="612dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="8dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <!-- 584 grid height -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="584dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="32dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofAvailableSpace="0.15808" />
+ </workspaceSpec>
+
+ <!-- Width spec is always the same -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="22dp" />
+ <endPadding launcher:fixedSize="22dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+</workspaceSpecs>
diff --git a/tests/res/xml/invalid_responsive_spec_6.xml b/tests/res/xml/invalid_responsive_spec_6.xml
new file mode 100644
index 0000000..9711efb
--- /dev/null
+++ b/tests/res/xml/invalid_responsive_spec_6.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2023 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.
+ -->
+<!-- invalid file - fixed size < maxAvailableSize (it must be lower or equal 1) -->
+<workspaceSpecs xmlns:launcher="http://schemas.android.com/apk/res-auto">
+ <specs launcher:maxAspectRatio="10">
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="34dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="371dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="24dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="716dp">
+ <startPadding launcher:fixedSize="16dp" />
+ <endPadding launcher:fixedSize="64dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="36dp" />
+ <endPadding launcher:fixedSize="80dp" />
+ <gutter launcher:fixedSize="12dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="602dp">
+ <startPadding launcher:fixedSize="200dp" />
+ <endPadding launcher:fixedSize="200dp" />
+ <gutter launcher:fixedSize="150dp" />
+ <cellSize launcher:fixedSize="80dp" />
+ </workspaceSpec>
+ </specs>
+
+ <!-- specs from land/handheld_workspace_spec_4x4.xml -->
+ <specs launcher:maxAspectRatio="12">
+ <!-- Height spec -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="2dp" />
+ <endPadding launcher:fixedSize="2dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+
+ <!-- Width spec -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="1dp" />
+ <endPadding launcher:fixedSize="1dp" />
+ <gutter launcher:fixedSize="8dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+
+ <specs launcher:maxAspectRatio="1.05">
+ <!-- 584 grid height + 28 remainder space -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="612dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="8dp" />
+ <endPadding launcher:ofRemainderSpace="1" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:fixedSize="104dp" />
+ </workspaceSpec>
+
+ <!-- 584 grid height -->
+ <workspaceSpec
+ launcher:dimensionType="height"
+ launcher:maxAvailableSize="584dp">
+ <startPadding launcher:fixedSize="0dp" />
+ <endPadding launcher:fixedSize="32dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofAvailableSpace="0.15808" />
+ </workspaceSpec>
+
+ <!-- Width spec is always the same -->
+ <workspaceSpec
+ launcher:dimensionType="width"
+ launcher:maxAvailableSize="9999dp">
+ <startPadding launcher:fixedSize="22dp" />
+ <endPadding launcher:fixedSize="22dp" />
+ <gutter launcher:fixedSize="16dp" />
+ <cellSize launcher:ofRemainderSpace="0.25" />
+ </workspaceSpec>
+ </specs>
+</workspaceSpecs>
diff --git a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
index a421006..30b5663 100644
--- a/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
+++ b/tests/src/com/android/launcher3/FakeInvariantDeviceProfileTest.kt
@@ -121,8 +121,8 @@
listOf(PointF(16f, 16f), PointF(16f, 16f), PointF(16f, 16f), PointF(16f, 16f))
.toTypedArray()
- numFolderRows = 3
- numFolderColumns = 3
+ numFolderRows = intArrayOf(3, 3, 3, 3)
+ numFolderColumns = intArrayOf(3, 3, 3, 3)
folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split
@@ -204,8 +204,8 @@
listOf(PointF(16f, 64f), PointF(64f, 16f), PointF(16f, 64f), PointF(16f, 64f))
.toTypedArray()
- numFolderRows = 3
- numFolderColumns = 3
+ numFolderRows = intArrayOf(3, 3, 3, 3)
+ numFolderColumns = intArrayOf(3, 3, 3, 3)
folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_6_5
@@ -288,8 +288,8 @@
listOf(PointF(16f, 16f), PointF(16f, 16f), PointF(16f, 20f), PointF(20f, 20f))
.toTypedArray()
- numFolderRows = 3
- numFolderColumns = 3
+ numFolderRows = intArrayOf(3, 3, 3, 3)
+ numFolderColumns = intArrayOf(3, 3, 3, 3)
folderStyle = R.style.FolderStyleDefault
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split
diff --git a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
index d71bf84..ee32e97 100644
--- a/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
+++ b/tests/src/com/android/launcher3/allapps/TaplKeyboardFocusTest.java
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.allapps;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
@@ -23,8 +23,6 @@
import static org.junit.Assert.assertTrue;
import android.view.KeyEvent;
-import android.view.View;
-import android.view.WindowInsets;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -33,6 +31,7 @@
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.rule.TestStabilityRule;
+import com.android.launcher3.views.ActivityContext;
import org.junit.Before;
import org.junit.Test;
@@ -102,11 +101,8 @@
executeOnLauncher(launcher -> launcher.getAppsView().getSearchUiManager().getEditText()
.hideKeyboard(/* clearFocus= */ false));
- waitForLauncherCondition("Keyboard still visible.", launcher -> {
- View root = launcher.getDragLayer();
- WindowInsets insets = root.getRootWindowInsets();
- return insets != null && !insets.isVisible(WindowInsets.Type.ime());
- });
+ waitForLauncherCondition("Keyboard still visible.",
+ ActivityContext::isSoftwareKeyboardHidden);
mLauncher.pressAndHoldKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0);
mLauncher.unpressKeyCode(KeyEvent.KEYCODE_DPAD_DOWN, 0);
diff --git a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java
index 2771483..c7942c7 100644
--- a/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java
+++ b/tests/src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java
@@ -16,7 +16,7 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.ui.TaplTestsLauncher3.expectFail;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
diff --git a/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java b/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java
index fd4619e..9f6bbdf 100644
--- a/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java
+++ b/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.allapps;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
diff --git a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
index 0f5d85b..a1f2cef 100644
--- a/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
+++ b/tests/src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java
@@ -16,7 +16,7 @@
package com.android.launcher3.appiconmenu;
import static com.android.launcher3.util.TestConstants.AppNames.TEST_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
diff --git a/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java b/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java
index 1fe02b2..d8ae74b 100644
--- a/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java
+++ b/tests/src/com/android/launcher3/celllayout/CellLayoutTestUtils.java
@@ -61,9 +61,7 @@
}
public static CellLayoutBoard viewsToBoard(List<View> views, int width, int height) {
- CellLayoutBoard board = new CellLayoutBoard();
- board.mWidth = width;
- board.mHeight = height;
+ CellLayoutBoard board = new CellLayoutBoard(width, height);
for (View callView : views) {
CellLayoutLayoutParams params = (CellLayoutLayoutParams) callView.getLayoutParams();
diff --git a/tests/src/com/android/launcher3/celllayout/ReorderAlgorithmUnitTest.java b/tests/src/com/android/launcher3/celllayout/ReorderAlgorithmUnitTest.java
index 88f54a2..bd52bda 100644
--- a/tests/src/com/android/launcher3/celllayout/ReorderAlgorithmUnitTest.java
+++ b/tests/src/com/android/launcher3/celllayout/ReorderAlgorithmUnitTest.java
@@ -22,7 +22,7 @@
import android.content.Context;
import android.graphics.Point;
-import android.graphics.Rect;
+import android.util.Log;
import android.view.View;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -31,9 +31,13 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
+import com.android.launcher3.MultipageCellLayout;
import com.android.launcher3.celllayout.board.CellLayoutBoard;
import com.android.launcher3.celllayout.board.IconPoint;
+import com.android.launcher3.celllayout.board.PermutedBoardComparator;
import com.android.launcher3.celllayout.board.WidgetRect;
+import com.android.launcher3.celllayout.testgenerator.RandomBoardGenerator;
+import com.android.launcher3.celllayout.testgenerator.RandomMultiBoardGenerator;
import com.android.launcher3.util.ActivityContextWrapper;
import com.android.launcher3.views.DoubleShadowBubbleTextView;
@@ -53,10 +57,25 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ReorderAlgorithmUnitTest {
+
+ private static final String TAG = "ReorderAlgorithmUnitTest";
+ private static final char MAIN_WIDGET_TYPE = 'z';
+
+ // There is nothing special about this numbers, the random seed is just to be able to reproduce
+ // the test cases and the height and width is a random number similar to what users expect on
+ // their devices
+ private static final int SEED = 897;
+ private static final int MAX_BOARD_SIZE = 13;
+
+ private static final int TOTAL_OF_CASES_GENERATED = 300;
private Context mApplicationContext;
private int mPrevNumColumns, mPrevNumRows;
+ /**
+ * This test reads existing test cases and makes sure the CellLayout produces the same
+ * output for each of them for a given input.
+ */
@Test
public void testAllCases() throws IOException {
List<ReorderAlgorithmUnitTestCase> testCases = getTestCases(
@@ -65,7 +84,7 @@
List<Integer> failingCases = new ArrayList<>();
for (int i = 0; i < testCases.size(); i++) {
try {
- evaluateTestCase(testCases.get(i));
+ evaluateTestCase(testCases.get(i), false);
} catch (AssertionError e) {
e.printStackTrace();
failingCases.add(i);
@@ -75,6 +94,47 @@
failingCases.size());
}
+ /**
+ * This test generates random CellLayout configurations and then try to reorder it and makes
+ * sure the result is a valid board meaning it didn't remove any widget or icon.
+ */
+ @Test
+ public void generateValidTests() {
+ Random generator = new Random(SEED);
+ mApplicationContext = new ActivityContextWrapper(getApplicationContext());
+ for (int i = 0; i < TOTAL_OF_CASES_GENERATED; i++) {
+ // Using a new seed so that we can replicate the same test cases.
+ int seed = generator.nextInt();
+ Log.d(TAG, "Seed = " + seed);
+ ReorderAlgorithmUnitTestCase testCase = generateRandomTestCase(
+ new RandomBoardGenerator(new Random(seed))
+ );
+ Log.d(TAG, "testCase = " + testCase);
+ assertTrue("invalid case " + i,
+ validateIntegrity(testCase.startBoard, testCase.endBoard, testCase));
+ }
+ }
+
+ /**
+ * Same as above but testing the Multipage CellLayout.
+ */
+ @Test
+ public void generateValidTests_Multi() {
+ Random generator = new Random(SEED);
+ mApplicationContext = new ActivityContextWrapper(getApplicationContext());
+ for (int i = 0; i < TOTAL_OF_CASES_GENERATED; i++) {
+ // Using a new seed so that we can replicate the same test cases.
+ int seed = generator.nextInt();
+ Log.d(TAG, "Seed = " + seed);
+ ReorderAlgorithmUnitTestCase testCase = generateRandomTestCase(
+ new RandomMultiBoardGenerator(new Random(seed))
+ );
+ Log.d(TAG, "testCase = " + testCase);
+ assertTrue("invalid case " + i,
+ validateIntegrity(testCase.startBoard, testCase.endBoard, testCase));
+ }
+ }
+
private void addViewInCellLayout(CellLayout cellLayout, int cellX, int cellY, int spanX,
int spanY, boolean isWidget) {
View cell = isWidget ? new View(mApplicationContext) : new DoubleShadowBubbleTextView(
@@ -84,15 +144,16 @@
(CellLayoutLayoutParams) cell.getLayoutParams(), true);
}
- public CellLayout createCellLayout(int width, int height) {
+ public CellLayout createCellLayout(int width, int height, boolean isMulti) {
Context c = mApplicationContext;
DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(c).getDeviceProfile(c).copy(c);
// modify the device profile.
- dp.inv.numColumns = width;
+ dp.inv.numColumns = isMulti ? width / 2 : width;
dp.inv.numRows = height;
dp.cellLayoutBorderSpacePx = new Point(0, 0);
- CellLayout cl = new CellLayout(getWrappedContext(c, dp));
+ CellLayout cl = isMulti ? new MultipageCellLayout(getWrappedContext(c, dp))
+ : new CellLayout(getWrappedContext(c, dp));
// I put a very large number for width and height so that all the items can fit, it doesn't
// need to be exact, just bigger than the sum of cell border
cl.measure(View.MeasureSpec.makeMeasureSpec(10000, View.MeasureSpec.EXACTLY),
@@ -109,8 +170,8 @@
}
public ItemConfiguration solve(CellLayoutBoard board, int x, int y, int spanX,
- int spanY, int minSpanX, int minSpanY) {
- CellLayout cl = createCellLayout(board.getWidth(), board.getHeight());
+ int spanY, int minSpanX, int minSpanY, boolean isMulti) {
+ CellLayout cl = createCellLayout(board.getWidth(), board.getHeight(), isMulti);
// The views have to be sorted or the result can vary
board.getIcons()
@@ -118,11 +179,15 @@
.map(IconPoint::getCoord)
.sorted(Comparator.comparing(p -> ((Point) p).x).thenComparing(p -> ((Point) p).y))
.forEach(p -> addViewInCellLayout(cl, p.x, p.y, 1, 1, false));
- board.getWidgets().stream()
- .sorted(Comparator.comparing(WidgetRect::getCellX)
- .thenComparing(WidgetRect::getCellY))
- .forEach(widget -> addViewInCellLayout(cl, widget.getCellX(), widget.getCellY(),
- widget.getSpanX(), widget.getSpanY(), true));
+ board.getWidgets()
+ .stream()
+ .sorted(Comparator
+ .comparing(WidgetRect::getCellX)
+ .thenComparing(WidgetRect::getCellY)
+ ).forEach(
+ widget -> addViewInCellLayout(cl, widget.getCellX(), widget.getCellY(),
+ widget.getSpanX(), widget.getSpanY(), true)
+ );
int[] testCaseXYinPixels = new int[2];
cl.regionToCenterPoint(x, y, spanX, spanY, testCaseXYinPixels);
@@ -133,6 +198,15 @@
solution = new ItemConfiguration();
solution.isSolution = false;
}
+ if (!solution.isSolution) {
+ cl.copyCurrentStateToSolution(solution, false);
+ if (cl instanceof MultipageCellLayout) {
+ solution =
+ ((MultipageCellLayout) cl).createReorderAlgorithm().removeSeamFromSolution(
+ solution);
+ }
+ solution.isSolution = false;
+ }
return solution;
}
@@ -143,17 +217,18 @@
new CellLayoutLayoutParams(val.cellX, val.cellY, val.spanX, val.spanY)));
CellLayoutBoard board = CellLayoutTestUtils.viewsToBoard(
new ArrayList<>(solution.map.keySet()), width, height);
- board.addWidget(solution.cellX, solution.cellY, solution.spanX, solution.spanY,
- 'z');
+ if (solution.isSolution) {
+ board.addWidget(solution.cellX, solution.cellY, solution.spanX, solution.spanY,
+ MAIN_WIDGET_TYPE);
+ }
return board;
}
- public void evaluateTestCase(ReorderAlgorithmUnitTestCase testCase) {
- ItemConfiguration solution = solve(testCase.startBoard, testCase.x,
- testCase.y, testCase.spanX, testCase.spanY, testCase.minSpanX,
- testCase.minSpanY);
- assertEquals("should be a valid solution", solution.isSolution,
- testCase.isValidSolution);
+ public void evaluateTestCase(ReorderAlgorithmUnitTestCase testCase, boolean isMultiCellLayout) {
+ ItemConfiguration solution = solve(testCase.startBoard, testCase.x, testCase.y,
+ testCase.spanX, testCase.spanY, testCase.minSpanX, testCase.minSpanY,
+ isMultiCellLayout);
+ assertEquals("should be a valid solution", solution.isSolution, testCase.isValidSolution);
if (testCase.isValidSolution) {
CellLayoutBoard finishBoard = boardFromSolution(solution,
testCase.startBoard.getWidth(), testCase.startBoard.getHeight());
@@ -178,36 +253,35 @@
dp.inv.numRows = mPrevNumRows;
}
- @SuppressWarnings("UnusedMethod")
- /**
- * Utility function used to generate all the test cases
- */
- private ReorderAlgorithmUnitTestCase generateRandomTestCase() {
+ private ReorderAlgorithmUnitTestCase generateRandomTestCase(
+ RandomBoardGenerator boardGenerator) {
ReorderAlgorithmUnitTestCase testCase = new ReorderAlgorithmUnitTestCase();
- int width = getRandom(3, 8);
- int height = getRandom(3, 8);
+ boolean isMultiCellLayout = boardGenerator instanceof RandomMultiBoardGenerator;
- int targetWidth = getRandom(1, width - 2);
- int targetHeight = getRandom(1, height - 2);
+ int width = isMultiCellLayout
+ ? boardGenerator.getRandom(3, MAX_BOARD_SIZE / 2) * 2
+ : boardGenerator.getRandom(3, MAX_BOARD_SIZE);
+ int height = boardGenerator.getRandom(3, MAX_BOARD_SIZE);
- int minTargetWidth = getRandom(1, targetWidth);
- int minTargetHeight = getRandom(1, targetHeight);
+ int targetWidth = boardGenerator.getRandom(1, width - 2);
+ int targetHeight = boardGenerator.getRandom(1, height - 2);
- int x = getRandom(0, width - targetWidth);
- int y = getRandom(0, height - targetHeight);
+ int minTargetWidth = boardGenerator.getRandom(1, targetWidth);
+ int minTargetHeight = boardGenerator.getRandom(1, targetHeight);
- CellLayoutBoard board = generateBoard(new CellLayoutBoard(width, height),
- new Rect(0, 0, width, height), targetWidth * targetHeight);
+ int x = boardGenerator.getRandom(0, width - targetWidth);
+ int y = boardGenerator.getRandom(0, height - targetHeight);
+
+ CellLayoutBoard board = boardGenerator.generateBoard(width, height,
+ targetWidth * targetHeight);
ItemConfiguration solution = solve(board, x, y, targetWidth, targetHeight,
- minTargetWidth, minTargetHeight);
+ minTargetWidth, minTargetHeight, isMultiCellLayout);
- CellLayoutBoard finishBoard = solution.isSolution ? boardFromSolution(solution,
- board.getWidth(), board.getHeight()) : new CellLayoutBoard(board.getWidth(),
+ CellLayoutBoard finishBoard = boardFromSolution(solution, board.getWidth(),
board.getHeight());
-
testCase.startBoard = board;
testCase.endBoard = finishBoard;
testCase.isValidSolution = solution.isSolution;
@@ -222,39 +296,24 @@
return testCase;
}
- private int getRandom(int start, int end) {
- int random = end == 0 ? 0 : new Random().nextInt(end);
- return start + random;
- }
-
- private CellLayoutBoard generateBoard(CellLayoutBoard board, Rect area,
- int emptySpaces) {
- if (area.height() * area.width() <= 0) return board;
-
- int width = getRandom(1, area.width() - 1);
- int height = getRandom(1, area.height() - 1);
-
- int x = area.left + getRandom(0, area.width() - width);
- int y = area.top + getRandom(0, area.height() - height);
-
- if (emptySpaces > 0) {
- emptySpaces -= width * height;
- } else if (width * height > 1) {
- board.addWidget(x, y, width, height);
- } else {
- board.addIcon(x, y);
+ /**
+ * Makes sure the final solution has valid integrity meaning that the number and sizes of
+ * widgets is the expect and there are no missing widgets.
+ */
+ public boolean validateIntegrity(CellLayoutBoard startBoard, CellLayoutBoard finishBoard,
+ ReorderAlgorithmUnitTestCase testCase) {
+ if (!testCase.isValidSolution) {
+ // if we couldn't place the widget then the solution should be identical to the board
+ return startBoard.compareTo(finishBoard) == 0;
}
-
- generateBoard(board,
- new Rect(area.left, area.top, area.right, y), emptySpaces);
- generateBoard(board,
- new Rect(area.left, y, x, area.bottom), emptySpaces);
- generateBoard(board,
- new Rect(x, y + height, area.right, area.bottom), emptySpaces);
- generateBoard(board,
- new Rect(x + width, y, area.right, y + height), emptySpaces);
-
- return board;
+ WidgetRect addedWidget = finishBoard.getWidgetOfType(MAIN_WIDGET_TYPE);
+ finishBoard.removeItem(MAIN_WIDGET_TYPE);
+ Comparator<CellLayoutBoard> comparator = new PermutedBoardComparator();
+ if (comparator.compare(startBoard, finishBoard) != 0) {
+ return false;
+ }
+ return addedWidget.getSpanX() >= testCase.minSpanX
+ && addedWidget.getSpanY() >= testCase.minSpanY;
}
private static List<ReorderAlgorithmUnitTestCase> getTestCases(String testPath)
diff --git a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java
index 72de885..30bde0a 100644
--- a/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java
+++ b/tests/src/com/android/launcher3/celllayout/ReorderWidgets.java
@@ -38,7 +38,6 @@
import com.android.launcher3.tapl.Widget;
import com.android.launcher3.tapl.WidgetResizeFrame;
import com.android.launcher3.ui.AbstractLauncherUiTest;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.ModelTestExtensions;
import com.android.launcher3.util.rule.ShellCommandRule;
@@ -73,7 +72,7 @@
@Before
public void setup() throws Throwable {
mWorkspaceBuilder = new TestWorkspaceBuilder(mTargetContext);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
}
@After
diff --git a/tests/src/com/android/launcher3/celllayout/board/CellLayoutBoard.java b/tests/src/com/android/launcher3/celllayout/board/CellLayoutBoard.java
index e90e145..dbbdcf5 100644
--- a/tests/src/com/android/launcher3/celllayout/board/CellLayoutBoard.java
+++ b/tests/src/com/android/launcher3/celllayout/board/CellLayoutBoard.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The Android Open Source Project
+ * Copyright (C) 2022 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.
@@ -18,8 +18,11 @@
import android.graphics.Point;
import android.graphics.Rect;
+import androidx.annotation.NonNull;
+
import java.util.ArrayDeque;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -31,73 +34,13 @@
public class CellLayoutBoard implements Comparable<CellLayoutBoard> {
- private boolean intersects(Rect r1, Rect r2) {
- // If one rectangle is on left side of other
- if (r1.left > r2.right || r2.left > r1.right) {
- return false;
- }
-
- // If one rectangle is above other
- if (r1.bottom > r2.top || r2.bottom > r1.top) {
- return false;
- }
-
- return true;
- }
-
- private boolean overlapsWithIgnored(Set<Rect> ignoredRectangles, Rect rect) {
- for (Rect ignoredRect : ignoredRectangles) {
- // Using the built in intersects doesn't work because it doesn't account for area 0
- if (intersects(ignoredRect, rect)) {
- return true;
- }
- }
- return false;
- }
+ public static final Comparator<CellLayoutBoard> COMPARATOR = new IdenticalBoardComparator();
@Override
- public int compareTo(CellLayoutBoard cellLayoutBoard) {
- // to be equal they need to have the same number of widgets and the same dimensions
- // their order can be different
- Set<Rect> widgetsSet = new HashSet<>();
- Set<Rect> ignoredRectangles = new HashSet<>();
- for (WidgetRect rect : mWidgetsRects) {
- if (rect.shouldIgnore()) {
- ignoredRectangles.add(rect.mBounds);
- } else {
- widgetsSet.add(rect.mBounds);
- }
- }
- for (WidgetRect rect : cellLayoutBoard.mWidgetsRects) {
- // ignore rectangles overlapping with the area marked by x
- if (overlapsWithIgnored(ignoredRectangles, rect.mBounds)) {
- continue;
- }
- if (!widgetsSet.contains(rect.mBounds)) {
- return -1;
- }
- widgetsSet.remove(rect.mBounds);
- }
- if (!widgetsSet.isEmpty()) {
- return 1;
- }
-
- // to be equal they need to have the same number of icons their order can be different
- Set<Point> iconsSet = new HashSet<>();
- mIconPoints.forEach(icon -> iconsSet.add(icon.getCoord()));
- for (IconPoint icon : cellLayoutBoard.mIconPoints) {
- if (!iconsSet.contains(icon.getCoord())) {
- return -1;
- }
- iconsSet.remove(icon.getCoord());
- }
- if (!iconsSet.isEmpty()) {
- return 1;
- }
- return 0;
+ public int compareTo(@NonNull CellLayoutBoard cellLayoutBoard) {
+ return COMPARATOR.compare(this, cellLayoutBoard);
}
-
private HashSet<Character> mUsedWidgetTypes = new HashSet<>();
static final int INFINITE = 99999;
@@ -112,7 +55,7 @@
WidgetRect mMain = null;
- public int mWidth, mHeight;
+ int mWidth, mHeight;
public CellLayoutBoard() {
for (int x = 0; x < mWidget.length; x++) {
@@ -123,7 +66,7 @@
}
public CellLayoutBoard(int width, int height) {
- mWidget = new char[width][height];
+ mWidget = new char[width + 1][height + 1];
this.mWidth = width;
this.mHeight = height;
for (int x = 0; x < mWidget.length; x++) {
@@ -139,6 +82,15 @@
return isXInRect && isYInRect;
}
+ public WidgetRect getWidgetAt(Point p) {
+ return getWidgetAt(p.x, p.y);
+ }
+
+ public WidgetRect getWidgetOfType(char type) {
+ return mWidgetsRects.stream()
+ .filter(widgetRect -> widgetRect.mType == type).findFirst().orElse(null);
+ }
+
public WidgetRect getWidgetAt(int x, int y) {
return mWidgetsRects.stream()
.filter(widgetRect -> pointInsideRect(x, y, widgetRect)).findFirst().orElse(null);
@@ -165,8 +117,8 @@
}
private void removeWidgetFromBoard(WidgetRect widget) {
- for (int xi = widget.mBounds.left; xi < widget.mBounds.right; xi++) {
- for (int yi = widget.mBounds.top; yi < widget.mBounds.bottom; yi++) {
+ for (int xi = widget.mBounds.left; xi <= widget.mBounds.right; xi++) {
+ for (int yi = widget.mBounds.bottom; yi <= widget.mBounds.top; yi++) {
mWidget[xi][yi] = '-';
}
}
@@ -207,7 +159,7 @@
private void removeOverlappingItems(Point p) {
// Remove overlapping widgets and remove them from the board
mWidgetsRects = mWidgetsRects.stream().filter(widget -> {
- if (widget.mBounds.contains(p.x, p.y)) {
+ if (IdenticalBoardComparator.Companion.touchesPoint(widget.mBounds, p)) {
removeWidgetFromBoard(widget);
return false;
}
@@ -237,8 +189,9 @@
}
private char getNextWidgetType() {
- for (char type = 'a'; type <= 'z'; type++) {
- if (type == 'i') continue;
+ for (char type = 'a'; type < 'z'; type++) {
+ if (type == CellType.ICON) continue;
+ if (type == CellType.IGNORE) continue;
if (mUsedWidgetTypes.contains(type)) continue;
mUsedWidgetTypes.add(type);
return type;
@@ -258,6 +211,17 @@
}
}
+ public void removeItem(char type) {
+ mWidgetsRects.stream()
+ .filter(widgetRect -> widgetRect.mType == type)
+ .forEach(widgetRect -> removeOverlappingItems(
+ new Point(widgetRect.getCellX(), widgetRect.getCellY())));
+ }
+
+ public void removeItem(Point p) {
+ removeOverlappingItems(p);
+ }
+
public void addWidget(int x, int y, int spanX, int spanY) {
addWidget(x, y, spanX, spanY, getNextWidgetType());
}
@@ -407,8 +371,8 @@
s.append("\n");
maxX = Math.min(maxX, mWidget.length);
maxY = Math.min(maxY, mWidget[0].length);
- for (int y = 0; y < maxY; y++) {
- for (int x = 0; x < maxX; x++) {
+ for (int y = 0; y <= maxY; y++) {
+ for (int x = 0; x <= maxX; x++) {
s.append(mWidget[x][y]);
}
s.append('\n');
diff --git a/tests/src/com/android/launcher3/celllayout/board/IdenticalBoardComparator.kt b/tests/src/com/android/launcher3/celllayout/board/IdenticalBoardComparator.kt
new file mode 100644
index 0000000..a4a420c
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/board/IdenticalBoardComparator.kt
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2023 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.celllayout.board
+
+import android.graphics.Point
+import android.graphics.Rect
+
+/**
+ * Compares two [CellLayoutBoard] and returns 0 if they are identical, meaning they have the same
+ * widget and icons in the same place, they can be different letters tough.
+ */
+class IdenticalBoardComparator : Comparator<CellLayoutBoard> {
+
+ /** Converts a list of WidgetRect into a map of the count of different widget.bounds */
+ private fun widgetsToBoundsMap(widgets: List<WidgetRect>) =
+ widgets.groupingBy { it.mBounds }.eachCount()
+
+ /** Converts a list of IconPoint into a map of the count of different icon.coord */
+ private fun iconsToPosCountMap(widgets: List<IconPoint>) =
+ widgets.groupingBy { it.getCoord() }.eachCount()
+
+ override fun compare(
+ cellLayoutBoard: CellLayoutBoard,
+ otherCellLayoutBoard: CellLayoutBoard
+ ): Int {
+ // to be equal they need to have the same number of widgets and the same dimensions
+ // their order can be different
+ val widgetsMap: Map<Rect, Int> =
+ widgetsToBoundsMap(cellLayoutBoard.widgets.filter { !it.shouldIgnore() })
+ val ignoredRectangles: Map<Rect, Int> =
+ widgetsToBoundsMap(cellLayoutBoard.widgets.filter { it.shouldIgnore() })
+
+ val otherWidgetMap: Map<Rect, Int> =
+ widgetsToBoundsMap(
+ otherCellLayoutBoard.widgets
+ .filter { !it.shouldIgnore() }
+ .filter { !overlapsWithIgnored(ignoredRectangles, it.mBounds) }
+ )
+
+ if (widgetsMap != otherWidgetMap) {
+ return -1
+ }
+
+ // to be equal they need to have the same number of icons their order can be different
+ return if (
+ iconsToPosCountMap(cellLayoutBoard.icons) ==
+ iconsToPosCountMap(otherCellLayoutBoard.icons)
+ ) {
+ 0
+ } else {
+ 1
+ }
+ }
+
+ private fun overlapsWithIgnored(ignoredRectangles: Map<Rect, Int>, rect: Rect): Boolean {
+ for (ignoredRect in ignoredRectangles.keys) {
+ // Using the built in intersects doesn't work because it doesn't account for area 0
+ if (touches(ignoredRect, rect)) {
+ return true
+ }
+ }
+ return false
+ }
+
+ companion object {
+ /**
+ * Similar function to {@link Rect#intersects} but this one returns true if the rectangles
+ * are intersecting or touching whereas {@link Rect#intersects} doesn't return true when
+ * they are touching.
+ */
+ fun touches(r1: Rect, r2: Rect): Boolean {
+ // If one rectangle is on left side of other
+ return if (r1.left > r2.right || r2.left > r1.right) {
+ false
+ } else r1.bottom <= r2.top && r2.bottom <= r1.top
+
+ // If one rectangle is above other
+ }
+
+ /**
+ * Similar function to {@link Rect#contains} but this one returns true if {link @Point} is
+ * intersecting or touching the {@link Rect}. Similar to {@link touches}.
+ */
+ fun touchesPoint(r1: Rect, p: Point): Boolean {
+ return r1.left <= p.x && p.x <= r1.right && r1.bottom <= p.y && p.y <= r1.top
+ }
+ }
+}
diff --git a/tests/src/com/android/launcher3/celllayout/board/PermutedBoardComparator.kt b/tests/src/com/android/launcher3/celllayout/board/PermutedBoardComparator.kt
new file mode 100644
index 0000000..c3d13a5
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/board/PermutedBoardComparator.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2023 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.celllayout.board
+
+import android.graphics.Point
+
+/**
+ * Compares two [CellLayoutBoard] and returns 0 if they contain the same widgets and icons even if
+ * they are in different positions i.e. in a different permutation.
+ */
+class PermutedBoardComparator : Comparator<CellLayoutBoard> {
+
+ /**
+ * The key for the set is the span since the widgets could change location but shouldn't change
+ * size
+ */
+ private fun boardToSpanCountMap(widgets: List<WidgetRect>) =
+ widgets.groupingBy { Point(it.spanX, it.spanY) }.eachCount()
+ override fun compare(
+ cellLayoutBoard: CellLayoutBoard,
+ otherCellLayoutBoard: CellLayoutBoard
+ ): Int {
+ return if (
+ boardToSpanCountMap(cellLayoutBoard.widgets) !=
+ boardToSpanCountMap(otherCellLayoutBoard.widgets)
+ ) {
+ 1
+ } else cellLayoutBoard.icons.size.compareTo(otherCellLayoutBoard.icons.size)
+ }
+}
diff --git a/tests/src/com/android/launcher3/celllayout/testgenerator/DeterministicRandomGenerator.kt b/tests/src/com/android/launcher3/celllayout/testgenerator/DeterministicRandomGenerator.kt
new file mode 100644
index 0000000..e582973
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/testgenerator/DeterministicRandomGenerator.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2023 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.celllayout.testgenerator
+
+import java.util.Random
+
+abstract class DeterministicRandomGenerator(private val generator: Random) {
+ fun getRandom(start: Int, end: Int): Int = start + (if (end == 0) 0 else generator.nextInt(end))
+}
diff --git a/tests/src/com/android/launcher3/celllayout/testgenerator/RandomBoardGenerator.kt b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomBoardGenerator.kt
new file mode 100644
index 0000000..770024f
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomBoardGenerator.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2023 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.celllayout.testgenerator
+
+import android.graphics.Rect
+import com.android.launcher3.celllayout.board.CellLayoutBoard
+import java.util.Random
+
+/** Generates a random CellLayoutBoard. */
+open class RandomBoardGenerator(generator: Random) : DeterministicRandomGenerator(generator) {
+ /**
+ * @param remainingEmptySpaces the maximum number of spaces we will fill with icons and widgets
+ * meaning that if the number is 100 we will try to fill the board with at most 100 spaces
+ * usually less than 100.
+ * @return a randomly generated board filled with icons and widgets.
+ */
+ open fun generateBoard(width: Int, height: Int, remainingEmptySpaces: Int): CellLayoutBoard? {
+ val cellLayoutBoard = CellLayoutBoard(width, height)
+ return fillBoard(cellLayoutBoard, Rect(0, 0, width, height), remainingEmptySpaces)
+ }
+
+ protected fun fillBoard(
+ board: CellLayoutBoard,
+ area: Rect,
+ remainingEmptySpacesArg: Int
+ ): CellLayoutBoard {
+ var remainingEmptySpaces = remainingEmptySpacesArg
+ if (area.height() * area.width() <= 0) return board
+ val width = getRandom(1, area.width() - 1)
+ val height = getRandom(1, area.height() - 1)
+ val x = area.left + getRandom(0, area.width() - width)
+ val y = area.top + getRandom(0, area.height() - height)
+ if (remainingEmptySpaces > 0) {
+ remainingEmptySpaces -= width * height
+ } else if (board.widgets.size <= 22 && width * height > 1) {
+ board.addWidget(x, y, width, height)
+ } else {
+ board.addIcon(x, y)
+ }
+ fillBoard(board, Rect(area.left, area.top, area.right, y), remainingEmptySpaces)
+ fillBoard(board, Rect(area.left, y, x, area.bottom), remainingEmptySpaces)
+ fillBoard(board, Rect(x, y + height, area.right, area.bottom), remainingEmptySpaces)
+ fillBoard(board, Rect(x + width, y, area.right, y + height), remainingEmptySpaces)
+ return board
+ }
+}
diff --git a/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
new file mode 100644
index 0000000..da4de7d
--- /dev/null
+++ b/tests/src/com/android/launcher3/celllayout/testgenerator/RandomMultiBoardGenerator.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2023 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.celllayout.testgenerator
+
+import android.graphics.Rect
+import com.android.launcher3.celllayout.board.CellLayoutBoard
+import java.util.Random
+
+class RandomMultiBoardGenerator(generator: Random) : RandomBoardGenerator(generator) {
+ override fun generateBoard(
+ width: Int,
+ height: Int,
+ remainingEmptySpaces: Int
+ ): CellLayoutBoard {
+ val cellLayoutBoard = CellLayoutBoard(width, height)
+ fillBoard(cellLayoutBoard, Rect(0, 0, width / 2, height), remainingEmptySpaces / 2)
+ return fillBoard(
+ cellLayoutBoard,
+ Rect(width / 2, 0, width, height),
+ remainingEmptySpaces / 2
+ )
+ }
+}
diff --git a/tests/src/com/android/launcher3/dragging/TaplDragTest.java b/tests/src/com/android/launcher3/dragging/TaplDragTest.java
index 7ec7826..e040367 100644
--- a/tests/src/com/android/launcher3/dragging/TaplDragTest.java
+++ b/tests/src/com/android/launcher3/dragging/TaplDragTest.java
@@ -19,7 +19,7 @@
import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.STORE_APP_NAME;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
diff --git a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
index d69287b..ed34307 100644
--- a/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
+++ b/tests/src/com/android/launcher3/dragging/TaplUninstallRemove.java
@@ -16,7 +16,7 @@
package com.android.launcher3.dragging;
import static com.android.launcher3.testing.shared.TestProtocol.ICON_MISSING;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.TestConstants.AppNames.DUMMY_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.GMAIL_APP_NAME;
import static com.android.launcher3.util.TestConstants.AppNames.MAPS_APP_NAME;
diff --git a/tests/src/com/android/launcher3/responsive/HotseatSpecsProviderTest.kt b/tests/src/com/android/launcher3/responsive/HotseatSpecsProviderTest.kt
index 32249e0..78cb1ac 100644
--- a/tests/src/com/android/launcher3/responsive/HotseatSpecsProviderTest.kt
+++ b/tests/src/com/android/launcher3/responsive/HotseatSpecsProviderTest.kt
@@ -110,4 +110,11 @@
TestResourceHelper(context, TestR.xml.invalid_hotseat_file_case_1)
)
}
+
+ @Test(expected = IllegalStateException::class)
+ fun parseInvalidFile_invalidFixedSize_throwsError() {
+ HotseatSpecsProvider.create(
+ TestResourceHelper(context, TestR.xml.invalid_hotseat_file_case_2)
+ )
+ }
}
diff --git a/tests/src/com/android/launcher3/responsive/ResponsiveCellSpecsProviderTest.kt b/tests/src/com/android/launcher3/responsive/ResponsiveCellSpecsProviderTest.kt
index 295f2e4..50cd358 100644
--- a/tests/src/com/android/launcher3/responsive/ResponsiveCellSpecsProviderTest.kt
+++ b/tests/src/com/android/launcher3/responsive/ResponsiveCellSpecsProviderTest.kt
@@ -108,4 +108,11 @@
TestResourceHelper(context, TestR.xml.invalid_cell_specs_2)
)
}
+
+ @Test(expected = IllegalStateException::class)
+ fun parseInvalidFile_invalidFixedSize_throwsError() {
+ ResponsiveCellSpecsProvider.create(
+ TestResourceHelper(context, TestR.xml.invalid_cell_specs_3)
+ )
+ }
}
diff --git a/tests/src/com/android/launcher3/responsive/ResponsiveSpecsProviderTest.kt b/tests/src/com/android/launcher3/responsive/ResponsiveSpecsProviderTest.kt
index 7af0823..9681ca8 100644
--- a/tests/src/com/android/launcher3/responsive/ResponsiveSpecsProviderTest.kt
+++ b/tests/src/com/android/launcher3/responsive/ResponsiveSpecsProviderTest.kt
@@ -134,6 +134,24 @@
ResponsiveSpecsProvider.create(resourceHelper, ResponsiveSpecType.Workspace)
}
+ @Test(expected = IllegalStateException::class)
+ fun parseInvalidFile_invalidRemainderSpace_throwsError() {
+ val resourceHelper = TestResourceHelper(context, R.xml.invalid_responsive_spec_4)
+ ResponsiveSpecsProvider.create(resourceHelper, ResponsiveSpecType.Workspace)
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun parseInvalidFile_invalidAvailableSpace_throwsError() {
+ val resourceHelper = TestResourceHelper(context, R.xml.invalid_responsive_spec_5)
+ ResponsiveSpecsProvider.create(resourceHelper, ResponsiveSpecType.Workspace)
+ }
+
+ @Test(expected = IllegalStateException::class)
+ fun parseInvalidFile_invalidFixedSize_throwsError() {
+ val resourceHelper = TestResourceHelper(context, R.xml.invalid_responsive_spec_6)
+ ResponsiveSpecsProvider.create(resourceHelper, ResponsiveSpecType.Workspace)
+ }
+
private fun validateSpecs(
specs: ResponsiveSpecGroup<ResponsiveSpec>,
expectedAspectRatio: Float,
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index cb1102e..5f536c7 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -220,6 +220,23 @@
@Rule
public SetFlagsRule mSetFlagsRule = new SetFlagsRule(DEVICE_DEFAULT);
+ public static void initialize(AbstractLauncherUiTest test) throws Exception {
+ initialize(test, false);
+ }
+
+ public static void initialize(
+ AbstractLauncherUiTest test, boolean clearWorkspace) throws Exception {
+ test.reinitializeLauncherData(clearWorkspace);
+ test.mDevice.pressHome();
+ test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
+ test.waitForState("Launcher internal state didn't switch to Home",
+ () -> LauncherState.NORMAL);
+ test.waitForResumed("Launcher internal state is still Background");
+ // Check that we switched to home.
+ test.mLauncher.getWorkspace();
+ AbstractLauncherUiTest.checkDetectedLeaks(test.mLauncher, true);
+ }
+
protected void clearPackageData(String pkg) throws IOException, InterruptedException {
final CountDownLatch count = new CountDownLatch(2);
final SimpleBroadcastReceiver broadcastReceiver =
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index f2cbd92..65d1f46 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -22,8 +22,6 @@
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
-import com.android.launcher3.LauncherState;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,23 +36,6 @@
initialize(this);
}
- public static void initialize(AbstractLauncherUiTest test) throws Exception {
- initialize(test, false);
- }
-
- public static void initialize(
- AbstractLauncherUiTest test, boolean clearWorkspace) throws Exception {
- test.reinitializeLauncherData(clearWorkspace);
- test.mDevice.pressHome();
- test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
- test.waitForState("Launcher internal state didn't switch to Home",
- () -> LauncherState.NORMAL);
- test.waitForResumed("Launcher internal state is still Background");
- // Check that we switched to home.
- test.mLauncher.getWorkspace();
- AbstractLauncherUiTest.checkDetectedLeaks(test.mLauncher, true);
- }
-
// Please don't add negative test cases for methods that fail only after a long wait.
public static void expectFail(String message, Runnable action) {
boolean failed = false;
diff --git a/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java b/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
index 5c753f9..3c88f1d 100644
--- a/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/RequestPinItemTest.java
@@ -18,8 +18,6 @@
import static android.app.PendingIntent.FLAG_MUTABLE;
import static android.app.PendingIntent.FLAG_ONE_SHOT;
-import static com.android.launcher3.ui.TaplTestsLauncher3.getAppPackageName;
-
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
@@ -44,7 +42,6 @@
import com.android.launcher3.testcomponent.AppWidgetWithConfig;
import com.android.launcher3.testcomponent.RequestPinItemActivity;
import com.android.launcher3.ui.AbstractLauncherUiTest;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.LauncherBindableItemsContainer.ItemOperator;
import com.android.launcher3.util.Wait;
import com.android.launcher3.util.Wait.Condition;
@@ -77,7 +74,7 @@
super.setUp();
mCallbackAction = UUID.randomUUID().toString();
mShortcutId = UUID.randomUUID().toString();
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
}
@Test
diff --git a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java
index a5e9868..465e9b4 100644
--- a/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.ui.widget;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
@@ -23,6 +23,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.MediumTest;
+
import com.android.launcher3.Launcher;
import com.android.launcher3.tapl.Widgets;
import com.android.launcher3.ui.AbstractLauncherUiTest;
@@ -34,11 +37,14 @@
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* This test run in both Out of process (Oop) and in-process (Ipc).
* Make sure the basic interactions with the WidgetPicker works.
*/
+@MediumTest
+@RunWith(AndroidJUnit4.class)
public class TaplWidgetPickerTest extends AbstractLauncherUiTest {
@Before
@@ -59,10 +65,12 @@
* Open Widget picker, make sure the widget picker can scroll and then go to home screen.
*/
@Test
- @Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/293191790
+ @Stability(flavors = LOCAL | PLATFORM_POSTSUBMIT) // b/303263644
@ScreenRecord
@PortraitLandscape
public void testWidgets() {
+ // Testing if this will fix b/303263644
+ mLauncher.goHome();
// Test opening widgets.
executeOnLauncher(launcher ->
assertTrue("Widgets is initially opened", getWidgetsView(launcher) == null));
diff --git a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
index d776f21..59c82a7 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java
@@ -15,7 +15,7 @@
*/
package com.android.launcher3.ui.workspace;
-import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+import static com.android.launcher3.ui.AbstractLauncherUiTest.initialize;
import static com.android.launcher3.util.TestConstants.AppNames.CHROME_APP_NAME;
import static org.junit.Assert.assertEquals;
diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
index 34c7707..e21918f 100644
--- a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java
@@ -36,7 +36,6 @@
import com.android.launcher3.tapl.HomeAppIcon;
import com.android.launcher3.tapl.HomeAppIconMenuItem;
import com.android.launcher3.ui.AbstractLauncherUiTest;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.Executors;
import org.junit.Test;
@@ -58,7 +57,7 @@
@Test
public void testIconWithoutTheme() throws Exception {
setThemeEnabled(false);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
@@ -76,7 +75,7 @@
@Test
public void testShortcutIconWithoutTheme() throws Exception {
setThemeEnabled(false);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
@@ -95,7 +94,7 @@
@Test
public void testIconWithTheme() throws Exception {
setThemeEnabled(true);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
@@ -113,7 +112,7 @@
@Test
public void testShortcutIconWithTheme() throws Exception {
setThemeEnabled(true);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
allApps.freeze();
diff --git a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
index 35b4883..e7112d1 100644
--- a/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
+++ b/tests/src/com/android/launcher3/ui/workspace/TwoPanelWorkspaceTest.java
@@ -35,7 +35,6 @@
import com.android.launcher3.tapl.Workspace;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.ui.TaplTestsLauncher3;
import com.android.launcher3.util.LauncherLayoutBuilder;
import com.android.launcher3.util.TestUtil;
@@ -74,7 +73,7 @@
.atWorkspace(3, -1, 0).putApp(
"com.android.vending", "com.android.vending.AssetBrowserActivity");
mLauncherLayout = TestUtil.setLauncherDefaultLayout(mTargetContext, builder);
- TaplTestsLauncher3.initialize(this);
+ AbstractLauncherUiTest.initialize(this);
assumeTrue(mLauncher.isTwoPanels());
// Pre verifying the screens