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 ea356969d..895d99ebf 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 @@ -902,8 +902,17 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { return } - val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || config.getFileSorting(directory.path) and SORT_BY_DATE_TAKEN != 0 - val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || config.getFileSorting(directory.path) and SORT_BY_DATE_MODIFIED != 0 + val sorting = config.getFileSorting(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 || + grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + + val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || + sorting and SORT_BY_DATE_MODIFIED != 0 || + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 val curMedia = mLastMediaFetcher!!.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, false) val newDir = if (curMedia.isEmpty()) { @@ -979,8 +988,17 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { return } - val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || config.getFileSorting(folder) and SORT_BY_DATE_TAKEN != 0 - val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || config.getFileSorting(folder) and SORT_BY_DATE_MODIFIED != 0 + val sorting = config.getFileSorting(folder) + val grouping = config.getFolderGrouping(folder) + val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || + sorting and SORT_BY_DATE_TAKEN != 0 || + grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + + val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || + sorting and SORT_BY_DATE_MODIFIED != 0 || + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 val newMedia = mLastMediaFetcher!!.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, false) if (newMedia.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 8da181faf..39f71e0d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -859,7 +859,10 @@ fun Context.addPathToDB(path: String) { fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, includedFolders: MutableSet, isSortingAscending: Boolean, getProperFileSize: Boolean): Directory { val OTGPath = config.OTGPath - var thumbnail = curMedia.firstOrNull { getDoesFilePathExist(it.path, OTGPath) }?.path ?: "" + val grouped = MediaFetcher(this).groupMedia(curMedia, path) + val sortedMedia = grouped.filter { it is Medium }.toMutableList() as ArrayList + + var thumbnail = sortedMedia.firstOrNull { getDoesFilePathExist(it.path, OTGPath) }?.path ?: "" albumCovers.forEach { if (it.path == path && getDoesFilePathExist(it.tmb, OTGPath)) { @@ -917,8 +920,19 @@ fun Context.updateDirectoryPath(path: String) { val albumCovers = config.parseAlbumCovers() val includedFolders = config.includedFolders val isSortingAscending = config.directorySorting.isSortingAscending() - val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 - val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 + + val sorting = config.getFileSorting(path) + val grouping = config.getFolderGrouping(path) + val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0 || + sorting and SORT_BY_DATE_TAKEN != 0 || + grouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || + grouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 + + val getProperLastModified = config.directorySorting and SORT_BY_DATE_MODIFIED != 0 || + sorting and SORT_BY_DATE_MODIFIED != 0 || + grouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || + grouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 + val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0 val favoritePaths = getFavoritePaths() val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize, favoritePaths, false)