Fix loading repositories from browser

This commit is contained in:
Blatzar 2022-08-15 17:03:06 +02:00
parent 5a351e1fe3
commit 7eb0c83dc5
3 changed files with 44 additions and 17 deletions

View file

@ -40,7 +40,9 @@
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME" android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" /> android:value="com.lagradost.cloudstream3.utils.CastOptionsProvider" />
<profileable android:shell="true" tools:targetApi="q" /> <profileable
android:shell="true"
tools:targetApi="q" />
<activity <activity
android:name=".ui.player.DownloadedPlayerActivity" android:name=".ui.player.DownloadedPlayerActivity"
@ -64,11 +66,16 @@
<data android:mimeType="*/*" /> <data android:mimeType="*/*" />
</intent-filter> </intent-filter>
</activity> </activity>
<!--
android:launchMode="singleTask"
is a bit experimental, it makes loading repositories from browser still stay on the same page
no idea about side effects
-->
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation" android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:exported="true" android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true" android:resizeableActivity="true"
android:supportsPictureInPicture="true"> android:supportsPictureInPicture="true">
<intent-filter android:exported="true"> <intent-filter android:exported="true">

View file

@ -16,6 +16,7 @@ import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.Some import com.lagradost.cloudstream3.mvvm.Some
import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observe
@ -51,6 +52,21 @@ class ExtensionsFragment : Fragment() {
private val extensionViewModel: ExtensionsViewModel by activityViewModels() private val extensionViewModel: ExtensionsViewModel by activityViewModels()
override fun onResume() {
super.onResume()
afterRepositoryLoadedEvent += ::reloadRepositories
}
override fun onStop() {
super.onStop()
afterRepositoryLoadedEvent -= ::reloadRepositories
}
private fun reloadRepositories(success: Boolean = true) {
extensionViewModel.loadStats()
extensionViewModel.loadRepositories()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
//context?.fixPaddingStatusbar(extensions_root) //context?.fixPaddingStatusbar(extensions_root)
@ -160,6 +176,7 @@ class ExtensionsFragment : Fragment() {
dialog.repo_url_input?.setText(fixedUrl) dialog.repo_url_input?.setText(fixedUrl)
} }
} }
dialog.list_repositories?.setOnClickListener { dialog.list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST) openBrowser(PUBLIC_REPOSITORIES_LIST)
} }
@ -189,7 +206,6 @@ class ExtensionsFragment : Fragment() {
} }
} }
extensionViewModel.loadStats() reloadRepositories()
extensionViewModel.loadRepositories()
} }
} }

View file

@ -15,6 +15,7 @@ import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIE
import com.lagradost.cloudstream3.ui.settings.extensions.PUBLIC_REPOSITORIES_LIST import com.lagradost.cloudstream3.ui.settings.extensions.PUBLIC_REPOSITORIES_LIST
import com.lagradost.cloudstream3.ui.settings.extensions.PluginsViewModel import com.lagradost.cloudstream3.ui.settings.extensions.PluginsViewModel
import com.lagradost.cloudstream3.ui.settings.extensions.RepoAdapter import com.lagradost.cloudstream3.ui.settings.extensions.RepoAdapter
import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
import kotlinx.android.synthetic.main.fragment_extensions.* import kotlinx.android.synthetic.main.fragment_extensions.*
import kotlinx.android.synthetic.main.fragment_setup_media.* import kotlinx.android.synthetic.main.fragment_setup_media.*
@ -52,18 +53,20 @@ class SetupFragmentExtensions : Fragment() {
} }
private fun setRepositories(success: Boolean = true) { private fun setRepositories(success: Boolean = true) {
val repositories = RepositoryManager.getRepositories() + PREBUILT_REPOSITORIES main {
val hasRepos = repositories.isNotEmpty() val repositories = RepositoryManager.getRepositories() + PREBUILT_REPOSITORIES
repo_recycler_view?.isVisible = hasRepos val hasRepos = repositories.isNotEmpty()
blank_repo_screen?.isVisible = !hasRepos repo_recycler_view?.isVisible = hasRepos
blank_repo_screen?.isVisible = !hasRepos
if (hasRepos) { if (hasRepos) {
repo_recycler_view?.adapter = RepoAdapter(true, {}, { repo_recycler_view?.adapter = RepoAdapter(true, {}, {
PluginsViewModel.downloadAll(activity, it.url, null) PluginsViewModel.downloadAll(activity, it.url, null)
}).apply { updateList(repositories) } }).apply { updateList(repositories) }
} else { } else {
list_repositories?.setOnClickListener { list_repositories?.setOnClickListener {
openBrowser(PUBLIC_REPOSITORIES_LIST) openBrowser(PUBLIC_REPOSITORIES_LIST)
}
} }
} }
} }
@ -84,14 +87,15 @@ class SetupFragmentExtensions : Fragment() {
next_btt?.setOnClickListener { next_btt?.setOnClickListener {
// Continue setup // Continue setup
println("ISSETUP $isSetup")
if (isSetup) if (isSetup)
findNavController().navigate(R.id.action_navigation_setup_extensions_to_navigation_setup_provider_languages) findNavController().navigate(R.id.action_navigation_setup_extensions_to_navigation_setup_provider_languages)
else else
findNavController().popBackStack() findNavController().navigate(R.id.navigation_home)
} }
prev_btt?.setOnClickListener { prev_btt?.setOnClickListener {
findNavController().popBackStack() findNavController().navigate(R.id.navigation_setup_language)
} }
} }
} }