1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-10 13:02:35 +01:00

Fix self loading

This commit is contained in:
Allan Wang 2017-11-15 04:03:16 -05:00
parent 0b60ad9b70
commit f6499a8741
2 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -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)
}