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

Commit e7adf0b5 authored by cketti's avatar cketti
Browse files

Add migration to rewrite theme setting from LIGHT to FOLLOW_SYSTEM

parent 2d0c6987
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import timber.log.Timber;


public class K9StoragePersister implements StoragePersister {
    private static final int DB_VERSION = 7;
    private static final int DB_VERSION = 8;
    private static final String DB_NAME = "preferences_storage";

    private final Context context;
+23 −0
Original line number Diff line number Diff line
package com.fsck.k9.preferences.migrations

import android.database.sqlite.SQLiteDatabase

/**
 * Rewrite theme setting to use `FOLLOW_SYSTEM` when it's currently set to `LIGHT`.
 */
class StorageMigrationTo8(
        private val db: SQLiteDatabase,
        private val migrationsHelper: StorageMigrationsHelper
) {
    fun rewriteTheme() {
        val theme = migrationsHelper.readValue(db, "theme")
        if (theme == THEME_LIGHT) {
            migrationsHelper.writeValue(db, "theme", THEME_FOLLOW_SYSTEM)
        }
    }

    companion object {
        private const val THEME_LIGHT = "LIGHT"
        private const val THEME_FOLLOW_SYSTEM = "FOLLOW_SYSTEM"
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -13,5 +13,6 @@ internal object StorageMigrations {
        if (oldVersion <= 4) StorageMigrationTo5(db, migrationsHelper).fixMailCheckFrequencies()
        if (oldVersion <= 5) StorageMigrationTo6(db, migrationsHelper).performLegacyMigrations()
        if (oldVersion <= 6) StorageMigrationTo7(db, migrationsHelper).rewriteEnumOrdinalsToNames()
        if (oldVersion <= 7) StorageMigrationTo8(db, migrationsHelper).rewriteTheme()
    }
}