diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt index 8bda65b90d..d89607843f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt @@ -39,4 +39,14 @@ data class SsoIdentityProvider( * This should be hosted by the homeserver service provider to not leak the client's IP address unnecessarily. */ @Json(name = "icon") val iconUrl: String? -) : Parcelable +) : Parcelable { + + companion object { + // Not really defined by the spec, but we may define some ids here + const val ID_GOOGLE = "google" + const val ID_GITHUB = "github" + const val ID_APPLE = "apple" + const val ID_FACEBOOK = "facebook" + const val ID_TWITTER = "twitter" + } +} diff --git a/vector/src/main/java/im/vector/app/features/login/SocialLoginButtonsView.kt b/vector/src/main/java/im/vector/app/features/login/SocialLoginButtonsView.kt index 5e5ea20d62..9290479a7a 100644 --- a/vector/src/main/java/im/vector/app/features/login/SocialLoginButtonsView.kt +++ b/vector/src/main/java/im/vector/app/features/login/SocialLoginButtonsView.kt @@ -16,7 +16,6 @@ package im.vector.app.features.login -import android.annotation.SuppressLint import android.content.Context import android.util.AttributeSet import android.util.TypedValue @@ -85,22 +84,22 @@ class SocialLoginButtonsView @JvmOverloads constructor(context: Context, attrs: // Use some heuristic to render buttons according to branding guidelines val button: MaterialButton = cachedViews[identityProvider.id] ?: when (identityProvider.id) { - "google" -> { + SsoIdentityProvider.ID_GOOGLE -> { MaterialButton(context, null, R.attr.vctr_social_login_button_google_style) } - "github" -> { + SsoIdentityProvider.ID_GITHUB -> { MaterialButton(context, null, R.attr.vctr_social_login_button_github_style) } - "apple" -> { + SsoIdentityProvider.ID_APPLE -> { MaterialButton(context, null, R.attr.vctr_social_login_button_apple_style) } - "facebook" -> { + SsoIdentityProvider.ID_FACEBOOK -> { MaterialButton(context, null, R.attr.vctr_social_login_button_facebook_style) } - "twitter" -> { + SsoIdentityProvider.ID_TWITTER -> { MaterialButton(context, null, R.attr.vctr_social_login_button_twitter_style) } - else -> { + else -> { // TODO Use iconUrl MaterialButton(context, null, R.attr.materialButtonStyle).apply { transformationMethod = null @@ -119,8 +118,8 @@ class SocialLoginButtonsView @JvmOverloads constructor(context: Context, attrs: private fun getButtonTitle(providerName: String?): String { return when (mode) { - Mode.MODE_SIGN_IN -> context.getString(R.string.login_social_signin_with, providerName) - Mode.MODE_SIGN_UP -> context.getString(R.string.login_social_signup_with, providerName) + Mode.MODE_SIGN_IN -> context.getString(R.string.login_social_signin_with, providerName) + Mode.MODE_SIGN_UP -> context.getString(R.string.login_social_signup_with, providerName) Mode.MODE_CONTINUE -> context.getString(R.string.login_social_continue_with, providerName) } } @@ -130,14 +129,13 @@ class SocialLoginButtonsView @JvmOverloads constructor(context: Context, attrs: gravity = Gravity.CENTER clipToPadding = false clipChildren = false - @SuppressLint("SetTextI18n") if (isInEditMode) { ssoIdentityProviders = listOf( - SsoIdentityProvider("google", "Google", null), - SsoIdentityProvider("facebook", "Facebook", null), - SsoIdentityProvider("apple", "Apple", null), - SsoIdentityProvider("github", "GitHub", null), - SsoIdentityProvider("twitter", "Twitter", null), + SsoIdentityProvider(SsoIdentityProvider.ID_GOOGLE, "Google", null), + SsoIdentityProvider(SsoIdentityProvider.ID_FACEBOOK, "Facebook", null), + SsoIdentityProvider(SsoIdentityProvider.ID_APPLE, "Apple", null), + SsoIdentityProvider(SsoIdentityProvider.ID_GITHUB, "GitHub", null), + SsoIdentityProvider(SsoIdentityProvider.ID_TWITTER, "Twitter", null), SsoIdentityProvider("Custom_pro", "SSO", null) ) }