summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppsCustomizePagedView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/AppsCustomizePagedView.java')
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java79
1 files changed, 40 insertions, 39 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 5f2a36608..b98a39196 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -185,7 +185,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;
@@ -197,7 +196,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);
@@ -215,6 +214,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int mWidgetLoadingId = -1;
PendingAddWidgetInfo mCreateWidgetInfo = null;
private boolean mDraggingWidget = false;
+ boolean mPageBackgroundsVisible;
private Toast mWidgetInstructionToast;
@@ -244,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);
@@ -284,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() {
@@ -364,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();
@@ -1001,14 +999,26 @@ 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);
- layout.setPadding(mAllAppsPadding.left, mAllAppsPadding.top, mAllAppsPadding.right,
- mAllAppsPadding.bottom);
+
+ Drawable bg = getContext().getDrawable(R.drawable.quantum_panel);
+ if (bg != null) {
+ layout.setBackground(bg);
+ bg.setVisible(mPageBackgroundsVisible, false);
+ }
+
setVisibilityOnChildren(layout, View.VISIBLE);
+ }
- Resources res = getContext().getResources();
- layout.setBackground(res.getDrawable(R.drawable.quantum_panel));
+ public void setPageBackgroundsVisible(boolean visible) {
+ mPageBackgroundsVisible = visible;
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; ++i) {
+ Drawable bg = getChildAt(i).getBackground();
+ if (bg != null) {
+ bg.setVisible(visible, false);
+ }
+ }
}
public void syncAppsPageItems(int page, boolean immediate) {
@@ -1153,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().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<Object> items = new ArrayList<Object>();
- 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;
@@ -1176,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);
@@ -1217,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);
}
@@ -1438,24 +1457,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
v.setRotationY(0f);
}
}
-
- // TODO: clean this up
- alpha = 1;
- translationX = 0;
- scale = 1;
-
- v.setTranslationX(translationX);
- v.setScaleX(scale);
- v.setScaleY(scale);
- v.setAlpha(alpha);
-
- // If the view has 0 alpha, we set it to be invisible so as to prevent
- // it from accepting touches
- if (alpha == 0) {
- v.setVisibility(INVISIBLE);
- } else if (v.getVisibility() != VISIBLE) {
- v.setVisibility(VISIBLE);
- }
}
}