diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 235e28764..a8b56c0a0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -120,6 +120,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { config.wasRecycleBinPinned = true config.saveFolderGrouping(SHOW_ALL, GROUP_BY_DATE_TAKEN or GROUP_DESCENDING) } + + checkRecycleBinItems() } override fun onStart() { @@ -925,6 +927,20 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { }, LAST_MEDIA_CHECK_PERIOD) } + private fun checkRecycleBinItems() { + if (config.useRecycleBin) { + Thread { + val mediumDao = galleryDB.MediumDao() + val deletedMedia = mediumDao.getDeletedMedia() + deletedMedia.forEach { + if (System.currentTimeMillis() > it.deletedTS + MONTH_MILLISECONDS) { + mediumDao.deleteMediumPath(it.path) + } + } + }.start() + } + } + override fun refreshItems() { getDirectories() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index 5f099c5a1..f77035eba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -1,5 +1,7 @@ package com.simplemobiletools.gallery.helpers +import com.simplemobiletools.commons.helpers.MONTH_SECONDS + // shared preferences const val DIRECTORY_SORT_ORDER = "directory_sort_order" const val SORT_FOLDER_PREFIX = "sort_folder_" @@ -76,6 +78,7 @@ const val MAX_COLUMN_COUNT = 20 const val SHOW_TEMP_HIDDEN_DURATION = 300000L const val CLICK_MAX_DURATION = 150 const val DRAG_THRESHOLD = 8 +const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L const val DIRECTORY = "directory" const val MEDIUM = "medium"