Skip to content

Commit

Permalink
Detect firefox.klar as well as firefox.focus
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsalarm committed Sep 10, 2017
1 parent 0507e88 commit be759d6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/src/main/java/com/pr0gramm/app/util/BrowserHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ object BrowserHelper {
}
}

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

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

0 comments on commit be759d6

Please sign in to comment.