aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-04 17:22:36 -0400
committerGitHub <noreply@github.com>2017-07-04 17:22:36 -0400
commita67f99fcf210792da5e028570efbad61407aeab2 (patch)
tree3a2d617e9d9649828f13e581d8491c0371c67223 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
parent4cf368be0cd2f179485b05a3d2cd9b7bc236ba8e (diff)
downloadfrost-a67f99fcf210792da5e028570efbad61407aeab2.tar.gz
frost-a67f99fcf210792da5e028570efbad61407aeab2.tar.bz2
frost-a67f99fcf210792da5e028570efbad61407aeab2.zip
Dev (#21) - fix search and file chooser
* Fix up search and add file chooser * Fix repeating file chooser
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt16
1 files changed, 7 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
index 00e72cc7..363bf795 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
@@ -2,10 +2,13 @@ package com.pitchedapps.frost.web
import android.net.Uri
import android.webkit.*
+import ca.allanwang.kau.utils.snackbar
+import com.pitchedapps.frost.contracts.ActivityWebContract
import com.pitchedapps.frost.utils.L
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject
+
/**
* Created by Allan Wang on 2017-05-31.
*/
@@ -13,6 +16,7 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() {
val progressObservable: Subject<Int> = webCore.progressObservable
val titleObservable: BehaviorSubject<String> = webCore.titleObservable
+ val activityContract = (webCore.context as? ActivityWebContract)
override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
L.i("Chrome Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}")
@@ -30,15 +34,9 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() {
progressObservable.onNext(newProgress)
}
- override fun onShowFileChooser(webView: WebView, filePathCallback: ValueCallback<Array<Uri>>?, fileChooserParams: FileChooserParams?): Boolean {
- L.d("On show file chooser")
- fileChooserParams?.apply {
- L.d(filenameHint ?: "hi")
- L.d("$mode")
- L.d(acceptTypes.contentToString())
- }
-
- return super.onShowFileChooser(webView, filePathCallback, fileChooserParams)
+ override fun onShowFileChooser(webView: WebView, filePathCallback: ValueCallback<Array<Uri>>, fileChooserParams: FileChooserParams): Boolean {
+ activityContract?.openFileChooser(filePathCallback, fileChooserParams) ?: webView.snackbar("File chooser not found")
+ return activityContract != null
}
override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) {