summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/PagedView.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-09-23 19:27:38 -0700
committerAdam Cohen <adamcohen@google.com>2013-09-24 10:43:42 -0700
commitaf9b0e51aac239457fbd038f7cb2088265054e42 (patch)
treee37eca5714bc4f173126ecd3d4d54c99a59d62ff /src/com/android/launcher3/PagedView.java
parenta64bdf433b64fa914ab9338cd8f43a4149a97d9c (diff)
downloadandroid_packages_apps_Trebuchet-af9b0e51aac239457fbd038f7cb2088265054e42.tar.gz
android_packages_apps_Trebuchet-af9b0e51aac239457fbd038f7cb2088265054e42.tar.bz2
android_packages_apps_Trebuchet-af9b0e51aac239457fbd038f7cb2088265054e42.zip
Getting RTL up to a reasonable state in Launcher3
-> Fixing random page jumps from one edge of page view to another (issue 10846070) -> Fixing screen -1 overlap (issue 10861684) -> Fixing callbacks / transition state related to Custom Content in RTL (issue 10858355) -> Overview mode now works in RTL -> Making visible page range code RTL-LTR independent Change-Id: I4dcc6127a02bf6669f5a1e8e1b62b340b60a5edc
Diffstat (limited to 'src/com/android/launcher3/PagedView.java')
-rw-r--r--src/com/android/launcher3/PagedView.java59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 31a979760..6ccd32f6c 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -911,8 +911,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
mPageScrolls[i] = childLeft - scrollOffset - offsetX;
if (i != endIndex - delta) {
+ childLeft += childWidth + scrollOffset;
int nextScrollOffset = (getViewportWidth() - getChildWidth(i + delta)) / 2;
- childLeft += childWidth + nextScrollOffset;
+ childLeft += nextScrollOffset;
}
}
}
@@ -1039,9 +1040,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
protected int getChildOffset(int index) {
if (index < 0 || index > getChildCount() - 1) return 0;
- final boolean isRtl = isLayoutRtl();
-
- if (isRtl) index = getChildCount() - index - 1;
int offset = getPageAt(index).getLeft() - getViewportOffsetX();
return offset;
@@ -1056,33 +1054,43 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
final int pageCount = getChildCount();
mTmpIntPoint[0] = mTmpIntPoint[1] = 0;
+ range[0] = -1;
+ range[1] = -1;
+
if (pageCount > 0) {
int viewportWidth = getViewportWidth();
- int leftScreen = 0;
- int rightScreen = 0;
+ int curScreen = 0;
- for (leftScreen = getNextPage(); leftScreen >= 0; --leftScreen) {
- View currPage = getPageAt(leftScreen);
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View currPage = getPageAt(i);
- // Check if the right edge of the page is in the viewport
- mTmpIntPoint[0] = currPage.getMeasuredWidth();
+ mTmpIntPoint[0] = 0;
Utilities.getDescendantCoordRelativeToParent(currPage, this, mTmpIntPoint, false);
- if (mTmpIntPoint[0] < 0) {
- break;
+ if (mTmpIntPoint[0] > viewportWidth) {
+ if (range[0] == -1) {
+ continue;
+ } else {
+ break;
+ }
}
- }
- for (rightScreen = getNextPage(); rightScreen < getChildCount(); ++rightScreen) {
- View currPage = getPageAt(rightScreen);
- // Check if the left edge of the page is in the viewport
- mTmpIntPoint[0] = 0;
+ mTmpIntPoint[0] = currPage.getMeasuredWidth();;
Utilities.getDescendantCoordRelativeToParent(currPage, this, mTmpIntPoint, false);
- if (mTmpIntPoint[0] >= viewportWidth) {
- break;
+ if (mTmpIntPoint[0] < 0) {
+ if (range[0] == -1) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ curScreen = i;
+ if (range[0] < 0) {
+ range[0] = curScreen;
}
}
- range[0] = Math.max(0, leftScreen);
- range[1] = Math.min(rightScreen, getChildCount() - 1);
+
+ range[1] = curScreen;
} else {
range[0] = -1;
range[1] = -1;
@@ -1558,8 +1566,13 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (!mFreeScroll) {
snapToPage(snapPage);
} else {
- mFreeScrollMinScrollX = getScrollForPage(mTempVisiblePagesRange[0]);
- mFreeScrollMaxScrollX = getScrollForPage(mTempVisiblePagesRange[1]);
+ if (isLayoutRtl()) {
+ mFreeScrollMinScrollX = getScrollForPage(mTempVisiblePagesRange[1]);
+ mFreeScrollMaxScrollX = getScrollForPage(mTempVisiblePagesRange[0]);
+ } else {
+ mFreeScrollMinScrollX = getScrollForPage(mTempVisiblePagesRange[0]);
+ mFreeScrollMaxScrollX = getScrollForPage(mTempVisiblePagesRange[1]);
+ }
if (getCurrentPage() < mTempVisiblePagesRange[0]) {
setCurrentPage(mTempVisiblePagesRange[0]);