Add more descriptive UI for conflicts while renaming.
Test: updated existing rename conflict test and ran all
Bug: 31647077
Change-Id: I013bb9348e4691aea42f41f58af83e18e8ca106d
diff --git a/src/com/android/documentsui/dirlist/Model.java b/src/com/android/documentsui/dirlist/Model.java
index 7a76098..9ba8b5c 100644
--- a/src/com/android/documentsui/dirlist/Model.java
+++ b/src/com/android/documentsui/dirlist/Model.java
@@ -45,8 +45,10 @@
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.function.Predicate;
/**
@@ -82,12 +84,14 @@
private static final String TAG = "Model";
+ /** Maps Model ID to cursor positions, for looking up items by Model ID. */
+ private final Map<String, Integer> mPositions = new HashMap<>();
+ private final Set<String> mFileNames = new HashSet<>();
+
private boolean mIsLoading;
private List<EventListener<Update>> mUpdateListeners = new ArrayList<>();
@Nullable private Cursor mCursor;
private int mCursorCount;
- /** Maps Model ID to cursor positions, for looking up items by Model ID. */
- private Map<String, Integer> mPositions = new HashMap<>();
private String mIds[] = new String[0];
@Nullable String info;
@@ -133,6 +137,7 @@
error = null;
doc = null;
mIsLoading = false;
+ mFileNames.clear();
notifyUpdateListeners();
}
@@ -174,7 +179,7 @@
*/
private void updateModelData() {
mIds = new String[mCursorCount];
-
+ mFileNames.clear();
mCursor.moveToPosition(-1);
for (int pos = 0; pos < mCursorCount; ++pos) {
if (!mCursor.moveToNext()) {
@@ -191,6 +196,7 @@
} else {
mIds[pos] = getCursorString(mCursor, Document.COLUMN_DOCUMENT_ID);
}
+ mFileNames.add(getCursorString(mCursor, Document.COLUMN_DISPLAY_NAME));
}
// Populate the positions.
@@ -200,6 +206,10 @@
}
}
+ public boolean hasFileWithName(String name) {
+ return mFileNames.contains(name);
+ }
+
public @Nullable Cursor getItem(String modelId) {
Integer pos = mPositions.get(modelId);
if (pos == null) {