Skip to content
Snippets Groups Projects
Commit 1ae09c4c authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Migrate the subtitles color setting

Fixes #2691
parent 26b2a5aa
No related branches found
No related tags found
1 merge request!1548Apply the VersionMigration sooner + subtitle migration
Pipeline #265149 passed with stage
in 3 minutes and 41 seconds
......@@ -26,6 +26,7 @@ package org.videolan.vlc.util
import android.content.Context
import android.content.SharedPreferences
import android.graphics.Color
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.edit
......@@ -39,7 +40,7 @@ import org.videolan.vlc.gui.onboarding.ONBOARDING_DONE_KEY
import java.io.File
import java.io.IOException
private const val CURRENT_VERSION = 9
private const val CURRENT_VERSION = 10
object VersionMigration {
......@@ -75,6 +76,10 @@ object VersionMigration {
migrateToVersion9(settings)
}
if (lastVersion < 10) {
migrateToVersion10(settings)
}
settings.putSingle(KEY_CURRENT_SETTINGS_VERSION, CURRENT_VERSION)
}
......@@ -216,4 +221,23 @@ object VersionMigration {
remove("enable_screenshot_gesture")
}
}
/**
* Migrate the subtitle color setting
*/
private fun migrateToVersion10(settings: SharedPreferences) {
Log.i(this::class.java.simpleName, "Migration to Version 10: Migrate the subtitle color setting")
if (settings.contains("subtitles_color"))
settings.edit(true) {
settings.getString("subtitles_color", "16777215")?.let {oldSetting ->
try {
val oldColor = oldSetting.toInt()
val newColor = Color.argb(255, Color.red(oldColor), Color.green(oldColor), Color.blue(oldColor))
putInt("subtitles_color", newColor)
} catch (e: Exception) {
remove("subtitles_color")
}
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment