[Android] Launch TV onboarding sooner
Nicolas Pomepuy
git at videolan.org
Tue Jun 14 15:45:48 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jun 13 15:50:20 2022 +0200| [174cca59f2841aaa376a44006996726d66e87742] | committer: Duncan McNamara
Launch TV onboarding sooner
It prevents some medialibrary initialization issues
> https://code.videolan.org/videolan/vlc-android/commit/174cca59f2841aaa376a44006996726d66e87742
---
.../src/main/java/org/videolan/resources/Constants.kt | 3 ++-
.../main/java/org/videolan/television/ui/MainTvActivity.kt | 13 ++++---------
.../java/org/videolan/television/ui/OnboardingFragment.kt | 6 ++++--
.../vlc-android/src/org/videolan/vlc/StartActivity.kt | 9 ++++++---
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt
index 89aabe9f0..0b7553c60 100644
--- a/application/resources/src/main/java/org/videolan/resources/Constants.kt
+++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt
@@ -270,4 +270,5 @@ const val TV_MAIN_ACTIVITY = "org.videolan.television.ui.MainTvActivity"
const val MOBILE_MAIN_ACTIVITY = "org.videolan.vlc.gui.MainActivity"
const val MOVIEPEDIA_ACTIVITY = "org.videolan.moviepedia.ui.MoviepediaActivity"
const val TV_AUDIOPLAYER_ACTIVITY = "org.videolan.television.ui.audioplayer.AudioPlayerActivity"
-const val MEDIAPARSING_SERVICE = "org.videolan.vlc.MediaParsingService"
\ No newline at end of file
+const val MEDIAPARSING_SERVICE = "org.videolan.vlc.MediaParsingService"
+const val TV_ONBOARDING_ACTIVITY = "org.videolan.television.ui.OnboardingActivity"
\ No newline at end of file
diff --git a/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt b/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
index abc13e861..801b3077c 100644
--- a/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/MainTvActivity.kt
@@ -31,10 +31,12 @@ import android.widget.ProgressBar
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.television.R
import org.videolan.television.ui.browser.BaseTvActivity
-import org.videolan.tools.*
+import org.videolan.tools.RESULT_RESCAN
+import org.videolan.tools.RESULT_RESTART
+import org.videolan.tools.RESULT_RESTART_APP
+import org.videolan.tools.WeakHandler
import org.videolan.vlc.ScanProgress
import org.videolan.vlc.StartActivity
-//import org.videolan.vlc.donations.VLCBilling
import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.Util
@@ -72,17 +74,10 @@ class MainTvActivity : BaseTvActivity() {
val fragmentManager = supportFragmentManager
browseFragment = fragmentManager.findFragmentById(R.id.browse_fragment) as MainTvFragment
progressBar = findViewById(R.id.tv_main_progress)
-// VLCBilling.getInstance(application).retrieveSkus()
-
- if (!Settings.getInstance(this).getBoolean(KEY_TV_ONBOARDING_DONE, false)) {
- // This is the first time running the app, let's go to onboarding
- startActivity(Intent(this, OnboardingActivity::class.java))
- }
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
-// if (VLCBilling.getInstance(this.application).iabHelper.handleActivityResult(requestCode, resultCode, data)) return
if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
when (resultCode) {
RESULT_RESCAN -> this.reloadLibrary()
diff --git a/application/television/src/main/java/org/videolan/television/ui/OnboardingFragment.kt b/application/television/src/main/java/org/videolan/television/ui/OnboardingFragment.kt
index 9abc2a54b..86f24b978 100644
--- a/application/television/src/main/java/org/videolan/television/ui/OnboardingFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/OnboardingFragment.kt
@@ -24,7 +24,7 @@
package org.videolan.television.ui
-import android.content.Context
+import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@@ -32,7 +32,7 @@ import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.leanback.app.OnboardingSupportFragment
-import androidx.leanback.widget.GuidedAction
+import org.videolan.resources.TV_MAIN_ACTIVITY
import org.videolan.resources.util.canReadStorage
import org.videolan.television.R
import org.videolan.tools.KEY_TV_ONBOARDING_DONE
@@ -82,6 +82,8 @@ class OnboardingFragment : OnboardingSupportFragment() {
super.onFinishFragment()
Settings.getInstance(requireActivity()).putSingle(KEY_TV_ONBOARDING_DONE, true)
requireActivity().finish()
+ val intent = Intent(Intent.ACTION_VIEW).setClassName(requireActivity(), TV_MAIN_ACTIVITY)
+ startActivity(intent)
}
override fun onCreateForegroundView(inflater: LayoutInflater?, container: ViewGroup?) = null
diff --git a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
index 89043a63f..5ddb6063a 100644
--- a/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/StartActivity.kt
@@ -33,7 +33,10 @@ import android.util.Log
import androidx.core.net.toUri
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
-import kotlinx.coroutines.*
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.MLServiceLocator
import org.videolan.resources.*
@@ -206,7 +209,7 @@ class StartActivity : FragmentActivity() {
private fun startApplication(tv: Boolean, firstRun: Boolean, upgrade: Boolean, target: Int, removeDevices:Boolean = false) {
val settings = Settings.getInstance(this at StartActivity)
- val onboarding = !tv && !settings.getBoolean(ONBOARDING_DONE_KEY, false)
+ val onboarding = !settings.getBoolean(if (tv) KEY_TV_ONBOARDING_DONE else 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 || !firstRun) {
@@ -229,7 +232,7 @@ class StartActivity : FragmentActivity() {
if (target != 0) mainIntent.putExtra(EXTRA_TARGET, target)
startActivity(mainIntent)
} else {
- startOnboarding()
+ if (!tv) startOnboarding() else startActivity(Intent(Intent.ACTION_VIEW).apply { setClassName(applicationContext, TV_ONBOARDING_ACTIVITY) })
}
}
More information about the Android
mailing list