From a31533418d18b46cb4a71b5f7e4e1a405a537ab5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 6 Nov 2016 21:42:23 +0100 Subject: [PATCH] fix #45, display proper filename when opening an item from Downloads folder --- .../gallery/activities/PhotoVideoActivity.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java index 4e7d587be..8fe81eb78 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java @@ -2,8 +2,10 @@ package com.simplemobiletools.gallery.activities; import android.content.Intent; import android.content.res.Configuration; +import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.provider.MediaStore; import android.support.v7.app.ActionBar; import android.view.Menu; import android.view.MenuItem; @@ -52,7 +54,21 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, mFragment).commit(); } hideSystemUI(); - setTitle(Utils.Companion.getFilename(mUri.toString())); + + if (mUri.getScheme().equals("content")) { + String[] proj = { MediaStore.Images.Media.TITLE }; + Cursor cursor = getContentResolver().query(mUri, proj, null, null, null); + if (cursor != null && cursor.getCount() != 0) { + int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE); + cursor.moveToFirst(); + setTitle(cursor.getString(columnIndex)); + } + if (cursor != null) { + cursor.close(); + } + } else { + setTitle(Utils.Companion.getFilename(mUri.toString())); + } } @Override