mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-04 16:18:55 +01:00
Allow deep linking to add external repo
This commit is contained in:
@@ -16,16 +16,22 @@ import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
|
||||
class ExtensionReposScreen : Screen() {
|
||||
class ExtensionReposScreen(
|
||||
private val url: String? = null,
|
||||
) : Screen() {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val context = LocalContext.current
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val screenModel = rememberScreenModel { ExtensionReposScreenModel() }
|
||||
|
||||
val screenModel = rememberScreenModel { ExtensionReposScreenModel() }
|
||||
val state by screenModel.state.collectAsState()
|
||||
|
||||
LaunchedEffect(url) {
|
||||
url?.let { screenModel.createRepo(it) }
|
||||
}
|
||||
|
||||
if (state is RepoScreenState.Loading) {
|
||||
LoadingScreen()
|
||||
return
|
||||
|
||||
@@ -56,6 +56,7 @@ import eu.kanade.presentation.components.AppStateBanners
|
||||
import eu.kanade.presentation.components.DownloadedOnlyBannerBackgroundColor
|
||||
import eu.kanade.presentation.components.IncognitoModeBannerBackgroundColor
|
||||
import eu.kanade.presentation.components.IndexingBannerBackgroundColor
|
||||
import eu.kanade.presentation.more.settings.screen.browse.ExtensionReposScreen
|
||||
import eu.kanade.presentation.more.settings.screen.data.RestoreBackupScreen
|
||||
import eu.kanade.presentation.util.AssistContentScreen
|
||||
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
|
||||
@@ -446,10 +447,18 @@ class MainActivity : BaseActivity() {
|
||||
null
|
||||
}
|
||||
Intent.ACTION_VIEW -> {
|
||||
// Handling opening of backup files
|
||||
if (intent.data.toString().endsWith(".tachibk")) {
|
||||
navigator.popUntilRoot()
|
||||
navigator.push(RestoreBackupScreen(intent.data.toString()))
|
||||
}
|
||||
// Deep link to add extension repo
|
||||
else if (intent.scheme == "tachiyomi" && intent.data?.host == "add-repo") {
|
||||
intent.data?.getQueryParameter("url")?.let { repoUrl ->
|
||||
navigator.popUntilRoot()
|
||||
navigator.push(ExtensionReposScreen(repoUrl))
|
||||
}
|
||||
}
|
||||
null
|
||||
}
|
||||
else -> return false
|
||||
|
||||
Reference in New Issue
Block a user