diff --git a/app/src/main/java/gallery/memories/NativeX.kt b/app/src/main/java/gallery/memories/NativeX.kt index b7e51363..ed02b9b6 100644 --- a/app/src/main/java/gallery/memories/NativeX.kt +++ b/app/src/main/java/gallery/memories/NativeX.kt @@ -172,8 +172,12 @@ class NativeX(private val mCtx: MainActivity) { } @JavascriptInterface - fun setServerId(auid: Long, serverId: Long) { - Thread { query.setServerId(auid, serverId) }.start() + fun setHasRemote(auids: String, value: Boolean) { + Thread { + val parsed = JSONArray(auids) + val list = List(parsed.length()) { parsed.getLong(it) } + query.setHasRemote(list, value) + }.start() } fun handleRequest(request: WebResourceRequest): WebResourceResponse { diff --git a/app/src/main/java/gallery/memories/dao/AppDatabase.kt b/app/src/main/java/gallery/memories/dao/AppDatabase.kt index 950f7247..c913e437 100644 --- a/app/src/main/java/gallery/memories/dao/AppDatabase.kt +++ b/app/src/main/java/gallery/memories/dao/AppDatabase.kt @@ -9,7 +9,7 @@ import gallery.memories.R import gallery.memories.mapper.Photo -@Database(entities = [Photo::class], version = 10) +@Database(entities = [Photo::class], version = 11) abstract class AppDatabase : RoomDatabase() { abstract fun photoDao(): PhotoDao diff --git a/app/src/main/java/gallery/memories/dao/PhotoDao.kt b/app/src/main/java/gallery/memories/dao/PhotoDao.kt index abc4c457..5046f35f 100644 --- a/app/src/main/java/gallery/memories/dao/PhotoDao.kt +++ b/app/src/main/java/gallery/memories/dao/PhotoDao.kt @@ -12,10 +12,10 @@ interface PhotoDao { @Query("SELECT 1") fun ping(): Int - @Query("SELECT dayid, COUNT(local_id) AS count FROM photos WHERE bucket_id IN (:bucketIds) AND server_id = 0 GROUP BY dayid ORDER BY dayid DESC") + @Query("SELECT dayid, COUNT(local_id) AS count FROM photos WHERE bucket_id IN (:bucketIds) AND has_remote = 0 GROUP BY dayid ORDER BY dayid DESC") fun getDays(bucketIds: List): List - @Query("SELECT * FROM photos WHERE dayid=:dayId AND bucket_id IN (:buckets) AND server_id = 0 ORDER BY date_taken DESC") + @Query("SELECT * FROM photos WHERE dayid=:dayId AND bucket_id IN (:buckets) AND has_remote = 0 ORDER BY date_taken DESC") fun getPhotosByDay(dayId: Long, buckets: List): List @Query("DELETE FROM photos WHERE local_id IN (:fileIds)") @@ -42,6 +42,6 @@ interface PhotoDao { @Query("SELECT bucket_id, bucket_name FROM photos GROUP BY bucket_id") fun getBuckets(): List - @Query("UPDATE photos SET server_id=:serverId WHERE auid=:auid") - fun setServerId(auid: Long, serverId: Long) + @Query("UPDATE photos SET has_remote=:v WHERE auid IN (:auids)") + fun setHasRemote(auids: List, v: Boolean) } \ No newline at end of file diff --git a/app/src/main/java/gallery/memories/mapper/Photo.kt b/app/src/main/java/gallery/memories/mapper/Photo.kt index 5ae0b254..106da2e2 100644 --- a/app/src/main/java/gallery/memories/mapper/Photo.kt +++ b/app/src/main/java/gallery/memories/mapper/Photo.kt @@ -12,13 +12,12 @@ import androidx.room.PrimaryKey Index(value = ["dayid"]), Index(value = ["flag"]), Index(value = ["bucket_id"]), - Index(value = ["bucket_id", "dayid", "server_id"]) + Index(value = ["bucket_id", "dayid", "has_remote"]) ] ) data class Photo( @PrimaryKey(autoGenerate = true) val id: Int? = null, @ColumnInfo(name = "local_id") val localId: Long, - @ColumnInfo(name = "server_id") val serverId: Long, @ColumnInfo(name = "auid") val auid: Long, @ColumnInfo(name = "mtime") val mtime: Long, @ColumnInfo(name = "date_taken") val dateTaken: Long, @@ -26,5 +25,6 @@ data class Photo( @ColumnInfo(name = "basename") val baseName: String, @ColumnInfo(name = "bucket_id") val bucketId: Long, @ColumnInfo(name = "bucket_name") val bucketName: String, + @ColumnInfo(name = "has_remote") val hasRemote: Boolean, @ColumnInfo(name = "flag") val flag: Int ) \ No newline at end of file diff --git a/app/src/main/java/gallery/memories/mapper/SystemImage.kt b/app/src/main/java/gallery/memories/mapper/SystemImage.kt index 8fc08b60..96088a5e 100644 --- a/app/src/main/java/gallery/memories/mapper/SystemImage.kt +++ b/app/src/main/java/gallery/memories/mapper/SystemImage.kt @@ -227,7 +227,7 @@ class SystemImage { bucketId = bucketId, bucketName = bucketName, flag = 0, - serverId = 0 + hasRemote = false ) } } \ No newline at end of file diff --git a/app/src/main/java/gallery/memories/service/TimelineQuery.kt b/app/src/main/java/gallery/memories/service/TimelineQuery.kt index 8030974a..acf536d5 100644 --- a/app/src/main/java/gallery/memories/service/TimelineQuery.kt +++ b/app/src/main/java/gallery/memories/service/TimelineQuery.kt @@ -412,12 +412,12 @@ class TimelineQuery(private val mCtx: MainActivity) { } /** - * Set server ID for local file. - * @param auid AUID - * @param serverId Server ID + * Set has_remote for list of AUIDs + * @param auids List of AUIDs + * @param value Value to set */ - fun setServerId(auid: Long, serverId: Long) { - mPhotoDao.setServerId(auid, serverId) + fun setHasRemote(auids: List, value: Boolean) { + mPhotoDao.setHasRemote(auids, value) } /**