diff options
author | Pin Ting <pinting@google.com> | 2012-02-07 18:11:25 +0800 |
---|---|---|
committer | Pin Ting <pinting@google.com> | 2012-02-08 01:07:41 +0800 |
commit | 1d33c69510326298c524593a8fb5d65b571013dc (patch) | |
tree | d4526a11cd0b4ed54b5601e20bfbb2bebd06565a /src/com/android | |
parent | ac7c72d8d8f7af477a74656603e0c27e01c25106 (diff) | |
download | android_packages_apps_Gallery2-1d33c69510326298c524593a8fb5d65b571013dc.tar.gz android_packages_apps_Gallery2-1d33c69510326298c524593a8fb5d65b571013dc.tar.bz2 android_packages_apps_Gallery2-1d33c69510326298c524593a8fb5d65b571013dc.zip |
Shows image filename read from OpenableColumns.
bug:5796182
Change-Id: If43d2dd048ab003c1703bb1a466a19b6013cae85
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/gallery3d/app/Gallery.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java index 7ab762812..06e904a0d 100644 --- a/src/com/android/gallery3d/app/Gallery.java +++ b/src/com/android/gallery3d/app/Gallery.java @@ -17,12 +17,15 @@ package com.android.gallery3d.app; import android.app.Dialog; +import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.Intent; +import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.provider.OpenableColumns; import android.view.Menu; import android.view.MenuItem; import android.view.Window; @@ -196,18 +199,32 @@ public final class Gallery extends AbstractGalleryActivity implements OnCancelLi Path albumPath = dm.getDefaultSetOf(itemPath); // TODO: Make this parameter public so other activities can reference it. boolean singleItemOnly = intent.getBooleanExtra("SingleItemOnly", false); - if (!singleItemOnly && albumPath != null) { - data.putString(PhotoPage.KEY_MEDIA_SET_PATH, - albumPath.toString()); + if (!singleItemOnly && (albumPath != null)) { + data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString()); } data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString()); - // Displays the filename as title, which is passed through intent from other apps. - // If other apps don't set this value, just display empty string. - // TODO: modify the javadoc of android.content.Intent.EXTRA_TITLE to include this - // usage - final String title = intent.getStringExtra(Intent.EXTRA_TITLE); - setTitle((title != null) ? title : ""); + // Displays the filename as title, reading the filename from the interface: + // {@link android.provider.OpenableColumns#DISPLAY_NAME}. + AsyncQueryHandler queryHandler = new AsyncQueryHandler(getContentResolver()) { + @Override + protected void onQueryComplete(int token, Object cookie, Cursor cursor) { + try { + if ((cursor != null) && cursor.moveToFirst()) { + String displayName = cursor.getString(0); + + // Just show empty title if other apps don't set DISPLAY_NAME + setTitle((displayName == null) ? "" : displayName); + } else { + Log.i(TAG, "The caller app doesn't set DISPLAY_NAME."); + } + } finally { + Utils.closeSilently(cursor); + } + } + }; + queryHandler.startQuery(0, null, uri, new String[] {OpenableColumns.DISPLAY_NAME}, + null, null, null); getStateManager().startState(PhotoPage.class, data); } |