Fade in/out taskbar bg alpha when unstash/stashing.
This prevents the case where we are drawing both the taskbar bg renderer and the stashed handle at the same time. Fixes: 287245176 Test: go home/overview, open/close notif shade, stash/unstash in app Change-Id: Ib025a0cf1ad5fd8a9afd079aa50210f3b2388d8e
This commit is contained in:
1 parent
af641a6e80
commit
d76713eb08
3 files changed
+58
-17
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user