|
|
|
@ -61,7 +61,6 @@ internal class WebClient(private val mUrlBarController: UrlBarController) : WebV
|
|
|
|
|
|| !TextUtils.equals(url, webViewExt.lastLoadedUrl))
|
|
|
|
|
if (!webViewExt.isIncognito
|
|
|
|
|
&& needsLookup
|
|
|
|
|
&& !request.isRedirect
|
|
|
|
|
&& startActivityForUrl(view, url)) {
|
|
|
|
|
return true
|
|
|
|
|
} else if (webViewExt.requestHeaders.isNotEmpty()) {
|
|
|
|
@ -106,7 +105,6 @@ internal class WebClient(private val mUrlBarController: UrlBarController) : WebV
|
|
|
|
|
} catch (ex: URISyntaxException) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
intent.setPackage(null)
|
|
|
|
|
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_BROWSABLE)
|
|
|
|
|
intent.component = null
|
|
|
|
@ -116,23 +114,23 @@ internal class WebClient(private val mUrlBarController: UrlBarController) : WebV
|
|
|
|
|
// If there only are browsers for this URL, handle it ourselves
|
|
|
|
|
intent = makeHandlerChooserIntent(context, intent, url) ?: return false
|
|
|
|
|
} else {
|
|
|
|
|
val packageName = intent.getPackage()
|
|
|
|
|
var packageName = intent.getPackage()
|
|
|
|
|
if (packageName != null
|
|
|
|
|
&& context.packageManager.resolveActivity(intent, 0) == null) {
|
|
|
|
|
// Explicit intent, but app is not installed - try to redirect to Play Store
|
|
|
|
|
val storeUri = Uri.parse("market://search?q=pname:$packageName")
|
|
|
|
|
if (packageName.equals("com.android.vending")) packageName = Uri.parse(url).getQueryParameter("id")
|
|
|
|
|
val storeUri = Uri.parse("https://play.google.com/store/apps/details?id=$packageName")
|
|
|
|
|
intent = Intent(Intent.ACTION_VIEW, storeUri)
|
|
|
|
|
.addCategory(Intent.CATEGORY_BROWSABLE)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
context.startActivity(intent)
|
|
|
|
|
return true
|
|
|
|
|
} catch (e: ActivityNotFoundException) {
|
|
|
|
|
Snackbar.make(view, context.getString(R.string.error_no_activity_found),
|
|
|
|
|
Snackbar.LENGTH_LONG).show()
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun makeHandlerChooserIntent(context: Context, intent: Intent, url: String): Intent? {
|
|
|
|
|