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

Reset the aout setting when migrating from VLC 3 to VLC 4

parent 6eb30a92
No related branches found
No related tags found
1 merge request!1625Update the libs
......@@ -70,6 +70,7 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicat
}
const val KEY_CURRENT_SETTINGS_VERSION = "current_settings_version"
const val KEY_CURRENT_MAJOR_VERSION = "key_current_major_version"
// Keys
const val KEY_ARTISTS_SHOW_ALL = "artists_show_all"
......
......@@ -37,6 +37,7 @@ import org.videolan.resources.AndroidDevices
import org.videolan.resources.util.getFromMl
import org.videolan.tools.*
import org.videolan.vlc.gui.onboarding.ONBOARDING_DONE_KEY
import org.videolan.vlc.isVLC4
import java.io.File
import java.io.IOException
......@@ -44,9 +45,12 @@ private const val CURRENT_VERSION = 10
object VersionMigration {
val currentMajorVersion = if (isVLC4()) 4 else 3
suspend fun migrateVersion(context: Context) {
val settings = Settings.getInstance(context)
val lastVersion = settings.getInt(KEY_CURRENT_SETTINGS_VERSION, 0)
val lastMajorVersion = settings.getInt(KEY_CURRENT_MAJOR_VERSION, 3)
if (lastVersion < 1) {
migrateToVersion1(settings)
}
......@@ -80,7 +84,13 @@ object VersionMigration {
migrateToVersion10(settings)
}
//Major version upgrade
if (lastMajorVersion == 3 && currentMajorVersion == 4) {
migrateToVlc4(settings)
}
settings.putSingle(KEY_CURRENT_SETTINGS_VERSION, CURRENT_VERSION)
settings.putSingle(KEY_CURRENT_MAJOR_VERSION, currentMajorVersion)
}
private fun migrateToVersion1(settings: SharedPreferences) {
......@@ -240,4 +250,17 @@ object VersionMigration {
}
}
}
/**
* Migration to vlc 4
* ⚠️⚠️⚠️ This should not be destructive! Any first install will run this.
*/
private fun migrateToVlc4(settings: SharedPreferences) {
Log.i(this::class.java.simpleName, "Migration to VLC 4")
// Removing the aout preference to choose aaudio by default
if (settings.contains("aout")) settings.edit(true) {
remove("aout")
}
}
}
\ 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