[Android] Make the nightly auto update an opt-in feature
Nicolas Pomepuy
git at videolan.org
Mon Aug 5 12:28:59 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul 30 14:37:35 2024 +0200| [0f89dade09565df9ff1b8650d57483cf8056d0c3] | committer: Duncan McNamara
Make the nightly auto update an opt-in feature
Fixes #3076
> https://code.videolan.org/videolan/vlc-android/commit/0f89dade09565df9ff1b8650d57483cf8056d0c3
---
application/resources/src/main/res/values/strings.xml | 2 ++
.../vlc-android/src/org/videolan/vlc/gui/MainActivity.kt | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 07da889945..0f54e94fec 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -626,6 +626,8 @@
<string name="install_nightly">Install the nightly version</string>
<string name="install_nightly_alert">Nightly builds are experimental versions updated everyday.\n\nExpect new features but also new bugs!</string>
<string name="nightly_version">Found version: %2$s - %1$s</string>
+ <string name="update_nightly_alert">You are running a nightly version. Would you like to periodically look for updates?</string>
+ <string name="update_nightly">Auto update</string>
<!-- Accessibility -->
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
index d577d34a82..b091f59841 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -23,6 +23,7 @@ package org.videolan.vlc.gui
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Activity
+import android.app.AlertDialog
import android.content.Intent
import android.os.Build
import android.os.Bundle
@@ -123,8 +124,20 @@ class MainActivity : ContentActivity(),
}
lifecycleScope.launch {
+ if (!BuildConfig.DEBUG) return at launch
AutoUpdate.clean(this at MainActivity.application)
if (!settings.getBoolean(KEY_SHOW_UPDATE, true)) return at launch
+ if (!settings.contains(KEY_SHOW_UPDATE)) {
+ AlertDialog.Builder(this at MainActivity)
+ .setTitle(resources.getString(R.string.update_nightly))
+ .setMessage(resources.getString(R.string.update_nightly_alert))
+ .setPositiveButton(R.string.yes){ _, _ ->
+ settings.putSingle(KEY_SHOW_UPDATE, true)
+ }
+ .setNegativeButton(R.string.no, null)
+ .show()
+ return at launch
+ }
AutoUpdate.checkUpdate(this at MainActivity.application) {url, date ->
val updateDialog = UpdateDialog().apply {
arguments = bundleOf(UPDATE_URL to url, UPDATE_DATE to date.time)
More information about the Android
mailing list