diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 03910a6e3..6ef5ae6bc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -95,7 +95,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList else -> TYPE_RAWS } - mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type) + mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type, false) supportActionBar?.title = mMedium!!.name bundle.putSerializable(MEDIUM, mMedium) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/databases/GalleryDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/databases/GalleryDatabase.kt index b8bd5f47c..56896a30b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/databases/GalleryDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/databases/GalleryDatabase.kt @@ -9,7 +9,7 @@ import com.simplemobiletools.gallery.interfaces.MediumDao import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Medium -@Database(entities = [(Directory::class), (Medium::class)], version = 2) +@Database(entities = [(Directory::class), (Medium::class)], version = 3) abstract class GalleryDatabase : RoomDatabase() { abstract fun DirectoryDao(): DirectoryDao diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 89c60e8f1..cf79c7532 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -210,7 +210,7 @@ class MediaFetcher(val context: Context) { else -> TYPE_RAWS } - val medium = Medium(null, filename, file.absolutePath, folder, lastModified, dateTaken, size, type) + val medium = Medium(null, filename, file.absolutePath, folder, lastModified, dateTaken, size, type, false) media.add(medium) } return media @@ -266,7 +266,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 medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type) + val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, false) media.add(medium) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt index 1c076f768..7d47aef32 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt @@ -8,7 +8,7 @@ import com.simplemobiletools.gallery.models.Medium @Dao interface MediumDao { - @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type FROM media WHERE parent_path = :path") + @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE parent_path = :path") fun getMediaFromPath(path: String): List @Insert(onConflict = REPLACE) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt index 9fe49658b..5f167a180 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Medium.kt @@ -25,7 +25,8 @@ data class Medium( @ColumnInfo(name = "last_modified") val modified: Long, @ColumnInfo(name = "date_taken") var taken: Long, @ColumnInfo(name = "size") val size: Long, - @ColumnInfo(name = "type") val type: Int) : Serializable { + @ColumnInfo(name = "type") val type: Int, + @ColumnInfo(name = "is_favorite") val isFavorite: Boolean) : Serializable { companion object { private const val serialVersionUID = -6553149366975455L diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt index f90441e46..7e6de9293 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/receivers/RefreshMediaReceiver.kt @@ -19,7 +19,7 @@ class RefreshMediaReceiver : BroadcastReceiver() { Thread { val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), - File(path).length(), getFileType(path)) + File(path).length(), getFileType(path), false) context.galleryDB.MediumDao().insert(medium) }.start() }