Merge "Removing dependency on wallpaper colors and using theme resources" into sc-dev
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index 4e03971..a81bdd5 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -22,7 +22,9 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
+import com.android.launcher3.util.Themes;
/**
* Definition for AllApps state
@@ -92,7 +94,7 @@
}
@Override
- public float getWorkspaceScrimAlpha(Launcher launcher) {
- return 1;
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 30c07b0..135c478 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -29,6 +29,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.util.Themes;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.util.LayoutUtils;
import com.android.quickstep.views.RecentsView;
@@ -108,8 +109,8 @@
}
@Override
- public float getWorkspaceScrimAlpha(Launcher launcher) {
- return 1f;
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
}
@Override
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
index 694998c..2d95ce2 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
@@ -16,7 +16,7 @@
package com.android.launcher3.uioverrides.touchcontrollers;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.HINT_STATE;
@@ -127,11 +127,11 @@
}
if (mFromState == NORMAL && mToState == HINT_STATE) {
- mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofFloat(
+ mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofArgb(
mLauncher.getScrimView(),
- VIEW_ALPHA,
- mFromState.getWorkspaceScrimAlpha(mLauncher),
- mToState.getWorkspaceScrimAlpha(mLauncher));
+ VIEW_BACKGROUND_COLOR,
+ mFromState.getWorkspaceScrimColor(mLauncher),
+ mToState.getWorkspaceScrimColor(mLauncher));
}
mStartedOverview = false;
mReachedOverview = false;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
index 77b0804..12de4a6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java
@@ -15,7 +15,6 @@
*/
package com.android.launcher3.uioverrides.touchcontrollers;
-import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
@@ -232,8 +231,8 @@
// - OverviewScrim
PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
xAnim.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], LINEAR);
- xAnim.setFloat(mLauncher.getScrimView(), VIEW_ALPHA,
- toState.getWorkspaceScrimAlpha(mLauncher), LINEAR);
+ xAnim.setViewBackgroundColor(mLauncher.getScrimView(),
+ toState.getWorkspaceScrimColor(mLauncher), LINEAR);
mXOverviewAnim = xAnim.createPlaybackController();
mXOverviewAnim.dispatchOnStart();
diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
index 2a6e478..c47300c 100644
--- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
@@ -92,7 +92,7 @@
};
private static final String TAG = "OrientationTouchTransformer";
- private static final boolean DEBUG = false;
+ private static final boolean DEBUG = true;
private static final int QUICKSTEP_ROTATION_UNINITIALIZED = -1;
@@ -163,6 +163,10 @@
void setNavigationMode(SysUINavigationMode.Mode newMode, Info info,
Resources newRes) {
+ if (DEBUG) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setNavigationMode new: " + newMode
+ + " oldMode: " + mMode + " " + this);
+ }
if (mMode == newMode) {
return;
}
@@ -254,10 +258,18 @@
mCurrentDisplay = new CurrentDisplay(region.realSize, region.rotation);
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplay);
+ if (DEBUG) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "cached region: " + regionToKeep
+ + " mCurrentDisplay: " + mCurrentDisplay + " " + this);
+ }
if (regionToKeep == null) {
regionToKeep = createRegionForDisplay(region);
}
mSwipeTouchRegions.clear();
+ if (DEBUG) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "adding region: " + regionToKeep
+ + " mCurrentDisplay: " + mCurrentDisplay + " " + this);
+ }
mSwipeTouchRegions.put(mCurrentDisplay, regionToKeep);
updateAssistantRegions(regionToKeep);
}
@@ -273,7 +285,8 @@
private OrientationRectF createRegionForDisplay(Info display) {
if (DEBUG) {
- Log.d(TAG, "creating rotation region for: " + mCurrentDisplay.rotation);
+ Log.d(TAG, "creating rotation region for: " + mCurrentDisplay.rotation
+ + " with mode: " + mMode + " displayRotation: " + display.rotation);
}
Point size = display.realSize;
@@ -287,14 +300,19 @@
} else {
mAssistantLeftRegion.setEmpty();
mAssistantRightRegion.setEmpty();
+ int navbarSize = getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
+ if (DEBUG) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "else case mode: " + mMode
+ + " getNavbarSize: " + navbarSize + " rotation: " + rotation + " " + this);
+ }
switch (rotation) {
case Surface.ROTATION_90:
orientationRectF.left = orientationRectF.right
- - getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
+ - navbarSize;
break;
case Surface.ROTATION_270:
orientationRectF.right = orientationRectF.left
- + getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
+ + navbarSize;
break;
default:
orientationRectF.top = orientationRectF.bottom - touchHeight;
@@ -339,7 +357,7 @@
boolean touchInValidSwipeRegions(float x, float y) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.NO_SWIPE_TO_HOME, "touchInValidSwipeRegions " + x + "," + y + " in "
- + mLastRectTouched);
+ + mLastRectTouched + " this: " + this);
}
if (mLastRectTouched != null) {
return mLastRectTouched.contains(x, y);
@@ -462,7 +480,8 @@
if (DEBUG) {
Log.d(TAG, "Transforming rotation due to forceTransform, "
+ "mCurrentRotation: " + mCurrentDisplay.rotation
- + "mRotation: " + mRotation);
+ + "mRotation: " + mRotation
+ + " this: " + this);
}
event.transform(mTmpMatrix);
return true;
@@ -473,9 +492,10 @@
if (DEBUG) {
Log.d(TAG, "original: " + event.getX() + ", " + event.getY()
- + " new: " + mTmpPoint[0] + ", " + mTmpPoint[1]
- + " rect: " + this + " forceTransform: " + forceTransform
- + " contains: " + contains(mTmpPoint[0], mTmpPoint[1]));
+ + " new: " + mTmpPoint[0] + ", " + mTmpPoint[1]
+ + " rect: " + this + " forceTransform: " + forceTransform
+ + " contains: " + contains(mTmpPoint[0], mTmpPoint[1])
+ + " this: " + this);
}
if (contains(mTmpPoint[0], mTmpPoint[1])) {
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index b4f1330..ef09957 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -54,6 +54,7 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.MotionEvent;
import android.view.Surface;
@@ -61,6 +62,7 @@
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
import com.android.launcher3.util.DisplayController.Info;
@@ -127,14 +129,27 @@
private boolean mIsUserSetupComplete;
public RecentsAnimationDeviceState(Context context) {
+ this(context, false);
+ }
+
+ /**
+ * @param isInstanceForTouches {@code true} if this is the persistent instance being used for
+ * gesture touch handling
+ */
+ public RecentsAnimationDeviceState(Context context, boolean isInstanceForTouches) {
mContext = context;
mDisplayController = DisplayController.INSTANCE.get(context);
mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
mDisplayId = mDisplayController.getInfo().id;
mIsOneHandedModeSupported = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
runOnDestroy(() -> mDisplayController.removeChangeListener(this));
- mRotationTouchHelper = new RotationTouchHelper(context, mDisplayController);
- runOnDestroy(mRotationTouchHelper::destroy);
+ mRotationTouchHelper = RotationTouchHelper.INSTANCE.get(context);
+ if (isInstanceForTouches) {
+ // rotationTouchHelper doesn't get initialized after being destroyed, so only destroy
+ // if primary TouchInteractionService instance needs to be destroyed.
+ mRotationTouchHelper.init();
+ runOnDestroy(mRotationTouchHelper::destroy);
+ }
// Register for user unlocked if necessary
mIsUserUnlocked = context.getSystemService(UserManager.class)
@@ -214,6 +229,7 @@
* Cleans up all the registered listeners and receivers.
*/
public void destroy() {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "destroying RADS", new Throwable());
for (Runnable r : mOnDestroyActions) {
r.run();
}
diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
index f4688a1..fd0de42 100644
--- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java
+++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.content.res.Resources;
+import android.util.Log;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
@@ -31,6 +32,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.MainThreadInitializedObject;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.QuickStepContract;
@@ -43,10 +45,13 @@
SysUINavigationMode.NavigationModeChangeListener,
DisplayInfoChangeListener {
- private final OrientationTouchTransformer mOrientationTouchTransformer;
- private final DisplayController mDisplayController;
- private final SysUINavigationMode mSysUiNavMode;
- private final int mDisplayId;
+ public static final MainThreadInitializedObject<RotationTouchHelper> INSTANCE =
+ new MainThreadInitializedObject<>(RotationTouchHelper::new);
+
+ private OrientationTouchTransformer mOrientationTouchTransformer;
+ private DisplayController mDisplayController;
+ private SysUINavigationMode mSysUiNavMode;
+ private int mDisplayId;
private int mDisplayRotation;
private final ArrayList<Runnable> mOnDestroyActions = new ArrayList<>();
@@ -117,25 +122,46 @@
*/
private boolean mInOverview;
private boolean mTaskListFrozen;
-
-
private final Context mContext;
- public RotationTouchHelper(Context context, DisplayController displayController) {
+ /**
+ * Keeps track of whether destroy has been called for this instance. Mainly used for TAPL tests
+ * where multiple instances of RotationTouchHelper are being created. b/177316094
+ */
+ private boolean mNeedsInit = true;
+
+ private RotationTouchHelper(Context context) {
mContext = context;
- mDisplayController = displayController;
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "RotationTouchHelper ctor init? " + mNeedsInit
+ + " " + this);
+ if (mNeedsInit) {
+ init();
+ }
+ }
+
+ public void init() {
+ if (!mNeedsInit) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "Did not need init? " + " " + this);
+ return;
+ }
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "RotationTouchHelper init() " + this,
+ new Throwable());
+ mDisplayController = DisplayController.INSTANCE.get(mContext);
Resources resources = mContext.getResources();
- mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
+ mSysUiNavMode = SysUINavigationMode.INSTANCE.get(mContext);
mDisplayId = mDisplayController.getInfo().id;
mOrientationTouchTransformer = new OrientationTouchTransformer(resources, mMode,
() -> QuickStepContract.getWindowCornerRadius(resources));
// Register for navigation mode changes
- onNavigationModeChanged(mSysUiNavMode.addModeChangeListener(this));
+ SysUINavigationMode.Mode newMode = mSysUiNavMode.addModeChangeListener(this);
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "AddedModeChangeListener: " + this +
+ " currentMode: " + newMode);
+ onNavigationModeChanged(newMode);
runOnDestroy(() -> mSysUiNavMode.removeModeChangeListener(this));
- mOrientationListener = new OrientationEventListener(context) {
+ mOrientationListener = new OrientationEventListener(mContext) {
@Override
public void onOrientationChanged(int degrees) {
int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees,
@@ -154,6 +180,7 @@
}
}
};
+ mNeedsInit = false;
}
private void setupOrientationSwipeHandler() {
@@ -176,9 +203,11 @@
* Cleans up all the registered listeners and receivers.
*/
public void destroy() {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "destroying " + this);
for (Runnable r : mOnDestroyActions) {
r.run();
}
+ mNeedsInit = true;
}
public boolean isTaskListFrozen() {
@@ -223,6 +252,7 @@
@Override
public void onNavigationModeChanged(SysUINavigationMode.Mode newMode) {
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "nav mode changed: " + newMode);
mDisplayController.removeChangeListener(this);
mDisplayController.addChangeListener(this);
onDisplayInfoChanged(mContext, mDisplayController.getInfo(), CHANGE_ALL);
@@ -374,4 +404,8 @@
pw.println(" displayRotation=" + getDisplayRotation());
mOrientationTouchTransformer.dump(pw);
}
+
+ public OrientationTouchTransformer getOrientationTouchTransformer() {
+ return mOrientationTouchTransformer;
+ }
}
diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
index b6dad2d..c87cd17 100644
--- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java
+++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java
@@ -86,6 +86,7 @@
@UiThread
public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState,
Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
+ Log.d("b/186444448", "startRecentsAnimation");
// Notify if recents animation is still running
if (mController != null) {
String msg = "New recents animation started before old animation completed";
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index f3fe0b4..c74f53b 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -300,7 +300,9 @@
// Everything else should be initialized in onUserUnlocked() below.
mMainChoreographer = Choreographer.getInstance();
mAM = ActivityManagerWrapper.getInstance();
- mDeviceState = new RecentsAnimationDeviceState(this);
+ mDeviceState = new RecentsAnimationDeviceState(this, true);
+ Log.d(TestProtocol.NO_SWIPE_TO_HOME, "RADS OTT instance: " +
+ mDeviceState.getRotationTouchHelper().getOrientationTouchTransformer());
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
mDeviceState.addOneHandedModeChangedCallback(this::onOneHandedModeOverlayChanged);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 2a3b86e..596f746 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1277,23 +1277,20 @@
}
float accumulatedTranslationX = 0;
- float[] fullscreenTranslations = new float[taskCount];
for (int i = 0; i < taskCount; i++) {
TaskView taskView = getTaskViewAt(i);
taskView.updateTaskSize();
- fullscreenTranslations[i] += accumulatedTranslationX;
+ taskView.getPrimaryFullscreenTranslationProperty().set(taskView,
+ accumulatedTranslationX);
+ taskView.getSecondaryFullscreenTranslationProperty().set(taskView, 0f);
// Compensate space caused by TaskView scaling.
float widthDiff =
taskView.getLayoutParams().width * (1 - taskView.getFullscreenScale());
// Compensate page spacing widening caused by RecentsView scaling.
widthDiff += mPageSpacing * (1 - 1 / mFullscreenScale);
- float fullscreenTranslationX = mIsRtl ? widthDiff : -widthDiff;
- accumulatedTranslationX += fullscreenTranslationX;
+ accumulatedTranslationX += mIsRtl ? widthDiff : -widthDiff;
}
- for (int i = 0; i < taskCount; i++) {
- getTaskViewAt(i).setFullscreenTranslationX(fullscreenTranslations[i]);
- }
mClearAllButton.setFullscreenTranslationPrimary(accumulatedTranslationX);
updateGridProperties();
@@ -1600,8 +1597,9 @@
* {@link #onGestureAnimationStart} and {@link #onGestureAnimationEnd()}.
*/
public void onSwipeUpAnimationSuccess() {
+ Log.d("b/186444448", "onSwipeUpAnimationSuccess");
if (getRunningTaskView() != null) {
- animateUpRunningTaskIconScale(0f);
+ animateUpRunningTaskIconScale();
}
setSwipeDownShouldLaunchApp(true);
}
@@ -1664,6 +1662,7 @@
* Called when a gesture from an app has finished, and the animation to the target has ended.
*/
public void onGestureAnimationEnd() {
+ Log.d("b/186444448", "onGestureEnd");
mGestureActive = false;
if (mOrientationState.setGestureActive(false)) {
updateOrientationHandler();
@@ -1818,15 +1817,13 @@
}
public void animateUpRunningTaskIconScale() {
- animateUpRunningTaskIconScale(0);
- }
-
- public void animateUpRunningTaskIconScale(float startProgress) {
mRunningTaskIconScaledDown = false;
TaskView firstTask = getRunningTaskView();
+ Log.d("b/186444448", "animateUpRunningTaskIconScale: firstTask="
+ + (firstTask != null ? "t:" + firstTask.getTask() : null));
if (firstTask != null) {
+ firstTask.setIconScaleAnimStartProgress(0f);
firstTask.animateIconScaleAndDimIntoView();
- firstTask.setIconScaleAnimStartProgress(startProgress);
}
}
@@ -1998,7 +1995,9 @@
gridTranslationAnimators.add(taskDismissAnimator);
}
taskView.setGridTranslationX(gridTranslations[i] - snappedTaskGridTranslationX);
- taskView.setNonFullscreenTranslationX(snappedTaskFullscreenScrollAdjustment);
+ taskView.getPrimaryNonFullscreenTranslationProperty().set(taskView,
+ snappedTaskFullscreenScrollAdjustment);
+ taskView.getSecondaryNonFullscreenTranslationProperty().set(taskView, 0f);
}
AnimatorSet gridTranslationAnimatorSet = new AnimatorSet();
gridTranslationAnimatorSet.playTogether(gridTranslationAnimators);
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 35acdd1..3349b74 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -250,6 +250,58 @@
}
};
+ private static final FloatProperty<TaskView> FULLSCREEN_TRANSLATION_X =
+ new FloatProperty<TaskView>("fullscreenTranslationX") {
+ @Override
+ public void setValue(TaskView taskView, float v) {
+ taskView.setFullscreenTranslationX(v);
+ }
+
+ @Override
+ public Float get(TaskView taskView) {
+ return taskView.mFullscreenTranslationX;
+ }
+ };
+
+ private static final FloatProperty<TaskView> FULLSCREEN_TRANSLATION_Y =
+ new FloatProperty<TaskView>("fullscreenTranslationY") {
+ @Override
+ public void setValue(TaskView taskView, float v) {
+ taskView.setFullscreenTranslationY(v);
+ }
+
+ @Override
+ public Float get(TaskView taskView) {
+ return taskView.mFullscreenTranslationY;
+ }
+ };
+
+ private static final FloatProperty<TaskView> NON_FULLSCREEN_TRANSLATION_X =
+ new FloatProperty<TaskView>("nonFullscreenTranslationX") {
+ @Override
+ public void setValue(TaskView taskView, float v) {
+ taskView.setNonFullscreenTranslationX(v);
+ }
+
+ @Override
+ public Float get(TaskView taskView) {
+ return taskView.mNonFullscreenTranslationX;
+ }
+ };
+
+ private static final FloatProperty<TaskView> NON_FULLSCREEN_TRANSLATION_Y =
+ new FloatProperty<TaskView>("nonFullscreenTranslationY") {
+ @Override
+ public void setValue(TaskView taskView, float v) {
+ taskView.setNonFullscreenTranslationY(v);
+ }
+
+ @Override
+ public Float get(TaskView taskView) {
+ return taskView.mNonFullscreenTranslationY;
+ }
+ };
+
private static final FloatProperty<TaskView> COLOR_TINT =
new FloatProperty<TaskView>("colorTint") {
@Override
@@ -284,9 +336,11 @@
private float mTaskResistanceTranslationY;
// The following translation variables should only be used in the same orientation as Launcher.
private float mFullscreenTranslationX;
+ private float mFullscreenTranslationY;
// Applied as a complement to fullscreenTranslation, for adjusting the carousel overview, or the
// in transition carousel before forming the grid on tablets.
private float mNonFullscreenTranslationX;
+ private float mNonFullscreenTranslationY;
private float mBoxTranslationY;
// The following grid translations scales with mGridProgress.
private float mGridTranslationX;
@@ -740,6 +794,8 @@
}
public void animateIconScaleAndDimIntoView() {
+ Log.d("b/186444448", "animateIconScaleAndDimIntoView: startProgress="
+ + mIconScaleAnimStartProgress);
if (mIconAndDimAnimator != null) {
mIconAndDimAnimator.cancel();
}
@@ -749,6 +805,7 @@
mIconAndDimAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
+ Log.d("b/186444448", "animateIconScaleAndDimIntoView: end");
mIconAndDimAnimator = null;
}
});
@@ -786,8 +843,9 @@
@Override
public void onRecycle() {
- mFullscreenTranslationX = mNonFullscreenTranslationX =
- mGridTranslationX = mGridTranslationY = mBoxTranslationY = 0f;
+ mFullscreenTranslationX = mFullscreenTranslationY = mNonFullscreenTranslationX =
+ mNonFullscreenTranslationY = mGridTranslationX = mGridTranslationY =
+ mBoxTranslationY = 0f;
resetViewTransforms();
// Clear any references to the thumbnail (it will be re-read either from the cache or the
// system on next bind)
@@ -929,16 +987,26 @@
applyTranslationY();
}
- public void setFullscreenTranslationX(float fullscreenTranslationX) {
+ private void setFullscreenTranslationX(float fullscreenTranslationX) {
mFullscreenTranslationX = fullscreenTranslationX;
applyTranslationX();
}
- public void setNonFullscreenTranslationX(float nonFullscreenTranslationX) {
+ private void setFullscreenTranslationY(float fullscreenTranslationY) {
+ mFullscreenTranslationY = fullscreenTranslationY;
+ applyTranslationY();
+ }
+
+ private void setNonFullscreenTranslationX(float nonFullscreenTranslationX) {
mNonFullscreenTranslationX = nonFullscreenTranslationX;
applyTranslationX();
}
+ private void setNonFullscreenTranslationY(float nonFullscreenTranslationY) {
+ mNonFullscreenTranslationY = nonFullscreenTranslationY;
+ applyTranslationY();
+ }
+
public void setGridTranslationX(float gridTranslationX) {
mGridTranslationX = gridTranslationX;
applyTranslationX();
@@ -960,9 +1028,9 @@
public float getScrollAdjustment(boolean fullscreenEnabled, boolean gridEnabled) {
float scrollAdjustment = 0;
if (fullscreenEnabled) {
- scrollAdjustment += mFullscreenTranslationX;
+ scrollAdjustment += getPrimaryFullscreenTranslationProperty().get(this);
} else {
- scrollAdjustment += mNonFullscreenTranslationX;
+ scrollAdjustment += getPrimaryNonFullscreenTranslationProperty().get(this);
}
if (gridEnabled) {
scrollAdjustment += mGridTranslationX;
@@ -1012,7 +1080,10 @@
* change according to a temporary state (e.g. task offset).
*/
public float getPersistentTranslationY() {
- return getGridTrans(mGridTranslationY) + mBoxTranslationY;
+ return mBoxTranslationY
+ + getFullscreenTrans(mFullscreenTranslationY)
+ + getNonFullscreenTrans(mNonFullscreenTranslationY)
+ + getGridTrans(mGridTranslationY);
}
public FloatProperty<TaskView> getPrimaryDismissTranslationProperty() {
@@ -1035,6 +1106,26 @@
TASK_RESISTANCE_TRANSLATION_X, TASK_RESISTANCE_TRANSLATION_Y);
}
+ public FloatProperty<TaskView> getPrimaryFullscreenTranslationProperty() {
+ return getPagedOrientationHandler().getPrimaryValue(
+ FULLSCREEN_TRANSLATION_X, FULLSCREEN_TRANSLATION_Y);
+ }
+
+ public FloatProperty<TaskView> getSecondaryFullscreenTranslationProperty() {
+ return getPagedOrientationHandler().getSecondaryValue(
+ FULLSCREEN_TRANSLATION_X, FULLSCREEN_TRANSLATION_Y);
+ }
+
+ public FloatProperty<TaskView> getPrimaryNonFullscreenTranslationProperty() {
+ return getPagedOrientationHandler().getPrimaryValue(
+ NON_FULLSCREEN_TRANSLATION_X, NON_FULLSCREEN_TRANSLATION_Y);
+ }
+
+ public FloatProperty<TaskView> getSecondaryNonFullscreenTranslationProperty() {
+ return getPagedOrientationHandler().getSecondaryValue(
+ NON_FULLSCREEN_TRANSLATION_X, NON_FULLSCREEN_TRANSLATION_Y);
+ }
+
@Override
public boolean hasOverlappingRendering() {
// TODO: Clip-out the icon region from the thumbnail, since they are overlapping.
diff --git a/res/color-v31/overview_scrim.xml b/res/color-v31/overview_scrim.xml
new file mode 100644
index 0000000..8079995
--- /dev/null
+++ b/res/color-v31/overview_scrim.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_500" android:lStar="87" />
+</selector>
diff --git a/res/color-v31/overview_scrim_dark.xml b/res/color-v31/overview_scrim_dark.xml
new file mode 100644
index 0000000..b8ed774
--- /dev/null
+++ b/res/color-v31/overview_scrim_dark.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral1_800" />
+</selector>
diff --git a/res/color/overview_scrim.xml b/res/color/overview_scrim.xml
new file mode 100644
index 0000000..48cf576
--- /dev/null
+++ b/res/color/overview_scrim.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#30000000" />
+</selector>
diff --git a/res/color/overview_scrim_dark.xml b/res/color/overview_scrim_dark.xml
new file mode 100644
index 0000000..48cf576
--- /dev/null
+++ b/res/color/overview_scrim_dark.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#30000000" />
+</selector>
diff --git a/res/layout/launcher.xml b/res/layout/launcher.xml
index f34e685..039d8d3 100644
--- a/res/layout/launcher.xml
+++ b/res/layout/launcher.xml
@@ -66,8 +66,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrim_view"
- android:background="?attr/allAppsScrimColor"
- android:alpha="0" />
+ android:background="@android:color/transparent" />
<include
android:id="@+id/apps_view"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 09dd95c..9089a64 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -35,6 +35,7 @@
<attr name="widgetsTheme" format="reference" />
<attr name="iconOnlyShortcutColor" format="color" />
<attr name="eduHalfSheetBGColor" format="color" />
+ <attr name="overviewScrimColor" format="color" />
<attr name="folderDotColor" format="color" />
<attr name="folderFillColor" format="color" />
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 5b37966..8d46f1c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -57,6 +57,7 @@
<item name="eduHalfSheetBGColor">?android:attr/colorAccent</item>
<item name="disabledIconAlpha">.54</item>
<item name="gridColor">?android:attr/colorAccent</item>
+ <item name="overviewScrimColor">@color/overview_scrim</item>
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">false</item>
@@ -112,6 +113,7 @@
<item name="iconOnlyShortcutColor">#B3FFFFFF</item>
<item name="workProfileOverlayTextColor">@android:color/white</item>
<item name="eduHalfSheetBGColor">#DD000000</item>
+ <item name="overviewScrimColor">@color/overview_scrim_dark</item>
</style>
<style name="LauncherTheme.Dark.DarkMainColor" parent="@style/LauncherTheme.Dark">
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index 803f8d2..b56c012 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -19,6 +19,8 @@
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.FloatProperty;
import android.util.IntProperty;
@@ -135,6 +137,22 @@
}
};
+ public static final IntProperty<View> VIEW_BACKGROUND_COLOR =
+ new IntProperty<View>("backgroundColor") {
+ @Override
+ public void setValue(View view, int color) {
+ view.setBackgroundColor(color);
+ }
+
+ @Override
+ public Integer get(View view) {
+ if (!(view.getBackground() instanceof ColorDrawable)) {
+ return Color.TRANSPARENT;
+ }
+ return ((ColorDrawable) view.getBackground()).getColor();
+ }
+ };
+
/**
* Utility method to create an {@link AnimatorListener} which executes a callback on animation
* cancel.
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 58df9c8..4c11725 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -30,6 +30,7 @@
import static com.android.launcher3.testing.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import android.content.Context;
+import android.graphics.Color;
import android.view.animation.Interpolator;
import com.android.launcher3.statemanager.BaseState;
@@ -217,8 +218,12 @@
return 0;
}
- public float getWorkspaceScrimAlpha(Launcher launcher) {
- return 0;
+ /**
+ * What color should the workspace scrim be in when at rest in this state.
+ * Return {@link Color#TRANSPARENT} for no scrim.
+ */
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return Color.TRANSPARENT;
}
/**
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index 6fa8142..aa99d52 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -166,8 +166,9 @@
propertySetter.setFloat(sysUiScrim, SYSUI_PROGRESS,
state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
- propertySetter.setViewAlpha(mLauncher.getScrimView(),
- state.getWorkspaceScrimAlpha(mLauncher),
+
+ propertySetter.setViewBackgroundColor(mLauncher.getScrimView(),
+ state.getWorkspaceScrimColor(mLauncher),
config.getInterpolator(ANIM_WORKSPACE_SCRIM_FADE, LINEAR));
}
diff --git a/src/com/android/launcher3/anim/PendingAnimation.java b/src/com/android/launcher3/anim/PendingAnimation.java
index 9068331..8057475 100644
--- a/src/com/android/launcher3/anim/PendingAnimation.java
+++ b/src/com/android/launcher3/anim/PendingAnimation.java
@@ -16,6 +16,7 @@
package com.android.launcher3.anim;
import static com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS;
+import static com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR;
import static com.android.launcher3.anim.AnimatorPlaybackController.addAnimationHoldersRecur;
import android.animation.Animator;
@@ -25,6 +26,7 @@
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
+import android.graphics.drawable.ColorDrawable;
import android.util.FloatProperty;
import android.util.IntProperty;
import android.view.View;
@@ -85,6 +87,17 @@
}
@Override
+ public void setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
+ if (view == null || (view.getBackground() instanceof ColorDrawable
+ && ((ColorDrawable) view.getBackground()).getColor() == color)) {
+ return;
+ }
+ ObjectAnimator anim = ObjectAnimator.ofArgb(view, VIEW_BACKGROUND_COLOR, color);
+ anim.setInterpolator(interpolator);
+ add(anim);
+ }
+
+ @Override
public <T> void setFloat(T target, FloatProperty<T> property, float value,
TimeInterpolator interpolator) {
if (property.get(target) == value) {
diff --git a/src/com/android/launcher3/anim/PropertySetter.java b/src/com/android/launcher3/anim/PropertySetter.java
index 2ce620b..729523f 100644
--- a/src/com/android/launcher3/anim/PropertySetter.java
+++ b/src/com/android/launcher3/anim/PropertySetter.java
@@ -41,6 +41,15 @@
}
/**
+ * Sets the background color of the provided view using the provided interpolator.
+ */
+ default void setViewBackgroundColor(View view, int color, TimeInterpolator interpolator) {
+ if (view != null) {
+ view.setBackgroundColor(color);
+ }
+ }
+
+ /**
* Updates the float property of the target using the provided interpolator
*/
default <T> void setFloat(T target, FloatProperty<T> property, float value,
diff --git a/src/com/android/launcher3/states/HintState.java b/src/com/android/launcher3/states/HintState.java
index 22c9d5b..8b52016 100644
--- a/src/com/android/launcher3/states/HintState.java
+++ b/src/com/android/launcher3/states/HintState.java
@@ -19,8 +19,12 @@
import android.content.Context;
+import androidx.core.graphics.ColorUtils;
+
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
+import com.android.launcher3.util.Themes;
/**
* Scale down workspace/hotseat to hint at going to either overview (on pause) or first home screen.
@@ -49,8 +53,9 @@
}
@Override
- public float getWorkspaceScrimAlpha(Launcher launcher) {
- return 0.4f;
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return ColorUtils.setAlphaComponent(
+ Themes.getAttrColor(launcher, R.attr.overviewScrimColor), 100);
}
@Override
diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java
index c9424de..722f578 100644
--- a/src/com/android/launcher3/views/ScrimView.java
+++ b/src/com/android/launcher3/views/ScrimView.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.graphics.Rect;
+import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.View;
@@ -26,9 +27,7 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
import com.android.launcher3.util.SystemUiController;
-import com.android.launcher3.util.Themes;
/**
* Simple scrim which draws a flat color
@@ -36,13 +35,10 @@
public class ScrimView extends View implements Insettable {
private static final float STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD = 0.9f;
- private final boolean mIsScrimDark;
private SystemUiController mSystemUiController;
public ScrimView(Context context, AttributeSet attrs) {
super(context, attrs);
- mIsScrimDark = ColorUtils.calculateLuminance(
- Themes.getAttrColor(context, R.attr.allAppsScrimColor)) < 0.5f;
setFocusable(false);
}
@@ -61,6 +57,12 @@
}
@Override
+ public void setBackgroundColor(int color) {
+ updateSysUiColors();
+ super.setBackgroundColor(color);
+ }
+
+ @Override
protected void onVisibilityChanged(View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
updateSysUiColors();
@@ -72,7 +74,7 @@
boolean forceChange =
getVisibility() == VISIBLE && getAlpha() > STATUS_BAR_COLOR_FORCE_UPDATE_THRESHOLD;
if (forceChange) {
- getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !mIsScrimDark);
+ getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !isScrimDark());
} else {
getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, 0);
}
@@ -84,4 +86,14 @@
}
return mSystemUiController;
}
+
+ private boolean isScrimDark() {
+ if (!(getBackground() instanceof ColorDrawable)) {
+ throw new IllegalStateException(
+ "ScrimView must have a ColorDrawable background, this one has: "
+ + getBackground());
+ }
+ return ColorUtils.calculateLuminance(
+ ((ColorDrawable) getBackground()).getColor()) < 0.5f;
+ }
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
index 53748b7..978c321 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -23,6 +23,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
+import com.android.launcher3.util.Themes;
/**
* Definition for AllApps state
@@ -76,7 +77,7 @@
}
@Override
- public float getWorkspaceScrimAlpha(Launcher launcher) {
- return 1;
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
}
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
index e85e505..d154317 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -19,7 +19,10 @@
import android.content.Context;
+import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.R;
+import com.android.launcher3.util.Themes;
/**
* Definition for overview state
@@ -56,4 +59,9 @@
public static OverviewState newSplitSelectState(int id) {
return new OverviewState(id);
}
+
+ @Override
+ public int getWorkspaceScrimColor(Launcher launcher) {
+ return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
+ }
}