From 4e243a2dad3700868035256af1882d7a4fee2385 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Sun, 10 Aug 2014 18:30:55 -0700 Subject: Updating the widget tray -> adding dark panel / associated visual updates -> cleaning up the sizing / padding / to match all apps -> fixing a couple things from previous CL -> (removed Context#getDrawable() calls, L-only) Change-Id: Ia65a6eb704b35f74e7305be9334c27971b22235a --- .../android/launcher3/AppsCustomizePagedView.java | 42 ++++++----- src/com/android/launcher3/Launcher.java | 87 ++++++++++++++-------- src/com/android/launcher3/PagedView.java | 13 ---- src/com/android/launcher3/PagedViewGridLayout.java | 12 --- src/com/android/launcher3/Workspace.java | 10 +-- 5 files changed, 79 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 24f90c341..02031ac4e 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -183,7 +183,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Dimens private int mContentWidth, mContentHeight; private int mWidgetCountX, mWidgetCountY; - private int mWidgetWidthGap, mWidgetHeightGap; private PagedViewCellLayout mWidgetSpacingLayout; private int mNumAppsPages; private int mNumWidgetPages; @@ -195,7 +194,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen private static float TRANSITION_SCALE_FACTOR = 0.74f; private static float TRANSITION_PIVOT = 0.65f; private static float TRANSITION_MAX_ROTATION = 22; - private static final boolean PERFORM_OVERSCROLL_ROTATION = true; + private static final boolean PERFORM_OVERSCROLL_ROTATION = false; private AccelerateInterpolator mAlphaInterpolator = new AccelerateInterpolator(0.9f); private DecelerateInterpolator mLeftScreenAlphaInterpolator = new DecelerateInterpolator(4); @@ -245,7 +244,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - mWidgetWidthGap = mWidgetHeightGap = grid.edgeMarginPx; mWidgetCountX = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountX, 2); mWidgetCountY = a.getInt(R.styleable.AppsCustomizePagedView_widgetCountY, 2); mClingFocusedX = a.getInt(R.styleable.AppsCustomizePagedView_clingFocusedX, 0); @@ -285,8 +283,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen void setAllAppsPadding(Rect r) { mAllAppsPadding.set(r); } + void setWidgetsPageIndicatorPadding(int pageIndicatorHeight) { - mPageLayoutPaddingBottom = pageIndicatorHeight; + setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), pageIndicatorHeight); } WidgetPreviewLoader getWidgetPreviewLoader() { @@ -365,8 +364,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // use for each page LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - mWidgetSpacingLayout.setPadding(mPageLayoutPaddingLeft, mPageLayoutPaddingTop, - mPageLayoutPaddingRight, mPageLayoutPaddingBottom); mCellCountX = (int) grid.allAppsNumCols; mCellCountY = (int) grid.allAppsNumRows; updatePageCounts(); @@ -1002,11 +999,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen setVisibilityOnChildren(layout, View.GONE); int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST); - layout.setMinimumWidth(getPageContentWidth()); layout.measure(widthSpec, heightSpec); - Resources res = getContext().getResources(); - Drawable bg = res.getDrawable(R.drawable.quantum_panel); + Drawable bg = getContext().getResources().getDrawable(R.drawable.quantum_panel); if (bg != null) { layout.setBackground(bg); bg.setVisible(mPageBackgroundsVisible, false); @@ -1168,21 +1163,23 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // immediately after syncing, we don't have a proper width. int widthSpec = MeasureSpec.makeMeasureSpec(mContentWidth, MeasureSpec.AT_MOST); int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST); - layout.setMinimumWidth(getPageContentWidth()); + layout.setBackground(getContext().getResources().getDrawable(R.drawable.quantum_panel_dark)); layout.measure(widthSpec, heightSpec); } public void syncWidgetPageItems(final int page, final boolean immediate) { int numItemsPerPage = mWidgetCountX * mWidgetCountY; + final PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(page); + // Calculate the dimensions of each cell we are giving to each widget final ArrayList items = new ArrayList(); - int contentWidth = mContentWidth; - final int cellWidth = ((contentWidth - mPageLayoutPaddingLeft - mPageLayoutPaddingRight - - ((mWidgetCountX - 1) * mWidgetWidthGap)) / mWidgetCountX); - int contentHeight = mContentHeight; - final int cellHeight = ((contentHeight - mPageLayoutPaddingTop - mPageLayoutPaddingBottom - - ((mWidgetCountY - 1) * mWidgetHeightGap)) / mWidgetCountY); + int contentWidth = mContentWidth - getPaddingLeft() - getPaddingRight() + - layout.getPaddingLeft() - layout.getPaddingRight(); + final int cellWidth = contentWidth / mWidgetCountX; + int contentHeight = mContentHeight - getPaddingTop() - getPaddingBottom() + - layout.getPaddingTop() - layout.getPaddingBottom(); + final int cellHeight = contentHeight / mWidgetCountY; // Prepare the set of widgets to load previews for in the background int offset = page * numItemsPerPage; @@ -1191,7 +1188,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } // Prepopulate the pages with the other widget info, and fill in the previews later - final PagedViewGridLayout layout = (PagedViewGridLayout) getPageAt(page); layout.setColumnCount(layout.getCellCountX()); for (int i = 0; i < items.size(); ++i) { Object rawInfo = items.get(i); @@ -1232,14 +1228,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Layout each widget int ix = i % mWidgetCountX; int iy = i / mWidgetCountX; + + if (ix > 0) { + View border = widget.findViewById(R.id.left_border); + border.setVisibility(View.VISIBLE); + } + if (ix < mWidgetCountX - 1) { + View border = widget.findViewById(R.id.right_border); + border.setVisibility(View.VISIBLE); + } + GridLayout.LayoutParams lp = new GridLayout.LayoutParams( GridLayout.spec(iy, GridLayout.START), GridLayout.spec(ix, GridLayout.TOP)); lp.width = cellWidth; lp.height = cellHeight; lp.setGravity(Gravity.TOP | Gravity.START); - if (ix > 0) lp.leftMargin = mWidgetWidthGap; - if (iy > 0) lp.topMargin = mWidgetHeightGap; layout.addView(widget, lp); } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 75ba8fd99..ebf3cc2ff 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3205,6 +3205,12 @@ public class Launcher extends Activity final View page = content.getPageAt(content.getCurrentPage()); final View revealView = toView.findViewById(R.id.fake_page); + if (contentType == AppsCustomizePagedView.ContentType.Widgets) { + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); + } else { + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); + } + // Hide the real page background, and swap in the fake one revealView.setVisibility(View.VISIBLE); content.setPageBackgroundsVisible(false); @@ -3227,24 +3233,27 @@ public class Launcher extends Activity mStateAnimation.play(panelAlphaAndDrift); - page.setVisibility(View.VISIBLE); - page.setLayerType(View.LAYER_TYPE_HARDWARE, null); - - ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0); - pageDrift.setDuration(revealDuration); - pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); - mStateAnimation.play(pageDrift); - - // TODO (adamcohen): remove this 0.01f hack once fw is fixed - // it's there to work around a framework bug (16918357) - page.setAlpha(0.01f); - ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f); - itemsAlpha.setDuration(revealDuration); - itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); - itemsAlpha.setStartDelay(itemsAlphaStagger); - mStateAnimation.play(itemsAlpha); + if (page != null) { + page.setVisibility(View.VISIBLE); + page.setLayerType(View.LAYER_TYPE_HARDWARE, null); + + ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0); + pageDrift.setDuration(revealDuration); + pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); + mStateAnimation.play(pageDrift); + + // TODO (adamcohen): remove this 0.01f hack once fw is fixed + // it's there to work around a framework bug (16918357) + page.setAlpha(0.01f); + ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f); + itemsAlpha.setDuration(revealDuration); + itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); + itemsAlpha.setStartDelay(itemsAlphaStagger); + mStateAnimation.play(itemsAlpha); + } - View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); + View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator); + pageIndicators.setAlpha(0.01f); ObjectAnimator indicatorsAlpha = ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f); indicatorsAlpha.setDuration(revealDuration); @@ -3267,7 +3276,9 @@ public class Launcher extends Activity revealView.setVisibility(View.INVISIBLE); revealView.setLayerType(View.LAYER_TYPE_NONE, null); - page.setLayerType(View.LAYER_TYPE_NONE, null); + if (page != null) { + page.setLayerType(View.LAYER_TYPE_NONE, null); + } content.setPageBackgroundsVisible(true); // Hide the search bar @@ -3396,6 +3407,13 @@ public class Launcher extends Activity final View page = content.getPageAt(content.getNextPage()); final View revealView = fromView.findViewById(R.id.fake_page); + AppsCustomizePagedView.ContentType contentType = content.getContentType(); + if (contentType == AppsCustomizePagedView.ContentType.Widgets) { + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark)); + } else { + revealView.setBackground(res.getDrawable(R.drawable.quantum_panel)); + } + int width = revealView.getMeasuredWidth(); int height = revealView.getMeasuredHeight(); float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4); @@ -3410,7 +3428,7 @@ public class Launcher extends Activity PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f); PropertyValuesHolder panelDrift = - PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0, yDrift); + PropertyValuesHolder.ofFloat("translationY", 0, yDrift); ObjectAnimator panelAlphaAndDrift = ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift); panelAlphaAndDrift.setDuration(revealDuration); @@ -3420,23 +3438,26 @@ public class Launcher extends Activity mStateAnimation.play(panelAlphaAndDrift); - page.setLayerType(View.LAYER_TYPE_HARDWARE, null); + if (page != null) { + page.setLayerType(View.LAYER_TYPE_HARDWARE, null); - ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, View.TRANSLATION_Y, 0, yDrift); - pageDrift.setDuration(revealDuration); - pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); - pageDrift.setStartDelay(itemsAlphaStagger); - mStateAnimation.play(pageDrift); + ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", 0, yDrift); + pageDrift.setDuration(revealDuration); + pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0)); + pageDrift.setStartDelay(itemsAlphaStagger); + mStateAnimation.play(pageDrift); - page.setAlpha(1f); - ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f); - itemsAlpha.setDuration(revealDuration); - itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0)); - mStateAnimation.play(itemsAlpha); + page.setAlpha(1f); + ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f); + itemsAlpha.setDuration(revealDuration); + itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0)); + mStateAnimation.play(itemsAlpha); + } View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator); + pageIndicators.setAlpha(1f); ObjectAnimator indicatorsAlpha = - ObjectAnimator.ofFloat(pageIndicators, View.ALPHA, 0f); + ObjectAnimator.ofFloat(pageIndicators, "alpha", 0f); indicatorsAlpha.setDuration(revealDuration); indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f)); mStateAnimation.play(indicatorsAlpha); @@ -3479,7 +3500,9 @@ public class Launcher extends Activity } revealView.setLayerType(View.LAYER_TYPE_NONE, null); - page.setLayerType(View.LAYER_TYPE_NONE, null); + if (page != null) { + page.setLayerType(View.LAYER_TYPE_NONE, null); + } content.setPageBackgroundsVisible(true); mAppsCustomizeContent.updateCurrentPageScroll(); } diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 4e34628da..90a6b1598 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -152,16 +152,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc protected int mTouchState = TOUCH_STATE_REST; protected boolean mForceScreenScrolled = false; - protected OnLongClickListener mLongClickListener; protected int mTouchSlop; private int mPagingTouchSlop; private int mMaximumVelocity; - protected int mPageLayoutPaddingTop; - protected int mPageLayoutPaddingBottom; - protected int mPageLayoutPaddingLeft; - protected int mPageLayoutPaddingRight; protected int mPageLayoutWidthGap; protected int mPageLayoutHeightGap; protected int mCellCountX = 0; @@ -283,14 +278,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, defStyle, 0); - mPageLayoutPaddingTop = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingTop, 0); - mPageLayoutPaddingBottom = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingBottom, 0); - mPageLayoutPaddingLeft = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingLeft, 0); - mPageLayoutPaddingRight = a.getDimensionPixelSize( - R.styleable.PagedView_pageLayoutPaddingRight, 0); mPageLayoutWidthGap = a.getDimensionPixelSize( R.styleable.PagedView_pageLayoutWidthGap, 0); mPageLayoutHeightGap = a.getDimensionPixelSize( diff --git a/src/com/android/launcher3/PagedViewGridLayout.java b/src/com/android/launcher3/PagedViewGridLayout.java index b28686113..f69fa562d 100644 --- a/src/com/android/launcher3/PagedViewGridLayout.java +++ b/src/com/android/launcher3/PagedViewGridLayout.java @@ -56,18 +56,6 @@ public class PagedViewGridLayout extends GridLayout implements Page { } } - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - // PagedView currently has issues with different-sized pages since it calculates the - // offset of each page to scroll to before it updates the actual size of each page - // (which can change depending on the content if the contents aren't a fixed size). - // We work around this by having a minimum size on each widget page). - int widthSpecSize = Math.min(getSuggestedMinimumWidth(), - MeasureSpec.getSize(widthMeasureSpec)); - int widthSpecMode = MeasureSpec.EXACTLY; - super.onMeasure(MeasureSpec.makeMeasureSpec(widthSpecSize, widthSpecMode), - heightMeasureSpec); - } - @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 7c8708b50..20682ca93 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -212,7 +212,6 @@ public class Workspace extends SmoothPagedView private final int[] mTempXY = new int[2]; private int[] mTempVisiblePagesRange = new int[2]; private boolean mOverscrollTransformsSet; - private float mLastOverscrollPivotX; public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; @@ -1694,20 +1693,13 @@ public class Workspace extends SmoothPagedView final boolean isLeftPage = mOverScrollX < 0; index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; - pivotX = isLeftPage ? rightBiasedPivot : leftBiasedPivot; CellLayout cl = (CellLayout) getChildAt(index); float scrollProgress = getScrollProgress(screenCenter, cl, index); cl.setOverScrollAmount(Math.abs(scrollProgress), isLeftPage); - float rotation = -WORKSPACE_OVERSCROLL_ROTATION * scrollProgress; - cl.setRotationY(rotation); - if (!mOverscrollTransformsSet || Float.compare(mLastOverscrollPivotX, pivotX) != 0) { + if (!mOverscrollTransformsSet) { mOverscrollTransformsSet = true; - mLastOverscrollPivotX = pivotX; - cl.setCameraDistance(mDensity * mCameraDistance); - cl.setPivotX(cl.getMeasuredWidth() * pivotX); - cl.setPivotY(cl.getMeasuredHeight() * 0.5f); cl.setOverscrollTransformsDirty(true); } } else { -- cgit v1.2.3