diff --git a/src/en/myhentaigallery/AndroidManifest.xml b/src/en/myhentaigallery/AndroidManifest.xml
new file mode 100644
index 000000000..7af6a9403
--- /dev/null
+++ b/src/en/myhentaigallery/AndroidManifest.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/en/myhentaigallery/build.gradle b/src/en/myhentaigallery/build.gradle
index 2d0a9dd63..4ac523c36 100644
--- a/src/en/myhentaigallery/build.gradle
+++ b/src/en/myhentaigallery/build.gradle
@@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MyHentaiGallery'
pkgNameSuffix = 'en.myhentaigallery'
extClass = '.MyHentaiGallery'
- extVersionCode = 1
+ extVersionCode = 2
libVersion = '1.2'
}
diff --git a/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGallery.kt b/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGallery.kt
index 0bc59970e..395143c57 100644
--- a/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGallery.kt
+++ b/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGallery.kt
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.extension.en.myhentaigallery
import eu.kanade.tachiyomi.network.GET
+import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.HttpUrl
@@ -9,6 +10,7 @@ import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
+import rx.Observable
class MyHentaiGallery : ParsedHttpSource() {
@@ -18,7 +20,7 @@ class MyHentaiGallery : ParsedHttpSource() {
override val lang = "en"
- override val supportsLatest = false
+ override val supportsLatest = true
override val client: OkHttpClient = network.cloudflareClient
@@ -42,18 +44,35 @@ class MyHentaiGallery : ParsedHttpSource() {
// Latest
- override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException("Not used")
+ override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/gallery/$page")
- override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used")
+ override fun latestUpdatesSelector() = popularMangaSelector()
- override fun latestUpdatesSelector() = throw UnsupportedOperationException("Not used")
+ override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element)
- override fun latestUpdatesFromElement(element: Element): SManga = throw UnsupportedOperationException("Not used")
-
- override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException("Not used")
+ override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector()
// Search
+ private fun searchMangaByIdRequest(id: String) = GET("$baseUrl/gallery/thumbnails/$id", headers)
+
+ private fun searchMangaByIdParse(response: Response, id: String): MangasPage {
+ val details = mangaDetailsParse(response)
+ details.url = "/gallery/thumbnails/$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 searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return if (query.isNotBlank()) {
GET("$baseUrl/search/$page?query=$query", headers)
@@ -212,4 +231,8 @@ class MyHentaiGallery : ParsedHttpSource() {
Filter.Select(displayName, vals.map { it.first }.toTypedArray()) {
fun toUriPart() = vals[state].second
}
+
+ companion object {
+ const val PREFIX_ID_SEARCH = "id:"
+ }
}
diff --git a/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGalleryUrlActivity.kt b/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGalleryUrlActivity.kt
new file mode 100644
index 000000000..8879c7dce
--- /dev/null
+++ b/src/en/myhentaigallery/src/eu/kanade/tachiyomi/extension/en/myhentaigallery/MyHentaiGalleryUrlActivity.kt
@@ -0,0 +1,38 @@
+package eu.kanade.tachiyomi.extension.en.myhentaigallery
+
+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://myhentaigallery.com/gallery/thumbnails/xxxxx intents and redirects them to
+ * the main Tachiyomi process.
+ */
+class MyHentaiGalleryUrlActivity : Activity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ val pathSegments = intent?.data?.pathSegments
+ if (pathSegments != null && pathSegments.size > 2) {
+ val id = pathSegments[2]
+ val mainIntent = Intent().apply {
+ action = "eu.kanade.tachiyomi.SEARCH"
+ putExtra("query", "${MyHentaiGallery.PREFIX_ID_SEARCH}$id")
+ putExtra("filter", packageName)
+ }
+
+ try {
+ startActivity(mainIntent)
+ } catch (e: ActivityNotFoundException) {
+ Log.e("MyHentaiGalUrlActivity", e.toString())
+ }
+ } else {
+ Log.e("MyHentaiGalUrlActivity", "could not parse uri from intent $intent")
+ }
+
+ finish()
+ exitProcess(0)
+ }
+}