Skip to content

Commit

Permalink
Handle kotatsu scheme links
Browse files Browse the repository at this point in the history
  • Loading branch information
Koitharu committed Oct 23, 2023
1 parent 7456961 commit ed9ebdc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@
<data android:host="kotatsu.app" />
<data android:path="/manga" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="kotatsu" />
<data android:host="manga" />
<data android:host="kotatsu.app" />
</intent-filter>
</activity>
<activity
android:name="org.koitharu.kotatsu.reader.ui.ReaderActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class MangaLinkResolver @Inject constructor(
) {

suspend fun resolve(uri: Uri): Manga {
return if (uri.host == "kotatsu.app") {
return if (uri.scheme == "kotatsu" || uri.host == "kotatsu.app") {
resolveAppLink(uri)
} else {
resolveExternalLink(uri)
} ?: throw NotFoundException("Manga not found", uri.toString())
} ?: throw NotFoundException("Cannot resolve link", uri.toString())
}

suspend fun resolveAppLink(uri: Uri): Manga? {
private suspend fun resolveAppLink(uri: Uri): Manga? {
require(uri.pathSegments.singleOrNull() == "manga") { "Invalid url" }
val sourceName = requireNotNull(uri.getQueryParameter("source")) { "Source is not specified" }
val source = MangaSource(sourceName)
Expand All @@ -42,7 +42,7 @@ class MangaLinkResolver @Inject constructor(
)
}

suspend fun resolveExternalLink(uri: Uri): Manga? {
private suspend fun resolveExternalLink(uri: Uri): Manga? {
dataRepository.findMangaByPublicUrl(uri.toString())?.let {
return it
}
Expand Down

0 comments on commit ed9ebdc

Please sign in to comment.