Skip to content
Snippets Groups Projects
Commit 096ae5bb authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Migrate app theme settings

parent 3539249c
No related branches found
No related tags found
1 merge request!254Allow skipping resuming video playback + settings migration
......@@ -674,12 +674,5 @@ fun BaseActivity.applyTheme() {
setTheme(R.style.Theme_VLC_Black)
return
}
if (settings.contains(KEY_APP_THEME)) {
AppCompatDelegate.setDefaultNightMode(Integer.valueOf(settings.getString(KEY_APP_THEME, "-1")!!))
} else if (settings.contains(KEY_DAYNIGHT) || settings.contains(KEY_BLACK_THEME)) { // legacy support
val daynight = settings.getBoolean(KEY_DAYNIGHT, false)
val dark = settings.getBoolean(KEY_BLACK_THEME, false)
val mode = if (dark) AppCompatDelegate.MODE_NIGHT_YES else if (daynight) AppCompatDelegate.MODE_NIGHT_AUTO else AppCompatDelegate.MODE_NIGHT_NO
AppCompatDelegate.setDefaultNightMode(mode)
}
AppCompatDelegate.setDefaultNightMode(Integer.valueOf(settings.getString(KEY_APP_THEME, "-1")!!))
}
......@@ -27,6 +27,7 @@ package org.videolan.vlc.util
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import androidx.appcompat.app.AppCompatDelegate
import org.videolan.vlc.BuildConfig
object SettingsMigration {
......@@ -43,11 +44,21 @@ object SettingsMigration {
private fun migrateToVersion3030000(settings: SharedPreferences) {
Log.i(this::class.java.simpleName, "Migrating preferences to 3030000")
val editor = settings.edit()
//Migrate video Resume confirmation
val dialogConfirmResume = settings.getBoolean("dialog_confirm_resume", false)
if (dialogConfirmResume) {
editor.putString(KEY_VIDEO_CONFIRM_RESUME, "2")
}
editor.remove("dialog_confirm_resume")
//Migrate apptheme
if (!settings.contains(KEY_APP_THEME)) {
val daynight = settings.getBoolean("daynight", false)
val dark = settings.getBoolean("enable_black_theme", false)
val mode = if (dark) AppCompatDelegate.MODE_NIGHT_YES else if (daynight) AppCompatDelegate.MODE_NIGHT_AUTO else AppCompatDelegate.MODE_NIGHT_NO
editor.putString(KEY_APP_THEME, mode.toString())
}
editor.remove("daynight").remove("enable_black_theme")
editor.apply()
}
}
\ 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