Prevent users from using Element FOSS on homeservers that enforce the usage of Element Pro.

This commit is contained in:
Benoit Marty
2025-08-05 16:55:39 +02:00
parent 0b895f631d
commit 2dec34374e
24 changed files with 556 additions and 36 deletions

View File

@@ -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()