summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-09-24 17:57:32 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-24 17:57:32 +0000
commit25cc19c8c9caeb10e808095d4817f82973570117 (patch)
treefc75b7cc30433446293b90cf72f8e447c8957aef /src/com
parent1e4e6ddb38d0b867d0564be834f3425ed53d46e1 (diff)
parentaf9b0e51aac239457fbd038f7cb2088265054e42 (diff)
downloadandroid_packages_apps_Trebuchet-25cc19c8c9caeb10e808095d4817f82973570117.tar.gz
android_packages_apps_Trebuchet-25cc19c8c9caeb10e808095d4817f82973570117.tar.bz2
android_packages_apps_Trebuchet-25cc19c8c9caeb10e808095d4817f82973570117.zip
Merge "Getting RTL up to a reasonable state in Launcher3" into jb-ub-now-indigo-rose
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/PagedView.java59
-rw-r--r--src/com/android/launcher3/Workspace.java20
2 files changed, 51 insertions, 28 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]);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index aab0a639a..53a6b6868 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -933,8 +933,9 @@ public class Workspace extends SmoothPagedView
boolean passRightSwipesToCustomContent =
(mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY;
- if (deltaX > 0 && getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID
- && passRightSwipesToCustomContent) {
+ boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0;
+ if (swipeInIgnoreDirection && getScreenIdForPageIndex(getCurrentPage()) ==
+ CUSTOM_CONTENT_SCREEN_ID && passRightSwipesToCustomContent) {
// Pass swipes to the right to the custom content page.
return;
}
@@ -1363,9 +1364,15 @@ public class Workspace extends SmoothPagedView
if (hasCustomContent()) {
int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
int scrollDelta = getScrollForPage(index + 1) - getScrollX();
- translationX = Math.max(scrollDelta, 0);
+ translationX = scrollDelta;
progress = (1.0f * scrollDelta) /
(getScrollForPage(index + 1) - getScrollForPage(index));
+
+ if (isLayoutRtl()) {
+ translationX = Math.min(0, translationX);
+ } else {
+ translationX = Math.max(0, translationX);
+ }
progress = Math.max(0, progress);
}
@@ -1396,7 +1403,10 @@ public class Workspace extends SmoothPagedView
updateStateForCustomContent(screenCenter);
enableHwLayersOnVisiblePages();
- if ((mOverScrollX < 0 && !hasCustomContent()) || mOverScrollX > mMaxScrollX) {
+ boolean shouldOverScroll = (mOverScrollX < 0 && (!hasCustomContent() || isLayoutRtl())) ||
+ (mOverScrollX > mMaxScrollX && (!hasCustomContent() || !isLayoutRtl()));
+
+ if (shouldOverScroll) {
int index = 0;
float pivotX = 0f;
final float leftBiasedPivot = 0.25f;
@@ -1857,7 +1867,7 @@ public class Workspace extends SmoothPagedView
} else if (stateIsOverview) {
mNewScale = mOverviewModeShrinkFactor;
} else if (stateIsSmall){
- mNewScale = mOverviewModeShrinkFactor - 0.1f;
+ mNewScale = mOverviewModeShrinkFactor - 0.3f;
}
if (oldStateIsNormal && stateIsSmall) {
zoomIn = false;