diff options
author | Allan Wang <me@allanwang.ca> | 2021-09-25 15:55:07 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-09-25 15:55:07 -0700 |
commit | 8db1930d7623ba071123f5978153679da7161278 (patch) | |
tree | 5ce5894c321fae7f0a2f5a9ab65c3dca031db724 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt | |
parent | 1ac15f84b05e83d3c3482cf1498c74123852d658 (diff) | |
download | frost-8db1930d7623ba071123f5978153679da7161278.tar.gz frost-8db1930d7623ba071123f5978153679da7161278.tar.bz2 frost-8db1930d7623ba071123f5978153679da7161278.zip |
Create hilt web file chooser implementation
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt | 13 |
1 files changed, 5 insertions, 8 deletions
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<Boolean> = web.parent.refreshChannel private val progress: SendChannel<Int> = web.parent.progressChannel private val title: SendChannel<String> = 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<Array<Uri>?>, 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() { |