[Android] Widgets preview: persist the playing switch state
Nicolas Pomepuy
git at videolan.org
Tue Aug 16 09:35:09 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Aug 12 08:37:36 2022 +0200| [cc55632d15a10b5791ae344d6ad1b897a357b2ae] | committer: Nicolas Pomepuy
Widgets preview: persist the playing switch state
Fixes #2647
> https://code.videolan.org/videolan/vlc-android/commit/cc55632d15a10b5791ae344d6ad1b897a357b2ae
---
.../tools/src/main/java/org/videolan/tools/Settings.kt | 3 +++
.../org/videolan/vlc/widget/MiniPlayerConfigureActivity.kt | 11 ++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 57f239fd2..8e84848ba 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -177,6 +177,9 @@ const val CUSTOM_POPUP_HEIGHT = "custom_popup_height"
//files
const val BROWSER_SHOW_HIDDEN_FILES = "browser_show_hidden_files"
+//widgets
+const val WIDGETS_PREVIEW_PLAYING = "widgets_preview_playing"
+
class DeviceInfo(context: Context) {
val pm = context.packageManager
val tm = context.getSystemService<TelephonyManager>()!!
diff --git a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerConfigureActivity.kt b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerConfigureActivity.kt
index 5d3731ae4..4cb119495 100644
--- a/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerConfigureActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/widget/MiniPlayerConfigureActivity.kt
@@ -41,10 +41,7 @@ import com.google.android.material.appbar.MaterialToolbar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import org.videolan.tools.PREF_WIDGETS_TIPS_SHOWN
-import org.videolan.tools.Settings
-import org.videolan.tools.dp
-import org.videolan.tools.putSingle
+import org.videolan.tools.*
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.databinding.WidgetMiniPlayerConfigureBinding
@@ -115,7 +112,11 @@ class MiniPlayerConfigureActivity : BaseActivity() {
.commit()
}
- binding.previewPlaying.setOnCheckedChangeListener { _, _ -> updatePreview() }
+ binding.previewPlaying.isChecked = Settings.getInstance(this).getBoolean(WIDGETS_PREVIEW_PLAYING, true)
+ binding.previewPlaying.setOnCheckedChangeListener { _, checked ->
+ Settings.getInstance(this).putSingle(WIDGETS_PREVIEW_PLAYING, checked)
+ updatePreview()
+ }
if (!settings.getBoolean(PREF_WIDGETS_TIPS_SHOWN, false)) {
val widgetExplanationDialog = WidgetExplanationDialog()
More information about the Android
mailing list