From 8db1930d7623ba071123f5978153679da7161278 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 25 Sep 2021 15:55:07 -0700 Subject: Create hilt web file chooser implementation --- .../kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt index e687dd2d..61a76e70 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt @@ -30,11 +30,9 @@ import ca.allanwang.kau.permissions.kauRequestPermissions import ca.allanwang.kau.utils.materialDialog import com.afollestad.materialdialogs.callbacks.onDismiss import com.afollestad.materialdialogs.input.input -import com.pitchedapps.frost.R -import com.pitchedapps.frost.contracts.ActivityContract +import com.pitchedapps.frost.contracts.WebFileChooser import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.frostSnackbar import com.pitchedapps.frost.views.FrostWebView import kotlinx.coroutines.channels.SendChannel @@ -49,13 +47,13 @@ import kotlinx.coroutines.channels.SendChannel */ class FrostChromeClient( web: FrostWebView, - private val themeProvider: ThemeProvider + private val themeProvider: ThemeProvider, + private val webFileChooser: WebFileChooser, ) : WebChromeClient() { private val refresh: SendChannel = web.parent.refreshChannel private val progress: SendChannel = web.parent.progressChannel private val title: SendChannel = web.parent.titleChannel - private val activity = (web.context as? ActivityContract) private val context = web.context!! override fun getDefaultVideoPoster(): Bitmap? = @@ -83,9 +81,8 @@ class FrostChromeClient( filePathCallback: ValueCallback?>, fileChooserParams: FileChooserParams ): Boolean { - activity?.openFileChooser(filePathCallback, fileChooserParams) - ?: webView.frostSnackbar(R.string.file_chooser_not_found, themeProvider) - return activity != null + webFileChooser.openMediaPicker(filePathCallback, fileChooserParams) + return true } private fun JsResult.frostCancel() { -- cgit v1.2.3