summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app/MovieActivity.java
diff options
context:
space:
mode:
authorPin Ting <pinting@google.com>2012-02-11 02:53:53 +0800
committerPin Ting <pinting@google.com>2012-02-11 03:36:46 +0800
commit72a973bffbeaf9e9d6ef9bccf1f34e60c6d6b735 (patch)
tree794339e6873d644c3bb80f2a44dac18c65a46237 /src/com/android/gallery3d/app/MovieActivity.java
parentab6b92971e8c498abc53cfdaddc0b32f1447b9fc (diff)
downloadandroid_packages_apps_Snap-72a973bffbeaf9e9d6ef9bccf1f34e60c6d6b735.tar.gz
android_packages_apps_Snap-72a973bffbeaf9e9d6ef9bccf1f34e60c6d6b735.tar.bz2
android_packages_apps_Snap-72a973bffbeaf9e9d6ef9bccf1f34e60c6d6b735.zip
Shows video filename read from OpenableColumns.
bug:5796182 Change-Id: I92bc652d713bcc70b5a048f5948dc17e90a5e874
Diffstat (limited to 'src/com/android/gallery3d/app/MovieActivity.java')
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index ed85582c0..9ad63dbe6 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.app;
import android.app.ActionBar;
import android.app.Activity;
+import android.content.AsyncQueryHandler;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
@@ -25,7 +26,7 @@ import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
+import android.provider.OpenableColumns;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -35,6 +36,7 @@ import android.view.WindowManager;
import android.widget.ShareActionProvider;
import com.android.gallery3d.R;
+import com.android.gallery3d.common.Utils;
/**
* This activity plays a video from a specified URI.
@@ -86,14 +88,39 @@ public class MovieActivity extends Activity {
private void initializeActionBar(Intent intent) {
mUri = intent.getData();
- ActionBar actionBar = getActionBar();
+ final ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP,
ActionBar.DISPLAY_HOME_AS_UP);
- // 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.
- final String title = intent.getStringExtra(Intent.EXTRA_TITLE);
- actionBar.setTitle((title != null) ? title : "");
+ String title = intent.getStringExtra(Intent.EXTRA_TITLE);
+ if (title != null) {
+ actionBar.setTitle(title);
+ } else {
+ // 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
+ actionBar.setTitle((displayName == null) ? "" :
+ displayName);
+ }
+ } finally {
+ Utils.closeSilently(cursor);
+ }
+ }
+ };
+ queryHandler.startQuery(0, null, mUri,
+ new String[] {OpenableColumns.DISPLAY_NAME}, null, null,
+ null);
+ }
}
@Override