From f1e1aec8487fd148eb8e75fe016a8438958989ad Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 21 Dec 2017 20:55:51 -0500 Subject: misc (#566) * Fix click validator * Update tests * Feature/fb requests (#567) * Add initial requesting interface * Update unit tests and dependencies * Resolve lint * Fix lint 2 * Fix toolbar location, closes #439 * Add prev version code, closes #551 * Clear test val * Update changelog --- .../frost/web/FrostUrlOverlayValidator.kt | 38 ++++------------------ 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt') 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 9255b5bb..253d4801 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -29,15 +29,16 @@ import org.jetbrains.anko.runOnUiThread * as we have no need of sending a new intent to the same activity */ fun FrostWebView.requestWebOverlay(url: String): Boolean { - if (url == "#" || !url.isIndependent) { - L.i("Forbid overlay switch", url) - return false - } + val context = context // finalize reference if (url.isVideoUrl && context is VideoViewHolder) { L.i("Found video", url) - context.runOnUiThread { (context as VideoViewHolder).showVideo(url) } + context.runOnUiThread { context.showVideo(url) } return true } + if (!url.isIndependent) { + L.i("Forbid overlay switch", url) + return false + } if (!Prefs.overlayEnabled) return false if (context is WebOverlayActivityBase) { L.v("Check web request from overlay", url) @@ -55,26 +56,6 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean { L.i("return false switch") return false } - /* - * Non facebook urls can be loaded - */ - if (!url.formattedFbUrl.isFacebookUrl) { - context.launchWebOverlay(url) - L.d("Request web overlay is not a facebook url", url) - return true - } - /* - * Check blacklist - */ - if (overlayBlacklist.any { url.contains(it) }) return false - /* - * Facebook messages have the following cases for the tid query - * mid* or id* for newer threads, which can be launched in new windows - * or a hash for old threads, which must be loaded on old threads - */ - if (url.contains("/messages/read/?tid=")) { - if (!url.contains("?tid=id") && !url.contains("?tid=mid")) return false - } L.v("Request web overlay passed", url) context.launchWebOverlay(url) return true @@ -87,9 +68,4 @@ val messageWhitelist = setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECE val String.shouldUseBasicAgent 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 - */ -val overlayBlacklist = setOf("messages/?pageNum", "photoset_token", "sharer.php") \ No newline at end of file +// get() = (messageWhitelist.any { contains(it) }) || this == FB_URL_BASE \ No newline at end of file -- cgit v1.2.3