[Android] Use a dedicated version number for migrations and code cleanup
Nicolas Pomepuy
git at videolan.org
Mon Oct 7 15:05:32 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Sep 24 08:32:24 2019 +0200| [ab7e9a4d61f3bfe4dea1d6f65bd863ecb25ded91] | committer: Geoffrey Métais
Use a dedicated version number for migrations and code cleanup
> https://code.videolan.org/videolan/vlc-android/commit/ab7e9a4d61f3bfe4dea1d6f65bd863ecb25ded91
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 2 +-
vlc-android/src/org/videolan/vlc/util/SettingsMigration.kt | 13 +++++++------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 615287faa..9004b6628 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -2316,7 +2316,7 @@ open class VideoPlayerActivity : AppCompatActivity(), IPlaybackSettingsControlle
if (extras != null) {
if (intent.hasExtra(PLAY_EXTRA_ITEM_LOCATION))
videoUri = extras.getParcelable(PLAY_EXTRA_ITEM_LOCATION)
- fromStart = extras.getBoolean(PLAY_EXTRA_FROM_START, false) || settings.getString(KEY_VIDEO_CONFIRM_RESUME, "0") == "1"
+ fromStart = fromStart or extras.getBoolean(PLAY_EXTRA_FROM_START, false)
// Consume fromStart option after first use to prevent
// restarting again when playback is paused.
intent.putExtra(PLAY_EXTRA_FROM_START, false)
diff --git a/vlc-android/src/org/videolan/vlc/util/SettingsMigration.kt b/vlc-android/src/org/videolan/vlc/util/SettingsMigration.kt
index 866293526..61d815d03 100644
--- a/vlc-android/src/org/videolan/vlc/util/SettingsMigration.kt
+++ b/vlc-android/src/org/videolan/vlc/util/SettingsMigration.kt
@@ -28,21 +28,22 @@ import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
-import org.videolan.vlc.BuildConfig
+
+private const val CURRENT_VERSION = 1
object SettingsMigration {
fun migrateSettings(context: Context) {
val settings = Settings.getInstance(context)
val lastVersion = settings.getInt(KEY_CURRENT_SETTINGS_VERSION, 0)
- if (lastVersion < 3030000) {
- migrateToVersion3030000(settings)
+ if (lastVersion < 1) {
+ migrateToVersion1(settings)
}
- settings.edit().putInt(KEY_CURRENT_SETTINGS_VERSION, BuildConfig.VERSION_CODE).apply()
+ settings.edit().putInt(KEY_CURRENT_SETTINGS_VERSION, CURRENT_VERSION).apply()
}
- private fun migrateToVersion3030000(settings: SharedPreferences) {
- Log.i(this::class.java.simpleName, "Migrating preferences to 3030000")
+ private fun migrateToVersion1(settings: SharedPreferences) {
+ Log.i(this::class.java.simpleName, "Migrating preferences to Version 1")
val editor = settings.edit()
//Migrate video Resume confirmation
val dialogConfirmResume = settings.getBoolean("dialog_confirm_resume", false)
More information about the Android
mailing list