diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1410f3e96..158500059 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -404,6 +404,13 @@ tools:node="remove" /> + + + + + () private val mutex = Mutex() - init { - ContextCompat.registerReceiver( - context, - object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - val sourceName = intent?.getStringExtra(AppRouter.KEY_SOURCE) ?: return - goAsync { - handleException(MangaSource(sourceName), exception = null, notify = false) - } - } - }, - IntentFilter().apply { addAction(ACTION_DISCARD) }, - ContextCompat.RECEIVER_NOT_EXPORTED, - ) - } - suspend fun handle(exception: CloudFlareException): Boolean = handleException(exception.source, exception, true) suspend fun discard(source: MangaSource) { @@ -251,6 +234,20 @@ class CaptchaHandler @Inject constructor( it.printStackTraceDebug() }.getOrNull() + @AndroidEntryPoint + class DiscardReceiver : BroadcastReceiver() { + + @Inject + lateinit var captchaHandler: CaptchaHandler + + override fun onReceive(context: Context?, intent: Intent?) { + val sourceName = intent?.getStringExtra(AppRouter.KEY_SOURCE) ?: return + goAsync { + captchaHandler.handleException(MangaSource(sourceName), exception = null, notify = false) + } + } + } + companion object { fun ImageRequest.Builder.ignoreCaptchaErrors() = apply {