mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
implement the Show Media Count toggle functionality
This commit is contained in:
parent
2a2b77fc6b
commit
5cd3fdf57f
6 changed files with 71 additions and 21 deletions
|
@ -56,6 +56,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private var mStoredAnimateGifs = true
|
private var mStoredAnimateGifs = true
|
||||||
private var mStoredCropThumbnails = true
|
private var mStoredCropThumbnails = true
|
||||||
private var mStoredScrollHorizontally = true
|
private var mStoredScrollHorizontally = true
|
||||||
|
private var mStoredShowMediaCount = true
|
||||||
private var mStoredTextColor = 0
|
private var mStoredTextColor = 0
|
||||||
private var mLoadedInitialPhotos = false
|
private var mLoadedInitialPhotos = false
|
||||||
private var mLatestMediaId = 0L
|
private var mLatestMediaId = 0L
|
||||||
|
@ -80,10 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
removeTempFolder()
|
removeTempFolder()
|
||||||
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
|
directories_refresh_layout.setOnRefreshListener({ getDirectories() })
|
||||||
mDirs = ArrayList()
|
mDirs = ArrayList()
|
||||||
mStoredAnimateGifs = config.animateGifs
|
storeStateVariables()
|
||||||
mStoredCropThumbnails = config.cropThumbnails
|
|
||||||
mStoredScrollHorizontally = config.scrollHorizontally
|
|
||||||
mStoredTextColor = config.textColor
|
|
||||||
checkWhatsNewDialog()
|
checkWhatsNewDialog()
|
||||||
|
|
||||||
directories_empty_text.setOnClickListener {
|
directories_empty_text.setOnClickListener {
|
||||||
|
@ -134,6 +132,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
directories_grid.adapter?.notifyDataSetChanged()
|
directories_grid.adapter?.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mStoredShowMediaCount != config.showMediaCount) {
|
||||||
|
(directories_grid.adapter as? DirectoryAdapter)?.apply {
|
||||||
|
showMediaCount = config.showMediaCount
|
||||||
|
notifyDataSetChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
if (mStoredScrollHorizontally != config.scrollHorizontally) {
|
||||||
(directories_grid.adapter as? DirectoryAdapter)?.apply {
|
(directories_grid.adapter as? DirectoryAdapter)?.apply {
|
||||||
scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally
|
scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally
|
||||||
|
@ -157,10 +162,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
storeDirectories()
|
storeDirectories()
|
||||||
directories_refresh_layout.isRefreshing = false
|
directories_refresh_layout.isRefreshing = false
|
||||||
mIsGettingDirs = false
|
mIsGettingDirs = false
|
||||||
mStoredAnimateGifs = config.animateGifs
|
storeStateVariables()
|
||||||
mStoredCropThumbnails = config.cropThumbnails
|
|
||||||
mStoredScrollHorizontally = config.scrollHorizontally
|
|
||||||
mStoredTextColor = config.textColor
|
|
||||||
directories_grid.listener = null
|
directories_grid.listener = null
|
||||||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||||
|
|
||||||
|
@ -175,6 +177,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
removeTempFolder()
|
removeTempFolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun storeStateVariables() {
|
||||||
|
config.apply {
|
||||||
|
mStoredAnimateGifs = animateGifs
|
||||||
|
mStoredCropThumbnails = cropThumbnails
|
||||||
|
mStoredScrollHorizontally = scrollHorizontally
|
||||||
|
mStoredShowMediaCount = showMediaCount
|
||||||
|
mStoredTextColor = textColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun removeTempFolder() {
|
private fun removeTempFolder() {
|
||||||
val newFolder = File(config.tempFolderPath)
|
val newFolder = File(config.tempFolderPath)
|
||||||
if (newFolder.exists() && newFolder.isDirectory) {
|
if (newFolder.exists() && newFolder.isDirectory) {
|
||||||
|
@ -188,10 +200,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun tryloadGallery() {
|
private fun tryloadGallery() {
|
||||||
handlePermission(PERMISSION_WRITE_STORAGE) {
|
handlePermission(PERMISSION_WRITE_STORAGE) {
|
||||||
if (it) {
|
if (it) {
|
||||||
if (config.showAll)
|
if (config.showAll) {
|
||||||
showAllMedia()
|
showAllMedia()
|
||||||
else
|
} else {
|
||||||
getDirectories()
|
getDirectories()
|
||||||
|
}
|
||||||
|
|
||||||
setupLayoutManager()
|
setupLayoutManager()
|
||||||
checkIfColorChanged()
|
checkIfColorChanged()
|
||||||
|
@ -305,10 +318,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter)
|
private fun getRecyclerAdapter() = (directories_grid.adapter as DirectoryAdapter)
|
||||||
|
|
||||||
private fun setupLayoutManager() {
|
private fun setupLayoutManager() {
|
||||||
if (config.viewTypeFolders == VIEW_TYPE_GRID)
|
if (config.viewTypeFolders == VIEW_TYPE_GRID) {
|
||||||
setupGridLayoutManager()
|
setupGridLayoutManager()
|
||||||
else
|
} else {
|
||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
|
|
|
@ -49,6 +49,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
setupPasswordProtection()
|
setupPasswordProtection()
|
||||||
setupDeleteEmptyFolders()
|
setupDeleteEmptyFolders()
|
||||||
setupAllowVideoGestures()
|
setupAllowVideoGestures()
|
||||||
|
setupShowMediaCount()
|
||||||
setupShowExtendedDetails()
|
setupShowExtendedDetails()
|
||||||
setupManageExtendedDetails()
|
setupManageExtendedDetails()
|
||||||
updateTextColors(settings_holder)
|
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() {
|
private fun setupScreenRotation() {
|
||||||
settings_screen_rotation.text = getScreenRotationText()
|
settings_screen_rotation.text = getScreenRotationText()
|
||||||
settings_screen_rotation_holder.setOnClickListener {
|
settings_screen_rotation_holder.setOnClickListener {
|
||||||
|
|
|
@ -30,17 +30,18 @@ import java.util.*
|
||||||
class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, val isPickIntent: Boolean,
|
class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Directory>, val listener: DirOperationsListener?, val isPickIntent: Boolean,
|
||||||
val itemClick: (Directory) -> Unit) : RecyclerView.Adapter<DirectoryAdapter.ViewHolder>() {
|
val itemClick: (Directory) -> Unit) : RecyclerView.Adapter<DirectoryAdapter.ViewHolder>() {
|
||||||
|
|
||||||
val multiSelector = MultiSelector()
|
|
||||||
val config = activity.config
|
val config = activity.config
|
||||||
val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
|
||||||
|
|
||||||
var actMode: ActionMode? = null
|
var actMode: ActionMode? = null
|
||||||
var itemViews = SparseArray<View>()
|
|
||||||
val selectedPositions = HashSet<Int>()
|
|
||||||
var primaryColor = config.primaryColor
|
var primaryColor = config.primaryColor
|
||||||
var textColor = config.textColor
|
|
||||||
var pinnedFolders = config.pinnedFolders
|
|
||||||
var scrollVertically = !config.scrollHorizontally
|
var scrollVertically = !config.scrollHorizontally
|
||||||
|
var showMediaCount = config.showMediaCount
|
||||||
|
|
||||||
|
private val multiSelector = MultiSelector()
|
||||||
|
private val isListViewType = config.viewTypeFolders == VIEW_TYPE_LIST
|
||||||
|
private var itemViews = SparseArray<View>()
|
||||||
|
private val selectedPositions = HashSet<Int>()
|
||||||
|
private var textColor = config.textColor
|
||||||
|
private var pinnedFolders = config.pinnedFolders
|
||||||
|
|
||||||
fun toggleItemSelection(select: Boolean, pos: Int) {
|
fun toggleItemSelection(select: Boolean, pos: Int) {
|
||||||
if (select) {
|
if (select) {
|
||||||
|
@ -350,7 +351,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val dir = dirs[position]
|
val dir = dirs[position]
|
||||||
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically, isListViewType, textColor))
|
itemViews.put(position, holder.bindView(dir, pinnedFolders.contains(dir.path), scrollVertically, isListViewType, textColor, showMediaCount))
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
holder.itemView.tag = holder
|
holder.itemView.tag = holder
|
||||||
}
|
}
|
||||||
|
@ -415,7 +416,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
class ViewHolder(val view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
|
||||||
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
val multiSelector: MultiSelector, val listener: DirOperationsListener?, val isPickIntent: Boolean, val itemClick: (Directory) -> (Unit)) :
|
||||||
SwappingHolder(view, MultiSelector()) {
|
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 {
|
itemView.apply {
|
||||||
dir_name.text = directory.name
|
dir_name.text = directory.name
|
||||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||||
|
@ -423,6 +424,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
activity.loadImage(directory.tmb, dir_thumbnail, scrollVertically)
|
activity.loadImage(directory.tmb, dir_thumbnail, scrollVertically)
|
||||||
dir_pin.beVisibleIf(isPinned)
|
dir_pin.beVisibleIf(isPinned)
|
||||||
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
dir_sd_card.beVisibleIf(activity.isPathOnSD(directory.path))
|
||||||
|
photo_cnt.beVisibleIf(showMediaCount)
|
||||||
|
|
||||||
if (isListView) {
|
if (isListView) {
|
||||||
dir_name.setTextColor(textColor)
|
dir_name.setTextColor(textColor)
|
||||||
|
|
|
@ -245,6 +245,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
get() = prefs.getBoolean(ALLOW_VIDEO_GESTURES, true)
|
get() = prefs.getBoolean(ALLOW_VIDEO_GESTURES, true)
|
||||||
set(allowVideoGestures) = prefs.edit().putBoolean(ALLOW_VIDEO_GESTURES, allowVideoGestures).apply()
|
set(allowVideoGestures) = prefs.edit().putBoolean(ALLOW_VIDEO_GESTURES, allowVideoGestures).apply()
|
||||||
|
|
||||||
|
var showMediaCount: Boolean
|
||||||
|
get() = prefs.getBoolean(SHOW_MEDIA_COUNT, true)
|
||||||
|
set(showMediaCount) = prefs.edit().putBoolean(SHOW_MEDIA_COUNT, showMediaCount).apply()
|
||||||
|
|
||||||
var slideshowInterval: Int
|
var slideshowInterval: Int
|
||||||
get() = prefs.getInt(SLIDESHOW_INTERVAL, SLIDESHOW_DEFAULT_INTERVAL)
|
get() = prefs.getInt(SLIDESHOW_INTERVAL, SLIDESHOW_DEFAULT_INTERVAL)
|
||||||
set(slideshowInterval) = prefs.edit().putInt(SLIDESHOW_INTERVAL, slideshowInterval).apply()
|
set(slideshowInterval) = prefs.edit().putInt(SLIDESHOW_INTERVAL, slideshowInterval).apply()
|
||||||
|
|
|
@ -36,6 +36,7 @@ val HIDE_SYSTEM_UI = "hide_system_ui"
|
||||||
val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
|
val REPLACE_SHARE_WITH_ROTATE = "replace_share_with_rotate"
|
||||||
val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
|
val DELETE_EMPTY_FOLDERS = "delete_empty_folders"
|
||||||
val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
|
val ALLOW_VIDEO_GESTURES = "allow_video_gestures"
|
||||||
|
val SHOW_MEDIA_COUNT = "show_media_count"
|
||||||
val TEMP_FOLDER_PATH = "temp_folder_path"
|
val TEMP_FOLDER_PATH = "temp_folder_path"
|
||||||
val VIEW_TYPE_FOLDERS = "view_type_folders"
|
val VIEW_TYPE_FOLDERS = "view_type_folders"
|
||||||
val VIEW_TYPE_FILES = "view_type_files"
|
val VIEW_TYPE_FILES = "view_type_files"
|
||||||
|
|
|
@ -328,6 +328,26 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_show_media_count_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||||
|
android:id="@+id/settings_show_media_count"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"
|
||||||
|
android:paddingLeft="@dimen/medium_margin"
|
||||||
|
android:paddingStart="@dimen/medium_margin"
|
||||||
|
android:text="@string/show_media_count"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_show_extended_details_holder"
|
android:id="@+id/settings_show_extended_details_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue