Improve openUrlInExternalApp API and move url to UnifiedPushConfig
This commit is contained in:
parent
b372a2af2d
commit
496e0ea566
3 changed files with 5 additions and 4 deletions
|
|
@ -156,10 +156,9 @@ fun Context.startSharePlainTextIntent(
|
||||||
fun Context.openUrlInExternalApp(
|
fun Context.openUrlInExternalApp(
|
||||||
url: String,
|
url: String,
|
||||||
errorMessage: String = getString(R.string.error_no_compatible_app_found),
|
errorMessage: String = getString(R.string.error_no_compatible_app_found),
|
||||||
inNewTask: Boolean = false,
|
|
||||||
) {
|
) {
|
||||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||||
if (inNewTask) {
|
if (this !is Activity) {
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ object UnifiedPushConfig {
|
||||||
*/
|
*/
|
||||||
const val DEFAULT_PUSH_GATEWAY_HTTP_URL: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify"
|
const val DEFAULT_PUSH_GATEWAY_HTTP_URL: String = "https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify"
|
||||||
|
|
||||||
|
const val UNIFIED_PUSH_DISTRIBUTORS_URL = "https://unifiedpush.org/users/distributors/"
|
||||||
|
|
||||||
const val INDEX = 1
|
const val INDEX = 1
|
||||||
const val NAME = "UnifiedPush"
|
const val NAME = "UnifiedPush"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.libraries.androidutils.system.openUrlInExternalApp
|
import io.element.android.libraries.androidutils.system.openUrlInExternalApp
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
import io.element.android.libraries.di.ApplicationContext
|
||||||
|
import io.element.android.libraries.pushproviders.unifiedpush.UnifiedPushConfig
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
interface OpenDistributorWebPageAction {
|
interface OpenDistributorWebPageAction {
|
||||||
|
|
@ -34,8 +35,7 @@ class DefaultOpenDistributorWebPageAction @Inject constructor(
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
// Open the distributor download page
|
// Open the distributor download page
|
||||||
context.openUrlInExternalApp(
|
context.openUrlInExternalApp(
|
||||||
url = "https://unifiedpush.org/users/distributors/",
|
url = UnifiedPushConfig.UNIFIED_PUSH_DISTRIBUTORS_URL,
|
||||||
inNewTask = true
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue