Skip to content

Commit be759d6

Browse files
committed
Detect firefox.klar as well as firefox.focus
1 parent 0507e88 commit be759d6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/src/main/java/com/pr0gramm/app/util/BrowserHelper.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,22 @@ object BrowserHelper {
4747
}
4848
}
4949

50-
private val firefoxFocusSupported by memorize<Context, Boolean> { context ->
51-
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"))
52-
intent.`package` = "org.mozilla.focus"
53-
return@memorize context.packageManager.queryIntentActivities(intent, 0).size > 0
50+
private val firefoxFocusPackage by memorize<Context, String?> { context ->
51+
return@memorize listOf("org.mozilla.klar", "org.mozilla.focus").firstOrNull {
52+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"))
53+
intent.`package` = "org.mozilla.focus"
54+
context.packageManager.queryIntentActivities(intent, 0).size > 0
55+
}
5456
}
5557

5658
/**
5759
* Creates a builder with reasonable defaults to create a webview activity.
5860
*/
5961
fun openIncognito(context: Context, url: String) {
6062
// if the firefox focus is installed, we'll open the page in this browser.
61-
if (firefoxFocusSupported(context)) {
63+
firefoxFocusPackage(context)?.let { packageName ->
6264
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
63-
intent.`package` = "org.mozilla.focus"
65+
intent.`package` = packageName
6466
context.startActivity(intent)
6567
return
6668
}

0 commit comments

Comments
 (0)