Tsumino - Implement Url Intent and fix sort by newest (#2786)
Tsumino - Implement Url Intent and fix sort by newest
This commit is contained in:
parent
9d30421ef9
commit
32ec0a2eae
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application>
|
||||||
|
<activity
|
||||||
|
android:name=".TsuminoUrlActivity"
|
||||||
|
android:theme="@android:style/Theme.NoDisplay"
|
||||||
|
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:scheme="https"
|
||||||
|
android:host="www.tsumino.com"
|
||||||
|
android:pathPattern="/entry/..*" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: Tsumino'
|
appName = 'Tachiyomi: Tsumino'
|
||||||
pkgNameSuffix = 'en.tsumino'
|
pkgNameSuffix = 'en.tsumino'
|
||||||
extClass = '.Tsumino'
|
extClass = '.Tsumino'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.extension.en.tsumino.TsuminoUtils.Companion.getChapte
|
||||||
import eu.kanade.tachiyomi.extension.en.tsumino.TsuminoUtils.Companion.getDesc
|
import eu.kanade.tachiyomi.extension.en.tsumino.TsuminoUtils.Companion.getDesc
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
import eu.kanade.tachiyomi.network.POST
|
||||||
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
import eu.kanade.tachiyomi.source.model.*
|
import eu.kanade.tachiyomi.source.model.*
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
@ -19,6 +20,7 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import rx.Observable
|
||||||
|
|
||||||
class Tsumino: ParsedHttpSource() {
|
class Tsumino: ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -102,6 +104,25 @@ class Tsumino: ParsedHttpSource() {
|
||||||
return POST("$baseUrl/Search/Operate/", headers, body)
|
return POST("$baseUrl/Search/Operate/", headers, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun searchMangaByIdRequest(id: String) = GET("$baseUrl/entry/$id", headers)
|
||||||
|
|
||||||
|
private fun searchMangaByIdParse(response: Response, id: String): MangasPage {
|
||||||
|
val details = mangaDetailsParse(response)
|
||||||
|
details.url = "/entry/$id"
|
||||||
|
return MangasPage(listOf(details), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||||
|
return if (query.startsWith(PREFIX_ID_SEARCH)) {
|
||||||
|
val id = query.removePrefix(PREFIX_ID_SEARCH)
|
||||||
|
client.newCall(searchMangaByIdRequest(id))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map { response -> searchMangaByIdParse(response, id) }
|
||||||
|
} else {
|
||||||
|
super.fetchSearchManga(page, query, filters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchMangaParse(response: Response): MangasPage = latestUpdatesParse(response)
|
override fun searchMangaParse(response: Response): MangasPage = latestUpdatesParse(response)
|
||||||
|
|
||||||
override fun searchMangaSelector() = latestUpdatesSelector()
|
override fun searchMangaSelector() = latestUpdatesSelector()
|
||||||
|
@ -214,6 +235,7 @@ class Tsumino: ParsedHttpSource() {
|
||||||
class ExcludeParodiesFilter : Filter.CheckBox("Exclude parodies")
|
class ExcludeParodiesFilter : Filter.CheckBox("Exclude parodies")
|
||||||
|
|
||||||
enum class SortType {
|
enum class SortType {
|
||||||
|
Popularity,
|
||||||
Newest,
|
Newest,
|
||||||
Oldest,
|
Oldest,
|
||||||
Alphabetical,
|
Alphabetical,
|
||||||
|
@ -222,7 +244,6 @@ class Tsumino: ParsedHttpSource() {
|
||||||
Views,
|
Views,
|
||||||
Random,
|
Random,
|
||||||
Comments,
|
Comments,
|
||||||
Popularity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class LengthType(val id: Int) {
|
enum class LengthType(val id: Int) {
|
||||||
|
@ -232,4 +253,7 @@ class Tsumino: ParsedHttpSource() {
|
||||||
Long(3)
|
Long(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val PREFIX_ID_SEARCH = "id:"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package eu.kanade.tachiyomi.extension.en.tsumino
|
||||||
|
|
||||||
|
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 https://www.tsumino.com/entry/xxxxx intents and redirects them to
|
||||||
|
* the main Tachiyomi process.
|
||||||
|
*/
|
||||||
|
class TsuminoUrlActivity : Activity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val pathSegments = intent?.data?.pathSegments
|
||||||
|
if (pathSegments != null && pathSegments.size > 1) {
|
||||||
|
val id = pathSegments[1]
|
||||||
|
val mainIntent = Intent().apply {
|
||||||
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
|
putExtra("query", "${Tsumino.PREFIX_ID_SEARCH}$id")
|
||||||
|
putExtra("filter", packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
startActivity(mainIntent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Log.e("TsuminoUrlActivity", e.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("TsuminoUrlActivity", "could not parse uri from intent $intent")
|
||||||
|
}
|
||||||
|
|
||||||
|
finish()
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue