New marking API

pull/653/merge
Varun Patil 2023-10-03 10:07:01 -07:00
parent d4765fef1a
commit 5ab50fe85d
6 changed files with 19 additions and 15 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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<String>): List<Day>
@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<String>): List<Photo>
@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<Bucket>
@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<Long>, v: Boolean)
}

View File

@ -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
)

View File

@ -227,7 +227,7 @@ class SystemImage {
bucketId = bucketId,
bucketName = bucketName,
flag = 0,
serverId = 0
hasRemote = false
)
}
}

View File

@ -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<Long>, value: Boolean) {
mPhotoDao.setHasRemote(auids, value)
}
/**