1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 12:02:33 +01:00

Remove resolveActivity

This commit is contained in:
Allan Wang 2021-09-25 18:45:27 -07:00
parent eb9fc5c6a5
commit 355d8ae268
No known key found for this signature in database
GPG Key ID: 69D90B885D405BDB
3 changed files with 12 additions and 10 deletions

View File

@ -19,6 +19,7 @@ package com.pitchedapps.frost.utils
import android.annotation.SuppressLint
import android.app.Activity
import android.app.ActivityOptions
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.graphics.Color
@ -135,7 +136,7 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay
ctxCoroutine.launch {
fbCookie.logout(this@launchWebOverlayImpl, deleteCookie = false)
}
} else if (!(prefs.linksInDefaultApp && resolveActivityForUri(Uri.parse(argUrl)))) {
} else if (!(prefs.linksInDefaultApp && startActivityForUri(Uri.parse(argUrl)))) {
startActivity<T>(
false,
intentBuilder = {
@ -308,7 +309,7 @@ fun Context.createPrivateMediaFile(extension: String) = createPrivateMediaFile("
* 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 {
fun Context.startActivityForUri(uri: Uri): Boolean {
val url = uri.toString()
if (url.isFacebookUrl && !url.isExplicitIntent) {
return false
@ -317,11 +318,12 @@ fun Context.resolveActivityForUri(uri: Uri): Boolean {
Intent.ACTION_VIEW,
uri.formattedFbUri
)
if (intent.resolveActivity(packageManager) == null) {
return false
return try {
startActivity(intent)
true
} catch (e: ActivityNotFoundException) {
false
}
startActivity(intent)
return true
}
/**

View File

@ -50,7 +50,7 @@ import com.pitchedapps.frost.utils.isImageUrl
import com.pitchedapps.frost.utils.isIndirectImageUrl
import com.pitchedapps.frost.utils.isMessengerUrl
import com.pitchedapps.frost.utils.launchImageActivity
import com.pitchedapps.frost.utils.resolveActivityForUri
import com.pitchedapps.frost.utils.startActivityForUri
import com.pitchedapps.frost.views.FrostWebView
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.launch
@ -253,7 +253,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
v { "Url path $path" }
val url = request.url.toString()
if (url.isExplicitIntent) {
view.context.resolveActivityForUri(request.url)
view.context.startActivityForUri(request.url)
return true
}
if (path.startsWith("/composer/")) {
@ -265,7 +265,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
if (url.isImageUrl) {
return launchImage(url.formattedFbUrl)
}
if (prefs.linksInDefaultApp && view.context.resolveActivityForUri(request.url)) {
if (prefs.linksInDefaultApp && view.context.startActivityForUri(request.url)) {
return true
}
// Convert desktop urls to mobile ones

View File

@ -16,7 +16,7 @@ org.gradle.daemon = true
APP_ID=Frost
APP_GROUP=com.pitchedapps
KAU=6.3.0
KAU=e2ac8e3
android.useAndroidX=true
android.enableJetifier=true