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 8baa4fa20..ef6cae120 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -56,6 +56,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true private var mStoredScrollHorizontally = true + private var mStoredShowMediaCount = true private var mStoredTextColor = 0 private var mLoadedInitialPhotos = false private var mLatestMediaId = 0L @@ -80,10 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { removeTempFolder() directories_refresh_layout.setOnRefreshListener({ getDirectories() }) mDirs = ArrayList() - mStoredAnimateGifs = config.animateGifs - mStoredCropThumbnails = config.cropThumbnails - mStoredScrollHorizontally = config.scrollHorizontally - mStoredTextColor = config.textColor + storeStateVariables() checkWhatsNewDialog() directories_empty_text.setOnClickListener { @@ -134,6 +132,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { directories_grid.adapter?.notifyDataSetChanged() } + if (mStoredShowMediaCount != config.showMediaCount) { + (directories_grid.adapter as? DirectoryAdapter)?.apply { + showMediaCount = config.showMediaCount + notifyDataSetChanged() + } + } + if (mStoredScrollHorizontally != config.scrollHorizontally) { (directories_grid.adapter as? DirectoryAdapter)?.apply { scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally @@ -157,10 +162,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { storeDirectories() directories_refresh_layout.isRefreshing = false mIsGettingDirs = false - mStoredAnimateGifs = config.animateGifs - mStoredCropThumbnails = config.cropThumbnails - mStoredScrollHorizontally = config.scrollHorizontally - mStoredTextColor = config.textColor + storeStateVariables() directories_grid.listener = null mLastMediaHandler.removeCallbacksAndMessages(null) @@ -175,6 +177,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { removeTempFolder() } + private fun storeStateVariables() { + config.apply { + mStoredAnimateGifs = animateGifs + mStoredCropThumbnails = cropThumbnails + mStoredScrollHorizontally = scrollHorizontally + mStoredShowMediaCount = showMediaCount + mStoredTextColor = textColor + } + } + private fun removeTempFolder() { val newFolder = File(config.tempFolderPath) if (newFolder.exists() && newFolder.isDirectory) { @@ -188,10 +200,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun tryloadGallery() { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { - if (config.showAll) + if (config.showAll) { showAllMedia() - else + } else { getDirectories() + } setupLayoutManager() checkIfColorChanged() @@ -305,10 +318,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter) private fun setupLayoutManager() { - if (config.viewTypeFolders == VIEW_TYPE_GRID) + if (config.viewTypeFolders == VIEW_TYPE_GRID) { setupGridLayoutManager() - else + } else { setupListLayoutManager() + } } private fun setupGridLayoutManager() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index 8851b6bd3..7c0b7b60b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -49,6 +49,7 @@ class SettingsActivity : SimpleActivity() { setupPasswordProtection() setupDeleteEmptyFolders() setupAllowVideoGestures() + setupShowMediaCount() setupShowExtendedDetails() setupManageExtendedDetails() updateTextColors(settings_holder) @@ -198,6 +199,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupShowMediaCount() { + settings_show_media_count.isChecked = config.showMediaCount + settings_show_media_count_holder.setOnClickListener { + settings_show_media_count.toggle() + config.showMediaCount = settings_show_media_count.isChecked + } + } + private fun setupScreenRotation() { settings_screen_rotation.text = getScreenRotationText() settings_screen_rotation_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 54565ee11..8edb4c9b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -30,17 +30,18 @@ import java.util.* class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> Unit) : RecyclerView.Adapter() { - val multiSelector = MultiSelector() val config = activity.config - val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST - var actMode: ActionMode? = null - var itemViews = SparseArray() - val selectedPositions = HashSet() var primaryColor = config.primaryColor - var textColor = config.textColor - var pinnedFolders = config.pinnedFolders var scrollVertically = !config.scrollHorizontally + var showMediaCount = config.showMediaCount + + private val multiSelector = MultiSelector() + private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST + private var itemViews = SparseArray() + private val selectedPositions = HashSet() + private var textColor = config.textColor + private var pinnedFolders = config.pinnedFolders fun toggleItemSelection(select: Boolean, pos: Int) { if (select) { @@ -350,7 +351,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, isListView: Boolean, textColor: Int): View { + fun bindView(directory: Directory, isPinned: Boolean, scrollVertically: Boolean, isListView: Boolean, textColor: Int, showMediaCount: Boolean): View { itemView.apply { dir_name.text = directory.name dir_path?.text = "${directory.path.substringBeforeLast("/")}/" @@ -423,6 +424,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList + + + + + +