am 2805e639: Animating workspace active background change
* commit '2805e639cdea6ae0051155611d122ed27556e658': Animating workspace active background change
This commit is contained in:
commit
2426fa6fee
4 files changed
+56
-48
No files matched your search
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2015, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item android:drawable="@drawable/screenpanel"/>
|
||||
<item android:drawable="@drawable/screenpanel_hover"/>
|
||||
|
||||
</transition>
|
||||
@@ -43,7 +43,6 @@
|
||||
|
||||
<!-- Workspace -->
|
||||
<dimen name="workspace_max_gap">16dp</dimen>
|
||||
<dimen name="workspace_overscroll_drawable_padding">0dp</dimen>
|
||||
|
||||
<!-- QSB -->
|
||||
<dimen name="toolbar_button_vertical_padding">4dip</dimen>
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.TransitionDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
@@ -87,31 +88,27 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
|
||||
// These are temporary variables to prevent having to allocate a new object just to
|
||||
// return an (x, y) value from helper functions. Do NOT use them to maintain other state.
|
||||
private final int[] mTmpXY = new int[2];
|
||||
@Thunk final int[] mTmpPoint = new int[2];
|
||||
int[] mTempLocation = new int[2];
|
||||
@Thunk final int[] mTempLocation = new int[2];
|
||||
|
||||
boolean[][] mOccupied;
|
||||
boolean[][] mTmpOccupied;
|
||||
private boolean mLastDownOnOccupiedCell = false;
|
||||
|
||||
private OnTouchListener mInterceptTouchListener;
|
||||
|
||||
private ArrayList<FolderRingAnimator> mFolderOuterRings = new ArrayList<FolderRingAnimator>();
|
||||
private int[] mFolderLeaveBehindCell = {-1, -1};
|
||||
|
||||
private float FOREGROUND_ALPHA_DAMPER = 0.65f;
|
||||
private static final float FOREGROUND_ALPHA_DAMPER = 0.65f;
|
||||
private int mForegroundAlpha = 0;
|
||||
private float mBackgroundAlpha;
|
||||
|
||||
private Drawable mNormalBackground;
|
||||
private Drawable mActiveGlowBackground;
|
||||
private static final int BACKGROUND_ACTIVATE_DURATION = 120;
|
||||
private final TransitionDrawable mBackground;
|
||||
|
||||
private final Drawable mOverScrollLeft;
|
||||
private final Drawable mOverScrollRight;
|
||||
private Drawable mOverScrollForegroundDrawable;
|
||||
private Drawable mOverScrollLeft;
|
||||
private Drawable mOverScrollRight;
|
||||
private Rect mBackgroundRect;
|
||||
private Rect mForegroundRect;
|
||||
private int mForegroundPadding;
|
||||
|
||||
// These values allow a fixed measurement to be set on the CellLayout.
|
||||
private int mFixedWidth = -1;
|
||||
@@ -173,7 +170,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
private static final int INVALID_DIRECTION = -100;
|
||||
private DropTarget.DragEnforcer mDragEnforcer;
|
||||
|
||||
private Rect mTempRect = new Rect();
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
||||
private final static Paint sPaint = new Paint();
|
||||
|
||||
@@ -221,20 +218,15 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
final Resources res = getResources();
|
||||
mHotseatScale = (float) grid.hotseatIconSizePx / grid.iconSizePx;
|
||||
|
||||
mNormalBackground = res.getDrawable(R.drawable.screenpanel);
|
||||
mActiveGlowBackground = res.getDrawable(R.drawable.screenpanel_hover);
|
||||
mBackground = (TransitionDrawable) res.getDrawable(R.drawable.bg_screenpanel);
|
||||
mBackground.setCallback(this);
|
||||
|
||||
mOverScrollLeft = res.getDrawable(R.drawable.overscroll_glow_left);
|
||||
mOverScrollRight = res.getDrawable(R.drawable.overscroll_glow_right);
|
||||
mForegroundPadding =
|
||||
res.getDimensionPixelSize(R.dimen.workspace_overscroll_drawable_padding);
|
||||
|
||||
mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE *
|
||||
grid.iconSizePx);
|
||||
|
||||
mNormalBackground.setFilterBitmap(true);
|
||||
mActiveGlowBackground.setFilterBitmap(true);
|
||||
|
||||
// Initialize the data structures used for the drag visualization.
|
||||
mEaseOutInterpolator = new DecelerateInterpolator(2.5f); // Quint ease out
|
||||
mDragCell[0] = mDragCell[1] = -1;
|
||||
@@ -292,9 +284,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
mDragOutlineAnims[i] = anim;
|
||||
}
|
||||
|
||||
mBackgroundRect = new Rect();
|
||||
mForegroundRect = new Rect();
|
||||
|
||||
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
|
||||
mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
|
||||
mCountX, mCountY);
|
||||
@@ -431,6 +420,11 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
void setIsDragOverlapping(boolean isDragOverlapping) {
|
||||
if (mIsDragOverlapping != isDragOverlapping) {
|
||||
mIsDragOverlapping = isDragOverlapping;
|
||||
if (mIsDragOverlapping) {
|
||||
mBackground.startTransition(BACKGROUND_ACTIVATE_DURATION);
|
||||
} else {
|
||||
mBackground.reverseTransition(BACKGROUND_ACTIVATE_DURATION);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
@@ -451,18 +445,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
// a drag). However, we also drag the mini hover background *over* one of those two
|
||||
// backgrounds
|
||||
if (mBackgroundAlpha > 0.0f) {
|
||||
Drawable bg;
|
||||
|
||||
if (mIsDragOverlapping) {
|
||||
// In the mini case, we draw the active_glow bg *over* the active background
|
||||
bg = mActiveGlowBackground;
|
||||
} else {
|
||||
bg = mNormalBackground;
|
||||
}
|
||||
|
||||
bg.setAlpha((int) (mBackgroundAlpha * 255));
|
||||
bg.setBounds(mBackgroundRect);
|
||||
bg.draw(canvas);
|
||||
mBackground.draw(canvas);
|
||||
}
|
||||
|
||||
final Paint paint = mDragOutlinePaint;
|
||||
@@ -561,7 +544,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
if (mForegroundAlpha > 0) {
|
||||
mOverScrollForegroundDrawable.setBounds(mForegroundRect);
|
||||
mOverScrollForegroundDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
@@ -924,12 +906,12 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
|
||||
// Expand the background drawing bounds by the padding baked into the background drawable
|
||||
Rect padding = new Rect();
|
||||
mNormalBackground.getPadding(padding);
|
||||
mBackgroundRect.set(-padding.left, -padding.top, w + padding.right, h + padding.bottom);
|
||||
mBackground.getPadding(mTempRect);
|
||||
mBackground.setBounds(-mTempRect.left, -mTempRect.top,
|
||||
w + mTempRect.right, h + mTempRect.bottom);
|
||||
|
||||
mForegroundRect.set(mForegroundPadding, mForegroundPadding,
|
||||
w - mForegroundPadding, h - mForegroundPadding);
|
||||
mOverScrollLeft.setBounds(0, 0, w, h);
|
||||
mOverScrollRight.setBounds(0, 0, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -949,10 +931,15 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
public void setBackgroundAlpha(float alpha) {
|
||||
if (mBackgroundAlpha != alpha) {
|
||||
mBackgroundAlpha = alpha;
|
||||
invalidate();
|
||||
mBackground.setAlpha((int) (mBackgroundAlpha * 255));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean verifyDrawable(Drawable who) {
|
||||
return super.verifyDrawable(who) || (mIsDragTarget && who == mBackground);
|
||||
}
|
||||
|
||||
public void setShortcutAndWidgetAlpha(float alpha) {
|
||||
mShortcutsAndWidgets.setAlpha(alpha);
|
||||
}
|
||||
@@ -1265,7 +1252,7 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
hitMaxX = xSize >= spanX;
|
||||
hitMaxY = ySize >= spanY;
|
||||
}
|
||||
final int[] cellXY = mTmpXY;
|
||||
final int[] cellXY = mTmpPoint;
|
||||
cellToCenterPoint(x, y, cellXY);
|
||||
|
||||
// We verify that the current rect is not a sub-rect of any of our previous
|
||||
@@ -3022,10 +3009,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean lastDownOnOccupiedCell() {
|
||||
return mLastDownOnOccupiedCell;
|
||||
}
|
||||
|
||||
public boolean findVacantCell(int spanX, int spanY, int[] outXY) {
|
||||
return Utilities.findVacantCell(outXY, spanX, spanY, mCountX, mCountY, mOccupied);
|
||||
}
|
||||
|
||||
@@ -1066,7 +1066,7 @@ public class Workspace extends SmoothPagedView
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (mTouchState == TOUCH_STATE_REST) {
|
||||
final CellLayout currentPage = (CellLayout) getChildAt(mCurrentPage);
|
||||
if (currentPage != null && !currentPage.lastDownOnOccupiedCell()) {
|
||||
if (currentPage != null) {
|
||||
onWallpaperTap(ev);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user