Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd9c4ce1 authored by Ellen Poe's avatar Ellen Poe
Browse files

Merge branch 'ellenhp/offline_notification_fix' into 'main'

Offline download notification changes to "Finished" when done

Closes #91

See merge request e/os/cardinal!54
parents 4315384a 3c98b42a
Loading
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -29,7 +29,7 @@ import earth.maps.cardinal.data.DownloadStatusConverter


@Database(
@Database(
    entities = [OfflineArea::class, RoutingProfile::class, DownloadedTile::class, SavedList::class, SavedPlace::class, ListItem::class, RecentSearch::class],
    entities = [OfflineArea::class, RoutingProfile::class, DownloadedTile::class, SavedList::class, SavedPlace::class, ListItem::class, RecentSearch::class],
    version = 12,
    version = 13,
    exportSchema = false
    exportSchema = false
)
)
@TypeConverters(TileTypeConverter::class, DownloadStatusConverter::class, ItemTypeConverter::class)
@TypeConverters(TileTypeConverter::class, DownloadStatusConverter::class, ItemTypeConverter::class)
@@ -224,6 +224,14 @@ abstract class AppDatabase : RoomDatabase() {
            }
            }
        }
        }


        private val MIGRATION_12_13 = object : Migration(12, 13) {
            override fun migrate(db: SupportSQLiteDatabase) {
                db.execSQL(
                    "ALTER TABLE downloaded_tiles ADD COLUMN processed INTEGER"
                )
            }
        }

        fun getDatabase(context: Context): AppDatabase {
        fun getDatabase(context: Context): AppDatabase {
            return INSTANCE ?: synchronized(this) {
            return INSTANCE ?: synchronized(this) {
                val instance = Room.databaseBuilder(
                val instance = Room.databaseBuilder(
@@ -239,6 +247,7 @@ abstract class AppDatabase : RoomDatabase() {
                    MIGRATION_9_10,
                    MIGRATION_9_10,
                    MIGRATION_10_11,
                    MIGRATION_10_11,
                    MIGRATION_11_12,
                    MIGRATION_11_12,
                    MIGRATION_12_13,
                ).build()
                ).build()
                INSTANCE = instance
                INSTANCE = instance
                instance
                instance
+1 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ data class DownloadedTile(
    val zoom: Int? = null,
    val zoom: Int? = null,
    val tileX: Int? = null,
    val tileX: Int? = null,
    val tileY: Int? = null,
    val tileY: Int? = null,
    val processed: Boolean? = null,


    // For Valhalla tiles (hierarchyLevel/tileIndex system)
    // For Valhalla tiles (hierarchyLevel/tileIndex system)
    val hierarchyLevel: Int? = null,
    val hierarchyLevel: Int? = null,
+6 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,12 @@ interface DownloadedTileDao {
    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId AND tileType = :tileType")
    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId AND tileType = :tileType")
    suspend fun getDownloadedTileCountForAreaAndType(areaId: String, tileType: TileType): Int
    suspend fun getDownloadedTileCountForAreaAndType(areaId: String, tileType: TileType): Int


    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId AND COALESCE(processed, 0) <> 0")
    suspend fun getProcessedTileCountForArea(areaId: String): Int

    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId AND COALESCE(processed, 0) == 0 AND zoom = 14")
    suspend fun getUnprocessedTileCountForArea(areaId: String): Int

    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId")
    @Query("SELECT COUNT(*) FROM downloaded_tiles WHERE areaId = :areaId")
    suspend fun getDownloadedTileCountForArea(areaId: String): Int
    suspend fun getDownloadedTileCountForArea(areaId: String): Int


+4 −2
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ interface DownloadProgressReporter {
    fun updateProgress(
    fun updateProgress(
        areaId: String,
        areaId: String,
        areaName: String,
        areaName: String,
        currentStage: DownloadStage?,
        currentStage: DownloadStage,
        stageProgress: Int,
        stageProgress: Int,
        stageTotal: Int,
        stageTotal: Int,
        isCompleted: Boolean,
        isCompleted: Boolean,
@@ -49,5 +49,7 @@ interface DownloadProgressReporter {
enum class DownloadStage {
enum class DownloadStage {
    BASEMAP,
    BASEMAP,
    VALHALLA,
    VALHALLA,
    PROCESSING
    PROCESSING,
    DONE,
    ERROR,
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -28,7 +28,7 @@ class ServiceProgressReporter(
    override fun updateProgress(
    override fun updateProgress(
        areaId: String,
        areaId: String,
        areaName: String,
        areaName: String,
        currentStage: DownloadStage?,
        currentStage: DownloadStage,
        stageProgress: Int,
        stageProgress: Int,
        stageTotal: Int,
        stageTotal: Int,
        isCompleted: Boolean,
        isCompleted: Boolean,
Loading