Remove scrim on highlighted spring-loaded panel.

Bug: 27135377
Change-Id: I470955ed082a45ae7dc5f8fdd1f3decb2b573dbc
This commit is contained in:
Tony Wickham
2016-02-18 14:37:07 -08:00
parent 16466f1bbb
commit 95cdb3a021
7 changed files with 51 additions and 9 deletions
+4 -3
View File
@@ -22,13 +22,14 @@
<item> <item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#3fffffff" /> <solid android:color="@color/spring_loaded_panel_color" />
</shape> </shape>
</item> </item>
<item> <item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="#3fffffff" /> <stroke
<stroke android:width="1dp" android:color="#fff" /> android:width="@dimen/spring_loaded_panel_border"
android:color="@color/spring_loaded_highlighted_panel_border_color" />
</shape> </shape>
</item> </item>
+3
View File
@@ -39,6 +39,9 @@
<color name="outline_color">#FFFFFFFF</color> <color name="outline_color">#FFFFFFFF</color>
<color name="launcher_accent_color">#ff009688</color> <color name="launcher_accent_color">#ff009688</color>
<color name="spring_loaded_panel_color">#40FFFFFF</color>
<color name="spring_loaded_highlighted_panel_border_color">#FFF</color>
<!-- Containers --> <!-- Containers -->
<color name="container_fastscroll_thumb_inactive_color">#009688</color> <color name="container_fastscroll_thumb_inactive_color">#009688</color>
<color name="container_fastscroll_thumb_active_color">#009688</color> <color name="container_fastscroll_thumb_active_color">#009688</color>
+2
View File
@@ -134,6 +134,8 @@
<dimen name="drag_flingToDeleteMinVelocity">-1500dp</dimen> <dimen name="drag_flingToDeleteMinVelocity">-1500dp</dimen>
<dimen name="spring_loaded_panel_border">1dp</dimen>
<!-- Theme --> <!-- Theme -->
<dimen name="quantum_panel_outer_padding">4dp</dimen> <dimen name="quantum_panel_outer_padding">4dp</dimen>
+1 -1
View File
@@ -55,7 +55,7 @@ public class Hotseat extends FrameLayout
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout(); mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
} }
CellLayout getLayout() { public CellLayout getLayout() {
return mContent; return mContent;
} }
+9 -3
View File
@@ -625,17 +625,23 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// we moved this functionality to a helper function so SmoothPagedView can reuse it // we moved this functionality to a helper function so SmoothPagedView can reuse it
protected boolean computeScrollHelper() { protected boolean computeScrollHelper() {
return computeScrollHelper(true);
}
protected boolean computeScrollHelper(boolean shouldInvalidate) {
if (mScroller.computeScrollOffset()) { if (mScroller.computeScrollOffset()) {
// Don't bother scrolling if the page does not need to be moved // Don't bother scrolling if the page does not need to be moved
if (getScrollX() != mScroller.getCurrX() if (getScrollX() != mScroller.getCurrX()
|| getScrollY() != mScroller.getCurrY()) { || getScrollY() != mScroller.getCurrY()) {
float scaleX = mFreeScroll ? getScaleX() : 1f; float scaleX = mFreeScroll ? getScaleX() : 1f;
int scrollX = (int) (mScroller.getCurrX() * (1 / scaleX)); int scrollX = (int) (mScroller.getCurrX() * (1 / scaleX));
scrollTo(scrollX, mScroller.getCurrY()); scrollTo(scrollX, mScroller.getCurrY());
} }
invalidate(); if (shouldInvalidate) {
invalidate();
}
return true; return true;
} else if (mNextPage != INVALID_PAGE) { } else if (mNextPage != INVALID_PAGE && shouldInvalidate) {
sendScrollAccessibilityEvent(); sendScrollAccessibilityEvent();
mCurrentPage = validateNewPage(mNextPage); mCurrentPage = validateNewPage(mNextPage);
+12 -2
View File
@@ -149,7 +149,7 @@ public class Workspace extends PagedView
*/ */
@Thunk CellLayout mDragTargetLayout = null; @Thunk CellLayout mDragTargetLayout = null;
/** /**
* The CellLayout that we will show as glowing * The CellLayout that we will show as highlighted
*/ */
private CellLayout mDragOverlappingLayout = null; private CellLayout mDragOverlappingLayout = null;
@@ -1421,6 +1421,10 @@ public class Workspace extends PagedView
mWallpaperOffset.syncWithScroll(); mWallpaperOffset.syncWithScroll();
} }
public void computeScrollWithoutInvalidation() {
computeScrollHelper(false);
}
@Override @Override
protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) { protected void determineScrollingStart(MotionEvent ev, float touchSlopScale) {
if (!isSwitchingState()) { if (!isSwitchingState()) {
@@ -2836,7 +2840,13 @@ public class Workspace extends PagedView
if (mDragOverlappingLayout != null) { if (mDragOverlappingLayout != null) {
mDragOverlappingLayout.setIsDragOverlapping(true); mDragOverlappingLayout.setIsDragOverlapping(true);
} }
invalidate(); // Invalidating the scrim will also force this CellLayout
// to be invalidated so that it is highlighted if necessary.
mLauncher.getDragLayer().invalidateScrim();
}
public CellLayout getCurrentDragOverlappingLayout() {
return mDragOverlappingLayout;
} }
void setCurrentDropOverCell(int x, int y) { void setCurrentDropOverCell(int x, int y) {
@@ -26,6 +26,7 @@ import android.content.res.Resources;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.DragEvent; import android.view.DragEvent;
@@ -42,6 +43,7 @@ import android.widget.TextView;
import com.android.launcher3.AppWidgetResizeFrame; import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.CellLayout; import com.android.launcher3.CellLayout;
import com.android.launcher3.Hotseat;
import com.android.launcher3.InsettableFrameLayout; import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.ItemInfo; import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher; import com.android.launcher3.Launcher;
@@ -92,6 +94,7 @@ public class DragLayer extends InsettableFrameLayout {
private boolean mHoverPointClosesFolder = false; private boolean mHoverPointClosesFolder = false;
private final Rect mHitRect = new Rect(); private final Rect mHitRect = new Rect();
private final Rect mHighlightRect = new Rect();
private TouchCompleteListener mTouchCompleteListener; private TouchCompleteListener mTouchCompleteListener;
@@ -922,12 +925,29 @@ public class DragLayer extends InsettableFrameLayout {
invalidate(); invalidate();
} }
public void invalidateScrim() {
if (mBackgroundAlpha > 0.0f) {
invalidate();
}
}
@Override @Override
protected void dispatchDraw(Canvas canvas) { protected void dispatchDraw(Canvas canvas) {
// Draw the background below children. // Draw the background below children.
if (mBackgroundAlpha > 0.0f) { if (mBackgroundAlpha > 0.0f) {
// Update the scroll position first to ensure scrim cutout is in the right place.
mLauncher.getWorkspace().computeScrollWithoutInvalidation();
int alpha = (int) (mBackgroundAlpha * 255); int alpha = (int) (mBackgroundAlpha * 255);
CellLayout currCellLayout = mLauncher.getWorkspace().getCurrentDragOverlappingLayout();
canvas.save();
if (currCellLayout != null && currCellLayout != mLauncher.getHotseat().getLayout()) {
// Cut a hole in the darkening scrim on the page that should be highlighted, if any.
getDescendantRectRelativeToSelf(currCellLayout, mHighlightRect);
canvas.clipRect(mHighlightRect, Region.Op.DIFFERENCE);
}
canvas.drawColor((alpha << 24) | SCRIM_COLOR); canvas.drawColor((alpha << 24) | SCRIM_COLOR);
canvas.restore();
} }
super.dispatchDraw(canvas); super.dispatchDraw(canvas);