From 37a04d300be36ecb0411632a88c45a0dac0dc770 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 May 2019 21:51:31 +0200 Subject: [PATCH] update the placeholder text appropriately if no media files are found --- app/build.gradle | 2 +- .../pro/activities/IncludedFoldersActivity.kt | 9 +------- .../gallery/pro/activities/MainActivity.kt | 23 +++++++++++++++---- .../gallery/pro/activities/SimpleActivity.kt | 13 +++++++++++ .../gallery/pro/helpers/Config.kt | 2 +- .../gallery/pro/helpers/Constants.kt | 1 + 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d403c672f..d48cf2074 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,7 +61,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.13.0' + implementation 'com.simplemobiletools:commons:5.13.1' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt index b6be4add2..f4e0258c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/IncludedFoldersActivity.kt @@ -3,9 +3,7 @@ package com.simplemobiletools.gallery.pro.activities import android.os.Bundle import android.view.Menu import android.view.MenuItem -import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.beVisibleIf -import com.simplemobiletools.commons.extensions.scanPathRecursively import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.adapters.ManageFoldersAdapter @@ -50,13 +48,8 @@ class IncludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun addFolder() { - FilePickerDialog(this, config.lastFilepickerPath, false, config.shouldShowHidden, false, true) { - config.lastFilepickerPath = it - config.addIncludedFolder(it) + showAddIncludedFolderDialog { updateFolders() - Thread { - scanPathRecursively(it) - }.start() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 2c7b24435..255ce9f8d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -117,10 +117,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { storeStateVariables() checkWhatsNewDialog() - directories_empty_text.setOnClickListener { - showFilterMediaDialog() - } - mIsPasswordProtectionPending = config.isAppPasswordProtectionOn setupLatestMediaId() @@ -1003,6 +999,25 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun checkPlaceholderVisibility(dirs: ArrayList) { directories_empty_text_label.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) directories_empty_text.beVisibleIf(dirs.isEmpty() && mLoadedInitialPhotos) + + if (dirs.isEmpty() && config.filterMedia == TYPE_DEFAULT_FILTER) { + directories_empty_text_label.text = getString(R.string.no_media_add_included) + directories_empty_text.text = getString(R.string.add_folder) + directories_empty_text.underlineText() + + directories_empty_text.setOnClickListener { + showAddIncludedFolderDialog { + refreshItems() + } + } + } else { + directories_empty_text_label.text = getString(R.string.no_media_with_filters) + directories_empty_text.text = getString(R.string.change_filters_underlined) + directories_empty_text.setOnClickListener { + showFilterMediaDialog() + } + } + directories_grid.beVisibleIf(directories_empty_text_label.isGone()) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt index 684fcd4dc..8b3505972 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SimpleActivity.kt @@ -6,8 +6,10 @@ import android.net.Uri import android.provider.MediaStore import android.view.WindowManager import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.getParentPath import com.simplemobiletools.commons.extensions.getRealPathFromURI +import com.simplemobiletools.commons.extensions.scanPathRecursively import com.simplemobiletools.commons.helpers.isPiePlus import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.addPathToDB @@ -79,4 +81,15 @@ open class SimpleActivity : BaseSimpleActivity() { } catch (ignored: Exception) { } } + + protected fun showAddIncludedFolderDialog(callback: () -> Unit) { + FilePickerDialog(this, config.lastFilepickerPath, false, config.shouldShowHidden, false, true) { + config.lastFilepickerPath = it + config.addIncludedFolder(it) + callback() + Thread { + scanPathRecursively(it) + }.start() + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 3f0c9839e..bd335ad6c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -203,7 +203,7 @@ class Config(context: Context) : BaseConfig(context) { set(blackBackground) = prefs.edit().putBoolean(BLACK_BACKGROUND, blackBackground).apply() var filterMedia: Int - get() = prefs.getInt(FILTER_MEDIA, TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS or TYPE_SVGS) + get() = prefs.getInt(FILTER_MEDIA, TYPE_DEFAULT_FILTER) set(filterMedia) = prefs.edit().putInt(FILTER_MEDIA, filterMedia).apply() var dirColumnCnt: Int diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index b9ba9581d..481d49080 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -154,6 +154,7 @@ const val TYPE_VIDEOS = 2 const val TYPE_GIFS = 4 const val TYPE_RAWS = 8 const val TYPE_SVGS = 16 +const val TYPE_DEFAULT_FILTER = TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS or TYPE_SVGS const val LOCATION_INTERNAL = 1 const val LOCATION_SD = 2