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