Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-qpr-dev
diff --git a/quickstep/res/drawable/ic_sysbar_back.xml b/quickstep/res/drawable/ic_sysbar_back.xml
index 1eea677..7d2bdee 100644
--- a/quickstep/res/drawable/ic_sysbar_back.xml
+++ b/quickstep/res/drawable/ic_sysbar_back.xml
@@ -16,13 +16,13 @@
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="28dp"
- android:height="28dp"
+ android:width="20dp"
+ android:height="20dp"
android:autoMirrored="true"
- android:viewportWidth="28"
- android:viewportHeight="28">
+ android:viewportWidth="20"
+ android:viewportHeight="20">
<path
android:fillColor="@android:color/white"
- android:pathData="M6.49,14.86c-0.66-0.39-0.66-1.34,0-1.73l6.02-3.53l5.89-3.46C19.11,5.73,20,6.26,20,7.1V14v6.9 c0,0.84-0.89,1.37-1.6,0.95l-5.89-3.46L6.49,14.86z" />
+ android:pathData="M15.5417 1.66669C15.1833 1.66669 14.8417 1.76669 14.5333 1.94169L3.21667 8.74169C2.775 9.00002 2.5 9.48335 2.5 10C2.5 10.5167 2.775 11 3.21667 11.2584L14.5333 18.05C14.8417 18.2334 15.1833 18.325 15.5417 18.325C16.625 18.325 17.5 17.45 17.5 16.3667V3.62502C17.5 2.54169 16.625 1.66669 15.5417 1.66669Z" />
</vector>
\ No newline at end of file
diff --git a/quickstep/res/drawable/ic_sysbar_home.xml b/quickstep/res/drawable/ic_sysbar_home.xml
index b4b397b..987f2f6 100644
--- a/quickstep/res/drawable/ic_sysbar_home.xml
+++ b/quickstep/res/drawable/ic_sysbar_home.xml
@@ -16,12 +16,12 @@
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="28dp"
- android:height="28dp"
- android:viewportWidth="28"
- android:viewportHeight="28">
+ android:width="20dp"
+ android:height="20dp"
+ android:viewportWidth="20"
+ android:viewportHeight="20">
<path
android:fillColor="@android:color/white"
- android:pathData="M 14 7 C 17.8659932488 7 21 10.1340067512 21 14 C 21 17.8659932488 17.8659932488 21 14 21 C 10.1340067512 21 7 17.8659932488 7 14 C 7 10.1340067512 10.1340067512 7 14 7 Z" />
+ android:pathData="M10.0001 18.3334C5.40008 18.3334 1.66675 14.6 1.66675 10C1.66675 5.40002 5.40008 1.66669 10.0001 1.66669C14.6001 1.66669 18.3334 5.40002 18.3334 10C18.3334 14.6 14.6001 18.3334 10.0001 18.3334Z" />
</vector>
\ No newline at end of file
diff --git a/quickstep/res/drawable/ic_sysbar_recent.xml b/quickstep/res/drawable/ic_sysbar_recent.xml
index f8c4778..26c4dc8 100644
--- a/quickstep/res/drawable/ic_sysbar_recent.xml
+++ b/quickstep/res/drawable/ic_sysbar_recent.xml
@@ -16,12 +16,12 @@
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="28dp"
- android:height="28dp"
- android:viewportWidth="28"
- android:viewportHeight="28">
+ android:width="20dp"
+ android:height="20dp"
+ android:viewportWidth="20"
+ android:viewportHeight="20">
<path
android:fillColor="@android:color/white"
- android:pathData="M19.9,21.5H8.1c-0.88,0-1.6-0.72-1.6-1.6V8.1c0-0.88,0.72-1.6,1.6-1.6h11.8c0.88,0,1.6,0.72,1.6,1.6v11.8 C21.5,20.78,20.78,21.5,19.9,21.5z" />
+ android:pathData="M4.47634 2.5H15.5241C16.6164 2.5 17.5002 3.38382 17.5002 4.4761V15.5239C17.5002 16.6162 16.6164 17.5 15.5241 17.5H4.47634C3.38407 17.5 2.50024 16.6162 2.50024 15.5239V4.4761C2.50024 3.38382 3.38407 2.5 4.47634 2.5Z" />
</vector>
\ No newline at end of file
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index e03c24d..fbf78ae 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -66,9 +66,10 @@
public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;
- private static final int DISPLAY_PROGRESS_COUNT = 4;
+ public static final int DISPLAY_PROGRESS_COUNT = 4;
- private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat();
+ private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat(
+ this::onInAppDisplayProgressChanged);
private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp =
new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress,
AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max);
@@ -102,9 +103,15 @@
onLauncherResumedOrPaused(mLauncher.hasBeenResumed(), true /* fromInit */);
onStashedInAppChanged(mLauncher.getDeviceProfile());
- mTaskbarLauncherStateController.onChangeScreenState(
+ mTaskbarLauncherStateController.updateStateForSysuiFlags(
mControllers.getSharedState().sysuiStateFlags, true /* fromInit */);
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
+
+ // Restore the in-app display progress from before Taskbar was recreated.
+ float[] prevProgresses = mControllers.getSharedState().inAppDisplayProgressMultiPropValues;
+ for (int i = 0; i < prevProgresses.length; i++) {
+ mTaskbarInAppDisplayProgressMultiProp.get(i).setValue(prevProgresses[i]);
+ }
}
@Override
@@ -118,6 +125,18 @@
updateTaskTransitionSpec(true);
}
+ private void onInAppDisplayProgressChanged() {
+ if (mControllers != null) {
+ // Update our shared state so we can restore it if taskbar gets recreated.
+ for (int i = 0; i < DISPLAY_PROGRESS_COUNT; i++) {
+ mControllers.getSharedState().inAppDisplayProgressMultiPropValues[i] =
+ mTaskbarInAppDisplayProgressMultiProp.get(i).getValue();
+ }
+ // Ensure nav buttons react to our latest state if necessary.
+ mControllers.navbarButtonsViewController.updateNavButtonTranslationY();
+ }
+ }
+
@Override
protected boolean isTaskbarTouchable() {
return !(mTaskbarLauncherStateController.isAnimatingToLauncher()
@@ -320,8 +339,8 @@
}
@Override
- public void onChangeScreenState(int screenState) {
- mTaskbarLauncherStateController.onChangeScreenState(screenState, false /* fromInit */);
+ public void updateStateForSysuiFlags(int sysuiFlags, boolean skipAnim) {
+ mTaskbarLauncherStateController.updateStateForSysuiFlags(sysuiFlags, skipAnim);
}
@Override
@@ -360,9 +379,10 @@
public void dumpLogs(String prefix, PrintWriter pw) {
super.dumpLogs(prefix, pw);
- pw.println(String.format("%s\tTaskbar in-app display progress:", prefix));
+ pw.println(String.format("%s\tTaskbar in-app display progress: %.2f", prefix,
+ mTaskbarInAppDisplayProgress.value));
mTaskbarInAppDisplayProgressMultiProp.dump(
- prefix + "\t",
+ prefix + "\t\t",
pw,
"mTaskbarInAppDisplayProgressMultiProp",
"MINUS_ONE_PAGE_PROGRESS_INDEX",
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index fd19695..352740f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -159,6 +159,7 @@
this::updateNavButtonTranslationY);
private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
this::updateNavButtonTranslationY);
+ private float mLastSetNavButtonTranslationY;
// Used for System UI state updates that should translate the nav button for in-app display.
private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat(
this::updateNavButtonInAppDisplayProgressForSysui);
@@ -606,7 +607,10 @@
}
}
- private void updateNavButtonTranslationY() {
+ /**
+ * Sets the translationY of the nav buttons based on the current device state.
+ */
+ public void updateNavButtonTranslationY() {
if (isPhoneButtonNavMode(mContext)) {
return;
}
@@ -618,9 +622,10 @@
&& ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout())
? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0;
- mNavButtonsView.setTranslationY(normalTranslationY
+ mLastSetNavButtonTranslationY = normalTranslationY
+ imeAdjustmentTranslationY
- + inAppDisplayAdjustmentTranslationY);
+ + inAppDisplayAdjustmentTranslationY;
+ mNavButtonsView.setTranslationY(mLastSetNavButtonTranslationY);
}
private void updateNavButtonColor() {
@@ -924,6 +929,13 @@
pw.println(prefix + "\tmFloatingRotationButtonBounds=" + mFloatingRotationButtonBounds);
pw.println(prefix + "\tmSysuiStateFlags=" + QuickStepContract.getSystemUiStateString(
mSysuiStateFlags));
+ pw.println(prefix + "\tLast set nav button translationY=" + mLastSetNavButtonTranslationY);
+ pw.println(prefix + "\t\tmTaskbarNavButtonTranslationY="
+ + mTaskbarNavButtonTranslationY.value);
+ pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForInAppDisplay="
+ + mTaskbarNavButtonTranslationYForInAppDisplay.value);
+ pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForIme="
+ + mTaskbarNavButtonTranslationYForIme.value);
}
private static String getStateString(int flags) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index a0adba6..77a9d78 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -32,7 +32,6 @@
import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
-import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_STATE_MASK;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING;
import android.animation.AnimatorSet;
@@ -591,8 +590,7 @@
mControllers.voiceInteractionWindowController.setIsVoiceInteractionWindowVisible(
(systemUiStateFlags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0, fromInit);
- mControllers.uiController.onChangeScreenState(
- systemUiStateFlags & SYSUI_STATE_SCREEN_STATE_MASK);
+ mControllers.uiController.updateStateForSysuiFlags(systemUiStateFlags, fromInit);
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index 4e79011..f7e6ee6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -159,7 +159,7 @@
if (iconShift != null) {
dragView.animateShift(-iconShift.x, -iconShift.y);
}
- btv.getIcon().setIsDisabled(true);
+ btv.setIconDisabled(true);
mControllers.taskbarAutohideSuspendController.updateFlag(
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING, true);
});
@@ -453,7 +453,7 @@
private void maybeOnDragEnd() {
if (!isDragging()) {
- ((BubbleTextView) mDragObject.originalView).getIcon().setIsDisabled(false);
+ ((BubbleTextView) mDragObject.originalView).setIconDisabled(false);
mControllers.taskbarAutohideSuspendController.updateFlag(
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING, false);
mActivity.onDragEnd();
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java
index 4e390f1..8cc8965 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java
@@ -30,6 +30,12 @@
| SYSUI_STATE_BACK_DISABLED | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED
| SYSUI_STATE_SCREEN_STATE_MASK;
+ // If any of these SysUi flags (via QuickstepContract) is set, the device to be considered
+ // locked.
+ public static final int MASK_ANY_SYSUI_LOCKED = SYSUI_STATE_BOUNCER_SHOWING
+ | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
+ | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
+
private final TaskbarActivityContext mContext;
private int mKeyguardSysuiFlags;
private boolean mBouncerShowing;
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 93a0c11..d997f56 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar;
+import static com.android.launcher3.taskbar.TaskbarKeyguardController.MASK_ANY_SYSUI_LOCKED;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
@@ -92,6 +93,9 @@
*/
private static final int FLAG_LAUNCHER_ACTIVE_AT_SCREEN_OFF = 1 << 4;
+ /** Whether the device is currently locked. */
+ private static final int FLAG_DEVICE_LOCKED = 1 << 5;
+
private static final int FLAGS_LAUNCHER_ACTIVE = FLAG_RESUMED | FLAG_TRANSITION_TO_RESUMED;
/** Equivalent to an int with all 1s for binary operation purposes */
private static final int FLAGS_ALL = ~0;
@@ -259,18 +263,23 @@
mShouldDelayLauncherStateAnim = shouldDelayLauncherStateAnim;
}
- /** Screen state changed, see QuickStepContract.SCREEN_STATE_* values. */
- public void onChangeScreenState(int screenState, boolean fromInit) {
+ /** SysUI flags updated, see QuickStepContract.SYSUI_STATE_* values. */
+ public void updateStateForSysuiFlags(int systemUiStateFlags, boolean skipAnim) {
final boolean prevScreenIsOn = hasAnyFlag(FLAG_SCREEN_ON);
- final boolean currScreenIsOn = hasAnyFlag(screenState, SYSUI_STATE_SCREEN_ON);
-
- if (prevScreenIsOn == currScreenIsOn) return;
+ final boolean currScreenIsOn = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_ON);
updateStateForFlag(FLAG_SCREEN_ON, currScreenIsOn);
- updateStateForFlag(FLAG_LAUNCHER_ACTIVE_AT_SCREEN_OFF,
- prevScreenIsOn && hasAnyFlag(FLAGS_LAUNCHER_ACTIVE));
+ if (prevScreenIsOn != currScreenIsOn) {
+ // The screen is switching between on/off. When turning off, capture whether the
+ // launcher is active and memoize this state.
+ updateStateForFlag(FLAG_LAUNCHER_ACTIVE_AT_SCREEN_OFF,
+ prevScreenIsOn && hasAnyFlag(FLAGS_LAUNCHER_ACTIVE));
+ }
- if (fromInit) {
+ boolean isDeviceLocked = hasAnyFlag(systemUiStateFlags, MASK_ANY_SYSUI_LOCKED);
+ updateStateForFlag(FLAG_DEVICE_LOCKED, isDeviceLocked);
+
+ if (skipAnim) {
applyState(0);
} else {
applyState();
@@ -368,7 +377,7 @@
}
}
- if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER_ACTIVE)) {
+ if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER_ACTIVE | FLAG_SCREEN_ON)) {
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
@@ -448,7 +457,13 @@
animatorSet.play(mTaskbarCornerRoundness.animateToValue(cornerRoundness));
}
- if (mIconAlignment.isAnimatingToValue(toAlignment)
+ if (hasAnyFlag(changedFlags, FLAG_DEVICE_LOCKED)) {
+ // When transitioning between locked/unlocked, there is no stashing animation.
+ mIconAlignment.cancelAnimation();
+ // updateValue ensures onIconAlignmentRatioChanged will be called if there is an actual
+ // change in value
+ mIconAlignment.updateValue(toAlignment);
+ } else if (mIconAlignment.isAnimatingToValue(toAlignment)
|| mIconAlignment.isSettledOnValue(toAlignment)) {
// Already at desired value, but make sure we run the callback at the end.
animatorSet.addListener(AnimatorListeners.forEndCallback(
@@ -538,12 +553,16 @@
animatorSet.play(stashAnimator);
}
- if (isAnimatingToLauncher() || mLauncherState == LauncherState.NORMAL) {
- // Translate back to 0 at a shorter or same duration as the icon alignment animation.
- // This ensures there is no jump after switching to hotseat, e.g. when swiping up from
- // overview to home. Currently we do duration / 2 just to make it feel snappier.
+ // Translate back to 0 at a shorter or same duration as the icon alignment animation.
+ // This ensures there is no jump after switching to hotseat, e.g. when swiping up from
+ // overview to home. When not in app, we do duration / 2 just to make it feel snappier.
+ long resetDuration = mControllers.taskbarStashController.isInApp()
+ ? duration
+ : duration / 2;
+ if (!mControllers.taskbarTranslationController.willAnimateToZeroBefore(resetDuration)
+ && (isAnimatingToLauncher() || mLauncherState == LauncherState.NORMAL)) {
animatorSet.play(mControllers.taskbarTranslationController
- .createAnimToResetTranslation(duration / 2));
+ .createAnimToResetTranslation(resetDuration));
}
}
@@ -656,6 +675,7 @@
appendFlag(result, flags, FLAG_SCREEN_ON, "screen_on");
appendFlag(result, flags, FLAG_LAUNCHER_ACTIVE_AT_SCREEN_OFF,
"launcher_active_at_screen_off");
+ appendFlag(result, flags, FLAG_DEVICE_LOCKED, "device_locked");
return result.toString();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
index 026eff7..6092998 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarSharedState.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
+import static com.android.launcher3.taskbar.LauncherTaskbarUIController.DISPLAY_PROGRESS_COUNT;
+
/**
* State shared across different taskbar instance
*/
@@ -38,4 +40,7 @@
public boolean setupUIVisible = false;
public boolean allAppsVisible = false;
+
+ // LauncherTaskbarUIController#mTaskbarInAppDisplayProgressMultiProp
+ public float[] inAppDisplayProgressMultiPropValues = new float[DISPLAY_PROGRESS_COUNT];
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index b613763..d26fbc4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -27,16 +27,14 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_SHOW;
+import static com.android.launcher3.taskbar.TaskbarKeyguardController.MASK_ANY_SYSUI_LOCKED;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
-import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
-import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
-import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -89,7 +87,8 @@
public static final int FLAG_IN_SETUP = 1 << 7; // In the Setup Wizard
public static final int FLAG_STASHED_SMALL_SCREEN = 1 << 8; // phone screen gesture nav, stashed
public static final int FLAG_STASHED_IN_APP_AUTO = 1 << 9; // Autohide (transient taskbar).
- public static final int FLAG_STASHED_SYSUI = 1 << 10; // app pinning, keyguard, etc.
+ public static final int FLAG_STASHED_SYSUI = 1 << 10; // app pinning,...
+ public static final int FLAG_STASHED_DEVICE_LOCKED = 1 << 11; // device is locked: keyguard, ...
// If any of these flags are enabled, isInApp should return true.
private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
@@ -110,6 +109,10 @@
private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP
& ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_TASKBAR_ALL_APPS;
+ // If any of these flags are enabled, the taskbar must be stashed.
+ private static final int FLAGS_FORCE_STASHED = FLAG_STASHED_SYSUI | FLAG_STASHED_DEVICE_LOCKED
+ | FLAG_STASHED_IN_TASKBAR_ALL_APPS | FLAG_STASHED_SMALL_SCREEN;
+
/**
* How long to stash/unstash when manually invoked via long press.
*
@@ -219,10 +222,7 @@
boolean inApp = hasAnyFlag(flags, FLAGS_IN_APP);
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
- boolean forceStashed = hasAnyFlag(flags,
- FLAG_STASHED_SYSUI
- | FLAG_STASHED_IN_TASKBAR_ALL_APPS
- | FLAG_STASHED_SMALL_SCREEN);
+ boolean forceStashed = hasAnyFlag(flags, FLAGS_FORCE_STASHED);
return (inApp && stashedInApp) || (!inApp && stashedLauncherState) || forceStashed;
});
@@ -584,8 +584,12 @@
// If Hotseat is not the top element during animation to/from Launcher, fade in/out a
// already stashed Taskbar.
- boolean skipStashAnimation = !mControllers.uiController.isHotseatIconOnTopWhenAligned()
- && hasAnyFlag(changedFlags, FLAG_IN_APP);
+ boolean hotseatTopElement = mControllers.uiController.isHotseatIconOnTopWhenAligned()
+ || !hasAnyFlag(changedFlags, FLAG_IN_APP);
+ // If transitioning between locked/unlocked device, do not play a stash animation.
+ boolean unLockedTransition = hasAnyFlag(changedFlags, FLAG_STASHED_DEVICE_LOCKED);
+ boolean skipStashAnimation = !hotseatTopElement || unLockedTransition;
+
if (isTransientTaskbar) {
createTransientAnimToIsStashed(mAnimator, isStashed, duration, animateBg, changedFlags,
skipStashAnimation);
@@ -905,11 +909,10 @@
updateStateForFlag(FLAG_STASHED_IN_APP_SYSUI, hasAnyFlag(systemUiStateFlags,
SYSUI_STATE_QUICK_SETTINGS_EXPANDED
| SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED));
- updateStateForFlag(FLAG_STASHED_SYSUI, hasAnyFlag(systemUiStateFlags,
- SYSUI_STATE_SCREEN_PINNING
- | SYSUI_STATE_BOUNCER_SHOWING
- | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING
- | SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED));
+ updateStateForFlag(FLAG_STASHED_SYSUI,
+ hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_PINNING));
+ updateStateForFlag(FLAG_STASHED_DEVICE_LOCKED,
+ hasAnyFlag(systemUiStateFlags, MASK_ANY_SYSUI_LOCKED));
// Only update FLAG_STASHED_IN_APP_IME when system gesture is not in progress.
mIsImeShowing = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_IME_SHOWING);
@@ -1081,6 +1084,7 @@
appendFlag(sj, flags, FLAG_IN_SETUP, "FLAG_IN_SETUP");
appendFlag(sj, flags, FLAG_STASHED_IN_APP_AUTO, "FLAG_STASHED_IN_APP_AUTO");
appendFlag(sj, flags, FLAG_STASHED_SYSUI, "FLAG_STASHED_SYSUI");
+ appendFlag(sj, flags, FLAG_STASHED_DEVICE_LOCKED, "FLAG_STASHED_DEVICE_LOCKED");
return sj.toString();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
index b9b63db..065d111 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarTranslationController.java
@@ -134,6 +134,21 @@
}
/**
+ * Returns true if we will animate to zero before the input duration.
+ */
+ public boolean willAnimateToZeroBefore(long duration) {
+ if (mSpringBounce != null && mSpringBounce.isRunning()) {
+ long springDuration = mSpringBounce.getDuration();
+ long current = mSpringBounce.getCurrentPlayTime();
+ return (springDuration - current < duration);
+ }
+ if (mTranslationYForSwipe.isAnimatingToValue(0)) {
+ return mTranslationYForSwipe.getRemainingTime() < duration;
+ }
+ return false;
+ }
+
+ /**
* Returns an animation to reset the taskbar translation to {@code 0}.
*/
public ObjectAnimator createAnimToResetTranslation(long duration) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 8046cd6..b9242b2 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -125,9 +125,9 @@
}
/**
- * Screen state changed, see QuickStepContract.SCREEN_STATE_* values.
+ * SysUI flags updated, see QuickStepContract.SYSUI_STATE_* values.
*/
- public void onChangeScreenState(int screenState){
+ public void updateStateForSysuiFlags(int sysuiFlags, boolean skipAnim){
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index ad16eed..fafd0bd 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -345,8 +345,8 @@
}
Rect stashedRect = new Rect(left, top, right, bottom);
- float radius = 0;
- float stashedRadius = stashedRect.width() / 2f;
+ float radius = viewBounds.height() / 2f;
+ float stashedRadius = stashedRect.height() / 2f;
return new RoundedRectRevealOutlineProvider(radius, stashedRadius, viewBounds, stashedRect)
.createRevealAnimator(view, !isStashed, 0);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
index 25207d4..3990dad 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PredictedAppIcon.java
@@ -17,6 +17,7 @@
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.icons.BitmapInfo.FLAG_THEMED;
+import static com.android.launcher3.icons.FastBitmapDrawable.getDisabledColorFilter;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -54,6 +55,7 @@
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.IconNormalizer;
import com.android.launcher3.icons.LauncherIcons;
+import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
@@ -361,6 +363,19 @@
}
@Override
+ public void setIconDisabled(boolean isDisabled) {
+ super.setIconDisabled(isDisabled);
+ mIconRingPaint.setColorFilter(isDisabled ? getDisabledColorFilter() : null);
+ invalidate();
+ }
+
+ @Override
+ protected void setItemInfo(ItemInfoWithIcon itemInfo) {
+ super.setItemInfo(itemInfo);
+ setIconDisabled(itemInfo.isDisabled());
+ }
+
+ @Override
public void getSourceVisualDragBounds(Rect bounds) {
super.getSourceVisualDragBounds(bounds);
if (!mIsPinned) {
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 753d736..f3fb259 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -278,8 +278,6 @@
private RunningWindowAnim[] mRunningWindowAnim;
// Possible second animation running at the same time as mRunningWindowAnim
private Animator mParallelRunningAnim;
- // Current running divider animation
- private ValueAnimator mDividerAnimator;
private boolean mIsMotionPaused;
private boolean mHasMotionEverBeenPaused;
@@ -325,8 +323,8 @@
private final boolean mIsTransientTaskbar;
// May be set to false when mIsTransientTaskbar is true.
private boolean mCanSlowSwipeGoHome = true;
- private boolean mHasReachedOverviewThreshold = false;
- private boolean mDividerHiddenBeforeAnimation = false;
+ // Indicates whether the divider is shown, only used when split screen is activated.
+ private boolean mIsDividerShown = true;
@Nullable
private RemoteAnimationTargets.ReleaseCheck mSwipePipToHomeReleaseCheck = null;
@@ -767,10 +765,6 @@
private void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask, boolean animate) {
if (mIsLikelyToStartNewTask != isLikelyToStartNewTask) {
- if (isLikelyToStartNewTask && mIsTransientTaskbar) {
- setDividerShown(false /* shown */, true /* immediate */);
- }
-
mIsLikelyToStartNewTask = isLikelyToStartNewTask;
maybeUpdateRecentsAttachedState(animate);
}
@@ -1110,9 +1104,8 @@
} else {
mStateCallback.setState(STATE_RESUME_LAST_TASK);
}
- if (mRecentsAnimationTargets != null) {
- setDividerShown(true /* shown */, true /* immediate */);
- }
+ // Restore the divider as it resumes the last top-tasks.
+ setDividerShown(true);
break;
}
ActiveGestureLog.INSTANCE.addLog(
@@ -1284,9 +1277,6 @@
if (mRecentsAnimationController != null) {
mRecentsAnimationController.detachNavigationBarFromApp(true);
}
- if (mIsTransientTaskbar) {
- setDividerShown(false /* shown */, true /* immediate */);
- }
} else if (endTarget == RECENTS) {
if (mRecentsView != null) {
int nearestPage = mRecentsView.getDestinationPage();
@@ -1686,12 +1676,6 @@
}
mRecentsAnimationController.enableInputConsumer();
-
- // Start hiding the divider
- if (!mIsTransientTaskbar || mTaskbarAlreadyOpen || mIsTaskbarAllAppsOpen
- || mDividerHiddenBeforeAnimation) {
- setDividerShown(false /* shown */, true /* immediate */);
- }
}
private void computeRecentsScrollIfInvisible() {
@@ -2155,9 +2139,6 @@
@Override
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
- if (!controller.getFinishTargetIsLauncher()) {
- setDividerShown(true /* shown */, false /* immediate */);
- }
mRecentsAnimationController = null;
mRecentsAnimationTargets = null;
if (mRecentsView != null) {
@@ -2257,18 +2238,23 @@
boolean notSwipingToHome = mRecentsAnimationTargets != null
&& mGestureState.getEndTarget() != HOME;
boolean setRecentsScroll = mRecentsViewScrollLinked && mRecentsView != null;
+ float progress = Math.max(mCurrentShift.value, getScaleProgressDueToScroll());
+ int scrollOffset = setRecentsScroll ? mRecentsView.getScrollOffset() : 0;
+ if (progress > 0 || scrollOffset != 0) {
+ // Hide the divider as the tasks start moving.
+ setDividerShown(false);
+ }
for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
AnimatorControllerWithResistance playbackController =
remoteHandle.getPlaybackController();
if (playbackController != null) {
- playbackController.setProgress(Math.max(mCurrentShift.value,
- getScaleProgressDueToScroll()), mDragLengthFactor);
+ playbackController.setProgress(progress, mDragLengthFactor);
}
if (notSwipingToHome) {
TaskViewSimulator taskViewSimulator = remoteHandle.getTaskViewSimulator();
if (setRecentsScroll) {
- taskViewSimulator.setScroll(mRecentsView.getScrollOffset());
+ taskViewSimulator.setScroll(scrollOffset);
}
taskViewSimulator.apply(remoteHandle.getTransformParams());
}
@@ -2327,10 +2313,6 @@
// "Catch up" with the displacement at mTaskbarCatchUpThreshold.
if (displacement < mTaskbarCatchUpThreshold) {
- if (!mHasReachedOverviewThreshold) {
- setDividerShown(false /* shown */, true /* immediate */);
- mHasReachedOverviewThreshold = true;
- }
return Utilities.mapToRange(displacement, mTaskbarAppWindowThreshold,
mTaskbarCatchUpThreshold, 0, mTaskbarCatchUpThreshold, ACCEL_DEACCEL);
}
@@ -2338,23 +2320,13 @@
return displacement;
}
- private void setDividerShown(boolean shown, boolean immediate) {
- if (mRecentsAnimationTargets == null) {
- if (!shown) {
- mDividerHiddenBeforeAnimation = true;
- }
+ private void setDividerShown(boolean shown) {
+ if (mRecentsAnimationTargets == null || mIsDividerShown == shown) {
return;
}
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- }
- mDividerAnimator = TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
- mRecentsAnimationTargets.nonApps, shown, (dividerAnimator) -> {
- dividerAnimator.start();
- if (immediate) {
- dividerAnimator.end();
- }
- });
+ mIsDividerShown = shown;
+ TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
+ mRecentsAnimationTargets.nonApps, shown, null /* animatorHandler */);
}
/**
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index 725f9e7..dde5d55 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -188,12 +188,8 @@
return;
}
} else if (nonAppTargets.length > 0) {
- TaskViewUtils.createSplitAuxiliarySurfacesAnimator(
- nonAppTargets /* nonApps */,
- true /*shown*/, dividerAnimator -> {
- dividerAnimator.start();
- dividerAnimator.end();
- });
+ TaskViewUtils.createSplitAuxiliarySurfacesAnimator(nonAppTargets /* nonApps */,
+ true /*shown*/, null /* animatorHandler */);
}
if (mController != null) {
if (mLastAppearedTaskTarget == null
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index da97df6..f0d0bdb 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -679,28 +679,36 @@
/**
* Creates an animation to show/hide the auxiliary surfaces (aka. divider bar), only calling
* {@param animatorHandler} if there are valid surfaces to animate.
+ * Passing null handler to apply the visibility immediately.
*
* @return the animator animating the surfaces
*/
public static ValueAnimator createSplitAuxiliarySurfacesAnimator(
- RemoteAnimationTarget[] nonApps, boolean shown,
- Consumer<ValueAnimator> animatorHandler) {
+ @Nullable RemoteAnimationTarget[] nonApps, boolean shown,
+ @Nullable Consumer<ValueAnimator> animatorHandler) {
if (nonApps == null || nonApps.length == 0) {
return null;
}
- SurfaceControl.Transaction t = new SurfaceControl.Transaction();
- List<SurfaceControl> auxiliarySurfaces = new ArrayList<>(nonApps.length);
- boolean hasSurfaceToAnimate = false;
- for (int i = 0; i < nonApps.length; ++i) {
- final RemoteAnimationTarget targ = nonApps[i];
- final SurfaceControl leash = targ.leash;
- if (targ.windowType == TYPE_DOCK_DIVIDER && leash != null && leash.isValid()) {
+ List<SurfaceControl> auxiliarySurfaces = new ArrayList<>();
+ for (RemoteAnimationTarget target : nonApps) {
+ final SurfaceControl leash = target.leash;
+ if (target.windowType == TYPE_DOCK_DIVIDER && leash != null && leash.isValid()) {
auxiliarySurfaces.add(leash);
- hasSurfaceToAnimate = true;
}
}
- if (!hasSurfaceToAnimate) {
+ if (auxiliarySurfaces.isEmpty()) {
+ return null;
+ }
+
+ SurfaceControl.Transaction t = new SurfaceControl.Transaction();
+ if (animatorHandler == null) {
+ // Apply the visibility directly without fade animation.
+ for (SurfaceControl leash : auxiliarySurfaces) {
+ t.setVisibility(leash, shown);
+ }
+ t.apply();
+ t.close();
return null;
}
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index ea79c55..8e1c279 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -72,9 +72,9 @@
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.PopupContainerWithArrow;
-import com.android.launcher3.util.MultiTranslateDelegate;
import com.android.launcher3.search.StringMatcherUtility;
import com.android.launcher3.util.IntArray;
+import com.android.launcher3.util.MultiTranslateDelegate;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.ShortcutUtil;
import com.android.launcher3.views.ActivityContext;
@@ -220,7 +220,6 @@
defaultIconSize = grid.folderChildIconSizePx;
} else if (mDisplay == DISPLAY_SEARCH_RESULT) {
setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
- setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
defaultIconSize = getResources().getDimensionPixelSize(R.dimen.search_row_icon_size);
} else if (mDisplay == DISPLAY_SEARCH_RESULT_SMALL) {
defaultIconSize = getResources().getDimensionPixelSize(
@@ -978,6 +977,13 @@
applyCompoundDrawables(icon);
}
+ /** Sets the icon visual state to disabled or not. */
+ public void setIconDisabled(boolean isDisabled) {
+ if (mIcon != null) {
+ mIcon.setIsDisabled(isDisabled);
+ }
+ }
+
protected boolean iconUpdateAnimationEnabled() {
return mEnableIconUpdateAnimation;
}
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 95d3ad9..9ef9320 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -121,7 +121,6 @@
public void onDrop(DragObject d, DragOptions options) {
if (canRemove(d.dragInfo)) {
mLauncher.getModelWriter().prepareToUndoDelete();
- d.dragInfo.container = NO_ID;
}
super.onDrop(d, options);
mStatsLogManager.logger().withInstanceId(d.logInstanceId)
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index e675add..fb4da0c 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -36,6 +36,8 @@
* Use same context for shared preferences, so that we use a single cached instance
*
* TODO(b/262721340): Replace all direct SharedPreference refs with LauncherPrefs / Item methods.
+ * TODO(b/274501660): Fix ReorderWidgets#simpleReorder test before enabling
+ * isBootAwareStartupDataEnabled
*/
class LauncherPrefs(private val encryptedContext: Context) {
private val deviceProtectedStorageContext =
@@ -228,7 +230,7 @@
* files.
*
* @return a list of editors with all transactions added so that the caller can determine to use
- * .apply() or .commit()
+ * .apply() or .commit()
*/
private fun prepareToRemove(items: Array<out Item>): List<SharedPreferences.Editor> {
val itemsPerFile = items.groupBy { it.encryptedPrefs }.toMutableMap()
diff --git a/src/com/android/launcher3/anim/AnimatedFloat.java b/src/com/android/launcher3/anim/AnimatedFloat.java
index 2380af4..2f3fa63 100644
--- a/src/com/android/launcher3/anim/AnimatedFloat.java
+++ b/src/com/android/launcher3/anim/AnimatedFloat.java
@@ -133,6 +133,15 @@
}
/**
+ * Returns the remaining time of the existing animation (if any).
+ */
+ public long getRemainingTime() {
+ return isAnimating() && mValueAnimator.isRunning()
+ ? Math.max(0, mValueAnimator.getDuration() - mValueAnimator.getCurrentPlayTime())
+ : 0;
+ }
+
+ /**
* Returns whether we are currently not animating, and the animation's value matches the given.
*/
public boolean isSettledOnValue(float endValue) {
diff --git a/src/com/android/launcher3/widget/WidgetCell.java b/src/com/android/launcher3/widget/WidgetCell.java
index 80bc1a7..9984991 100644
--- a/src/com/android/launcher3/widget/WidgetCell.java
+++ b/src/com/android/launcher3/widget/WidgetCell.java
@@ -16,6 +16,7 @@
package com.android.launcher3.widget;
+import static android.view.View.MeasureSpec.getSize;
import static android.view.View.MeasureSpec.makeMeasureSpec;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
@@ -118,6 +119,8 @@
private TextView mWidgetName;
private TextView mWidgetDims;
private TextView mWidgetDescription;
+ private Consumer<Bitmap> mCallback;
+ private @Nullable Bitmap mCachedPreview;
protected WidgetItem mItem;
@@ -429,6 +432,8 @@
*/
private void ensurePreviewWithCallback(Consumer<Bitmap> callback,
@Nullable Bitmap cachedPreview) {
+ mCallback = callback;
+ mCachedPreview = cachedPreview;
if (mAppWidgetHostViewPreview != null) {
int containerWidth = (int) (mTargetPreviewWidth * mPreviewContainerScale);
int containerHeight = (int) (mTargetPreviewHeight * mPreviewContainerScale);
@@ -469,6 +474,7 @@
INDEX_WIDGET_CENTERING,
-(params.width - (params.width * mPreviewContainerScale)) / 2.0f,
-(params.height - (params.height * mPreviewContainerScale)) / 2.0f);
+ mWidgetImageContainer.removeAllViews();
mWidgetImageContainer.addView(mAppWidgetHostViewPreview, /* index= */ 0);
mWidgetImage.setVisibility(View.GONE);
applyPreview(null);
@@ -579,4 +585,19 @@
(mTargetPreviewHeight - verticalPadding) * mPreviewContainerScale
/ appWidgetContentHeight);
}
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int padding = getPaddingLeft() + getPaddingRight();
+ int allowedWidth = getSize(widthMeasureSpec) - padding;
+
+ // Here we prevent having clipped widgets when they're too large as the preview width is
+ // larger than the max allowed width. We then re-do the preview with the new preview width
+ if (allowedWidth > 0 && mCachedPreview == null && allowedWidth < mTargetPreviewWidth) {
+ mTargetPreviewWidth = allowedWidth;
+ ensurePreviewWithCallback(mCallback, null);
+ }
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
}
diff --git a/tests/src/com/android/launcher3/LauncherPrefsTest.kt b/tests/src/com/android/launcher3/LauncherPrefsTest.kt
index 41ef3de..d59e02a 100644
--- a/tests/src/com/android/launcher3/LauncherPrefsTest.kt
+++ b/tests/src/com/android/launcher3/LauncherPrefsTest.kt
@@ -25,6 +25,8 @@
import com.google.common.truth.Truth.assertThat
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
+import org.junit.AfterClass
+import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
@@ -45,8 +47,18 @@
private val context by lazy { InstrumentationRegistry.getInstrumentation().targetContext }
private val launcherPrefs by lazy { LauncherPrefs.get(context) }
- init {
- isBootAwareStartupDataEnabled = true
+ companion object {
+ @BeforeClass
+ @JvmStatic
+ fun setup() {
+ isBootAwareStartupDataEnabled = true
+ }
+
+ @AfterClass
+ @JvmStatic
+ fun teardown() {
+ isBootAwareStartupDataEnabled = false
+ }
}
@Test