[Android] Migration for the playback speed preferences

Nicolas Pomepuy git at videolan.org
Fri Feb 14 13:01:41 UTC 2025


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Feb 14 09:41:32 2025 +0100| [75712ac3242bc3a148f91853041c86d1b235ca42] | committer: Duncan McNamara

Migration for the playback speed preferences

> https://code.videolan.org/videolan/vlc-android/commit/75712ac3242bc3a148f91853041c86d1b235ca42
---

 .../src/org/videolan/vlc/util/VersionMigration.kt  | 34 ++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
index 8c3cc195d0..65c5a2ff70 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VersionMigration.kt
@@ -41,6 +41,10 @@ import org.videolan.tools.PLAYLIST_MODE_VIDEO
 import org.videolan.tools.KEY_APP_THEME
 import org.videolan.tools.KEY_CURRENT_MAJOR_VERSION
 import org.videolan.tools.KEY_CURRENT_SETTINGS_VERSION
+import org.videolan.tools.KEY_PLAYBACK_SPEED_AUDIO_GLOBAL
+import org.videolan.tools.KEY_PLAYBACK_SPEED_AUDIO_GLOBAL_VALUE
+import org.videolan.tools.KEY_PLAYBACK_SPEED_VIDEO_GLOBAL
+import org.videolan.tools.KEY_PLAYBACK_SPEED_VIDEO_GLOBAL_VALUE
 import org.videolan.tools.KEY_VIDEO_CONFIRM_RESUME
 import org.videolan.tools.SCREENSHOT_MODE
 import org.videolan.tools.Settings
@@ -53,7 +57,7 @@ import org.videolan.vlc.isVLC4
 import java.io.File
 import java.io.IOException
 
-private const val CURRENT_VERSION = 13
+private const val CURRENT_VERSION = 14
 
 object VersionMigration {
 
@@ -112,6 +116,10 @@ object VersionMigration {
             migrateToVersion13(settings)
         }
 
+        if (lastVersion < 14) {
+            migrateToVersion14(settings)
+        }
+
         //Major version upgrade
         if (lastMajorVersion == 3 && currentMajorVersion == 4) {
             migrateToVlc4(settings)
@@ -314,7 +322,7 @@ object VersionMigration {
                 remove("browser_show_all_files")
             }
     }
-    private val TAG = this::class.java.name
+
     /**
      * Migrate after refactor to move all FORCE_PLAY_ALL_VIDEO/AUDIO to PLAYLIST_MODE_VIDEO/AUDIO
      * This is to have the constant name and setting name more similar
@@ -335,6 +343,28 @@ object VersionMigration {
         }
     }
 
+    /**
+     * Migrate after refactor of the playback speed dialog to move all playback_speed/playback_speed_video to KEY_PLAYBACK_SPEED_AUDIO_GLOBAL/KEY_PLAYBACK_SPEED_VIDEO_GLOBAL
+     *
+     */
+    private fun migrateToVersion14(settings: SharedPreferences) {
+        Log.i(this::class.java.simpleName, "Migration to Version 14: refactor to move all playback_speed/playback_speed_video to KEY_PLAYBACK_SPEED_AUDIO_GLOBAL/KEY_PLAYBACK_SPEED_VIDEO_GLOBAL")
+        if (settings.contains("playback_speed")) {
+            settings.edit(true) {
+                putBoolean(KEY_PLAYBACK_SPEED_AUDIO_GLOBAL, settings.getBoolean("playback_speed", false))
+                putFloat(KEY_PLAYBACK_SPEED_AUDIO_GLOBAL_VALUE, settings.getFloat("playback_rate", 1F))
+                remove("playback_speed")
+            }
+        }
+        if (settings.contains("playback_speed_video")) {
+            settings.edit(true) {
+                putBoolean(KEY_PLAYBACK_SPEED_VIDEO_GLOBAL, settings.getBoolean("playback_speed_video", false))
+                putFloat(KEY_PLAYBACK_SPEED_VIDEO_GLOBAL_VALUE, settings.getFloat("playback_rate_video", 1F))
+                remove("playback_speed_video")
+            }
+        }
+    }
+
     /**
      * Migration to vlc 4
      * ⚠️⚠️⚠️ This should not be destructive! Any first install will run this.



More information about the Android mailing list