aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-19 09:47:05 -0700
committerGitHub <noreply@github.com>2017-08-19 09:47:05 -0700
commit84bf883a47b956865d31b1b618d5495fcd7d4876 (patch)
tree0fb0f83af4862a127bca7d8451ef2c7188a08d83 /app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
parent5d9a3fd7fb8f2f9d0f592c89446824980c9841c6 (diff)
downloadfrost-1.4.7.tar.gz
frost-1.4.7.tar.bz2
frost-1.4.7.zip
v1.4.7 (#195)v1.4.7
* Add try catch (#179) * Add checks before injections (#180) * Enhancement/url redirect manager (#182) * Initial blacklist * Move js checks to java * Optimize imports and clean up request interceptor * Misc (#190) * Update play store description * Finalize description * Update kotlin and bg2 for custom themes * Update to Android Studio 3.0 beta 2 * Update test dependencies and add logging to image activity * Rename throwable to errorRef * Update searchview and media picker through kau * Update themes (#183) * Theme content now found view * Update verified bg and bg2 for transparent themes * Fix check in star text * Various fixes * Create base svg sass images * Feature/theme accent (#192) * Add lots of theming components * Optimize and add * Update accents * Misc 2 (#191) * Add further checks for iab and remove generic error dialog * Theme all snackbars * Add dynamic media action tile * Enhancement/media-camera-picker (#194) * Update kau * Update changelog
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
new file mode 100644
index 00000000..0a1878b3
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -0,0 +1,48 @@
+package com.pitchedapps.frost.web
+
+import android.content.Context
+import com.pitchedapps.frost.facebook.formattedFbUrl
+import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.isFacebookUrl
+import com.pitchedapps.frost.utils.launchWebOverlay
+
+/**
+ * Created by Allan Wang on 2017-08-15.
+ *
+ * Due to the nature of facebook href's, many links
+ * cannot be resolved on a new window and must instead
+ * by loaded in the current page
+ * This helper method will collect all known cases and launch the overlay accordingly
+ * Returns {@code true} (default) if overlay is launcher, {@code false} otherwise
+ */
+fun Context.requestWebOverlay(url: String): Boolean {
+ if (url == "#") return false
+ /*
+ * Non facebook urls can be loaded
+ */
+ if (!url.formattedFbUrl.isFacebookUrl) {
+ 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)
+ launchWebOverlay(url)
+ return true
+}
+
+/**
+ * The following components should never be launched in a new overlay
+ */
+val overlayBlacklist = setOf("messages/?pageNum", "photoset_token") \ No newline at end of file