aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-25 00:23:44 -0500
committerGitHub <noreply@github.com>2018-01-25 00:23:44 -0500
commit8bfbbac2b8f364bb03866712b113cd2f5de8b9d9 (patch)
tree8001dd1e467ddd22e4dcec84a9c9e3aa36d2bbb8 /app/src/main/kotlin/com/pitchedapps/frost/web
parent6fe7bd43581d5dfbb85e4e0deb524e65d07b5ce6 (diff)
downloadfrost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.gz
frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.tar.bz2
frost-8bfbbac2b8f364bb03866712b113cd2f5de8b9d9.zip
Enhancement/video (#669)v1.8.0
* Test stricter video extractor * Mess around with mutations * Revert back to strict click listener * Update theme * Update dependencies * Update theme * Create pip toggle * Add pip disabler * Update theme * Update theme
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt18
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt16
3 files changed, 19 insertions, 19 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
index d735fd50..4a3fa2a2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -26,17 +26,19 @@ class FrostJSI(val web: FrostWebView) {
* or {@code false} otherwise, meaning the event should be propagated
*/
@JavascriptInterface
- fun loadUrl(url: String?): Boolean
- = if (url == null) false else web.requestWebOverlay(url)
+ fun loadUrl(url: String?): Boolean = if (url == null) false else web.requestWebOverlay(url)
@JavascriptInterface
- fun loadVideo(url: String?, isGif: Boolean) {
- if (url != null)
- web.post {
- (context as? VideoViewHolder)?.showVideo(url, isGif)
- ?: L.d { "Could not load video; contract not implemented" }
+ fun loadVideo(url: String?, isGif: Boolean): Boolean =
+ if (url != null && Prefs.enablePip) {
+ web.post {
+ (context as? VideoViewHolder)?.showVideo(url, isGif)
+ ?: L.e { "Could not load video; contract not implemented" }
+ }
+ true
+ } else {
+ false
}
- }
@JavascriptInterface
fun reloadBaseUrl(animate: Boolean) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index 6c09de7c..8df5b065 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -31,8 +31,8 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
L.v { "Request web overlay: $url" }
val context = context // finalize reference
if (url.isVideoUrl && context is VideoViewHolder) {
- L.d { "Found video" }
- context.runOnUiThread { context.showVideo(url) }
+ L.d { "Found video through overlay" }
+ context.runOnUiThread { context.showVideo(url.formattedFbUrl) }
return true
}
if (url.isImageUrl) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index f1b30795..4f36fdba 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -27,8 +27,7 @@ import org.jetbrains.anko.withAlpha
*/
open class BaseWebViewClient : WebViewClient() {
- override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse?
- = view.shouldFrostInterceptRequest(request)
+ override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? = view.shouldFrostInterceptRequest(request)
}
@@ -74,7 +73,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
Prefs.themeInjector,
CssHider.NON_RECENT.maybe((web.url?.contains("?sk=h_chr") ?: false)
&& Prefs.aggressiveRecents),
- JsAssets.DOCUMENT_WATCHER)
+ JsAssets.DOCUMENT_WATCHER,
+ JsAssets.CLICK_A,
+ CssHider.ADS.maybe(!Prefs.showFacebookAds && IS_FROST_PRO),
+ JsAssets.CONTEXT_A,
+ JsAssets.MEDIA)
else
refresh.onNext(false)
}
@@ -101,13 +104,8 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
injectBackgroundColor()
web.jsInject(
JsActions.LOGIN_CHECK,
- JsAssets.CLICK_A,
JsAssets.TEXTAREA_LISTENER,
- CssHider.ADS.maybe(!Prefs.showFacebookAds && IS_FROST_PRO),
- JsAssets.CONTEXT_A,
- JsAssets.MEDIA,
- JsAssets.HEADER_BADGES.maybe(web.parent.baseEnum != null)
- )
+ JsAssets.HEADER_BADGES.maybe(isMain))
}
open fun handleHtml(html: String?) {