mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 18:36:49 +00:00
Fixing issue where holographic outlines were offset when dragging from/to folders/hotseat. (Bug: 5399792)
Change-Id: Iaa39ef1293b45a1d116210ec9d7fbde17dbc99cc
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
<dimen name="workspace_divider_padding_top">12dp</dimen>
|
||||
<dimen name="workspace_divider_padding_bottom">12dp</dimen>
|
||||
|
||||
<dimen name="app_icon_padding_top">6dp</dimen>
|
||||
|
||||
<!-- height of the bottom row of controls -->
|
||||
<dimen name="button_bar_height">68dip</dimen>
|
||||
<!-- Because portal animations go beyond the bounds of an icon, we need
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
<dimen name="folder_cell_width">96dp</dimen>
|
||||
<dimen name="folder_cell_height">96dp</dimen>
|
||||
|
||||
<dimen name="app_icon_padding_top">4dp</dimen>
|
||||
|
||||
<!-- AppsCustomize -->
|
||||
<dimen name="apps_customize_tab_bar_height">56dp</dimen>
|
||||
<dimen name="apps_customize_cell_width">96dp</dimen>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<item name="android:drawablePadding">0dp</item>
|
||||
<item name="android:paddingLeft">4dp</item>
|
||||
<item name="android:paddingRight">4dp</item>
|
||||
<item name="android:paddingTop">4dp</item>
|
||||
<item name="android:paddingTop">@dimen/app_icon_padding_top</item>
|
||||
<item name="android:paddingBottom">4dp</item>
|
||||
<item name="android:textSize">13sp</item>
|
||||
</style>
|
||||
@@ -38,7 +38,7 @@
|
||||
<item name="android:drawablePadding">0dp</item>
|
||||
<item name="android:paddingLeft">4dp</item>
|
||||
<item name="android:paddingRight">4dp</item>
|
||||
<item name="android:paddingTop">4dp</item>
|
||||
<item name="android:paddingTop">@dimen/app_icon_padding_top</item>
|
||||
<item name="android:paddingBottom">4dp</item>
|
||||
<item name="android:textSize">13sp</item>
|
||||
</style>
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
<dimen name="hotseat_height_gap">-1dp</dimen>
|
||||
<dimen name="workspace_overscroll_drawable_padding">0dp</dimen>
|
||||
|
||||
<dimen name="app_icon_padding_top">8dp</dimen>
|
||||
|
||||
<!-- QSB -->
|
||||
<dimen name="toolbar_button_vertical_padding">0dip</dimen>
|
||||
<dimen name="toolbar_button_horizontal_padding">12dip</dimen>
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<item name="android:drawablePadding">8dp</item>
|
||||
<item name="android:paddingLeft">4dp</item>
|
||||
<item name="android:paddingRight">4dp</item>
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:paddingTop">@dimen/app_icon_padding_top</item>
|
||||
<item name="android:paddingBottom">4dp</item>
|
||||
</style>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<item name="android:drawablePadding">2dp</item>
|
||||
<item name="android:paddingLeft">4dp</item>
|
||||
<item name="android:paddingRight">4dp</item>
|
||||
<item name="android:paddingTop">6dp</item>
|
||||
<item name="android:paddingTop">@dimen/app_icon_padding_top</item>
|
||||
<item name="android:paddingBottom">4dp</item>
|
||||
</style>
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ public class CellLayout extends ViewGroup {
|
||||
});
|
||||
mCrosshairsAnimator.getAnimator().setInterpolator(mEaseOutInterpolator);
|
||||
|
||||
mDragCell[0] = mDragCell[1] = -1;
|
||||
for (int i = 0; i < mDragOutlines.length; i++) {
|
||||
mDragOutlines[i] = new Point(-1, -1);
|
||||
}
|
||||
@@ -1171,13 +1172,13 @@ public class CellLayout extends ViewGroup {
|
||||
result[1] = Math.max(0, result[1]); // Snap to top
|
||||
}
|
||||
|
||||
void visualizeDropLocation(
|
||||
View v, Bitmap dragOutline, int originX, int originY, int spanX, int spanY) {
|
||||
void visualizeDropLocation(View v, Bitmap dragOutline, int originX, int originY,
|
||||
int spanX, int spanY, Point dragOffset, Rect dragRegion) {
|
||||
|
||||
final int oldDragCellX = mDragCell[0];
|
||||
final int oldDragCellY = mDragCell[1];
|
||||
final int[] nearest = findNearestVacantArea(originX, originY, spanX, spanY, v, mDragCell);
|
||||
if (v != null) {
|
||||
if (v != null && dragOffset == null) {
|
||||
mDragCenter.set(originX + (v.getWidth() / 2), originY + (v.getHeight() / 2));
|
||||
} else {
|
||||
mDragCenter.set(originX, originY);
|
||||
@@ -1198,7 +1199,7 @@ public class CellLayout extends ViewGroup {
|
||||
int left = topLeft[0];
|
||||
int top = topLeft[1];
|
||||
|
||||
if (v != null) {
|
||||
if (v != null && dragOffset == null) {
|
||||
// When drawing the drag outline, it did not account for margin offsets
|
||||
// added by the view's parent.
|
||||
MarginLayoutParams lp = (MarginLayoutParams) v.getLayoutParams();
|
||||
@@ -1213,11 +1214,19 @@ public class CellLayout extends ViewGroup {
|
||||
left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
|
||||
- dragOutline.getWidth()) / 2;
|
||||
} else {
|
||||
// Center the drag outline in the cell
|
||||
left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
|
||||
- dragOutline.getWidth()) / 2;
|
||||
top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
|
||||
- dragOutline.getHeight()) / 2;
|
||||
if (dragOffset != null && dragRegion != null) {
|
||||
// Center the drag region *horizontally* in the cell and apply a drag
|
||||
// outline offset
|
||||
left += dragOffset.x + ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
|
||||
- dragRegion.width()) / 2;
|
||||
top += dragOffset.y;
|
||||
} else {
|
||||
// Center the drag outline in the cell
|
||||
left += ((mCellWidth * spanX) + ((spanX - 1) * mWidthGap)
|
||||
- dragOutline.getWidth()) / 2;
|
||||
top += ((mCellHeight * spanY) + ((spanY - 1) * mHeightGap)
|
||||
- dragOutline.getHeight()) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
final int oldIndex = mDragOutlineCurrent;
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Handler;
|
||||
@@ -187,7 +186,7 @@ public class DragController {
|
||||
int dragLayerX = loc[0];
|
||||
int dragLayerY = loc[1];
|
||||
|
||||
startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, dragRegion);
|
||||
startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, dragRegion);
|
||||
b.recycle();
|
||||
|
||||
if (dragAction == DRAG_ACTION_MOVE) {
|
||||
@@ -214,7 +213,7 @@ public class DragController {
|
||||
int dragLayerX = loc[0];
|
||||
int dragLayerY = loc[1];
|
||||
|
||||
startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, dragAction, dragRegion);
|
||||
startDrag(bmp, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, dragRegion);
|
||||
|
||||
if (dragAction == DRAG_ACTION_MOVE) {
|
||||
v.setVisibility(View.GONE);
|
||||
@@ -235,7 +234,7 @@ public class DragController {
|
||||
*/
|
||||
public void startDrag(Bitmap b, int dragLayerX, int dragLayerY,
|
||||
DragSource source, Object dragInfo, int dragAction) {
|
||||
startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null);
|
||||
startDrag(b, dragLayerX, dragLayerY, source, dragInfo, dragAction, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +252,7 @@ public class DragController {
|
||||
* Makes dragging feel more precise, e.g. you can clip out a transparent border
|
||||
*/
|
||||
public void startDrag(Bitmap b, int dragLayerX, int dragLayerY,
|
||||
DragSource source, Object dragInfo, int dragAction, Rect dragRegion) {
|
||||
DragSource source, Object dragInfo, int dragAction, Point dragOffset, Rect dragRegion) {
|
||||
if (PROFILE_DRAWING_DURING_DRAG) {
|
||||
android.os.Debug.startMethodTracing("Launcher");
|
||||
}
|
||||
@@ -290,6 +289,9 @@ public class DragController {
|
||||
final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX,
|
||||
registrationY, 0, 0, b.getWidth(), b.getHeight());
|
||||
|
||||
if (dragOffset != null) {
|
||||
dragView.setDragVisualizeOffset(new Point(dragOffset));
|
||||
}
|
||||
if (dragRegion != null) {
|
||||
dragView.setDragRegion(new Rect(dragRegion));
|
||||
}
|
||||
|
||||
@@ -24,11 +24,9 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.IBinder;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import com.android.launcher.R;
|
||||
@@ -39,6 +37,7 @@ public class DragView extends View {
|
||||
private int mRegistrationX;
|
||||
private int mRegistrationY;
|
||||
|
||||
private Point mDragVisualizeOffset = null;
|
||||
private Rect mDragRegion = null;
|
||||
private DragLayer mDragLayer = null;
|
||||
private boolean mHasDrawn = false;
|
||||
@@ -135,6 +134,14 @@ public class DragView extends View {
|
||||
return mDragRegion.height();
|
||||
}
|
||||
|
||||
public void setDragVisualizeOffset(Point p) {
|
||||
mDragVisualizeOffset = p;
|
||||
}
|
||||
|
||||
public Point getDragVisualizeOffset() {
|
||||
return mDragVisualizeOffset;
|
||||
}
|
||||
|
||||
public void setDragRegion(Rect r) {
|
||||
mDragRegion = r;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.Animator.AnimatorListener;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.Animator.AnimatorListener;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.WallpaperManager;
|
||||
@@ -40,6 +40,7 @@ import android.graphics.Camera;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
@@ -1784,7 +1785,7 @@ public class Workspace extends SmoothPagedView
|
||||
v.getWidth() + padding, v.getHeight() + padding, Bitmap.Config.ARGB_8888);
|
||||
|
||||
canvas.setBitmap(b);
|
||||
drawDragView(v, canvas, padding, false);
|
||||
drawDragView(v, canvas, padding, true);
|
||||
mOutlineHelper.applyMediumExpensiveOutlineWithBlur(b, canvas, outlineColor, outlineColor);
|
||||
canvas.setBitmap(null);
|
||||
return b;
|
||||
@@ -1866,6 +1867,8 @@ public class Workspace extends SmoothPagedView
|
||||
}
|
||||
|
||||
public void beginDragShared(View child, DragSource source) {
|
||||
Resources r = getResources();
|
||||
|
||||
// We need to add extra padding to the bitmap to make room for the glow effect
|
||||
final int bitmapPadding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS;
|
||||
|
||||
@@ -1878,17 +1881,22 @@ public class Workspace extends SmoothPagedView
|
||||
final int dragLayerX = (int) mTempXY[0] + (child.getWidth() - bmpWidth) / 2;
|
||||
int dragLayerY = mTempXY[1] - bitmapPadding / 2;
|
||||
|
||||
Point dragVisualizeOffset = null;
|
||||
Rect dragRect = null;
|
||||
if (child instanceof BubbleTextView) {
|
||||
int iconSize = getResources().getDimensionPixelSize(R.dimen.app_icon_size);
|
||||
if (child instanceof BubbleTextView || child instanceof PagedViewIcon) {
|
||||
int iconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
|
||||
int iconPaddingTop = r.getDimensionPixelSize(R.dimen.app_icon_padding_top);
|
||||
int top = child.getPaddingTop();
|
||||
int left = (bmpWidth - iconSize) / 2;
|
||||
int right = left + iconSize;
|
||||
int bottom = top + iconSize;
|
||||
dragLayerY += top;
|
||||
// Note: The drag region is used to calculate drag layer offsets, but the
|
||||
// dragVisualizeOffset in addition to the dragRect (the size) to position the outline.
|
||||
dragVisualizeOffset = new Point(-bitmapPadding / 2, iconPaddingTop - bitmapPadding / 2);
|
||||
dragRect = new Rect(left, top, right, bottom);
|
||||
} else if (child instanceof FolderIcon) {
|
||||
int previewSize = getResources().getDimensionPixelSize(R.dimen.folder_preview_size);
|
||||
int previewSize = r.getDimensionPixelSize(R.dimen.folder_preview_size);
|
||||
dragRect = new Rect(0, 0, child.getWidth(), previewSize);
|
||||
}
|
||||
|
||||
@@ -1899,7 +1907,7 @@ public class Workspace extends SmoothPagedView
|
||||
}
|
||||
|
||||
mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(),
|
||||
DragController.DRAG_ACTION_MOVE, dragRect);
|
||||
DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect);
|
||||
b.recycle();
|
||||
}
|
||||
|
||||
@@ -2354,13 +2362,13 @@ public class Workspace extends SmoothPagedView
|
||||
showOutlines();
|
||||
layout.setIsDragOccuring(true);
|
||||
layout.onDragEnter();
|
||||
layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1);
|
||||
layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1, null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
case DragEvent.ACTION_DRAG_LOCATION:
|
||||
// Visualize the drop location
|
||||
layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1);
|
||||
layout.visualizeDropLocation(null, mDragOutline, x, y, 1, 1, null, null);
|
||||
return true;
|
||||
case DragEvent.ACTION_DROP: {
|
||||
// Try and add any shortcuts
|
||||
@@ -2727,7 +2735,8 @@ public class Workspace extends SmoothPagedView
|
||||
if (!mCreateUserFolderOnDrop && !isOverFolder) {
|
||||
mDragTargetLayout.visualizeDropLocation(child, mDragOutline,
|
||||
(int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1],
|
||||
item.spanX, item.spanY);
|
||||
item.spanX, item.spanY, d.dragView.getDragVisualizeOffset(),
|
||||
d.dragView.getDragRegion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user