diff --git a/src/all/ehentai/AndroidManifest.xml b/src/all/ehentai/AndroidManifest.xml new file mode 100644 index 000000000..632e2699a --- /dev/null +++ b/src/all/ehentai/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/src/all/ehentai/build.gradle b/src/all/ehentai/build.gradle index ca1998bd5..f3a993524 100644 --- a/src/all/ehentai/build.gradle +++ b/src/all/ehentai/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: E-Hentai' pkgNameSuffix = 'all.ehentai' extClass = '.EHFactory' - extVersionCode = 9 + extVersionCode = 10 libVersion = '1.2' } diff --git a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHUrlActivity.kt b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHUrlActivity.kt new file mode 100644 index 000000000..5010414f3 --- /dev/null +++ b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHUrlActivity.kt @@ -0,0 +1,39 @@ +package eu.kanade.tachiyomi.extension.all.ehentai + +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://e-hentai.net/g/xxxxx/yyyyy/ intents and redirects them to + * the main Tachiyomi process. + */ +class EHUrlActivity : 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 key = pathSegments[2] + val mainIntent = Intent().apply { + action = "eu.kanade.tachiyomi.SEARCH" + putExtra("query", "${EHentai.PREFIX_ID_SEARCH}$id/$key") + putExtra("filter", packageName) + } + + try { + startActivity(mainIntent) + } catch (e: ActivityNotFoundException) { + Log.e("EHUrlActivity", e.toString()) + } + } else { + Log.e("EHUrlActivity", "could not parse uri from intent $intent") + } + + finish() + exitProcess(0) + } +} diff --git a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt index a5e206dc8..7ba139cc2 100644 --- a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt +++ b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt @@ -209,6 +209,25 @@ open class EHentai(override val lang: String, private val ehLang: String) : Http } } + private fun searchMangaByIdRequest(id: String) = GET("$baseUrl/g/$id", headers) + + private fun searchMangaByIdParse(response: Response, id: String): MangasPage { + val details = mangaDetailsParse(response) + details.url = "/g/$id/" + return MangasPage(listOf(details), false) + } + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { + 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 chapterListParse(response: Response) = throw UnsupportedOperationException("Unused method was called somehow!") override fun pageListParse(response: Response) = throw UnsupportedOperationException("Unused method was called somehow!") @@ -284,7 +303,7 @@ open class EHentai(override val lang: String, private val ehLang: String) : Http GenreGroup(), AdvancedGroup() ) - + class Watched : Filter.CheckBox("Watched List"), UriFilter { override fun addToUri(builder: Uri.Builder) { if(state) @@ -366,6 +385,7 @@ open class EHentai(override val lang: String, private val ehLang: String) : Http companion object { const val QUERY_PREFIX = "?f_apply=Apply+Filter" + const val PREFIX_ID_SEARCH = "id:" const val TR_SUFFIX = "TR" } }