diff options
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/xml/document_provider.xml | 19 | ||||
-rw-r--r-- | src/com/android/providers/downloads/DownloadStorageProvider.java | 31 |
3 files changed, 17 insertions, 35 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 49f039ef..8e848d50 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -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 index 77891cbc..00000000 --- a/res/xml/document_provider.xml +++ /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> diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index f1cd8fa9..9315ea32 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -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); } } |