Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d469c870 authored by cketti's avatar cketti
Browse files

Display link to support page when signing in with Google

parent 7666714c
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import app.k9mail.core.ui.compose.theme2.MainTheme
import app.k9mail.feature.account.oauth.R
import app.k9mail.feature.account.oauth.ui.AccountOAuthContract.Event
import app.k9mail.feature.account.oauth.ui.AccountOAuthContract.State
import app.k9mail.feature.account.oauth.ui.view.GoogleSignInSupportText
import app.k9mail.feature.account.oauth.ui.view.SignInView

@Composable
@@ -36,11 +37,17 @@ internal fun AccountOAuthContent(
                message = stringResource(id = R.string.account_oauth_loading_message),
            )
        } else if (state.error != null) {
            Column {
                ErrorView(
                    title = stringResource(id = R.string.account_oauth_loading_error),
                    message = state.error.toResourceString(resources),
                    onRetry = { onEvent(Event.OnRetryClicked) },
                )

                if (state.isGoogleSignIn) {
                    GoogleSignInSupportText()
                }
            }
        } else {
            SignInView(
                onSignInClick = { onEvent(Event.SignInClicked) },
+41 −0
Original line number Diff line number Diff line
package app.k9mail.feature.account.oauth.ui.view

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withLink
import androidx.compose.ui.text.withStyle
import app.k9mail.core.ui.compose.common.resources.annotatedStringResource
import app.k9mail.core.ui.compose.designsystem.atom.text.TextBodySmall
import app.k9mail.core.ui.compose.theme2.MainTheme
import app.k9mail.feature.account.oauth.R

private const val GOOGLE_OAUTH_SUPPORT_PAGE = "https://support.thunderbird.net/kb/gmail-thunderbird-android"

@Composable
internal fun GoogleSignInSupportText() {
    val extraText = annotatedStringResource(
        id = R.string.account_oauth_google_sign_in_support_text,
        argument = buildAnnotatedString {
            withStyle(
                style = SpanStyle(
                    color = MainTheme.colors.primary,
                    textDecoration = TextDecoration.Underline,
                ),
            ) {
                withLink(LinkAnnotation.Url(GOOGLE_OAUTH_SUPPORT_PAGE)) {
                    append(stringResource(R.string.account_oauth_google_sign_in_support_text_link_text))
                }
            }
        },
    )

    TextBodySmall(
        text = extraText,
        textAlign = TextAlign.Center,
    )
}
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ internal fun SignInView(
                onClick = onSignInClick,
                enabled = isEnabled,
            )

            GoogleSignInSupportText()
        } else {
            ButtonFilled(
                text = stringResource(id = R.string.account_oauth_sign_in_button),
+4 −0
Original line number Diff line number Diff line
@@ -11,4 +11,8 @@
    <string name="account_oauth_error_not_supported">OAuth 2.0 is currently not supported with this provider.</string>
    <string name="account_oauth_error_browser_not_available">The app couldn\'t find a browser to use for granting access to your account.</string>

    <!-- This is displayed below the "Sign in with Google" button. {placeHolder} will be replaced with the text from account_oauth_google_sign_in_support_text_link_text. -->
    <string name="account_oauth_google_sign_in_support_text">"If you're experiencing problems when signing in with Google, please consult our {placeHolder}."</string>
    <!-- The {placeHolder} in account_oauth_google_sign_in_support_text will be replaced by this text (that, in the user interface, will be a link to the support article). -->
    <string name="account_oauth_google_sign_in_support_text_link_text">support article</string>
</resources>