Allow deep linking to add external repo

This commit is contained in:
arkon 2024-01-07 12:25:56 -05:00
parent 8a8362203f
commit f115edf2ea
3 changed files with 65 additions and 32 deletions

View File

@ -8,7 +8,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Storage --> <!-- Storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" /> tools:ignore="ScopedStorage" />
<!-- For background jobs --> <!-- For background jobs -->
@ -21,17 +22,20 @@
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" /> <uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION" />
<!-- To view extension packages in API 30+ --> <!-- To view extension packages in API 30+ -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" <uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" /> tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" <uses-permission
android:name="android.permission.READ_APP_SPECIFIC_LOCALES"
tools:ignore="ProtectedPermissions" /> tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<!-- Remove permission from Firebase dependency --> <!-- Remove permission from Firebase dependency -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" <uses-permission
android:name="com.google.android.gms.permission.AD_ID"
tools:node="remove" /> tools:node="remove" />
<application <application
@ -52,16 +56,30 @@
<activity <activity
android:name=".ui.main.MainActivity" android:name=".ui.main.MainActivity"
android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/Theme.Tachiyomi.SplashScreen" android:theme="@style/Theme.Tachiyomi.SplashScreen">
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<intent-filter> <!-- Deep link to add repos -->
<intent-filter android:label="@string/action_add_repo">
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tachiyomi" />
<data android:host="add-repo" />
</intent-filter>
<!-- Open backup files -->
<intent-filter android:label="@string/pref_restore_backup">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
@ -69,7 +87,6 @@
<data android:scheme="content" /> <data android:scheme="content" />
<data android:host="*" /> <data android:host="*" />
<data android:mimeType="*/*" /> <data android:mimeType="*/*" />
<!-- <!--
Work around Android's ugly primitive PatternMatcher Work around Android's ugly primitive PatternMatcher
implementation that can't cope with finding a . early in implementation that can't cope with finding a . early in
@ -93,16 +110,16 @@
</activity> </activity>
<activity <activity
android:process=":error_handler"
android:name=".crash.CrashActivity" android:name=".crash.CrashActivity"
android:exported="false" /> android:exported="false"
android:process=":error_handler" />
<activity <activity
android:name=".ui.deeplink.DeepLinkActivity" android:name=".ui.deeplink.DeepLinkActivity"
android:launchMode="singleTask" android:exported="true"
android:theme="@android:style/Theme.NoDisplay"
android:label="@string/action_search" android:label="@string/action_search"
android:exported="true"> android:launchMode="singleTask"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" /> <action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
@ -126,20 +143,21 @@
<activity <activity
android:name=".ui.reader.ReaderActivity" android:name=".ui.reader.ReaderActivity"
android:launchMode="singleTask" android:exported="false"
android:exported="false"> android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="com.samsung.android.support.REMOTE_ACTION" /> <action android:name="com.samsung.android.support.REMOTE_ACTION" />
</intent-filter> </intent-filter>
<meta-data android:name="com.samsung.android.support.REMOTE_ACTION" <meta-data
android:resource="@xml/s_pen_actions"/> android:name="com.samsung.android.support.REMOTE_ACTION"
android:resource="@xml/s_pen_actions" />
</activity> </activity>
<activity <activity
android:name=".ui.security.UnlockActivity" android:name=".ui.security.UnlockActivity"
android:theme="@style/Theme.Tachiyomi" android:exported="false"
android:exported="false" /> android:theme="@style/Theme.Tachiyomi" />
<activity <activity
android:name=".ui.webview.WebViewActivity" android:name=".ui.webview.WebViewActivity"
@ -148,25 +166,25 @@
<activity <activity
android:name=".extension.util.ExtensionInstallActivity" android:name=".extension.util.ExtensionInstallActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" android:exported="false"
android:exported="false" /> android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity <activity
android:name=".ui.setting.track.TrackLoginActivity" android:name=".ui.setting.track.TrackLoginActivity"
android:label="@string/track_activity_name" android:exported="true"
android:exported="true"> android:label="@string/track_activity_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:host="anilist-auth"/> <data android:scheme="tachiyomi" />
<data android:host="bangumi-auth"/>
<data android:host="myanimelist-auth"/>
<data android:host="shikimori-auth"/>
<data android:scheme="tachiyomi"/> <data android:host="anilist-auth" />
<data android:host="bangumi-auth" />
<data android:host="myanimelist-auth" />
<data android:host="shikimori-auth" />
</intent-filter> </intent-filter>
</activity> </activity>
@ -206,9 +224,9 @@
<provider <provider
android:name="rikka.shizuku.ShizukuProvider" android:name="rikka.shizuku.ShizukuProvider"
android:authorities="${applicationId}.shizuku" android:authorities="${applicationId}.shizuku"
android:multiprocess="false"
android:enabled="true" android:enabled="true"
android:exported="true" android:exported="true"
android:multiprocess="false"
android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" /> android:permission="android.permission.INTERACT_ACROSS_USERS_FULL" />
<meta-data <meta-data

View File

@ -16,16 +16,22 @@ import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
import tachiyomi.presentation.core.screens.LoadingScreen import tachiyomi.presentation.core.screens.LoadingScreen
class ExtensionReposScreen : Screen() { class ExtensionReposScreen(
private val url: String? = null,
) : Screen() {
@Composable @Composable
override fun Content() { override fun Content() {
val context = LocalContext.current val context = LocalContext.current
val navigator = LocalNavigator.currentOrThrow val navigator = LocalNavigator.currentOrThrow
val screenModel = rememberScreenModel { ExtensionReposScreenModel() }
val screenModel = rememberScreenModel { ExtensionReposScreenModel() }
val state by screenModel.state.collectAsState() val state by screenModel.state.collectAsState()
LaunchedEffect(url) {
url?.let { screenModel.createRepo(it) }
}
if (state is RepoScreenState.Loading) { if (state is RepoScreenState.Loading) {
LoadingScreen() LoadingScreen()
return return

View File

@ -56,6 +56,7 @@ import eu.kanade.presentation.components.AppStateBanners
import eu.kanade.presentation.components.DownloadedOnlyBannerBackgroundColor import eu.kanade.presentation.components.DownloadedOnlyBannerBackgroundColor
import eu.kanade.presentation.components.IncognitoModeBannerBackgroundColor import eu.kanade.presentation.components.IncognitoModeBannerBackgroundColor
import eu.kanade.presentation.components.IndexingBannerBackgroundColor 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.more.settings.screen.data.RestoreBackupScreen
import eu.kanade.presentation.util.AssistContentScreen import eu.kanade.presentation.util.AssistContentScreen
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
@ -446,10 +447,18 @@ class MainActivity : BaseActivity() {
null null
} }
Intent.ACTION_VIEW -> { Intent.ACTION_VIEW -> {
// Handling opening of backup files
if (intent.data.toString().endsWith(".tachibk")) { if (intent.data.toString().endsWith(".tachibk")) {
navigator.popUntilRoot() navigator.popUntilRoot()
navigator.push(RestoreBackupScreen(intent.data.toString())) 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 null
} }
else -> return false else -> return false