RS add url intent (#14404)

This commit is contained in:
Henrik 2022-12-01 04:50:43 +01:00 committed by GitHub
parent b6320edfcf
commit d938c3ceb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 2 deletions

View File

@ -1,2 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="eu.kanade.tachiyomi.extension" />
<manifest package="eu.kanade.tachiyomi.extension" xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name=".en.reaperscans.ReaperScansUrlActivity"
android:excludeFromRecents="true"
android:exported="true"
android:theme="@android:style/Theme.NoDisplay">
<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="reaperscans.com"
android:pathPattern="/comics/..*"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -6,7 +6,7 @@ ext {
extName = 'Reaper Scans'
pkgNameSuffix = 'en.reaperscans'
extClass = '.ReaperScans'
extVersionCode = 39
extVersionCode = 40
}
apply from: "$rootDir/common.gradle"

View File

@ -30,6 +30,7 @@ import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
import uy.kohesive.injekt.injectLazy
import java.util.Calendar
import java.util.concurrent.TimeUnit
@ -149,6 +150,19 @@ class ReaperScans : ParsedHttpSource() {
}
}
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
if (query.startsWith(PREFIX_ID_SEARCH)) {
val realUrl = "/comics/" + query.removePrefix(PREFIX_ID_SEARCH)
val manga = SManga.create().apply {
url = realUrl
}
return fetchMangaDetails(manga).map {
MangasPage(listOf(it.apply { url = realUrl }), false)
}
}
return super.fetchSearchManga(page, query, filters)
}
// Details
override fun mangaDetailsParse(document: Document): SManga {
return SManga.create().apply {
@ -317,5 +331,6 @@ class ReaperScans : ParsedHttpSource() {
companion object {
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaType()
const val PREFIX_ID_SEARCH = "id:"
}
}

View File

@ -0,0 +1,34 @@
package eu.kanade.tachiyomi.extension.en.reaperscans
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.util.Log
import kotlin.system.exitProcess
class ReaperScansUrlActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val pathSegments = intent?.data?.pathSegments
if (pathSegments != null && pathSegments.size >= 2) {
val id = pathSegments[1]
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", ReaperScans.PREFIX_ID_SEARCH + id)
putExtra("filter", packageName)
}
try {
startActivity(mainIntent)
} catch (e: ActivityNotFoundException) {
Log.e("ReaperScansUrlActivity", e.toString())
}
} else {
Log.e("ReaperScansUrlActivity", "could not parse uri from intent $intent")
}
finish()
exitProcess(0)
}
}