Hint sorting, remove XML, follow refactor.
Jeff Sharkey [Mon, 9 Sep 2013 16:16:29 +0000 (09:16 -0700)]
Bug: 10672973, 10577809
Change-Id: I92314c35b37ac590830e881489e6a88afd860de4

AndroidManifest.xml
res/xml/document_provider.xml [deleted file]
src/com/android/providers/downloads/DownloadStorageProvider.java

index 49f039e..8e848d5 100644 (file)
@@ -87,7 +87,7 @@
             android:permission="android.permission.MANAGE_DOCUMENTS">
             <meta-data
                 android:name="android.content.DOCUMENT_PROVIDER"
-                android:resource="@xml/document_provider" />
+                android:value="true" />
         </provider>
 
         <service android:name=".DownloadService"
diff --git a/res/xml/document_provider.xml b/res/xml/document_provider.xml
deleted file mode 100644 (file)
index 77891cb..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<documents-provider xmlns:android="http://schemas.android.com/apk/res/android"
-    android:customRoots="true">
-</documents-provider>
index f1cd8fa..9315ea3 100644 (file)
@@ -83,12 +83,12 @@ public class DownloadStorageProvider extends DocumentsProvider {
     public Cursor queryRoots(String[] projection) throws FileNotFoundException {
         final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
         final RowBuilder row = result.newRow();
-        row.offer(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
-        row.offer(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SHORTCUT);
-        row.offer(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS);
-        row.offer(Root.COLUMN_ICON, R.mipmap.ic_launcher_download);
-        row.offer(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
-        row.offer(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
+        row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
+        row.add(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SHORTCUT);
+        row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS);
+        row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher_download);
+        row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
+        row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
         return result;
     }
 
@@ -198,8 +198,9 @@ public class DownloadStorageProvider extends DocumentsProvider {
 
     private void includeDefaultDocument(MatrixCursor result) {
         final RowBuilder row = result.newRow();
-        row.offer(Document.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
-        row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
+        row.add(Document.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
+        row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
+        row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_LAST_MODIFIED);
     }
 
     private void includeDownloadFromCursor(MatrixCursor result, Cursor cursor) {
@@ -257,12 +258,12 @@ public class DownloadStorageProvider extends DocumentsProvider {
                 cursor.getColumnIndexOrThrow(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP));
 
         final RowBuilder row = result.newRow();
-        row.offer(Document.COLUMN_DOCUMENT_ID, docId);
-        row.offer(Document.COLUMN_DISPLAY_NAME, displayName);
-        row.offer(Document.COLUMN_SUMMARY, summary);
-        row.offer(Document.COLUMN_SIZE, size);
-        row.offer(Document.COLUMN_MIME_TYPE, mimeType);
-        row.offer(Document.COLUMN_LAST_MODIFIED, lastModified);
-        row.offer(Document.COLUMN_FLAGS, flags);
+        row.add(Document.COLUMN_DOCUMENT_ID, docId);
+        row.add(Document.COLUMN_DISPLAY_NAME, displayName);
+        row.add(Document.COLUMN_SUMMARY, summary);
+        row.add(Document.COLUMN_SIZE, size);
+        row.add(Document.COLUMN_MIME_TYPE, mimeType);
+        row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
+        row.add(Document.COLUMN_FLAGS, flags);
     }
 }