mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 16:26:47 +00:00
Merge "Fade in/out taskbar bg alpha when unstash/stashing." into udc-dev am: 613cc95c8a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23696768 Change-Id: I8155e8db1ce215f25e842058de3564f49d57f83f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -33,6 +34,8 @@ import androidx.annotation.Nullable;
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.MultiPropertyFactory;
|
||||
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,25 @@ import com.android.launcher3.views.BaseDragLayer;
|
||||
*/
|
||||
public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
|
||||
private static final int INDEX_ALL_OTHER_STATES = 0;
|
||||
private static final int INDEX_STASH_ANIM = 1;
|
||||
private static final int INDEX_COUNT = 2;
|
||||
|
||||
private static final FloatProperty<TaskbarDragLayer> BG_ALPHA =
|
||||
new FloatProperty<>("taskbarBgAlpha") {
|
||||
@Override
|
||||
public void setValue(TaskbarDragLayer dragLayer, float alpha) {
|
||||
dragLayer.mBackgroundRenderer.getPaint().setAlpha((int) (alpha * 255));
|
||||
dragLayer.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float get(TaskbarDragLayer dragLayer) {
|
||||
return dragLayer.mBackgroundRenderer.getPaint().getAlpha() / 255f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private final TaskbarBackgroundRenderer mBackgroundRenderer;
|
||||
private final ViewTreeObserver.OnComputeInternalInsetsListener mTaskbarInsetsComputer =
|
||||
this::onComputeTaskbarInsets;
|
||||
@@ -49,6 +71,8 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
|
||||
private float mTaskbarBackgroundOffset;
|
||||
|
||||
private final MultiPropertyFactory<TaskbarDragLayer> mTaskbarBackgroundAlpha;
|
||||
|
||||
public TaskbarDragLayer(@NonNull Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -66,7 +90,11 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, 1 /* alphaChannelCount */);
|
||||
mBackgroundRenderer = new TaskbarBackgroundRenderer(mActivity);
|
||||
mBackgroundRenderer.getPaint().setAlpha(0);
|
||||
|
||||
mTaskbarBackgroundAlpha = new MultiPropertyFactory<>(this, BG_ALPHA, INDEX_COUNT,
|
||||
(a, b) -> a * b, 1f);
|
||||
mTaskbarBackgroundAlpha.get(INDEX_ALL_OTHER_STATES).setValue(0);
|
||||
mTaskbarBackgroundAlpha.get(INDEX_STASH_ANIM).setValue(1);
|
||||
}
|
||||
|
||||
public void init(TaskbarDragLayerController.TaskbarDragLayerCallbacks callbacks) {
|
||||
@@ -133,13 +161,12 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the alpha of the background color behind all the Taskbar contents.
|
||||
* @param alpha 0 is fully transparent, 1 is fully opaque.
|
||||
*/
|
||||
protected void setTaskbarBackgroundAlpha(float alpha) {
|
||||
mBackgroundRenderer.getPaint().setAlpha((int) (alpha * 255));
|
||||
invalidate();
|
||||
protected MultiProperty getBackgroundRendererAlpha() {
|
||||
return mTaskbarBackgroundAlpha.get(INDEX_ALL_OTHER_STATES);
|
||||
}
|
||||
|
||||
protected MultiProperty getBackgroundRendererAlphaForStash() {
|
||||
return mTaskbarBackgroundAlpha.get(INDEX_STASH_ANIM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimatedFloat;
|
||||
import com.android.launcher3.util.DimensionUtils;
|
||||
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@@ -62,12 +63,14 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
private TaskbarStashViaTouchController mTaskbarStashViaTouchController;
|
||||
private AnimatedFloat mOnBackgroundNavButtonColorIntensity;
|
||||
|
||||
private MultiProperty mBackgroundRendererAlpha;
|
||||
private float mLastSetBackgroundAlpha;
|
||||
|
||||
public TaskbarDragLayerController(TaskbarActivityContext activity,
|
||||
TaskbarDragLayer taskbarDragLayer) {
|
||||
mActivity = activity;
|
||||
mTaskbarDragLayer = taskbarDragLayer;
|
||||
mBackgroundRendererAlpha = mTaskbarDragLayer.getBackgroundRendererAlpha();
|
||||
final Resources resources = mTaskbarDragLayer.getResources();
|
||||
mFolderMargin = resources.getDimensionPixelSize(R.dimen.taskbar_folder_margin);
|
||||
}
|
||||
@@ -152,11 +155,15 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
|
||||
* mNotificationShadeBgTaskbar.value * mImeBgTaskbar.value
|
||||
* mAssistantBgTaskbar.value;
|
||||
mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar);
|
||||
mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha);
|
||||
mBackgroundRendererAlpha.setValue(mLastSetBackgroundAlpha);
|
||||
|
||||
updateOnBackgroundNavButtonColorIntensity();
|
||||
}
|
||||
|
||||
public MultiProperty getBackgroundRendererAlphaForStash() {
|
||||
return mTaskbarDragLayer.getBackgroundRendererAlphaForStash();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the translation of the background during the swipe up gesture.
|
||||
*/
|
||||
|
||||
@@ -232,6 +232,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
// Taskbar background properties.
|
||||
private AnimatedFloat mTaskbarBackgroundOffset;
|
||||
private AnimatedFloat mTaskbarImeBgAlpha;
|
||||
private MultiProperty mTaskbarBackgroundAlphaForStash;
|
||||
// TaskbarView icon properties.
|
||||
private MultiProperty mIconAlphaForStash;
|
||||
private AnimatedFloat mIconScaleForStash;
|
||||
@@ -303,6 +304,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
TaskbarDragLayerController dragLayerController = controllers.taskbarDragLayerController;
|
||||
mTaskbarBackgroundOffset = dragLayerController.getTaskbarBackgroundOffset();
|
||||
mTaskbarImeBgAlpha = dragLayerController.getImeBgTaskbar();
|
||||
mTaskbarBackgroundAlphaForStash = dragLayerController.getBackgroundRendererAlphaForStash();
|
||||
|
||||
TaskbarViewController taskbarViewController = controllers.taskbarViewController;
|
||||
mIconAlphaForStash = taskbarViewController.getTaskbarIconAlpha().get(
|
||||
@@ -747,37 +749,42 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
final float backgroundOffsetTarget = isStashed ? 1 : 0;
|
||||
final float iconAlphaTarget = isStashed ? 0 : 1;
|
||||
final float stashedHandleAlphaTarget = isStashed ? 1 : 0;
|
||||
final float backgroundAlphaTarget = isStashed ? 0 : 1;
|
||||
|
||||
// Timing for the alpha values depend on the animation played
|
||||
long iconAlphaStartDelay = 0, iconAlphaDuration = 0, stashedHandleAlphaDelay = 0,
|
||||
stashedHandleAlphaDuration = 0;
|
||||
long iconAlphaStartDelay = 0, iconAlphaDuration = 0, backgroundAndHandleAlphaStartDelay = 0,
|
||||
backgroundAndHandleAlphaDuration = 0;
|
||||
if (duration > 0) {
|
||||
if (animationType == TRANSITION_HANDLE_FADE) {
|
||||
// When fading, the handle fades in/out at the beginning of the transition with
|
||||
// TASKBAR_STASH_ALPHA_DURATION.
|
||||
stashedHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
|
||||
backgroundAndHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
|
||||
// The iconAlphaDuration must be set to duration for the skippable interpolators
|
||||
// below to work.
|
||||
iconAlphaDuration = duration;
|
||||
} else {
|
||||
iconAlphaStartDelay = TASKBAR_STASH_ALPHA_START_DELAY;
|
||||
iconAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
|
||||
stashedHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
|
||||
backgroundAndHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
|
||||
|
||||
if (isStashed) {
|
||||
if (animationType == TRANSITION_HOME_TO_APP) {
|
||||
iconAlphaStartDelay = TASKBAR_STASH_ICON_ALPHA_HOME_TO_APP_START_DELAY;
|
||||
}
|
||||
stashedHandleAlphaDelay = iconAlphaStartDelay;
|
||||
stashedHandleAlphaDuration = Math.max(0, duration - iconAlphaStartDelay);
|
||||
backgroundAndHandleAlphaStartDelay = iconAlphaStartDelay;
|
||||
backgroundAndHandleAlphaDuration = Math.max(0, duration - iconAlphaStartDelay);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
play(as, mTaskbarStashedHandleAlpha.animateToValue(stashedHandleAlphaTarget),
|
||||
stashedHandleAlphaDelay,
|
||||
stashedHandleAlphaDuration, LINEAR);
|
||||
backgroundAndHandleAlphaStartDelay,
|
||||
backgroundAndHandleAlphaDuration, LINEAR);
|
||||
|
||||
play(as, mTaskbarBackgroundAlphaForStash.animateToValue(backgroundAlphaTarget),
|
||||
backgroundAndHandleAlphaStartDelay,
|
||||
backgroundAndHandleAlphaDuration, LINEAR);
|
||||
|
||||
// The rest of the animations might be "skipped" in TRANSITION_HANDLE_FADE transitions.
|
||||
AnimatorSet skippable = as;
|
||||
|
||||
Reference in New Issue
Block a user