[Android] Onboarding: Improve trigger condition
Geoffrey Métais
git at videolan.org
Thu May 2 13:22:31 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 2 12:14:09 2019 +0200| [8d802ef185a53bd7e6600aaf6b85affb7b629b66] | committer: Geoffrey Métais
Onboarding: Improve trigger condition
Onboarding could be launched on upgrade for old installation prior to
onboarding introduction
> https://code.videolan.org/videolan/vlc-android/commit/8d802ef185a53bd7e6600aaf6b85affb7b629b66
---
vlc-android/src/org/videolan/vlc/StartActivity.kt | 12 ++++++++----
.../org/videolan/vlc/gui/onboarding/OnboardingActivity.kt | 2 ++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/StartActivity.kt b/vlc-android/src/org/videolan/vlc/StartActivity.kt
index b38c5ede5..3beef17a7 100644
--- a/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -102,8 +102,8 @@ class StartActivity : FragmentActivity() {
/* Check if it's the first run */
val firstRun = savedVersionNumber == -1
val upgrade = firstRun || savedVersionNumber != currentVersionNumber
- if (upgrade) settings.edit().putInt(PREF_FIRST_RUN, currentVersionNumber).apply()
val tv = showTvUi()
+ if (upgrade && (tv || !firstRun)) settings.edit().putInt(PREF_FIRST_RUN, currentVersionNumber).apply()
// Route search query
if (Intent.ACTION_SEARCH == action || "com.google.android.gms.actions.SEARCH_ACTION" == action) {
startActivity(intent.setClass(this, if (tv) org.videolan.vlc.gui.tv.SearchActivity::class.java else SearchActivity::class.java))
@@ -135,11 +135,15 @@ class StartActivity : FragmentActivity() {
}
private fun startApplication(tv: Boolean, firstRun: Boolean, upgrade: Boolean, target: Int) {
- val onboarding = !tv && !Settings.getInstance(this at StartActivity).getBoolean(ONBOARDING_DONE_KEY, false)
+ val settings = Settings.getInstance(this at StartActivity)
+ val onboarding = !tv && !settings.getBoolean(ONBOARDING_DONE_KEY, false)
// Start Medialibrary from background to workaround Dispatchers.Main causing ANR
// cf https://github.com/Kotlin/kotlinx.coroutines/issues/878
- if (!onboarding) {
- Thread(Runnable { this at StartActivity.startMedialibrary(firstRun, upgrade, true) }).start()
+ if (!onboarding || !firstRun) {
+ Thread {
+ this at StartActivity.startMedialibrary(firstRun, upgrade, true)
+ if (onboarding) settings.edit().putBoolean(ONBOARDING_DONE_KEY, true).apply()
+ }.start()
val intent = Intent(this at StartActivity, if (tv) MainTvActivity::class.java else MainActivity::class.java)
.putExtra(EXTRA_FIRST_RUN, firstRun)
.putExtra(EXTRA_UPGRADE, upgrade)
diff --git a/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt b/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
index 6b6cd9d9c..d96eb613b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
@@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import kotlinx.coroutines.*
+import org.videolan.vlc.BuildConfig
import org.videolan.vlc.MediaParsingService
import org.videolan.vlc.R
import org.videolan.vlc.gui.MainActivity
@@ -128,6 +129,7 @@ class OnboardingActivity : AppCompatActivity(), ViewPager.OnPageChangeListener,
setResult(PreferencesActivity.RESULT_RESTART)
Settings.getInstance(this)
.edit()
+ .putInt(PREF_FIRST_RUN, BuildConfig.VERSION_CODE)
.putBoolean(ONBOARDING_DONE_KEY, true)
.putInt(KEY_MEDIALIBRARY_SCAN, if (viewModel.scanStorages) ML_SCAN_ON else ML_SCAN_OFF)
.putInt("fragment_id", if (viewModel.scanStorages) R.id.nav_video else R.id.nav_directories)
More information about the Android
mailing list