mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
move folder sorting handling in Commons
This commit is contained in:
parent
3e401bb3af
commit
44e07edb81
12 changed files with 17 additions and 34 deletions
|
@ -78,7 +78,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.23.11'
|
||||
implementation 'com.simplemobiletools:commons:5.23.13'
|
||||
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'
|
||||
|
|
|
@ -901,7 +901,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val sorting = config.getFileSorting(directory.path)
|
||||
val sorting = config.getFolderSorting(directory.path)
|
||||
val grouping = config.getFolderGrouping(directory.path)
|
||||
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
sorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
|
@ -987,7 +987,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val sorting = config.getFileSorting(folder)
|
||||
val sorting = config.getFolderSorting(folder)
|
||||
val grouping = config.getFolderGrouping(folder)
|
||||
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
sorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
|
|
|
@ -159,7 +159,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
media_empty_text_label.setTextColor(config.textColor)
|
||||
media_empty_text.setTextColor(getAdjustedPrimaryColor())
|
||||
|
||||
if (mMedia.isEmpty() || config.getFileSorting(mPath) and SORT_BY_RANDOM == 0) {
|
||||
if (mMedia.isEmpty() || config.getFolderSorting(mPath) and SORT_BY_RANDOM == 0) {
|
||||
tryLoadGallery()
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
media_horizontal_fastscroller.isHorizontal = true
|
||||
media_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll)
|
||||
|
||||
val sorting = config.getFileSorting(if (mShowAll) SHOW_ALL else mPath)
|
||||
val sorting = config.getFolderSorting(if (mShowAll) SHOW_ALL else mPath)
|
||||
if (allowHorizontalScroll) {
|
||||
media_horizontal_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
media_horizontal_fastscroller.setViews(media_grid, media_refresh_layout) {
|
||||
|
@ -437,7 +437,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun checkLastMediaChanged() {
|
||||
if (isDestroyed || config.getFileSorting(mPath) and SORT_BY_RANDOM != 0) {
|
||||
if (isDestroyed || config.getFolderSorting(mPath) and SORT_BY_RANDOM != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
media_horizontal_fastscroller.isHorizontal = true
|
||||
media_horizontal_fastscroller.beVisibleIf(allowHorizontalScroll)
|
||||
|
||||
val sorting = config.getFileSorting(SHOW_ALL)
|
||||
val sorting = config.getFolderSorting(SHOW_ALL)
|
||||
if (allowHorizontalScroll) {
|
||||
media_horizontal_fastscroller.allowBubbleDisplay = config.showInfoBubble
|
||||
media_horizontal_fastscroller.setViews(media_grid) {
|
||||
|
|
|
@ -1095,7 +1095,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
|
||||
private fun refreshViewPager() {
|
||||
if (config.getFileSorting(mDirectory) and SORT_BY_RANDOM == 0) {
|
||||
if (config.getFolderSorting(mDirectory) and SORT_BY_RANDOM == 0) {
|
||||
GetMediaAsynctask(applicationContext, mDirectory, false, false, mShowAll) {
|
||||
gotMedia(it)
|
||||
}.execute()
|
||||
|
|
|
@ -20,7 +20,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
||||
val pathToUse = if (showAll) SHOW_ALL else mPath
|
||||
val folderGrouping = context.config.getFolderGrouping(pathToUse)
|
||||
val fileSorting = context.config.getFileSorting(pathToUse)
|
||||
val fileSorting = context.config.getFolderSorting(pathToUse)
|
||||
val getProperDateTaken = fileSorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 ||
|
||||
folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0
|
||||
|
@ -40,7 +40,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
media.addAll(newMedia)
|
||||
}
|
||||
|
||||
mediaFetcher.sortMedia(media, context.config.getFileSorting(SHOW_ALL))
|
||||
mediaFetcher.sortMedia(media, context.config.getFolderSorting(SHOW_ALL))
|
||||
media
|
||||
} else {
|
||||
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, getVideoDurations)
|
||||
|
|
|
@ -22,7 +22,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
private var view: View
|
||||
|
||||
init {
|
||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFileSorting(pathToUse)
|
||||
currSorting = if (isDirectorySorting) config.directorySorting else config.getFolderSorting(pathToUse)
|
||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
||||
use_for_this_folder_divider.beVisibleIf(showFolderCheckbox || (currSorting and SORT_BY_NAME != 0 || currSorting and SORT_BY_PATH != 0))
|
||||
|
||||
|
@ -97,9 +97,9 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val isDirectorySorti
|
|||
config.directorySorting = sorting
|
||||
} else {
|
||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
||||
config.saveFileSorting(pathToUse, sorting)
|
||||
config.saveCustomSorting(pathToUse, sorting)
|
||||
} else {
|
||||
config.removeFileSorting(pathToUse)
|
||||
config.removeCustomSorting(pathToUse)
|
||||
config.sorting = sorting
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||
}
|
||||
|
||||
val scrollHorizontally = activity.config.scrollHorizontally && isGridViewType
|
||||
val sorting = activity.config.getFileSorting(if (path.isEmpty()) SHOW_ALL else path)
|
||||
val sorting = activity.config.getFolderSorting(if (path.isEmpty()) SHOW_ALL else path)
|
||||
view.apply {
|
||||
media_grid.adapter = adapter
|
||||
|
||||
|
|
|
@ -599,7 +599,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||
}) as ArrayList<Medium>
|
||||
|
||||
val pathToUse = if (path.isEmpty()) SHOW_ALL else path
|
||||
mediaFetcher.sortMedia(media, config.getFileSorting(pathToUse))
|
||||
mediaFetcher.sortMedia(media, config.getFolderSorting(pathToUse))
|
||||
val grouped = mediaFetcher.groupMedia(media, pathToUse)
|
||||
callback(grouped.clone() as ArrayList<ThumbnailItem>)
|
||||
val OTGPath = config.OTGPath
|
||||
|
@ -865,7 +865,7 @@ fun Context.updateDirectoryPath(path: String) {
|
|||
val albumCovers = config.parseAlbumCovers()
|
||||
val includedFolders = config.includedFolders
|
||||
|
||||
val sorting = config.getFileSorting(path)
|
||||
val sorting = config.getFolderSorting(path)
|
||||
val grouping = config.getFolderGrouping(path)
|
||||
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
sorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||
|
|
|
@ -21,22 +21,6 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
get(): Int = prefs.getInt(DIRECTORY_SORT_ORDER, SORT_BY_DATE_MODIFIED or SORT_DESCENDING)
|
||||
set(order) = prefs.edit().putInt(DIRECTORY_SORT_ORDER, order).apply()
|
||||
|
||||
fun saveFileSorting(path: String, value: Int) {
|
||||
if (path.isEmpty()) {
|
||||
sorting = value
|
||||
} else {
|
||||
prefs.edit().putInt(SORT_FOLDER_PREFIX + path.toLowerCase(), value).apply()
|
||||
}
|
||||
}
|
||||
|
||||
fun getFileSorting(path: String) = prefs.getInt(SORT_FOLDER_PREFIX + path.toLowerCase(), sorting)
|
||||
|
||||
fun removeFileSorting(path: String) {
|
||||
prefs.edit().remove(SORT_FOLDER_PREFIX + path.toLowerCase()).apply()
|
||||
}
|
||||
|
||||
fun hasCustomSorting(path: String) = prefs.contains(SORT_FOLDER_PREFIX + path.toLowerCase())
|
||||
|
||||
fun saveFolderGrouping(path: String, value: Int) {
|
||||
if (path.isEmpty()) {
|
||||
groupBy = value
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.simplemobiletools.commons.helpers.MONTH_SECONDS
|
|||
|
||||
// shared preferences
|
||||
const val DIRECTORY_SORT_ORDER = "directory_sort_order"
|
||||
const val SORT_FOLDER_PREFIX = "sort_folder_"
|
||||
const val GROUP_FOLDER_PREFIX = "group_folder_"
|
||||
const val VIEW_TYPE_PREFIX = "view_type_folder_"
|
||||
const val SHOW_HIDDEN_MEDIA = "show_hidden_media"
|
||||
|
|
|
@ -38,7 +38,7 @@ class MediaFetcher(val context: Context) {
|
|||
curMedia.addAll(newMedia)
|
||||
}
|
||||
|
||||
sortMedia(curMedia, context.config.getFileSorting(curPath))
|
||||
sortMedia(curMedia, context.config.getFolderSorting(curPath))
|
||||
|
||||
return curMedia
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue