[Search][Motion] Introduce header protection in AllApps
ScrimView exposes ScrimDrawingController that allow FloatingHeaderView to observe AllApps scroll progress and draw header protection on Scrim. In addition, search box independently adopts header protection background to ensure proper clipping behavior. Test: local preview: https://drive.google.com/file/d/1_E577AAJ0LBg0zrKJQSEJK9GQnrtx7uv/view?usp=sharing&resourcekey=0-MTxjlB3xWyJ3qPvr4qMdig Bug: 184946772 Change-Id: I64c0f4f50d26c475d31542148a15c7c145588d3f
This commit is contained in:
1 parent
f94540b28a
commit
acebd1f69a
6 files changed
+127
-9
No files matched your search
@@ -18,6 +18,7 @@ package com.android.launcher3.views;
|
||||
import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.AttributeSet;
|
||||
@@ -37,13 +38,16 @@ public class ScrimView extends View implements Insettable {
|
||||
|
||||
private SystemUiController mSystemUiController;
|
||||
|
||||
private ScrimDrawingController mDrawingController;
|
||||
|
||||
public ScrimView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInsets(Rect insets) { }
|
||||
public void setInsets(Rect insets) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
@@ -62,6 +66,14 @@ public class ScrimView extends View implements Insettable {
|
||||
super.setBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (mDrawingController != null) {
|
||||
mDrawingController.drawOnScrim(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||
super.onVisibilityChanged(changedView, visibility);
|
||||
@@ -96,4 +108,24 @@ public class ScrimView extends View implements Insettable {
|
||||
return ColorUtils.calculateLuminance(
|
||||
((ColorDrawable) getBackground()).getColor()) < 0.5f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets drawing controller. Invalidates ScrimView if drawerController has changed.
|
||||
*/
|
||||
public void setDrawingController(ScrimDrawingController drawingController) {
|
||||
if (mDrawingController != drawingController) {
|
||||
mDrawingController = drawingController;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A Utility interface allowing for other surfaces to draw on ScrimView
|
||||
*/
|
||||
public interface ScrimDrawingController {
|
||||
/**
|
||||
* Called inside ScrimView#OnDraw
|
||||
*/
|
||||
void drawOnScrim(Canvas canvas);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user