diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
3 files changed, 16 insertions, 8 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 4700c894..71ceb4ca 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -4,6 +4,7 @@ import android.content.Context import android.support.v4.widget.SwipeRefreshLayout import android.webkit.JavascriptInterface import com.pitchedapps.frost.activities.MainActivity +import com.pitchedapps.frost.contracts.VideoViewerContract import com.pitchedapps.frost.dbflow.CookieModel import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.utils.* @@ -36,9 +37,10 @@ class FrostJSI(val webView: FrostWebViewCore) { = if (url == null) false else webView.requestWebOverlay(url) @JavascriptInterface - fun loadVideo(url: String?) { + fun loadVideo(url: String?, isGif: Boolean) { if (url != null) - webView.post { activity?.showVideo(url) } + webView.post { (context as? VideoViewerContract)?.showVideo(url, isGif) + ?: L.d("Could not load video; contract not implemented") } } @JavascriptInterface 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 ac5cde29..334ef51b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -3,13 +3,12 @@ package com.pitchedapps.frost.web import com.pitchedapps.frost.activities.WebOverlayActivity import com.pitchedapps.frost.activities.WebOverlayActivityBase import com.pitchedapps.frost.activities.WebOverlayBasicActivity +import com.pitchedapps.frost.contracts.VideoViewerContract import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.facebook.formattedFbUrl -import com.pitchedapps.frost.utils.L -import com.pitchedapps.frost.utils.isFacebookUrl -import com.pitchedapps.frost.utils.launchWebOverlay +import com.pitchedapps.frost.utils.* /** * Created by Allan Wang on 2017-08-15. @@ -26,6 +25,12 @@ import com.pitchedapps.frost.utils.launchWebOverlay */ fun FrostWebViewCore.requestWebOverlay(url: String): Boolean { if (url == "#") return false + if (url.isVideoUrl && context is VideoViewerContract) { + L.i("Found video", url) + (context as VideoViewerContract).showVideo(url) + return true + } + if (!Prefs.overlayEnabled) return false if (context is WebOverlayActivityBase) { L.v("Check web request from overlay", url) //already overlay; manage user agent @@ -73,7 +78,8 @@ fun FrostWebViewCore.requestWebOverlay(url: String): Boolean { val messageWhitelist = setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECENT, FbItem.FEED_TOP_STORIES).map { it.url }.toSet() val String.shouldUseBasicAgent - get() = (messageWhitelist.any { contains(it) }) || this == FB_URL_BASE + get() = !contains("story.php") //we will use basic agent for anything that isn't a comment section +// get() = (messageWhitelist.any { contains(it) }) || this == FB_URL_BASE /** * The following components should never be launched in a new overlay 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 e3803134..c8c7e2e7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -106,11 +106,11 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient injectBackgroundColor() webCore.jsInject( JsActions.LOGIN_CHECK, - JsAssets.CLICK_A.maybe(Prefs.overlayEnabled), + JsAssets.CLICK_A, JsAssets.TEXTAREA_LISTENER, CssHider.ADS.maybe(!Prefs.showFacebookAds && IS_FROST_PRO), JsAssets.CONTEXT_A, - JsAssets.MEDIA.maybe(webCore.baseEnum != null), + JsAssets.MEDIA, JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null) ) } |