From 53beff0949ff537ee6a53f3cb3876977d20e73c5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 14 Oct 2022 16:35:11 +0200 Subject: [PATCH] renaming some variables here and there --- .../gallery/pro/activities/MainActivity.kt | 8 ++--- .../gallery/pro/activities/MediaActivity.kt | 6 ++-- .../pro/activities/SettingsActivity.kt | 1 - .../pro/activities/WidgetConfigureActivity.kt | 2 +- .../gallery/pro/adapters/DirectoryAdapter.kt | 2 +- .../pro/asynctasks/GetMediaAsynctask.kt | 8 ++--- .../gallery/pro/extensions/Activity.kt | 2 +- .../gallery/pro/extensions/Context.kt | 12 +++---- .../gallery/pro/helpers/MyWidgetProvider.kt | 4 +-- .../gallery/pro/interfaces/MediumDao.kt | 2 +- .../gallery/pro/models/Directory.kt | 31 ++++++++++--------- 11 files changed, 39 insertions(+), 39 deletions(-) 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 0d91caba2..a31d1437a 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 @@ -677,7 +677,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { ensureBackgroundThread { folders.filter { !getDoesFilePathExist(it.absolutePath, OTGPath) }.forEach { - directoryDao.deleteDirPath(it.absolutePath) + directoryDB.deleteDirPath(it.absolutePath) } if (config.deleteEmptyFolders) { @@ -1063,7 +1063,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (dirPathsToRemove.isNotEmpty()) { val dirsToRemove = dirs.filter { dirPathsToRemove.contains(it.path) } dirsToRemove.forEach { - directoryDao.deleteDirPath(it.path) + directoryDB.deleteDirPath(it.path) } dirs.removeAll(dirsToRemove) setupAdapter(dirs) @@ -1132,7 +1132,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { // make sure to create a new thread for these operations, dont just use the common bg thread Thread { try { - directoryDao.insert(newDir) + directoryDB.insert(newDir) if (folder != RECYCLE_BIN && folder != FAVORITES) { mediaDB.insertAll(newMedia) } @@ -1346,7 +1346,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { setupAdapter(dirs) invalidDirs.forEach { try { - directoryDao.deleteDirPath(it.path) + directoryDB.deleteDirPath(it.path) } catch (ignored: Exception) { } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index c2a21cda3..a7887ca24 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -517,7 +517,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { val paths = mMedia.filter { it is Medium }.map { (it as Medium).path } as ArrayList restoreRecycleBinPaths(paths) { ensureBackgroundThread { - directoryDao.deleteDirPath(RECYCLE_BIN) + directoryDB.deleteDirPath(RECYCLE_BIN) } finish() } @@ -625,7 +625,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (mPath == FAVORITES) { ensureBackgroundThread { - directoryDao.deleteDirPath(FAVORITES) + directoryDB.deleteDirPath(FAVORITES) } } @@ -639,7 +639,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun deleteDBDirectory() { ensureBackgroundThread { try { - directoryDao.deleteDirPath(mPath) + directoryDB.deleteDirPath(mPath) } catch (ignored: Exception) { } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 7fa1d10da..1dae7a4a1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -224,7 +224,6 @@ class SettingsActivity : SimpleActivity() { private fun setupShowHiddenItems() { if (isRPlus() && !isExternalStorageManager()) { settings_show_hidden_items_holder.beGone() - settings_manage_excluded_folders_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme) } settings_show_hidden_items.isChecked = config.showHiddenMedia diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 38cd63ad7..166ae2f9e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -173,7 +173,7 @@ class WidgetConfigureActivity : SimpleActivity() { } ensureBackgroundThread { - val path = directoryDao.getDirectoryThumbnail(folderPath) + val path = directoryDB.getDirectoryThumbnail(folderPath) if (path != null) { runOnUiThread { val signature = ObjectKey(System.currentTimeMillis().toString()) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index bc6ad8279..0e727f854 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -266,7 +266,7 @@ class DirectoryAdapter( updateDirs(dirs) ensureBackgroundThread { try { - activity.directoryDao.updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath) + activity.directoryDB.updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath) listener?.refreshItems() } catch (e: Exception) { activity.showErrorToast(e) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt index d14813aa5..0067953da 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt @@ -18,16 +18,16 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage override fun doInBackground(vararg params: Void): ArrayList { val pathToUse = if (showAll) SHOW_ALL else mPath val folderGrouping = context.config.getFolderGrouping(pathToUse) - val fileSorting = context.config.getFolderSorting(pathToUse) - val getProperDateTaken = fileSorting and SORT_BY_DATE_TAKEN != 0 || + val folderSorting = context.config.getFolderSorting(pathToUse) + val getProperDateTaken = folderSorting and SORT_BY_DATE_TAKEN != 0 || folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 || folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0 - val getProperLastModified = fileSorting and SORT_BY_DATE_MODIFIED != 0 || + val getProperLastModified = folderSorting and SORT_BY_DATE_MODIFIED != 0 || folderGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 || folderGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0 - val getProperFileSize = fileSorting and SORT_BY_SIZE != 0 + val getProperFileSize = folderSorting and SORT_BY_SIZE != 0 val favoritePaths = context.getFavoritePaths() val getVideoDurations = context.config.showThumbnailVideoDuration val lastModifieds = if (getProperLastModified) mediaFetcher.getLastModifieds() else HashMap() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 150325f48..35985ac94 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -460,7 +460,7 @@ fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) { try { recycleBin.deleteRecursively() mediaDB.clearRecycleBin() - directoryDao.deleteRecycleBin() + directoryDB.deleteRecycleBin() toast(R.string.recycle_bin_emptied) callback?.invoke() } catch (e: Exception) { 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 774c1d90c..ca75e9b3b 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 @@ -56,7 +56,7 @@ val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicatio val Context.mediaDB: MediumDao get() = GalleryDatabase.getInstance(applicationContext).MediumDao() -val Context.directoryDao: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao() +val Context.directoryDB: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao() val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao() @@ -397,7 +397,7 @@ fun Context.rescanFolderMediaSync(path: String) { fun Context.storeDirectoryItems(items: ArrayList) { ensureBackgroundThread { - directoryDao.insertAll(items) + directoryDB.insertAll(items) } } @@ -644,7 +644,7 @@ fun Context.getCachedDirectories( } val directories = try { - directoryDao.getAll() as ArrayList + directoryDB.getAll() as ArrayList } catch (e: Exception) { ArrayList() } @@ -801,11 +801,11 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag } fun Context.removeInvalidDBDirectories(dirs: ArrayList? = null) { - val dirsToCheck = dirs ?: directoryDao.getAll() + val dirsToCheck = dirs ?: directoryDB.getAll() val OTGPath = config.OTGPath dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !getDoesFilePathExist(it.path, OTGPath) && it.path != config.tempFolderPath }.forEach { try { - directoryDao.deleteDirPath(it.path) + directoryDB.deleteDirPath(it.path) } catch (ignored: Exception) { } } @@ -823,7 +823,7 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) { fun Context.updateDBDirectory(directory: Directory) { try { - directoryDao.updateDirectory( + directoryDB.updateDirectory( directory.path, directory.tmb, directory.mediaCnt, diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt index a72da533d..6dfc107ec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MyWidgetProvider.kt @@ -18,7 +18,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.activities.MediaActivity import com.simplemobiletools.gallery.pro.extensions.config -import com.simplemobiletools.gallery.pro.extensions.directoryDao +import com.simplemobiletools.gallery.pro.extensions.directoryDB import com.simplemobiletools.gallery.pro.extensions.getFolderNameFromPath import com.simplemobiletools.gallery.pro.extensions.widgetsDB import com.simplemobiletools.gallery.pro.models.Widget @@ -45,7 +45,7 @@ class MyWidgetProvider : AppWidgetProvider() { setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath)) } - val path = context.directoryDao.getDirectoryThumbnail(it.folderPath) ?: return@forEach + val path = context.directoryDB.getDirectoryThumbnail(it.folderPath) ?: return@forEach val options = RequestOptions() .signature(path.getFileSignature()) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index bbc3d3535..09c1c1bd6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -40,7 +40,7 @@ interface MediumDao { fun deleteMediumPath(path: String) @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") - fun updateMedium(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String) + fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String) @Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE") fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt index 8734dd2d4..702c36091 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/models/Directory.kt @@ -10,22 +10,23 @@ import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN @Entity(tableName = "directories", indices = [Index(value = ["path"], unique = true)]) data class Directory( - @PrimaryKey(autoGenerate = true) var id: Long?, - @ColumnInfo(name = "path") var path: String, - @ColumnInfo(name = "thumbnail") var tmb: String, - @ColumnInfo(name = "filename") var name: String, - @ColumnInfo(name = "media_count") var mediaCnt: Int, - @ColumnInfo(name = "last_modified") var modified: Long, - @ColumnInfo(name = "date_taken") var taken: Long, - @ColumnInfo(name = "size") var size: Long, - @ColumnInfo(name = "location") var location: Int, - @ColumnInfo(name = "media_types") var types: Int, - @ColumnInfo(name = "sort_value") var sortValue: String, + @PrimaryKey(autoGenerate = true) var id: Long?, + @ColumnInfo(name = "path") var path: String, + @ColumnInfo(name = "thumbnail") var tmb: String, + @ColumnInfo(name = "filename") var name: String, + @ColumnInfo(name = "media_count") var mediaCnt: Int, + @ColumnInfo(name = "last_modified") var modified: Long, + @ColumnInfo(name = "date_taken") var taken: Long, + @ColumnInfo(name = "size") var size: Long, + @ColumnInfo(name = "location") var location: Int, + @ColumnInfo(name = "media_types") var types: Int, + @ColumnInfo(name = "sort_value") var sortValue: String, - // used with "Group direct subfolders" enabled - @Ignore var subfoldersCount: Int = 0, - @Ignore var subfoldersMediaCount: Int = 0, - @Ignore var containsMediaFilesDirectly: Boolean = true) { + // used with "Group direct subfolders" enabled + @Ignore var subfoldersCount: Int = 0, + @Ignore var subfoldersMediaCount: Int = 0, + @Ignore var containsMediaFilesDirectly: Boolean = true +) { constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, "", 0, 0)