merge in jb-mr2-release history after reset to jb-mr2-dev
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index ddb9b64..024bb37 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -283,7 +283,9 @@
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 @@
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 @@
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 @@
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/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index a819cb7..fccc1a6 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -34,6 +34,7 @@
import android.view.ViewParent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -222,6 +223,31 @@
}
@Override
+ public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
+ Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
+ if (currentFolder != null) {
+ if (child == currentFolder) {
+ return super.onRequestSendAccessibilityEvent(child, event);
+ }
+ // Skip propagating onRequestSendAccessibilityEvent all for other children
+ // when a folder is open
+ return false;
+ }
+ return super.onRequestSendAccessibilityEvent(child, event);
+ }
+
+ @Override
+ public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) {
+ Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
+ if (currentFolder != null) {
+ // Only add the folder as a child for accessibility when it is open
+ childrenForAccessibility.add(currentFolder);
+ } else {
+ super.addChildrenForAccessibility(childrenForAccessibility);
+ }
+ }
+
+ @Override
public boolean onHoverEvent(MotionEvent ev) {
// If we've received this, we've already done the necessary handling
// in onInterceptHoverEvent. Return true to consume the event.
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 5520e23..e8be3ef 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -156,6 +156,7 @@
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 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/Launcher.java b/src/com/android/launcher2/Launcher.java
index 9f97442..b20e3a5 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2287,6 +2287,11 @@
}
folder.animateOpen();
growAndFadeOutFolderIcon(folderIcon);
+
+ // Notify the accessibility manager that this folder "window" has appeared and occluded
+ // the workspace items
+ folder.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+ getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
public void closeFolder() {
@@ -2311,6 +2316,10 @@
shrinkAndFadeInFolderIcon(fi);
}
folder.animateClosed();
+
+ // Notify the accessibility manager that this folder "window" has disappeard and no
+ // longer occludeds the workspace items
+ getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}
public boolean onLongClick(View v) {
diff --git a/src/com/android/launcher2/ShortcutAndWidgetContainer.java b/src/com/android/launcher2/ShortcutAndWidgetContainer.java
index 8daf395..36f135a 100644
--- a/src/com/android/launcher2/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher2/ShortcutAndWidgetContainer.java
@@ -39,16 +39,22 @@
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 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 @@
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();