From da2db7991359126e85d6f202d3905e91178fcfa2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 5 Dec 2017 23:45:09 +0100 Subject: [PATCH] show an info bubble at fastscroller dragging --- app/build.gradle | 2 +- .../gallery/activities/MainActivity.kt | 4 +++- .../gallery/activities/MediaActivity.kt | 4 +++- .../gallery/fragments/ViewPagerFragment.kt | 2 +- .../com/simplemobiletools/gallery/models/Directory.kt | 9 +++++++++ .../com/simplemobiletools/gallery/models/Medium.kt | 11 ++++++++--- 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5148e061c..d54939b3c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -43,7 +43,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.1.3' + implementation 'com.simplemobiletools:commons:3.1.4' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0' implementation 'com.android.support:multidex:1.0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 44f01058e..aca94dfc4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -583,7 +583,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { if (allowHorizontalScroll) { directories_horizontal_fastscroller.setViews(directories_grid, directories_refresh_layout) } else { - directories_vertical_fastscroller.setViews(directories_grid, directories_refresh_layout) + directories_vertical_fastscroller.setViews(directories_grid, directories_refresh_layout) { + directories_vertical_fastscroller.updateBubbleText(mDirs[it].getBubbleText()) + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 25e32a347..4f231fd42 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -203,7 +203,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { if (allowHorizontalScroll) { media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) } else { - media_vertical_fastscroller.setViews(media_grid, media_refresh_layout) + media_vertical_fastscroller.setViews(media_grid, media_refresh_layout) { + media_vertical_fastscroller.updateBubbleText(mMedia[it].getBubbleText()) + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt index 7ccb83d45..d4ddfa698 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt @@ -45,7 +45,7 @@ abstract class ViewPagerFragment : Fragment() { } if (detailsFlag and EXT_LAST_MODIFIED != 0) { - file.lastModified().formatLastModified().let { if (it.isNotEmpty()) details.appendln(it) } + file.lastModified().formatDate().let { if (it.isNotEmpty()) details.appendln(it) } } if (detailsFlag and EXT_DATE_TAKEN != 0) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index d03b4d1be..e545ff080 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -1,5 +1,7 @@ package com.simplemobiletools.gallery.models +import com.simplemobiletools.commons.extensions.formatDate +import com.simplemobiletools.commons.extensions.formatSize import com.simplemobiletools.commons.helpers.* import java.io.Serializable @@ -37,4 +39,11 @@ data class Directory(val path: String, val tmb: String, val name: String, var me } return result } + + fun getBubbleText() = when { + sorting and SORT_BY_SIZE != 0 -> size.formatSize() + sorting and SORT_BY_DATE_MODIFIED != 0 -> modified.formatDate() + sorting and SORT_BY_DATE_TAKEN != 0 -> taken.formatDate() + else -> name + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index bf15cd20c..638dc3f9b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -1,8 +1,6 @@ package com.simplemobiletools.gallery.models -import com.simplemobiletools.commons.extensions.getMimeTypeFromPath -import com.simplemobiletools.commons.extensions.isGif -import com.simplemobiletools.commons.extensions.isPng +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* import java.io.Serializable @@ -48,4 +46,11 @@ data class Medium(var name: String, var path: String, val video: Boolean, val mo } return result } + + fun getBubbleText() = when { + sorting and SORT_BY_SIZE != 0 -> size.formatSize() + sorting and SORT_BY_DATE_MODIFIED != 0 -> modified.formatDate() + sorting and SORT_BY_DATE_TAKEN != 0 -> taken.formatDate() + else -> name + } }