mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
add a new field to media, the timestamp of their move to recycle bin
This commit is contained in:
parent
3468a9860b
commit
f7e7482fc8
6 changed files with 14 additions and 10 deletions
|
@ -95,7 +95,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
else -> TYPE_RAWS
|
else -> TYPE_RAWS
|
||||||
}
|
}
|
||||||
|
|
||||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type, false)
|
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type, false, 0)
|
||||||
supportActionBar?.title = mMedium!!.name
|
supportActionBar?.title = mMedium!!.name
|
||||||
bundle.putSerializable(MEDIUM, mMedium)
|
bundle.putSerializable(MEDIUM, mMedium)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.simplemobiletools.gallery.interfaces.MediumDao
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
|
|
||||||
@Database(entities = [(Directory::class), (Medium::class)], version = 3)
|
@Database(entities = [(Directory::class), (Medium::class)], version = 4)
|
||||||
abstract class GalleryDatabase : RoomDatabase() {
|
abstract class GalleryDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun DirectoryDao(): DirectoryDao
|
abstract fun DirectoryDao(): DirectoryDao
|
||||||
|
|
|
@ -224,7 +224,7 @@ class MediaFetcher(val context: Context) {
|
||||||
|
|
||||||
val path = file.absolutePath
|
val path = file.absolutePath
|
||||||
val isFavorite = favoritePaths.contains(path)
|
val isFavorite = favoritePaths.contains(path)
|
||||||
val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite)
|
val medium = Medium(null, filename, path, file.parent, lastModified, dateTaken, size, type, isFavorite, 0)
|
||||||
media.add(medium)
|
media.add(medium)
|
||||||
}
|
}
|
||||||
return media
|
return media
|
||||||
|
@ -281,7 +281,7 @@ class MediaFetcher(val context: Context) {
|
||||||
|
|
||||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", OTG_PATH))
|
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", OTG_PATH))
|
||||||
val isFavorite = favoritePaths.contains(path)
|
val isFavorite = favoritePaths.contains(path)
|
||||||
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, isFavorite)
|
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, isFavorite, 0)
|
||||||
media.add(medium)
|
media.add(medium)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,18 @@ import com.simplemobiletools.gallery.models.Medium
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface MediumDao {
|
interface MediumDao {
|
||||||
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE parent_path = :path COLLATE NOCASE")
|
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite, deleted_ts FROM media WHERE deleted_ts = 0 AND parent_path = :path COLLATE NOCASE")
|
||||||
fun getMediaFromPath(path: String): List<Medium>
|
fun getMediaFromPath(path: String): List<Medium>
|
||||||
|
|
||||||
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE is_favorite = 1")
|
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite, deleted_ts FROM media WHERE deleted_ts = 0 AND is_favorite = 1")
|
||||||
fun getFavorites(): List<Medium>
|
fun getFavorites(): List<Medium>
|
||||||
|
|
||||||
@Query("SELECT full_path FROM media WHERE is_favorite = 1")
|
@Query("SELECT full_path FROM media WHERE deleted_ts = 0 AND is_favorite = 1")
|
||||||
fun getFavoritePaths(): List<String>
|
fun getFavoritePaths(): List<String>
|
||||||
|
|
||||||
|
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite, deleted_ts FROM media WHERE deleted_ts != 0")
|
||||||
|
fun getDeletedMedia(): List<Medium>
|
||||||
|
|
||||||
@Insert(onConflict = REPLACE)
|
@Insert(onConflict = REPLACE)
|
||||||
fun insert(medium: Medium)
|
fun insert(medium: Medium)
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,11 @@ data class Medium(
|
||||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||||
@ColumnInfo(name = "size") val size: Long,
|
@ColumnInfo(name = "size") val size: Long,
|
||||||
@ColumnInfo(name = "type") val type: Int,
|
@ColumnInfo(name = "type") val type: Int,
|
||||||
@ColumnInfo(name = "is_favorite") var isFavorite: Boolean) : Serializable, ThumbnailItem() {
|
@ColumnInfo(name = "is_favorite") var isFavorite: Boolean,
|
||||||
|
@ColumnInfo(name = "deleted_ts") var deletedTS: Int) : Serializable, ThumbnailItem() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val serialVersionUID = -6553149366975455L
|
private const val serialVersionUID = -6553149366975655L
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isGif() = type == TYPE_GIFS
|
fun isGif() = type == TYPE_GIFS
|
||||||
|
|
|
@ -19,7 +19,7 @@ class RefreshMediaReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
||||||
File(path).length(), getFileType(path), false)
|
File(path).length(), getFileType(path), false, 0)
|
||||||
context.galleryDB.MediumDao().insert(medium)
|
context.galleryDB.MediumDao().insert(medium)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue