From f6499a8741b8234770ba61c003f8065da041cdfe Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 15 Nov 2017 04:03:16 -0500 Subject: Fix self loading --- app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 5 ++++- app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 082f4758..d8fa2ce9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -190,9 +190,12 @@ fun Context.createPrivateMediaFile(extension: String) = createPrivateMediaFile(" /** * Tries to send the uri to the proper activity via an intent - * @returns {@code true} if activity is resolved, {@code false} otherwise + * returns [true] if activity is resolved, [false] otherwise + * For safety, any uri that [isFacebookUrl] without [isExplicitIntent] will return [false] */ fun Context.resolveActivityForUri(uri: Uri): Boolean { + val url = uri.toString() + if (url.isFacebookUrl && !url.isExplicitIntent) return false val intent = Intent(Intent.ACTION_VIEW, uri) if (intent.resolveActivity(packageManager) == null) return false startActivity(intent) 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 22b6c0b6..5fc1ab27 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -146,14 +146,13 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : BaseWebViewClient L.v("Url Loading Path", path) val url = request.url.toString() if (url.isExplicitIntent) { - if (!url.contains("com.facebook")) - view.context.resolveActivityForUri(request.url) + view.context.resolveActivityForUri(request.url) return true } if (path.startsWith("/composer/")) return launchRequest(request) if (url.contains("scontent-sea1-1.xx.fbcdn.net") && (path.endsWith(".jpg") || path.endsWith(".png"))) return launchImage(url) - if (Prefs.linksInDefaultApp && !url.isFacebookUrl && view.context.resolveActivityForUri(request.url)) return true + if (Prefs.linksInDefaultApp && view.context.resolveActivityForUri(request.url)) return true return super.shouldOverrideUrlLoading(view, request) } -- cgit v1.2.3