summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-04-16 23:26:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-16 23:26:55 +0000
commit02d1863c595d14338045e806668ec60d7db45293 (patch)
tree9cf32fed1cb3426e0f6112b40bf6eaf5977a9816 /src
parent5a0300783cef1216f5d13dcbe98ef44f8cc78fc7 (diff)
parent2374abfda3e53f84e005df8923170308e4df8c03 (diff)
downloadandroid_packages_apps_Trebuchet-02d1863c595d14338045e806668ec60d7db45293.tar.gz
android_packages_apps_Trebuchet-02d1863c595d14338045e806668ec60d7db45293.tar.bz2
android_packages_apps_Trebuchet-02d1863c595d14338045e806668ec60d7db45293.zip
Merge "Making folders work in RTL (issue 8569879)" into jb-mr2-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java25
-rw-r--r--src/com/android/launcher2/Folder.java9
-rw-r--r--src/com/android/launcher2/ShortcutAndWidgetContainer.java26
3 files changed, 52 insertions, 8 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index ddb9b6418..024bb37af 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -283,7 +283,9 @@ public class CellLayout extends ViewGroup {
mForegroundRect = new Rect();
mShortcutsAndWidgets = new ShortcutAndWidgetContainer(context);
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
+ mCountX);
+
addView(mShortcutsAndWidgets);
}
@@ -331,9 +333,16 @@ public class CellLayout extends ViewGroup {
mOccupied = new boolean[mCountX][mCountY];
mTmpOccupied = new boolean[mCountX][mCountY];
mTempRectStack.clear();
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
+ mCountX);
requestLayout();
}
+ // Set whether or not to invert the layout horizontally if the layout is in RTL mode.
+ public void setInvertIfRtl(boolean invert) {
+ mShortcutsAndWidgets.setInvertIfRtl(invert);
+ }
+
private void invalidateBubbleTextView(BubbleTextView icon) {
final int padding = icon.getPressedOrFocusedBackgroundPadding();
invalidate(icon.getLeft() + getPaddingLeft() - padding,
@@ -985,7 +994,8 @@ public class CellLayout extends ViewGroup {
int vFreeSpace = vSpace - (mCountY * mCellHeight);
mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
- mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+ mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap,
+ mCountX);
} else {
mWidthGap = mOriginalWidthGap;
mHeightGap = mOriginalHeightGap;
@@ -3242,12 +3252,17 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
this.cellVSpan = cellVSpan;
}
- public void setup(int cellWidth, int cellHeight, int widthGap, int heightGap) {
+ public void setup(int cellWidth, int cellHeight, int widthGap, int heightGap,
+ boolean invertHorizontally, int colCount) {
if (isLockedToGrid) {
final int myCellHSpan = cellHSpan;
final int myCellVSpan = cellVSpan;
- final int myCellX = useTmpCoords ? tmpCellX : cellX;
- final int myCellY = useTmpCoords ? tmpCellY : cellY;
+ int myCellX = useTmpCoords ? tmpCellX : cellX;
+ int myCellY = useTmpCoords ? tmpCellY : cellY;
+
+ if (invertHorizontally) {
+ myCellX = colCount - myCellX - cellHSpan;
+ }
width = myCellHSpan * cellWidth + ((myCellHSpan - 1) * widthGap) -
leftMargin - rightMargin;
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 5520e23f3..e8be3eff2 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -156,6 +156,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mContent = (CellLayout) findViewById(R.id.folder_content);
mContent.setGridSize(0, 0);
mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false);
+ mContent.setInvertIfRtl(true);
mFolderName = (FolderEditText) findViewById(R.id.folder_name);
mFolderName.setFolder(this);
mFolderName.setOnFocusChangeListener(this);
@@ -612,10 +613,18 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
}
}
+ public boolean isLayoutRtl() {
+ return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
+ }
+
public void onDragOver(DragObject d) {
float[] r = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, d.dragView, null);
mTargetCell = mContent.findNearestArea((int) r[0], (int) r[1], 1, 1, mTargetCell);
+ if (isLayoutRtl()) {
+ mTargetCell[0] = mContent.getCountX() - mTargetCell[0] - 1;
+ }
+
if (mTargetCell[0] != mPreviousTargetCell[0] || mTargetCell[1] != mPreviousTargetCell[1]) {
mReorderAlarm.cancelAlarm();
mReorderAlarm.setOnAlarmListener(mReorderAlarmListener);
diff --git a/src/com/android/launcher2/ShortcutAndWidgetContainer.java b/src/com/android/launcher2/ShortcutAndWidgetContainer.java
index 8daf3954d..36f135aff 100644
--- a/src/com/android/launcher2/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher2/ShortcutAndWidgetContainer.java
@@ -39,16 +39,22 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
private int mWidthGap;
private int mHeightGap;
+ private int mCountX;
+
+ private boolean mInvertIfRtl = false;
+
public ShortcutAndWidgetContainer(Context context) {
super(context);
mWallpaperManager = WallpaperManager.getInstance(context);
}
- public void setCellDimensions(int cellWidth, int cellHeight, int widthGap, int heightGap ) {
+ public void setCellDimensions(int cellWidth, int cellHeight, int widthGap, int heightGap,
+ int countX) {
mCellWidth = cellWidth;
mCellHeight = cellHeight;
mWidthGap = widthGap;
mHeightGap = heightGap;
+ mCountX = countX;
}
public View getChildAt(int x, int y) {
@@ -96,7 +102,13 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
}
public void setupLp(CellLayout.LayoutParams lp) {
- lp.setup(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
+ lp.setup(mCellWidth, mCellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(),
+ mCountX);
+ }
+
+ // Set whether or not to invert the layout horizontally if the layout is in RTL mode.
+ public void setInvertIfRtl(boolean invert) {
+ mInvertIfRtl = invert;
}
public void measureChild(View child) {
@@ -104,13 +116,21 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
final int cellHeight = mCellHeight;
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
- lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap);
+ lp.setup(cellWidth, cellHeight, mWidthGap, mHeightGap, invertLayoutHorizontally(), mCountX);
int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(lp.height,
MeasureSpec.EXACTLY);
child.measure(childWidthMeasureSpec, childheightMeasureSpec);
}
+ private boolean invertLayoutHorizontally() {
+ return mInvertIfRtl && isLayoutRtl();
+ }
+
+ public boolean isLayoutRtl() {
+ return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
+ }
+
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int count = getChildCount();