ReaderFront: add URL intent (#10145)
This commit is contained in:
parent
b62726e1a6
commit
f647034957
21
multisrc/overrides/readerfront/default/AndroidManifest.xml
Normal file
21
multisrc/overrides/readerfront/default/AndroidManifest.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="eu.kanade.tachiyomi.extension">
|
||||||
|
<application>
|
||||||
|
<activity android:name="eu.kanade.tachiyomi.multisrc.readerfront.ReaderFrontActivity"
|
||||||
|
android:theme="@android:style/Theme.NoDisplay"
|
||||||
|
android:exported="true"
|
||||||
|
android:excludeFromRecents="true">
|
||||||
|
<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:host="${SOURCEHOST}"/>
|
||||||
|
<data android:host="*.${SOURCEHOST}"/>
|
||||||
|
<data android:pathPattern="/work/..*"
|
||||||
|
android:scheme="${SOURCESCHEME}" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
@ -113,10 +113,21 @@ abstract class ReaderFront(
|
|||||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList) =
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList) =
|
||||||
client.newCall(popularMangaRequest(page)).asObservableSuccess().map { res ->
|
client.newCall(popularMangaRequest(page)).asObservableSuccess().map { res ->
|
||||||
popularMangaParse(res).let { mp ->
|
popularMangaParse(res).let { mp ->
|
||||||
mp.copy(mp.mangas.filter { it.title.contains(query, true) })
|
when {
|
||||||
|
query.isBlank() -> mp
|
||||||
|
!query.startsWith(STUB_QUERY) -> mp.filter {
|
||||||
|
it.title.contains(query, true)
|
||||||
|
}
|
||||||
|
else -> mp.filter {
|
||||||
|
it.url == query.substringAfter(STUB_QUERY)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}!!
|
}!!
|
||||||
|
|
||||||
|
private inline fun MangasPage.filter(predicate: (SManga) -> Boolean) =
|
||||||
|
copy(mangas.filter(predicate))
|
||||||
|
|
||||||
private inline fun <reified T> Response.parse(name: String) =
|
private inline fun <reified T> Response.parse(name: String) =
|
||||||
json.parseToJsonElement(body!!.string()).jsonObject.run {
|
json.parseToJsonElement(body!!.string()).jsonObject.run {
|
||||||
if (containsKey("errors")) {
|
if (containsKey("errors")) {
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package eu.kanade.tachiyomi.multisrc.readerfront
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Springboard that accepts `{baseUrl}/work/{lang}/{stub}`
|
||||||
|
* intents and redirects them to the main Tachiyomi process.
|
||||||
|
*/
|
||||||
|
class ReaderFrontActivity : Activity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val segments = intent?.data?.pathSegments
|
||||||
|
if (segments != null && segments.size > 2) {
|
||||||
|
val activity = Intent().apply {
|
||||||
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
|
putExtra("query", STUB_QUERY + segments[2])
|
||||||
|
putExtra("filter", packageName)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
startActivity(activity)
|
||||||
|
} catch (ex: ActivityNotFoundException) {
|
||||||
|
Log.e("ReaderFrontActivity", ex.message, ex)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("ReaderFrontActivity", "Failed to parse URI from intent: $intent")
|
||||||
|
}
|
||||||
|
finish()
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ class ReaderFrontGenerator : ThemeSourceGenerator {
|
|||||||
|
|
||||||
override val themeClass = "ReaderFront"
|
override val themeClass = "ReaderFront"
|
||||||
|
|
||||||
override val baseVersionCode = 3
|
override val baseVersionCode = 4
|
||||||
|
|
||||||
override val sources = listOf(
|
override val sources = listOf(
|
||||||
MultiLang("Ravens Scans", "https://ravens-scans.com", listOf("es", "en"), true),
|
MultiLang("Ravens Scans", "https://ravens-scans.com", listOf("es", "en"), true),
|
||||||
|
@ -3,6 +3,8 @@ package eu.kanade.tachiyomi.multisrc.readerfront
|
|||||||
private fun String.encodeUri() =
|
private fun String.encodeUri() =
|
||||||
android.net.Uri.encode(trimMargin())!!
|
android.net.Uri.encode(trimMargin())!!
|
||||||
|
|
||||||
|
internal const val STUB_QUERY = "stub:"
|
||||||
|
|
||||||
fun works(lang: Int, sort: String, order: String, page: Int, limit: Int) = """{
|
fun works(lang: Int, sort: String, order: String, page: Int, limit: Int) = """{
|
||||||
|works(
|
|works(
|
||||||
| orderBy: "$order"
|
| orderBy: "$order"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user