Fixing RTL issues with apps ordering and snapping to page. (Bug 8238938, Bug 8374016, Bug 8373578)

Change-Id: I57ff58a6202a2794f02cfc13ed6124b10256dbbf
This commit is contained in:
Winson Chung
2013-04-01 16:52:31 -07:00
parent e233a8bf79
commit fe1fe268b6
3 changed files with 24 additions and 8 deletions
@@ -998,6 +998,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void syncAppsPageItems(int page, boolean immediate) {
// ensure that we have the right number of items on the pages
final boolean isRtl = isLayoutRtl();
int numCells = mCellCountX * mCellCountY;
int startIndex = page * numCells;
int endIndex = Math.min(startIndex + numCells, mApps.size());
@@ -1019,6 +1020,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int index = i - startIndex;
int x = index % mCellCountX;
int y = index / mCellCountX;
if (isRtl) {
x = mCellCountX - x - 1;
}
layout.addViewToCellLayout(icon, -1, i, new PagedViewCellLayout.LayoutParams(x,y, 1,1));
items.add(info);
+10 -6
View File
@@ -516,22 +516,26 @@ public class DragController {
mLastTouch[0] = x;
mLastTouch[1] = y;
final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY;
final DragLayer dragLayer = mLauncher.getDragLayer();
final boolean isRtl = (dragLayer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
final int forwardDirection = isRtl ? SCROLL_RIGHT : SCROLL_LEFT;
final int backwardsDirection = isRtl ? SCROLL_LEFT : SCROLL_RIGHT;
if (x < mScrollZone) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) {
mLauncher.getDragLayer().onEnterScrollArea(SCROLL_LEFT);
mScrollRunnable.setDirection(SCROLL_LEFT);
if (mDragScroller.onEnterScrollArea(x, y, forwardDirection)) {
dragLayer.onEnterScrollArea(forwardDirection);
mScrollRunnable.setDirection(forwardDirection);
mHandler.postDelayed(mScrollRunnable, delay);
}
}
} else if (x > mScrollView.getWidth() - mScrollZone) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) {
mScrollState = SCROLL_WAITING_IN_ZONE;
if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) {
mLauncher.getDragLayer().onEnterScrollArea(SCROLL_RIGHT);
mScrollRunnable.setDirection(SCROLL_RIGHT);
if (mDragScroller.onEnterScrollArea(x, y, backwardsDirection)) {
dragLayer.onEnterScrollArea(backwardsDirection);
mScrollRunnable.setDirection(backwardsDirection);
mHandler.postDelayed(mScrollRunnable, delay);
}
}
+10 -2
View File
@@ -742,6 +742,13 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
invalidate();
}
/**
* Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
*/
private boolean isLayoutRtl() {
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
@@ -753,8 +760,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect);
int page = workspace.getNextPage();
CellLayout leftPage = (CellLayout) workspace.getChildAt(page - 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(page + 1);
final boolean isRtl = isLayoutRtl();
CellLayout leftPage = (CellLayout) workspace.getChildAt(isRtl ? page + 1 : page - 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(isRtl ? page - 1 : page + 1);
if (leftPage != null && leftPage.getIsDragOverlapping()) {
mLeftHoverDrawable.setBounds(0, childRect.top,