diff options
author | Allan Wang <me@allanwang.ca> | 2019-12-30 12:18:46 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-12-30 12:18:46 -0800 |
commit | c4afa99d44c94dd9f95ed74f57e00466cd431d18 (patch) | |
tree | 95d426513e3dc466b1ab2568275e078b9cc075b7 /app/src/main | |
parent | 999e87a8c879d8112e62baf45cbe4e876d35b9cc (diff) | |
download | frost-c4afa99d44c94dd9f95ed74f57e00466cd431d18.tar.gz frost-c4afa99d44c94dd9f95ed74f57e00466cd431d18.tar.bz2 frost-c4afa99d44c94dd9f95ed74f57e00466cd431d18.zip |
Use MaterialDialog for webviews
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt | 72 | ||||
-rw-r--r-- | app/src/main/play/en-US/whatsnew | 4 | ||||
-rw-r--r-- | app/src/main/res/values/colors.xml | 1 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/xml/frost_changelog.xml | 2 |
5 files changed, 80 insertions, 3 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 9577aeb0..03bfacd5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt @@ -19,11 +19,16 @@ package com.pitchedapps.frost.web import android.net.Uri import android.webkit.ConsoleMessage import android.webkit.GeolocationPermissions +import android.webkit.JsPromptResult +import android.webkit.JsResult import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebView import ca.allanwang.kau.permissions.PERMISSION_ACCESS_FINE_LOCATION 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.utils.L @@ -73,6 +78,73 @@ class FrostChromeClient(web: FrostWebView) : WebChromeClient() { return activity != null } + override fun onJsAlert( + view: WebView, + url: String, + message: String, + result: JsResult + ): Boolean { + view.context.materialDialog { + title(text = url) + message(text = message) + positiveButton { result.confirm() } + onDismiss { result.cancel() } + } + return true + } + + override fun onJsConfirm( + view: WebView, + url: String, + message: String, + result: JsResult + ): Boolean { + view.context.materialDialog { + title(text = url) + message(text = message) + positiveButton { result.confirm() } + negativeButton { result.cancel() } + onDismiss { result.cancel() } + } + return true + } + + override fun onJsBeforeUnload( + view: WebView, + url: String, + message: String, + result: JsResult + ): Boolean { + view.context.materialDialog { + title(text = url) + message(text = message) + positiveButton { result.confirm() } + negativeButton { result.cancel() } + onDismiss { result.cancel() } + } + return true + } + + override fun onJsPrompt( + view: WebView, + url: String, + message: String, + defaultValue: String?, + result: JsPromptResult + ): Boolean { + view.context.materialDialog { + title(text = url) + message(text = message) + input(prefill = defaultValue) { _, charSequence -> + result.confirm(charSequence.toString()) + } + // positive button added through input + negativeButton { result.cancel() } + onDismiss { result.cancel() } + } + return true + } + override fun onGeolocationPermissionsShowPrompt( origin: String, callback: GeolocationPermissions.Callback diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index e8ecee32..a7a34ee3 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -3,4 +3,6 @@ v2.4.2 * Fix back stack history * Fix search suggestions * Redesign navigation layout -* Update theme
\ No newline at end of file +* Update theme +* Open formatted urls from context menu +* Allow copying text with emojis
\ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4c685908..1f1f0872 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,6 +2,7 @@ <resources> <color name="frost_splash_background">@color/facebook_blue</color> <color name="facebook_blue">#3b5998</color> + <color name="facebook_blue_light">#6183C8</color> <color name="facebook_blue_dark">#2e4b86</color> <color name="frost_notification_accent">@color/facebook_blue</color> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f17d005c..f4fa9e6c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -3,7 +3,7 @@ <style name="FrostTheme" parent="Theme.MaterialComponents.NoActionBar"> <item name="colorPrimary">@color/facebook_blue</item> <item name="colorPrimaryDark">@color/facebook_blue_dark</item> - <item name="colorAccent">@android:color/white</item> + <item name="colorAccent">@color/facebook_blue_light</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowBackground">@null</item> <item name="android:windowSoftInputMode">adjustResize</item> @@ -14,7 +14,7 @@ <style name="FrostTheme.Light" parent="Theme.MaterialComponents.Light.NoActionBar"> <item name="colorPrimary">@color/facebook_blue</item> <item name="colorPrimaryDark">@color/facebook_blue_dark</item> - <item name="colorAccent">@android:color/black</item> + <item name="colorAccent">@color/facebook_blue</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowBackground">@null</item> <item name="android:windowSoftInputMode">adjustResize</item> diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index 4f2ed1b0..746112ae 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -11,6 +11,8 @@ <item text="Fix search suggestions" /> <item text="Redesign navigation layout" /> <item text="Update theme" /> + <item text="Open formatted urls from context menu" /> + <item text="Allow copying text with emojis" /> <item text="" /> <version title="v2.4.1" /> |