diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-09-09 09:16:52 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-09-09 17:53:01 -0700 |
commit | 82c4ab2390570a461e297a4e319b5358d55f757b (patch) | |
tree | 330f724e499ce56ce6917aa97c6c28a07f252ae3 | |
parent | cf88e9a9b8df520c53f7192df0aa0661a1058a26 (diff) | |
download | MediaProvider-82c4ab2390570a461e297a4e319b5358d55f757b.tar.gz |
Remove XML, follow refactor.
Bug: 10577809
Change-Id: Ie09bce123f678d112005347ea265338c20783e52
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/xml/document_provider.xml | 19 | ||||
-rw-r--r-- | src/com/android/providers/media/MediaDocumentsProvider.java | 86 |
3 files changed, 44 insertions, 63 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c0d6ef41e..9d0d4480b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -33,7 +33,7 @@ android:permission="android.permission.MANAGE_DOCUMENTS"> <meta-data android:name="android.content.DOCUMENT_PROVIDER" - android:resource="@xml/document_provider" /> + android:value="true" /> </provider> <!-- Handles database upgrades after OTAs, then disables itself --> diff --git a/res/xml/document_provider.xml b/res/xml/document_provider.xml deleted file mode 100644 index 77891cbcc..000000000 --- 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/media/MediaDocumentsProvider.java b/src/com/android/providers/media/MediaDocumentsProvider.java index a377ffa04..511c9089f 100644 --- a/src/com/android/providers/media/MediaDocumentsProvider.java +++ b/src/com/android/providers/media/MediaDocumentsProvider.java @@ -344,39 +344,39 @@ public class MediaDocumentsProvider extends DocumentsProvider { private void includeImagesRoot(MatrixCursor result) { final RowBuilder row = result.newRow(); - row.offer(Root.COLUMN_ROOT_ID, TYPE_IMAGE); - 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_gallery); - row.offer(Root.COLUMN_TITLE, getContext().getString(R.string.root_images)); - row.offer(Root.COLUMN_DOCUMENT_ID, TYPE_IMAGE); - row.offer(Root.COLUMN_MIME_TYPES, IMAGE_MIME_TYPES); + row.add(Root.COLUMN_ROOT_ID, TYPE_IMAGE); + 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_gallery); + row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_images)); + row.add(Root.COLUMN_DOCUMENT_ID, TYPE_IMAGE); + row.add(Root.COLUMN_MIME_TYPES, IMAGE_MIME_TYPES); } private void includeAudioRoot(MatrixCursor result) { final RowBuilder row = result.newRow(); - row.offer(Root.COLUMN_ROOT_ID, TYPE_AUDIO); - row.offer(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SHORTCUT); - row.offer(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY); - row.offer(Root.COLUMN_ICON, R.drawable.ic_search_category_music_song); - row.offer(Root.COLUMN_TITLE, getContext().getString(R.string.root_audio)); - row.offer(Root.COLUMN_DOCUMENT_ID, TYPE_AUDIO); - row.offer(Root.COLUMN_MIME_TYPES, AUDIO_MIME_TYPES); + row.add(Root.COLUMN_ROOT_ID, TYPE_AUDIO); + row.add(Root.COLUMN_ROOT_TYPE, Root.ROOT_TYPE_SHORTCUT); + row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY); + row.add(Root.COLUMN_ICON, R.drawable.ic_search_category_music_song); + row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_audio)); + row.add(Root.COLUMN_DOCUMENT_ID, TYPE_AUDIO); + row.add(Root.COLUMN_MIME_TYPES, AUDIO_MIME_TYPES); } private void includeImages(MatrixCursor result) { final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, TYPE_IMAGE); - row.offer(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_images)); - row.offer(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID); - row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_DOCUMENT_ID, TYPE_IMAGE); + row.add(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_images)); + row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID); + row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); } private void includeAudio(MatrixCursor result) { final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, TYPE_AUDIO); - row.offer(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_audio)); - row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_DOCUMENT_ID, TYPE_AUDIO); + row.add(Document.COLUMN_DISPLAY_NAME, getContext().getString(R.string.root_audio)); + row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); } private interface BucketQuery { @@ -395,12 +395,12 @@ public class MediaDocumentsProvider extends DocumentsProvider { final String docId = getDocIdForIdent(TYPE_BUCKET, id); final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, docId); - row.offer(Document.COLUMN_DISPLAY_NAME, cursor.getString(BucketQuery.BUCKET_DISPLAY_NAME)); - row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); - row.offer(Document.COLUMN_LAST_MODIFIED, + row.add(Document.COLUMN_DOCUMENT_ID, docId); + row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(BucketQuery.BUCKET_DISPLAY_NAME)); + row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(BucketQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS); - row.offer(Document.COLUMN_FLAGS, + row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_GRID | Document.FLAG_SUPPORTS_THUMBNAIL); } @@ -424,13 +424,13 @@ public class MediaDocumentsProvider extends DocumentsProvider { final String docId = getDocIdForIdent(TYPE_IMAGE, id); final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, docId); - row.offer(Document.COLUMN_DISPLAY_NAME, cursor.getString(ImageQuery.DISPLAY_NAME)); - row.offer(Document.COLUMN_SIZE, cursor.getLong(ImageQuery.SIZE)); - row.offer(Document.COLUMN_MIME_TYPE, cursor.getString(ImageQuery.MIME_TYPE)); - row.offer(Document.COLUMN_LAST_MODIFIED, + row.add(Document.COLUMN_DOCUMENT_ID, docId); + row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(ImageQuery.DISPLAY_NAME)); + row.add(Document.COLUMN_SIZE, cursor.getLong(ImageQuery.SIZE)); + row.add(Document.COLUMN_MIME_TYPE, cursor.getString(ImageQuery.MIME_TYPE)); + row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(ImageQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS); - row.offer(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL); + row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_THUMBNAIL); } private interface ArtistQuery { @@ -447,9 +447,9 @@ public class MediaDocumentsProvider extends DocumentsProvider { final String docId = getDocIdForIdent(TYPE_ARTIST, id); final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, docId); - row.offer(Document.COLUMN_DISPLAY_NAME, cursor.getString(ArtistQuery.ARTIST)); - row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_DOCUMENT_ID, docId); + row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(ArtistQuery.ARTIST)); + row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); } private interface AlbumQuery { @@ -466,9 +466,9 @@ public class MediaDocumentsProvider extends DocumentsProvider { final String docId = getDocIdForIdent(TYPE_ALBUM, id); final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, docId); - row.offer(Document.COLUMN_DISPLAY_NAME, cursor.getString(AlbumQuery.ALBUM)); - row.offer(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_DOCUMENT_ID, docId); + row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(AlbumQuery.ALBUM)); + row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); } private interface SongQuery { @@ -491,11 +491,11 @@ public class MediaDocumentsProvider extends DocumentsProvider { final String docId = getDocIdForIdent(TYPE_AUDIO, id); final RowBuilder row = result.newRow(); - row.offer(Document.COLUMN_DOCUMENT_ID, docId); - row.offer(Document.COLUMN_DISPLAY_NAME, cursor.getString(SongQuery.TITLE)); - row.offer(Document.COLUMN_SIZE, cursor.getLong(SongQuery.SIZE)); - row.offer(Document.COLUMN_MIME_TYPE, cursor.getString(SongQuery.MIME_TYPE)); - row.offer(Document.COLUMN_LAST_MODIFIED, + row.add(Document.COLUMN_DOCUMENT_ID, docId); + row.add(Document.COLUMN_DISPLAY_NAME, cursor.getString(SongQuery.TITLE)); + row.add(Document.COLUMN_SIZE, cursor.getLong(SongQuery.SIZE)); + row.add(Document.COLUMN_MIME_TYPE, cursor.getString(SongQuery.MIME_TYPE)); + row.add(Document.COLUMN_LAST_MODIFIED, cursor.getLong(SongQuery.DATE_MODIFIED) * DateUtils.SECOND_IN_MILLIS); } |