Merge "Allow drag-n-drop to auto-scroll when near top/bottom of dirlist." into nyc-andromeda-dev
diff --git a/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java b/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
index cb2d904..9925d5b 100644
--- a/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
+++ b/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
@@ -56,6 +56,10 @@
final Intent intent = new Intent(context, FilesActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity = getInstrumentation().startActivitySync(intent);
+ try {
+ device.setOrientationNatural();
+ } catch (RemoteException e) {
+ }
}
public void tearDownInLoop() {
@@ -63,6 +67,11 @@
mActivity.finish();
mActivity = null;
}
+ try {
+ final UiDevice device = UiDevice.getInstance(getInstrumentation());
+ device.unfreezeRotation();
+ } catch (RemoteException e) {
+ }
}
public void setupAndOpenInLoop() throws Exception {
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 28f5f88..416bb6f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,7 +16,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title of the documents application [CHAR LIMIT=32] -->
- <string name="app_label">Documents</string>
+ <string name="app_label">Files</string>
<!-- Title of the standalone downloads activity. [CHAR LIMIT=32] -->
<string name="downloads_label">Downloads</string>
diff --git a/src/com/android/documentsui/Events.java b/src/com/android/documentsui/Events.java
index 2d0dbe8..95934c3 100644
--- a/src/com/android/documentsui/Events.java
+++ b/src/com/android/documentsui/Events.java
@@ -35,34 +35,13 @@
* Returns true if event was triggered by a mouse.
*/
public static boolean isMouseEvent(MotionEvent e) {
- return isMouseType(e.getToolType(0));
- }
-
- /**
- * Returns true if event was triggered by a finger or stylus touch.
- */
- public static boolean isTouchEvent(MotionEvent e) {
- return isTouchType(e.getToolType(0));
- }
-
- /**
- * Returns true if event was triggered by a mouse.
- */
- public static boolean isMouseType(int toolType) {
+ int toolType = e.getToolType(0);
return toolType == MotionEvent.TOOL_TYPE_MOUSE;
}
/**
* Returns true if event was triggered by a finger or stylus touch.
*/
- public static boolean isTouchType(int toolType) {
- return toolType == MotionEvent.TOOL_TYPE_FINGER
- || toolType == MotionEvent.TOOL_TYPE_STYLUS;
- }
-
- /**
- * Returns true if event was triggered by a finger or stylus touch.
- */
public static boolean isActionDown(MotionEvent e) {
return e.getActionMasked() == MotionEvent.ACTION_DOWN;
}
@@ -116,7 +95,6 @@
* of related code.
*/
public interface InputEvent extends AutoCloseable {
- boolean isTouchEvent();
boolean isMouseEvent();
boolean isPrimaryButtonPressed();
boolean isSecondaryButtonPressed();
@@ -212,11 +190,6 @@
}
@Override
- public boolean isTouchEvent() {
- return Events.isTouchEvent(mEvent);
- }
-
- @Override
public boolean isMouseEvent() {
return Events.isMouseEvent(mEvent);
}
diff --git a/src/com/android/documentsui/dirlist/BandController.java b/src/com/android/documentsui/dirlist/BandController.java
index bcaf182..5ab85c1 100644
--- a/src/com/android/documentsui/dirlist/BandController.java
+++ b/src/com/android/documentsui/dirlist/BandController.java
@@ -84,14 +84,14 @@
new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
- try (MotionInputEvent event = MotionInputEvent.obtain(e, view)) {
+ try (InputEvent event = MotionInputEvent.obtain(e, view)) {
return handleEvent(event);
}
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
if (Events.isMouseEvent(e)) {
- try (MotionInputEvent event = MotionInputEvent.obtain(e, view)) {
+ try (InputEvent event = MotionInputEvent.obtain(e, view)) {
processInputEvent(event);
}
}
@@ -199,7 +199,7 @@
mSelection = selection;
}
- private boolean handleEvent(MotionInputEvent e) {
+ private boolean handleEvent(InputEvent e) {
// Don't start, or extend bands on right click.
if (e.isSecondaryButtonPressed()) {
return false;
@@ -248,7 +248,7 @@
}
}
- boolean shouldStart(MotionInputEvent e) {
+ boolean shouldStart(InputEvent e) {
return !isActive()
&& e.isActionDown() // the initial button press
&& mAdapter.getItemCount() > 0
diff --git a/src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java b/src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java
index 42634ba..32bb5b1 100644
--- a/src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java
+++ b/src/com/android/documentsui/dirlist/TouchSwipeRefreshLayout.java
@@ -17,6 +17,8 @@
package com.android.documentsui.dirlist;
import android.content.Context;
+import android.content.res.TypedArray;
+import android.support.annotation.ColorRes;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
@@ -28,12 +30,20 @@
*/
public class TouchSwipeRefreshLayout extends SwipeRefreshLayout {
+ private static final int[] COLOR_RES = new int[] { android.R.attr.colorAccent };
+ private static int COLOR_ACCENT_INDEX = 0;
+
public TouchSwipeRefreshLayout(Context context) {
this(context, null);
}
public TouchSwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
+
+ TypedArray a = context.obtainStyledAttributes(COLOR_RES);
+ @ColorRes int colorId = a.getResourceId(COLOR_ACCENT_INDEX, -1);
+ a.recycle();
+ setColorSchemeResources(colorId);
}
@Override
diff --git a/src/com/android/documentsui/services/CopyJob.java b/src/com/android/documentsui/services/CopyJob.java
index c8f6a64..8eabbe4 100644
--- a/src/com/android/documentsui/services/CopyJob.java
+++ b/src/com/android/documentsui/services/CopyJob.java
@@ -273,6 +273,8 @@
try {
final ContentResolver resolver = appContext.getContentResolver();
final Iterable<Uri> uris = srcs.getUris(appContext);
+
+ int docProcessed = 0;
for (Uri uri : uris) {
DocumentInfo doc = DocumentInfo.fromUri(resolver, uri);
if (canCopy(doc, stack.root)) {
@@ -280,11 +282,16 @@
} else {
onFileFailed(doc);
}
+ ++docProcessed;
if (isCanceled()) {
return;
}
}
+
+ // If docProcessed is different than the count claimed by UrisSupplier, add the number
+ // to failedFileCount.
+ failedFileCount += (srcs.getItemCount() - docProcessed);
} catch(IOException e) {
failedFileCount += srcs.getItemCount();
throw new ResourceException("Failed to open the list of docs to copy.", e);
diff --git a/src/com/android/documentsui/services/DeleteJob.java b/src/com/android/documentsui/services/DeleteJob.java
index 64bc1a7..5a36818 100644
--- a/src/com/android/documentsui/services/DeleteJob.java
+++ b/src/com/android/documentsui/services/DeleteJob.java
@@ -120,6 +120,10 @@
++mDocsProcessed;
}
+
+ // If mDocProcessed is different than the count claimed by UrisSupplier, add the number
+ // to failedFileCount.
+ failedFileCount += (this.srcs.getItemCount() - mDocsProcessed);
Metrics.logFileOperation(service, operationType, srcs, null);
} catch(IOException e) {
Log.e(TAG, "Failed to get list of docs or parent source.", e);
diff --git a/tests/src/com/android/documentsui/FileManagementUiTest.java b/tests/src/com/android/documentsui/FileManagementUiTest.java
index 623f68a..44f417d 100644
--- a/tests/src/com/android/documentsui/FileManagementUiTest.java
+++ b/tests/src/com/android/documentsui/FileManagementUiTest.java
@@ -67,17 +67,6 @@
bots.directory.waitForDocument("Kung Fu Panda");
}
- public void testDeleteDocument() throws Exception {
- bots.directory.clickDocument("file1.png");
- device.waitForIdle();
- bots.main.clickToolbarItem(R.id.menu_delete);
-
- bots.main.clickDialogOkButton();
- device.waitForIdle();
-
- bots.directory.assertDocumentsAbsent("file1.png");
- }
-
public void testKeyboard_CutDocument() throws Exception {
bots.directory.clickDocument("file1.png");
device.waitForIdle();
@@ -111,7 +100,7 @@
bots.directory.waitForDocument("file1.png");
}
- public void testDeleteDocument_Cancel() throws Exception {
+ public void testDeleteDocument_Cancel_ThenOK() throws Exception {
bots.directory.clickDocument("file1.png");
device.waitForIdle();
bots.main.clickToolbarItem(R.id.menu_delete);
@@ -119,5 +108,13 @@
bots.main.clickDialogCancelButton();
bots.directory.waitForDocument("file1.png");
+
+ device.waitForIdle();
+ bots.main.clickToolbarItem(R.id.menu_delete);
+
+ bots.main.clickDialogOkButton();
+ device.waitForIdle();
+
+ bots.directory.assertDocumentsAbsent("file1.png");
}
}
diff --git a/tests/src/com/android/documentsui/TestInputEvent.java b/tests/src/com/android/documentsui/TestInputEvent.java
index 36e7c1b..e6936d6 100644
--- a/tests/src/com/android/documentsui/TestInputEvent.java
+++ b/tests/src/com/android/documentsui/TestInputEvent.java
@@ -22,11 +22,6 @@
}
@Override
- public boolean isTouchEvent() {
- return !mouseEvent;
- }
-
- @Override
public boolean isMouseEvent() {
return mouseEvent;
}