Prevent users from using Element FOSS on homeservers that enforce the usage of Element Pro.
This commit is contained in:
@@ -165,6 +165,7 @@ fun Context.startSharePlainTextIntent(
|
||||
fun Context.openUrlInExternalApp(
|
||||
url: String,
|
||||
errorMessage: String = getString(R.string.error_no_compatible_app_found),
|
||||
throwInCaseOfError: Boolean = false,
|
||||
) {
|
||||
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
|
||||
if (this !is Activity) {
|
||||
@@ -173,10 +174,27 @@ fun Context.openUrlInExternalApp(
|
||||
try {
|
||||
startActivity(intent)
|
||||
} catch (activityNotFoundException: ActivityNotFoundException) {
|
||||
if (throwInCaseOfError) throw activityNotFoundException
|
||||
toast(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open Google Play on the provided application Id.
|
||||
*/
|
||||
fun Context.openGooglePlay(
|
||||
appId: String,
|
||||
) {
|
||||
try {
|
||||
openUrlInExternalApp(
|
||||
url = "market://details?id=$appId",
|
||||
throwInCaseOfError = true,
|
||||
)
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
openUrlInExternalApp("https://play.google.com/store/apps/details?id=$appId")
|
||||
}
|
||||
}
|
||||
|
||||
// Not in KTX anymore
|
||||
fun Context.toast(resId: Int) {
|
||||
Toast.makeText(this, resId, Toast.LENGTH_SHORT).show()
|
||||
|
||||
Reference in New Issue
Block a user