From c609072eafe4fa18bb72fc1f97abbd1f49fe04ab Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 10 Nov 2016 20:46:11 +0100 Subject: [PATCH] display a file name at the media activity --- .../gallery/activities/MediaActivity.java | 2 +- .../gallery/activities/PhotoVideoActivity.java | 2 +- .../gallery/activities/ViewPagerActivity.java | 2 +- .../simplemobiletools/gallery/models/Medium.java | 8 +++++++- .../gallery/adapters/MediaAdapter.kt | 3 +++ app/src/main/res/drawable/gradient_background.xml | 7 +++++++ app/src/main/res/layout/photo_video_item.xml | 13 +++++++++++++ 7 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/gradient_background.xml diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java index 9ac675736..0609030f6 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MediaActivity.java @@ -232,7 +232,7 @@ public class MediaActivity extends SimpleActivity if (file.exists()) { final int dateIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATE_MODIFIED); final long timestamp = cursor.getLong(dateIndex); - media.add(new Medium(curPath, (i == 1), timestamp, file.length())); + media.add(new Medium(file.getName(), curPath, (i == 1), timestamp, file.length())); } else { invalidFiles.add(file.getAbsolutePath()); } 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 8fe81eb78..105fbe87c 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/PhotoVideoActivity.java @@ -44,7 +44,7 @@ public class PhotoVideoActivity extends SimpleActivity implements ViewPagerFragm final Bundle bundle = new Bundle(); final File file = new File(mUri.toString()); - final Medium medium = new Medium(mUri.toString(), mIsVideo, 0, file.length()); + final Medium medium = new Medium(file.getName(), mUri.toString(), mIsVideo, 0, file.length()); bundle.putSerializable(Constants.MEDIUM, medium); if (savedInstanceState == null) { diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index 82edd1dc5..5789edea7 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -380,7 +380,7 @@ public class ViewPagerActivity extends SimpleActivity final int sizeIndex = cursor.getColumnIndex(MediaStore.Images.Media.SIZE); final long size = cursor.getLong(sizeIndex); - media.add(new Medium(curPath, i == 1, timestamp, size)); + media.add(new Medium("", curPath, i == 1, timestamp, size)); } } while (cursor.moveToNext()); cursor.close(); diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java index e9b4703db..4522efc2a 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Medium.java @@ -6,19 +6,25 @@ import java.io.Serializable; public class Medium implements Serializable, Comparable { private static final long serialVersionUID = -6543139465975455L; + private final String mName; private final boolean mIsVideo; private final long mTimestamp; private final long mSize; public static int mSorting; private String mPath; - public Medium(String path, boolean isVideo, long timestamp, long size) { + public Medium(String name, String path, boolean isVideo, long timestamp, long size) { + mName = name; mPath = path; mIsVideo = isVideo; mTimestamp = timestamp; mSize = size; } + public String getName() { + return mName; + } + public void setPath(String path) { mPath = path; } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 9029d0db2..19acb1d5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import android.widget.BaseAdapter import android.widget.ImageView +import android.widget.TextView import com.bumptech.glide.Glide import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.signature.StringSignature @@ -35,6 +36,7 @@ class MediaAdapter(private val mContext: Context, private val mMedia: MutableLis viewHolder.playOutline.visibility = if (medium.isVideo) View.VISIBLE else View.GONE + viewHolder.fileName.text = medium.name val path = medium.path val timestampSignature = StringSignature(medium.timestamp.toString()) if (medium.isGif) { @@ -68,5 +70,6 @@ class MediaAdapter(private val mContext: Context, private val mMedia: MutableLis internal class ViewHolder(view: View) { val photoThumbnail: ImageView = view.medium_thumbnail val playOutline: View = view.play_outline + val fileName: TextView = view.file_name } } diff --git a/app/src/main/res/drawable/gradient_background.xml b/app/src/main/res/drawable/gradient_background.xml new file mode 100644 index 000000000..6ccc99cfc --- /dev/null +++ b/app/src/main/res/drawable/gradient_background.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/layout/photo_video_item.xml b/app/src/main/res/layout/photo_video_item.xml index 07389a24b..a8e3f550c 100644 --- a/app/src/main/res/layout/photo_video_item.xml +++ b/app/src/main/res/layout/photo_video_item.xml @@ -16,4 +16,17 @@ android:src="@mipmap/play_outline" android:visibility="gone"/> + +