mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
allow setting a different grouping for Show All Folders Content
This commit is contained in:
parent
0f3daf9052
commit
61e66a3d5d
5 changed files with 15 additions and 13 deletions
|
@ -477,7 +477,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun showGroupByDialog() {
|
||||
ChangeGroupingDialog(this, mShowAll, mPath) {
|
||||
ChangeGroupingDialog(this, mPath) {
|
||||
mLoadedInitialPhotos = false
|
||||
media_grid.adapter = null
|
||||
getMedia()
|
||||
|
@ -644,7 +644,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
private fun calculateContentHeight(media: ArrayList<ThumbnailItem>) {
|
||||
val layoutManager = media_grid.layoutManager as MyGridLayoutManager
|
||||
val hasSections = config.getFolderGrouping(mPath) and GROUP_BY_NONE == 0 && !config.scrollHorizontally
|
||||
val pathToCheck = if (mPath.isEmpty()) SHOW_ALL else mPath
|
||||
val hasSections = config.getFolderGrouping(pathToCheck) and GROUP_BY_NONE == 0 && !config.scrollHorizontally
|
||||
val sectionTitleHeight = if (hasSections) layoutManager.getChildAt(0)?.height ?: 0 else 0
|
||||
val thumbnailHeight = if (hasSections) layoutManager.getChildAt(1)?.height ?: 0 else layoutManager.getChildAt(0)?.height
|
||||
?: 0
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
|
|||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.getFavoritePaths
|
||||
import com.simplemobiletools.gallery.helpers.MediaFetcher
|
||||
import com.simplemobiletools.gallery.helpers.SHOW_ALL
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import com.simplemobiletools.gallery.models.ThumbnailItem
|
||||
import java.util.*
|
||||
|
@ -31,7 +32,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
} else {
|
||||
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, favoritePaths)
|
||||
}
|
||||
return mediaFetcher.groupMedia(media, mPath)
|
||||
return mediaFetcher.groupMedia(media, if (showAll) SHOW_ALL else mPath)
|
||||
}
|
||||
|
||||
override fun onPostExecute(media: ArrayList<ThumbnailItem>) {
|
||||
|
|
|
@ -11,18 +11,17 @@ import com.simplemobiletools.gallery.extensions.config
|
|||
import com.simplemobiletools.gallery.helpers.*
|
||||
import kotlinx.android.synthetic.main.dialog_change_grouping.view.*
|
||||
|
||||
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val isShowingAll: Boolean, val path: String = "", val callback: () -> Unit) :
|
||||
class ChangeGroupingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) :
|
||||
DialogInterface.OnClickListener {
|
||||
private var currGrouping = 0
|
||||
private var config = activity.config
|
||||
private val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||
private var view: View
|
||||
|
||||
init {
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_grouping, null).apply {
|
||||
use_for_this_folder_divider.beVisibleIf(!isShowingAll)
|
||||
grouping_dialog_use_for_this_folder.beVisibleIf(!isShowingAll)
|
||||
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(path)
|
||||
grouping_dialog_radio_folder.beVisibleIf(isShowingAll)
|
||||
grouping_dialog_use_for_this_folder.isChecked = config.hasCustomGrouping(pathToUse)
|
||||
grouping_dialog_radio_folder.beVisibleIf(path.isEmpty())
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
|
@ -32,7 +31,7 @@ class ChangeGroupingDialog(val activity: BaseSimpleActivity, val isShowingAll: B
|
|||
activity.setupDialogStuff(view, this, R.string.group_by)
|
||||
}
|
||||
|
||||
currGrouping = config.getFolderGrouping(path)
|
||||
currGrouping = config.getFolderGrouping(pathToUse)
|
||||
setupGroupRadio()
|
||||
setupOrderRadio()
|
||||
}
|
||||
|
@ -77,9 +76,9 @@ class ChangeGroupingDialog(val activity: BaseSimpleActivity, val isShowingAll: B
|
|||
}
|
||||
|
||||
if (view.grouping_dialog_use_for_this_folder.isChecked) {
|
||||
config.saveFolderGrouping(path, grouping)
|
||||
config.saveFolderGrouping(pathToUse, grouping)
|
||||
} else {
|
||||
config.removeFolderGrouping(path)
|
||||
config.removeFolderGrouping(pathToUse)
|
||||
config.groupBy = grouping
|
||||
}
|
||||
callback()
|
||||
|
|
|
@ -46,7 +46,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
|
||||
fun getFolderGrouping(path: String): Int {
|
||||
var groupBy = prefs.getInt(GROUP_FOLDER_PREFIX + path.toLowerCase(), groupBy)
|
||||
if (path.isNotEmpty() && groupBy and GROUP_BY_FOLDER != 0) {
|
||||
if (path != SHOW_ALL && groupBy and GROUP_BY_FOLDER != 0) {
|
||||
groupBy -= GROUP_BY_FOLDER + 1
|
||||
}
|
||||
return groupBy
|
||||
|
|
|
@ -346,7 +346,8 @@ class MediaFetcher(val context: Context) {
|
|||
|
||||
fun groupMedia(media: ArrayList<Medium>, path: String): ArrayList<ThumbnailItem> {
|
||||
val mediumGroups = LinkedHashMap<String, ArrayList<Medium>>()
|
||||
val currentGrouping = context.config.getFolderGrouping(path)
|
||||
val pathToCheck = if (path.isEmpty()) SHOW_ALL else path
|
||||
val currentGrouping = context.config.getFolderGrouping(pathToCheck)
|
||||
if (currentGrouping and GROUP_BY_NONE != 0) {
|
||||
return media as ArrayList<ThumbnailItem>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue