Chopper f1a59ba618 PeachScan: Deep linking support (#3162)
* Add support to deep linking

* Fix baseUrl

* Remove redirect

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>

---------

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
2024-06-03 05:44:48 +01:00

43 lines
1.3 KiB
Kotlin

package eu.kanade.tachiyomi.multisrc.peachscan
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 PeachScanUrlActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val pathSegments = intent?.data?.pathSegments
if (pathSegments != null && pathSegments.size >= 1) {
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", "${slug(pathSegments)}")
putExtra("filter", packageName)
}
try {
startActivity(mainIntent)
} catch (e: ActivityNotFoundException) {
Log.e("PeachScanUrlActivity", e.toString())
}
} else {
Log.e("PeachScanUrlActivity", "could not parse uri from intent $intent")
}
finish()
exitProcess(0)
}
private fun slug(pathSegments: MutableList<String>): String? {
return if (pathSegments.size >= 1) {
val slug = pathSegments[0]
"${PeachScan.URL_SEARCH_PREFIX}$slug"
} else {
null
}
}
}