summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2016-02-24 19:19:06 -0800
committerAdam Cohen <adamcohen@google.com>2016-03-03 09:24:45 -0800
commitefca0279eb927faebffc38c8382818df67fcd159 (patch)
tree15ede9a36767c9d04a47e355edc5550b25dfb36c /src/com/android/launcher3/CellLayout.java
parent992a5f566e7f1b1fc8bd766f1fd00bee7ea2a634 (diff)
downloadandroid_packages_apps_Trebuchet-efca0279eb927faebffc38c8382818df67fcd159.tar.gz
android_packages_apps_Trebuchet-efca0279eb927faebffc38c8382818df67fcd159.tar.bz2
android_packages_apps_Trebuchet-efca0279eb927faebffc38c8382818df67fcd159.zip
Switch all folder preview rendering to be programmatic (ie. no assets)
-> Refactored the preview background rendering to be much more self-contained. This cleans up a lot of code in the CellLayout, and keeps the logic in the right place. -> We switch to software rendering for performance and compatibility reasons. -> Removed all assets. -> FolderIcon accept animation includes animation of the clipped region. -> 1:1 hand-off of drawing of the FolderIcon background between the FolderIcon and the CellLayout. Unfortunately, CellLayout rendering is still required to work around clipping issues (due to use of software layer). We also need this to support folder creation feedback. Change-Id: Ib8f7fa6359dfedff8145f38dd50ba03849ca0d51
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java117
1 files changed, 47 insertions, 70 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 5832b9f0d..af3703314 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -55,7 +55,6 @@ import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.folder.FolderIcon;
-import com.android.launcher3.folder.FolderIcon.FolderRingAnimator;
import com.android.launcher3.util.ParcelableSparseArray;
import com.android.launcher3.util.Thunk;
@@ -108,8 +107,9 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
private OnTouchListener mInterceptTouchListener;
private StylusEventHelper mStylusEventHelper;
- private ArrayList<FolderRingAnimator> mFolderOuterRings = new ArrayList<FolderRingAnimator>();
- private int[] mFolderLeaveBehindCell = {-1, -1};
+ private ArrayList<FolderIcon.PreviewBackground> mFolderBackgrounds = new ArrayList<FolderIcon.PreviewBackground>();
+ FolderIcon.PreviewBackground mFolderLeaveBehind = new FolderIcon.PreviewBackground();
+ Paint mFolderBgPaint = new Paint();
private float mBackgroundAlpha;
@@ -209,6 +209,9 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
mPreviousReorderDirection[0] = INVALID_DIRECTION;
mPreviousReorderDirection[1] = INVALID_DIRECTION;
+ mFolderLeaveBehind.delegateCellX = -1;
+ mFolderLeaveBehind.delegateCellY = -1;
+
setAlwaysDrawnWithCacheEnabled(false);
final Resources res = getResources();
mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx;
@@ -501,88 +504,62 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
}
}
- int previewOffset = FolderRingAnimator.sPreviewSize;
-
- // The folder outer / inner ring image(s)
- DeviceProfile grid = mLauncher.getDeviceProfile();
- for (int i = 0; i < mFolderOuterRings.size(); i++) {
- FolderRingAnimator fra = mFolderOuterRings.get(i);
-
- Drawable d;
- int width, height;
- cellToPoint(fra.mCellX, fra.mCellY, mTempLocation);
- View child = getChildAt(fra.mCellX, fra.mCellY);
-
- if (child != null) {
- int centerX = mTempLocation[0] + mCellWidth / 2;
- int centerY = mTempLocation[1] + previewOffset / 2 +
- child.getPaddingTop() + grid.folderBackgroundOffset;
-
- // Draw outer ring, if it exists
- if (FolderIcon.HAS_OUTER_RING) {
- d = FolderRingAnimator.sSharedOuterRingDrawable;
- width = (int) (fra.getOuterRingSize() * getChildrenScale());
- height = width;
- canvas.save();
- canvas.translate(centerX - width / 2, centerY - height / 2);
- d.setBounds(0, 0, width, height);
- d.draw(canvas);
- canvas.restore();
- }
-
- // Draw inner ring
- d = FolderRingAnimator.sSharedInnerRingDrawable;
- width = (int) (fra.getInnerRingSize() * getChildrenScale());
- height = width;
- canvas.save();
- canvas.translate(centerX - width / 2, centerY - width / 2);
- d.setBounds(0, 0, width, height);
- d.draw(canvas);
- canvas.restore();
- }
+ for (int i = 0; i < mFolderBackgrounds.size(); i++) {
+ FolderIcon.PreviewBackground bg = mFolderBackgrounds.get(i);
+ cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation);
+ canvas.save();
+ canvas.translate(mTempLocation[0], mTempLocation[1]);
+ bg.drawBackground(canvas, mFolderBgPaint);
+ canvas.restore();
}
- if (mFolderLeaveBehindCell[0] >= 0 && mFolderLeaveBehindCell[1] >= 0) {
- Drawable d = FolderIcon.sSharedFolderLeaveBehind;
- int width = d.getIntrinsicWidth();
- int height = d.getIntrinsicHeight();
+ if (mFolderLeaveBehind.delegateCellX >= 0 && mFolderLeaveBehind.delegateCellY >= 0) {
+ cellToPoint(mFolderLeaveBehind.delegateCellX,
+ mFolderLeaveBehind.delegateCellY, mTempLocation);
+ canvas.save();
+ canvas.translate(mTempLocation[0], mTempLocation[1]);
+ mFolderLeaveBehind.drawLeaveBehind(canvas, mFolderBgPaint);
+ canvas.restore();
+ }
+ }
- cellToPoint(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1], mTempLocation);
- View child = getChildAt(mFolderLeaveBehindCell[0], mFolderLeaveBehindCell[1]);
- if (child != null) {
- int centerX = mTempLocation[0] + mCellWidth / 2;
- int centerY = mTempLocation[1] + previewOffset / 2 +
- child.getPaddingTop() + grid.folderBackgroundOffset;
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
- canvas.save();
- canvas.translate(centerX - width / 2, centerY - width / 2);
- d.setBounds(0, 0, width, height);
- d.draw(canvas);
- canvas.restore();
- }
+ for (int i = 0; i < mFolderBackgrounds.size(); i++) {
+ FolderIcon.PreviewBackground bg = mFolderBackgrounds.get(i);
+ cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation);
+ canvas.save();
+ canvas.translate(mTempLocation[0], mTempLocation[1]);
+ bg.drawBackgroundStroke(canvas, mFolderBgPaint);
+ canvas.restore();
}
}
- public void showFolderAccept(FolderRingAnimator fra) {
- mFolderOuterRings.add(fra);
+ public void addFolderBackground(FolderIcon.PreviewBackground bg) {
+ mFolderBackgrounds.add(bg);
}
-
- public void hideFolderAccept(FolderRingAnimator fra) {
- if (mFolderOuterRings.contains(fra)) {
- mFolderOuterRings.remove(fra);
- }
- invalidate();
+ public void removeFolderBackground(FolderIcon.PreviewBackground bg) {
+ mFolderBackgrounds.remove(bg);
}
public void setFolderLeaveBehindCell(int x, int y) {
- mFolderLeaveBehindCell[0] = x;
- mFolderLeaveBehindCell[1] = y;
+
+ DeviceProfile grid = mLauncher.getDeviceProfile();
+ View child = getChildAt(x, y);
+
+ mFolderLeaveBehind.setup(getResources().getDisplayMetrics(), grid, null,
+ child.getMeasuredWidth(), child.getPaddingTop());
+
+ mFolderLeaveBehind.delegateCellX = x;
+ mFolderLeaveBehind.delegateCellY = y;
invalidate();
}
public void clearFolderLeaveBehind() {
- mFolderLeaveBehindCell[0] = -1;
- mFolderLeaveBehindCell[1] = -1;
+ mFolderLeaveBehind.delegateCellX = -1;
+ mFolderLeaveBehind.delegateCellY = -1;
invalidate();
}