Merge "Remove references to Google packages." into nyc-dev
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java
index 1321221..6d7313d 100644
--- a/core/java/android/widget/GridView.java
+++ b/core/java/android/widget/GridView.java
@@ -1644,7 +1644,7 @@
boolean handled = false;
int action = event.getAction();
if (KeyEvent.isConfirmKey(keyCode)
- && event.hasNoModifiers() && action == KeyEvent.ACTION_UP) {
+ && event.hasNoModifiers() && action != KeyEvent.ACTION_UP) {
handled = resurrectSelectionIfNeeded();
if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) {
keyPressed();
diff --git a/libs/hwui/tests/unit/GlopBuilderTests.cpp b/libs/hwui/tests/unit/GlopBuilderTests.cpp
index 949c541..454011f 100644
--- a/libs/hwui/tests/unit/GlopBuilderTests.cpp
+++ b/libs/hwui/tests/unit/GlopBuilderTests.cpp
@@ -16,7 +16,6 @@
#include <gtest/gtest.h>
-#include "BakedOpRenderer.h"
#include "Glop.h"
#include "GlopBuilder.h"
#include "Rect.h"
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
index be70417..ae746b6 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -1263,12 +1263,15 @@
}
// Handle enter key events
- if (keyCode == KeyEvent.KEYCODE_ENTER) {
- if (event.isShiftPressed()) {
- return onSelect(doc);
- } else {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_ENTER:
+ if (event.isShiftPressed()) {
+ return onSelect(doc);
+ }
+ // For non-shifted enter keypresses, fall through.
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ case KeyEvent.KEYCODE_BUTTON_A:
return onActivate(doc);
- }
}
return false;
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/Model.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/Model.java
index 68b1bcc..c5ee592 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/Model.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/Model.java
@@ -20,9 +20,10 @@
import static com.android.documentsui.State.SORT_ORDER_DISPLAY_NAME;
import static com.android.documentsui.State.SORT_ORDER_LAST_MODIFIED;
import static com.android.documentsui.State.SORT_ORDER_SIZE;
+import static com.android.documentsui.model.DocumentInfo.getCursorLong;
+import static com.android.documentsui.model.DocumentInfo.getCursorString;
import android.database.Cursor;
-import android.database.MergeCursor;
import android.os.Bundle;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
@@ -61,17 +62,34 @@
private String mIds[] = new String[0];
private int mSortOrder = SORT_ORDER_DISPLAY_NAME;
- private int mAuthorityIndex = -1;
- private int mDocIdIndex = -1;
- private int mMimeTypeIndex = -1;
- private int mDisplayNameIndex = -1;
- private int mColumnSizeIndex = -1;
- private int mLastModifiedIndex = -1;
-
@Nullable String info;
@Nullable String error;
@Nullable DocumentInfo doc;
+ /**
+ * Generates a Model ID for a cursor entry that refers to a document. The Model ID is a unique
+ * string that can be used to identify the document referred to by the cursor.
+ *
+ * @param c A cursor that refers to a document.
+ */
+ private static String createModelId(Cursor c) {
+ // TODO: Maybe more efficient to use just the document ID, in cases where there is only one
+ // authority (which should be the majority of cases).
+ return createModelId(
+ getCursorString(c, RootCursorWrapper.COLUMN_AUTHORITY),
+ getCursorString(c, Document.COLUMN_DOCUMENT_ID));
+ }
+
+ /**
+ * Generates a Model ID for a cursor entry that refers to a document. The Model ID is a unique
+ * string that can be used to identify the document referred to by the cursor.
+ *
+ * @param c A cursor that refers to a document.
+ */
+ static String createModelId(String authority, String docId) {
+ return authority + "|" + docId;
+ }
+
private void notifyUpdateListeners() {
for (UpdateListener listener: mUpdateListeners) {
listener.onModelUpdate(this);
@@ -109,13 +127,6 @@
mCursor = result.cursor;
mCursorCount = mCursor.getCount();
mSortOrder = result.sortOrder;
- mAuthorityIndex = mCursor.getColumnIndex(RootCursorWrapper.COLUMN_AUTHORITY);
- assert(mAuthorityIndex != -1);
- mDocIdIndex = mCursor.getColumnIndex(Document.COLUMN_DOCUMENT_ID);
- mMimeTypeIndex = mCursor.getColumnIndex(Document.COLUMN_MIME_TYPE);
- mDisplayNameIndex = mCursor.getColumnIndex(Document.COLUMN_DISPLAY_NAME);
- mColumnSizeIndex = mCursor.getColumnIndex(Document.COLUMN_SIZE);
-
doc = result.doc;
updateModelData();
@@ -162,30 +173,22 @@
for (int pos = 0; pos < mCursorCount; ++pos) {
mCursor.moveToNext();
positions[pos] = pos;
+ mIds[pos] = createModelId(mCursor);
- // Generates a Model ID for a cursor entry that refers to a document. The Model ID is a
- // unique string that can be used to identify the document referred to by the cursor.
- // If the cursor is a merged cursor over multiple authorities, then prefix the ids
- // with the authority to avoid collisions.
- if (mCursor instanceof MergeCursor) {
- mIds[pos] = getString(mAuthorityIndex) + "|" + mCursor.getString(mDocIdIndex);
- } else {
- mIds[pos] = mCursor.getString(mDocIdIndex);
- }
-
- mimeType = getString(mMimeTypeIndex);
+ mimeType = getCursorString(mCursor, Document.COLUMN_MIME_TYPE);
isDirs[pos] = Document.MIME_TYPE_DIR.equals(mimeType);
- switch (mSortOrder) {
+ switch(mSortOrder) {
case SORT_ORDER_DISPLAY_NAME:
- displayNames[pos] = getString(mDisplayNameIndex);
+ final String displayName = getCursorString(
+ mCursor, Document.COLUMN_DISPLAY_NAME);
+ displayNames[pos] = displayName;
break;
case SORT_ORDER_LAST_MODIFIED:
- longValues[pos] = getLastModified();
+ longValues[pos] = getLastModified(mCursor);
break;
case SORT_ORDER_SIZE:
- longValues[pos] = mColumnSizeIndex != -1
- ? mCursor.getLong(mColumnSizeIndex) : 0;
+ longValues[pos] = getCursorLong(mCursor, Document.COLUMN_SIZE);
break;
}
}
@@ -361,17 +364,13 @@
}
}
- private String getString(int columnIndex) {
- return columnIndex != -1 ? mCursor.getString(columnIndex) : null;
- }
-
/**
* @return Timestamp for the given document. Some docs (e.g. active downloads) have a null
* timestamp - these will be replaced with MAX_LONG so that such files get sorted to the top
* when sorting by date.
*/
- private long getLastModified() {
- long l = mCursor.getLong(mLastModifiedIndex);
+ long getLastModified(Cursor cursor) {
+ long l = getCursorLong(mCursor, Document.COLUMN_LAST_MODIFIED);
return (l == -1) ? Long.MAX_VALUE : l;
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/MultiSelectManager.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/MultiSelectManager.java
index b0cc09a..b80486d 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/MultiSelectManager.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/MultiSelectManager.java
@@ -903,7 +903,7 @@
public Selection createFromParcel(Parcel in, ClassLoader loader) {
return new Selection(
in.readString(),
- (ArrayList<String>) in.readArrayList(loader));
+ in.readArrayList(loader));
}
@Override
@@ -931,7 +931,6 @@
Rect getAbsoluteRectForChildViewAt(int index);
int getAdapterPositionAt(int index);
int getColumnCount();
- int getRowCount();
int getChildCount();
int getVisibleChildCount();
/**
@@ -1008,13 +1007,6 @@
}
@Override
- public int getRowCount() {
- int numFullColumns = getChildCount() / getColumnCount();
- boolean hasPartiallyFullColumn = getChildCount() % getColumnCount() != 0;
- return numFullColumns + (hasPartiallyFullColumn ? 1 : 0);
- }
-
- @Override
public int getHeight() {
return mView.getHeight();
}
@@ -1202,6 +1194,7 @@
}
mCurrentPosition = input.getOrigin();
+ mModel.resizeSelection(input.getOrigin());
scrollViewIfNecessary();
resizeBandSelectRectangle();
}
@@ -1549,11 +1542,7 @@
mColumnBounds, new Limits(absoluteChildRect.left, absoluteChildRect.right));
}
- if (mRowBounds.size() != mHelper.getRowCount()) {
- // If not all y-limits have been recorded, record this one.
- recordLimits(
- mRowBounds, new Limits(absoluteChildRect.top, absoluteChildRect.bottom));
- }
+ recordLimits(mRowBounds, new Limits(absoluteChildRect.top, absoluteChildRect.bottom));
SparseIntArray columnList = mColumns.get(absoluteChildRect.left);
if (columnList == null) {
@@ -1747,6 +1736,11 @@
return ((Limits) other).lowerLimit == lowerLimit &&
((Limits) other).upperLimit == upperLimit;
}
+
+ @Override
+ public String toString() {
+ return "(" + lowerLimit + ", " + upperLimit + ")";
+ }
}
/**
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/ModelTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/ModelTest.java
index 3536593..c6ad511 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/ModelTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/ModelTest.java
@@ -284,7 +284,7 @@
String id = Integer.toString(i);
row.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY);
row.add(Document.COLUMN_DOCUMENT_ID, id);
- currentDownloads.add(id);
+ currentDownloads.add(Model.createModelId(AUTHORITY, id));
}
DirectoryResult r = new DirectoryResult();
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_GridModelTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_GridModelTest.java
index 353d4bd..0c0e0b7 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_GridModelTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/MultiSelectManager_GridModelTest.java
@@ -27,6 +27,7 @@
import com.android.documentsui.dirlist.MultiSelectManager.GridModel;
import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
@SmallTest
@@ -42,6 +43,17 @@
private Set<String> lastSelection;
private int viewWidth;
+ // TLDR: Don't call model.{start|resize}Selection; use the local #startSelection and
+ // #resizeSelection methods instead.
+ //
+ // The reason for this is that selection is stateful and involves operations that take the
+ // current UI state (e.g scrolling) into account. This test maintains its own copy of the
+ // selection bounds as control data for verifying selections. Keep this data in sync by calling
+ // #startSelection and
+ // #resizeSelection.
+ private Point mSelectionOrigin;
+ private Point mSelectionPoint;
+
private void initData(final int numChildren, int numColumns) {
env = new TestEnvironment(numChildren, numColumns);
adapter = new TestDocumentsAdapter(new ArrayList<String>()) {
@@ -76,139 +88,241 @@
public void testSelectionLeftOfItems() {
initData(20, 5);
- model.startSelection(new Point(0, 10));
- model.resizeSelection(new Point(1, 11));
- assertSelected();
+ startSelection(new Point(0, 10));
+ resizeSelection(new Point(1, 11));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testSelectionRightOfItems() {
initData(20, 4);
- model.startSelection(new Point(viewWidth - 1, 10));
- model.resizeSelection(new Point(viewWidth - 2, 11));
- assertSelected();
+ startSelection(new Point(viewWidth - 1, 10));
+ resizeSelection(new Point(viewWidth - 2, 11));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testSelectionAboveItems() {
initData(20, 4);
- model.startSelection(new Point(10, 0));
- model.resizeSelection(new Point(11, 1));
- assertSelected();
+ startSelection(new Point(10, 0));
+ resizeSelection(new Point(11, 1));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testSelectionBelowItems() {
initData(5, 4);
- model.startSelection(new Point(10, VIEWPORT_HEIGHT - 1));
- model.resizeSelection(new Point(11, VIEWPORT_HEIGHT - 2));
- assertSelected();
+ startSelection(new Point(10, VIEWPORT_HEIGHT - 1));
+ resizeSelection(new Point(11, VIEWPORT_HEIGHT - 2));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testVerticalSelectionBetweenItems() {
initData(20, 4);
- model.startSelection(new Point(106, 0));
- model.resizeSelection(new Point(107, 200));
- assertSelected();
+ startSelection(new Point(106, 0));
+ resizeSelection(new Point(107, 200));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testHorizontalSelectionBetweenItems() {
initData(20, 4);
- model.startSelection(new Point(0, 105));
- model.resizeSelection(new Point(200, 106));
- assertSelected();
+ startSelection(new Point(0, 105));
+ resizeSelection(new Point(200, 106));
+ assertNoSelection();
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testGrowingAndShrinkingSelection() {
initData(20, 4);
- model.startSelection(new Point(0, 0));
- model.resizeSelection(new Point(5, 5));
- assertSelected(0);
- model.resizeSelection(new Point(109, 109));
- assertSelected(0);
- model.resizeSelection(new Point(110, 109));
- assertSelected(0, 1);
- model.resizeSelection(new Point(110, 110));
- assertSelected(0, 1, 4, 5);
- model.resizeSelection(new Point(214, 214));
- assertSelected(0, 1, 4, 5);
- model.resizeSelection(new Point(215, 214));
- assertSelected(0, 1, 2, 4, 5, 6);
- model.resizeSelection(new Point(214, 214));
- assertSelected(0, 1, 4, 5);
- model.resizeSelection(new Point(110, 110));
- assertSelected(0, 1, 4, 5);
- model.resizeSelection(new Point(110, 109));
- assertSelected(0, 1);
- model.resizeSelection(new Point(109, 109));
- assertSelected(0);
- model.resizeSelection(new Point(5, 5));
- assertSelected(0);
- model.resizeSelection(new Point(0, 0));
- assertSelected();
+ startSelection(new Point(0, 0));
+
+ resizeSelection(new Point(5, 5));
+ verifySelection();
+
+ resizeSelection(new Point(109, 109));
+ verifySelection();
+
+ resizeSelection(new Point(110, 109));
+ verifySelection();
+
+ resizeSelection(new Point(110, 110));
+ verifySelection();
+
+ resizeSelection(new Point(214, 214));
+ verifySelection();
+
+ resizeSelection(new Point(215, 214));
+ verifySelection();
+
+ resizeSelection(new Point(214, 214));
+ verifySelection();
+
+ resizeSelection(new Point(110, 110));
+ verifySelection();
+
+ resizeSelection(new Point(110, 109));
+ verifySelection();
+
+ resizeSelection(new Point(109, 109));
+ verifySelection();
+
+ resizeSelection(new Point(5, 5));
+ verifySelection();
+
+ resizeSelection(new Point(0, 0));
+ verifySelection();
+
assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
public void testSelectionMovingAroundOrigin() {
initData(16, 4);
- model.startSelection(new Point(210, 210));
- model.resizeSelection(new Point(viewWidth - 1, 0));
- assertSelected(2, 3, 6, 7);
- model.resizeSelection(new Point(0, 0));
- assertSelected(0, 1, 4, 5);
- model.resizeSelection(new Point(0, 420));
- assertSelected(8, 9, 12, 13);
- model.resizeSelection(new Point(viewWidth - 1, 420));
- assertSelected(10, 11, 14, 15);
- assertEquals(10, model.getPositionNearestOrigin());
+
+ startSelection(new Point(210, 210));
+ resizeSelection(new Point(viewWidth - 1, 0));
+ verifySelection();
+
+ resizeSelection(new Point(0, 0));
+ verifySelection();
+
+ resizeSelection(new Point(0, 420));
+ verifySelection();
+
+ resizeSelection(new Point(viewWidth - 1, 420));
+ verifySelection();
+
+ // This is manually figured and will need to be adjusted if the separator position is
+ // changed.
+ assertEquals(7, model.getPositionNearestOrigin());
}
public void testScrollingBandSelect() {
initData(40, 4);
- model.startSelection(new Point(0, 0));
- model.resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
- assertSelected(0, 4, 8, 12, 16);
+
+ startSelection(new Point(0, 0));
+ resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
+ verifySelection();
+
scroll(CHILD_VIEW_EDGE_PX);
- assertSelected(0, 4, 8, 12, 16, 20);
- model.resizeSelection(new Point(200, VIEWPORT_HEIGHT - 1));
- assertSelected(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21);
+ verifySelection();
+
+ resizeSelection(new Point(200, VIEWPORT_HEIGHT - 1));
+ verifySelection();
+
scroll(CHILD_VIEW_EDGE_PX);
- assertSelected(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25);
+ verifySelection();
+
scroll(-2 * CHILD_VIEW_EDGE_PX);
- assertSelected(0, 1, 4, 5, 8, 9, 12, 13, 16, 17);
- model.resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
- assertSelected(0, 4, 8, 12, 16);
+ verifySelection();
+
+ resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
+ verifySelection();
+
assertEquals(0, model.getPositionNearestOrigin());
}
- private void assertSelected(int... selectedPositions) {
- assertEquals(selectedPositions.length, lastSelection.size());
- for (int position : selectedPositions) {
- assertTrue(lastSelection.contains(Integer.toString(position)));
+ /** Returns the current selection area as a Rect. */
+ private Rect getSelectionArea() {
+ // Construct a rect from the two selection points.
+ Rect selectionArea = new Rect(
+ mSelectionOrigin.x, mSelectionOrigin.y, mSelectionOrigin.x, mSelectionOrigin.y);
+ selectionArea.union(mSelectionPoint.x, mSelectionPoint.y);
+ // Rect intersection tests are exclusive of bounds, while the MSM's selection code is
+ // inclusive. Expand the rect by 1 pixel in all directions to account for this.
+ selectionArea.inset(-1, -1);
+
+ return selectionArea;
+ }
+
+ /** Asserts that the selection is currently empty. */
+ private void assertNoSelection() {
+ assertEquals("Unexpected items " + lastSelection + " in selection " + getSelectionArea(),
+ 0, lastSelection.size());
+ }
+
+ /** Verifies the selection using actual bbox checks. */
+ private void verifySelection() {
+ Rect selectionArea = getSelectionArea();
+ for (TestEnvironment.Item item: env.items) {
+ if (Rect.intersects(selectionArea, item.rect)) {
+ assertTrue("Expected item " + item + " was not in selection " + selectionArea,
+ lastSelection.contains(item.name));
+ } else {
+ assertFalse("Unexpected item " + item + " in selection" + selectionArea,
+ lastSelection.contains(item.name));
+ }
}
}
+ private void startSelection(Point p) {
+ model.startSelection(p);
+ mSelectionOrigin = env.createAbsolutePoint(p);
+ }
+
+ private void resizeSelection(Point p) {
+ model.resizeSelection(p);
+ mSelectionPoint = env.createAbsolutePoint(p);
+ }
+
private void scroll(int dy) {
assertTrue(env.verticalOffset + VIEWPORT_HEIGHT + dy <= env.getTotalHeight());
env.verticalOffset += dy;
+ // Correct the cached selection point as well.
+ mSelectionPoint.y += dy;
model.onScrolled(null, 0, dy);
}
private static final class TestEnvironment implements MultiSelectManager.SelectionEnvironment {
- public int horizontalOffset = 0;
- public int verticalOffset = 0;
private final int mNumColumns;
private final int mNumRows;
private final int mNumChildren;
+ private final int mSeparatorPosition;
+
+ public int horizontalOffset = 0;
+ public int verticalOffset = 0;
+ private List<Item> items = new ArrayList<>();
public TestEnvironment(int numChildren, int numColumns) {
mNumChildren = numChildren;
mNumColumns = numColumns;
- mNumRows = (int) Math.ceil((double) numChildren / mNumColumns);
+ mSeparatorPosition = mNumColumns + 1;
+ mNumRows = setupGrid();
+ }
+
+ private int setupGrid() {
+ // Split the input set into folders and documents. Do this such that there is a
+ // partially-populated row in the middle of the grid, to test corner cases in layout
+ // code.
+ int y = VIEW_PADDING_PX;
+ int i = 0;
+ int numRows = 0;
+ while (i < mNumChildren) {
+ int top = y;
+ int height = CHILD_VIEW_EDGE_PX;
+ int width = CHILD_VIEW_EDGE_PX;
+ for (int j = 0; j < mNumColumns && i < mNumChildren; j++) {
+ int left = VIEW_PADDING_PX + (j * (width + VIEW_PADDING_PX));
+ items.add(new Item(
+ Integer.toString(i),
+ new Rect(
+ left,
+ top,
+ left + width - 1,
+ top + height - 1)));
+
+ // Create a partially populated row at the separator position.
+ if (++i == mSeparatorPosition) {
+ break;
+ }
+ }
+ y += height + VIEW_PADDING_PX;
+ numRows++;
+ }
+
+ return numRows;
}
private int getTotalHeight() {
@@ -227,8 +341,16 @@
private int getNumItemsInRow(int index) {
assertTrue(index >= 0 && index < mNumRows);
- if (index == mNumRows - 1 && mNumChildren % mNumColumns != 0) {
- return mNumChildren % mNumColumns;
+ int mod = mSeparatorPosition % mNumColumns;
+ if (index == (mSeparatorPosition / mNumColumns)) {
+ // The row containing the separator may be incomplete
+ return mod > 0 ? mod : mNumColumns;
+ }
+ // Account for the partial separator row in the final row tally.
+ if (index == mNumRows - 1) {
+ // The last row may be incomplete
+ int finalRowCount = (mNumChildren - mod) % mNumColumns;
+ return finalRowCount > 0 ? finalRowCount : mNumColumns;
}
return mNumColumns;
@@ -257,21 +379,18 @@
@Override
public int getAdapterPositionAt(int index) {
- return index + mNumColumns * (getFirstVisibleRowIndex());
+ // Account for partial rows by actually tallying up the items in hidden rows.
+ int hiddenCount = 0;
+ for (int i = 0; i < getFirstVisibleRowIndex(); i++) {
+ hiddenCount += getNumItemsInRow(i);
+ }
+ return index + hiddenCount;
}
@Override
public Rect getAbsoluteRectForChildViewAt(int index) {
- int adapterPosition = (getFirstVisibleRowIndex() * mNumColumns) + index;
- int rowIndex = adapterPosition / mNumColumns;
- int columnIndex = adapterPosition % mNumColumns;
-
- Rect rect = new Rect();
- rect.top = VIEW_PADDING_PX + rowIndex * (CHILD_VIEW_EDGE_PX + VIEW_PADDING_PX);
- rect.bottom = rect.top + CHILD_VIEW_EDGE_PX - 1;
- rect.left = VIEW_PADDING_PX + columnIndex * (CHILD_VIEW_EDGE_PX + VIEW_PADDING_PX);
- rect.right = rect.left + CHILD_VIEW_EDGE_PX - 1;
- return rect;
+ int adapterPosition = getAdapterPositionAt(index);
+ return items.get(adapterPosition).rect;
}
@Override
@@ -285,11 +404,6 @@
}
@Override
- public int getRowCount() {
- return mNumRows;
- }
-
- @Override
public void showBand(Rect rect) {
throw new UnsupportedOperationException();
}
@@ -328,5 +442,19 @@
public boolean isLayoutItem(int adapterPosition) {
return false;
}
+
+ public static final class Item {
+ public String name;
+ public Rect rect;
+
+ public Item(String n, Rect r) {
+ name = n;
+ rect = r;
+ }
+
+ public String toString() {
+ return name + ": " + rect;
+ }
+ }
}
}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestModel.java b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestModel.java
index 2d819ff..d8c29db 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestModel.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestModel.java
@@ -62,7 +62,9 @@
update(r);
}
+ // Note that model id includes authority qualifier and is distinct
+ // WRT documentId because of this.
String idForPosition(int p) {
- return Integer.toString(p);
+ return createModelId(mAuthority, Integer.toString(p));
}
}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestSelectionEnvironment.java b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestSelectionEnvironment.java
index 8e624a0..56e54a6 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestSelectionEnvironment.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/dirlist/TestSelectionEnvironment.java
@@ -87,11 +87,6 @@
}
@Override
- public int getRowCount() {
- return 0;
- }
-
- @Override
public int getChildCount() {
return 0;
}
diff --git a/packages/SystemUI/res/drawable-hdpi/recents_empty.png b/packages/SystemUI/res/drawable-hdpi/recents_empty.png
deleted file mode 100755
index dec97b6..0000000
--- a/packages/SystemUI/res/drawable-hdpi/recents_empty.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/recents_empty.png b/packages/SystemUI/res/drawable-mdpi/recents_empty.png
deleted file mode 100755
index d16763a..0000000
--- a/packages/SystemUI/res/drawable-mdpi/recents_empty.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/recents_empty.png b/packages/SystemUI/res/drawable-xhdpi/recents_empty.png
deleted file mode 100755
index 1e02844..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/recents_empty.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxhdpi/recents_empty.png b/packages/SystemUI/res/drawable-xxhdpi/recents_empty.png
deleted file mode 100755
index 9d94be7..0000000
--- a/packages/SystemUI/res/drawable-xxhdpi/recents_empty.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xxxhdpi/recents_empty.png b/packages/SystemUI/res/drawable-xxxhdpi/recents_empty.png
deleted file mode 100755
index 24599c3..0000000
--- a/packages/SystemUI/res/drawable-xxxhdpi/recents_empty.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable/recents_empty.xml b/packages/SystemUI/res/drawable/recents_empty.xml
new file mode 100644
index 0000000..5506de1
--- /dev/null
+++ b/packages/SystemUI/res/drawable/recents_empty.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="100dp"
+ android:height="132dp"
+ android:viewportWidth="100"
+ android:viewportHeight="132">
+
+ <path
+ android:fillColor="#5AFFFFFF"
+ android:pathData="M86.91,68.67H13.09c-4.96,0-9,4.04-9,9V119c0,4.96,4.04,9,9,9h73.82c4.96,0,9-4.04,9-9V77.67
+C95.91,72.7,91.87,68.67,86.91,68.67z M27.59,77.27h26.72v3.94H27.59V77.27z
+M18.73,74.74c2.49,0,4.5,2.01,4.5,4.5
+c0,2.49-2.01,4.5-4.5,4.5s-4.5-2.01-4.5-4.5C14.23,76.75,16.24,74.74,18.73,74.74z
+M89.91,119c0,1.65-1.35,3-3,3H13.09 c-1.65,0-3-1.35-3-3V88.67h79.82V119z" />
+ <path
+ android:fillColor="#5AFFFFFF"
+ android:pathData="M86.91,36.3H13.09c-4.96,0-9,4.04-9,9v23c1.65-1.58,3.71-2.73,6-3.28v-9.08h79.82v9.08
+c2.29,0.55,4.35,1.69,6,3.28v-23C95.91,40.34,91.87,36.3,86.91,36.3z
+M18.73,51.38c-2.49,0-4.5-2.01-4.5-4.5s2.01-4.5,4.5-4.5
+s4.5,2.01,4.5,4.5S21.22,51.38,18.73,51.38z M54.31,48.84H27.59v-3.94h26.72V48.84z" />
+ <path
+ android:fillColor="#5AFFFFFF"
+ android:pathData="M86.91,4H13.09c-4.96,0-9,4.04-9,9v22.94c1.65-1.58,3.71-2.73,6-3.28V24h79.82v8.67
+c2.29,0.55,4.35,1.69,6,3.28V13C95.91,8.04,91.87,4,86.91,4z
+M18.73,18.5c-2.49,0-4.5-2.01-4.5-4.5s2.01-4.5,4.5-4.5
+s4.5,2.01,4.5,4.5S21.22,18.5,18.73,18.5z M54.31,15.97H27.59v-3.94h26.72V15.97z" />
+ <path
+ android:pathData="M 0 0 H 100 V 132 H 0 V 0 Z" />
+</vector>
\ No newline at end of file