[Android] Prevent showing the what's new screen on first run
Nicolas Pomepuy
git at videolan.org
Fri Jan 26 14:12:59 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jan 23 09:29:02 2024 +0100| [9b45debef3c130c2dd429303c5da0e7121a89b0b] | committer: Nicolas Pomepuy
Prevent showing the what's new screen on first run
Fixes #3023
> https://code.videolan.org/videolan/vlc-android/commit/9b45debef3c130c2dd429303c5da0e7121a89b0b
---
application/tools/src/main/java/org/videolan/tools/Settings.kt | 1 +
application/vlc-android/src/org/videolan/vlc/StartActivity.kt | 1 +
application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt | 2 +-
.../vlc-android/src/org/videolan/vlc/util/WhatsNewManager.kt | 7 ++++++-
4 files changed, 9 insertions(+), 2 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 3197d1a0ab..994a4f07a8 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -14,6 +14,7 @@ import org.videolan.tools.Settings.init
object Settings : SingletonHolder<SharedPreferences, Context>({ init(it.applicationContext) }) {
+ var firstRun: Boolean = false
var showVideoThumbs = true
var tvUI = false
var listTitleEllipsize = 0
diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index aa24819dac..638f629216 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -163,6 +163,7 @@ class StartActivity : FragmentActivity() {
val savedVersionNumber = settings.getInt(PREF_FIRST_RUN, -1)
/* Check if it's the first run */
val firstRun = savedVersionNumber == -1
+ Settings.firstRun = firstRun
val upgrade = firstRun || savedVersionNumber != currentVersionNumber
val tv = showTvUi()
if (upgrade && (tv || !firstRun)) settings.putSingle(PREF_FIRST_RUN, currentVersionNumber)
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 857756ab42..1e91fd6939 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -102,7 +102,7 @@ class MainActivity : ContentActivity(),
if (!NotificationPermissionManager.launchIfNeeded(this)) {
if (!WidgetMigration.launchIfNeeded(this)) {
- WhatsNewManager.launchIfNeeded(this)
+ if (!Settings.firstRun) WhatsNewManager.launchIfNeeded(this) else WhatsNewManager.markAsShown(settings)
}
}
}
diff --git a/application/vlc-android/src/org/videolan/vlc/util/WhatsNewManager.kt b/application/vlc-android/src/org/videolan/vlc/util/WhatsNewManager.kt
index 0ec13f0799..8d713e658b 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/WhatsNewManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/WhatsNewManager.kt
@@ -24,6 +24,7 @@
package org.videolan.vlc.util
+import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import org.videolan.tools.KEY_LAST_WHATS_NEW
import org.videolan.tools.KEY_SHOW_WHATS_NEW
@@ -36,9 +37,13 @@ object WhatsNewManager {
val preferences = Settings.getInstance(context)
val needed = preferences.getBoolean(KEY_SHOW_WHATS_NEW, true) && preferences.getString(KEY_LAST_WHATS_NEW, "") != "3.6"
if (needed) {
- preferences.putSingle(KEY_LAST_WHATS_NEW, "3.6")
+ markAsShown(preferences)
val whatsNewDialog = WhatsNewDialog()
whatsNewDialog.show(context.supportFragmentManager, "fragment_whats_new")
}
}
+
+ fun markAsShown(preferences: SharedPreferences) {
+ preferences.putSingle(KEY_LAST_WHATS_NEW, "3.6")
+ }
}
\ No newline at end of file
More information about the Android
mailing list