From d31ad7e18758f3da57b0d83571d2fe1b0384972c Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 23 Sep 2021 12:33:48 +0100 Subject: [PATCH] extracting constants for the pusher kinds and email appId --- .../matrix/android/sdk/api/session/pushers/Pusher.kt | 10 +++++++++- .../internal/session/pushers/DefaultPushersService.kt | 6 +++--- .../app/features/settings/push/PushGatewayItem.kt | 7 +++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt index eed75c9daf..139bd72c6a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushers/Pusher.kt @@ -26,7 +26,15 @@ data class Pusher( val data: PusherData, val state: PusherState -) +) { + companion object { + + const val KIND_EMAIL = "email" + const val KIND_HTTP = "http" + const val APP_ID_EMAIL = "m.email" + + } +} enum class PusherState { UNREGISTERED, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt index de33428adb..999a0c7ee1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/DefaultPushersService.kt @@ -70,7 +70,7 @@ internal class DefaultPushersService @Inject constructor( ) = addPusher( JsonPusher( pushKey = pushkey, - kind = "http", + kind = Pusher.KIND_HTTP, appId = appId, profileTag = profileTag, lang = lang, @@ -84,8 +84,8 @@ internal class DefaultPushersService @Inject constructor( override fun addEmailPusher(email: String, lang: String, emailBranding: String, appDisplayName: String, deviceDisplayName: String) = addPusher( JsonPusher( pushKey = email, - kind = "email", - appId = "m.email", + kind = Pusher.KIND_EMAIL, + appId = Pusher.APP_ID_EMAIL, profileTag = "", lang = lang, appDisplayName = appDisplayName, diff --git a/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt b/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt index ec67e362ee..ee0ef87cc7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt @@ -37,10 +37,9 @@ abstract class PushGatewayItem : EpoxyModelWithHolder() override fun bind(holder: Holder) { super.bind(holder) holder.kind.text = when (pusher.kind) { - // TODO Create const - "http" -> "Http Pusher" - "mail" -> "Email Pusher" - else -> pusher.kind + Pusher.KIND_HTTP -> "Http Pusher" + Pusher.KIND_EMAIL -> "Email Pusher" + else -> pusher.kind } holder.appId.text = pusher.appId