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

Commit 94f2bdf3 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

feat: display toast error if browser is not present

parent 2a8484c8
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -123,7 +123,11 @@ abstract class OpenIdAuthenticationBaseFragment(private val identityProvider: Id
            return
        }

        viewModel.requestAuthCode(serviceConfiguration, requireActivity().intent)
        val isAuthorizationLaunched = viewModel.requestAuthCode(serviceConfiguration, requireActivity().intent)
        if (!isAuthorizationLaunched) {
            showAuthorizationToast()
            return
        }
        requireActivity().setResult(Activity.RESULT_OK)
        requireActivity().finish()
    }
@@ -204,6 +208,11 @@ abstract class OpenIdAuthenticationBaseFragment(private val identityProvider: Id
        finishActivity()
    }

    private fun showAuthorizationToast() {
        Toast.makeText(requireContext(), R.string.login_oauth_couldnt_open_authorization, Toast.LENGTH_LONG).show()
        finishActivity()
    }

    protected fun getAuthState(): AuthState = viewModel.getAuthState()

    protected fun proceedNext(userName: String, baseUrl: String, cardDavUrl: String? = null) {
+13 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package at.bitfire.davdroid.ui.setup

import android.app.Application
import android.app.PendingIntent
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Build
import androidx.annotation.WorkerThread
@@ -93,7 +94,7 @@ class OpenIdAuthenticationViewModel @Inject constructor(
    fun requestAuthCode(
        serviceConfiguration: AuthorizationServiceConfiguration,
        intent: Intent
    ) {
    ): Boolean {
        authState = AuthState(serviceConfiguration)
        val provider = requireNotNull(identityProvider) { "identityProvider must be set before requestAuthCode()" }

@@ -117,11 +118,17 @@ class OpenIdAuthenticationViewModel @Inject constructor(
            .setLoginHint(sanitizeHint(loginHint))
            .build()

        return try {
            authorizationService.performAuthorizationRequest(
                authRequest,
                createPostAuthorizationIntent(authRequest, intent),
                authorizationService.createCustomTabsIntentBuilder().build()
            )
            true
        } catch (e: ActivityNotFoundException) {
            Logger.log.log(Level.WARNING, "Couldn't start OpenID authorization intent", e)
            false
        }
    }

    private fun sanitizeHint(hint: String?): String? {
+2 −1
Original line number Diff line number Diff line
@@ -498,6 +498,7 @@
    <string name="login_google_client_privacy_policy"><![CDATA[%1$süberträgt Ihre Google-Kontakte und -Kalenderdaten zur Synchronisierung mit diesem Gerät. Siehe auch unsere <a href="%2$s">Datenschutzrichtlinie</a>für mehr Informationen.]]></string>
    <string name="login_google_client_limited_use"><![CDATA[%1$srichtet sich nach der <a href="%2$s">Google API Services Nutzerdaten-Richtlinie</a>, inklusive der eingeschränkten Nutzungsbedingungen.]]></string>
    <string name="login_oauth_couldnt_obtain_auth_code">Authentifizierungscode konnte nicht abgerufen werden</string>
    <string name="login_oauth_couldnt_open_authorization">Autorisierungsseite konnte nicht geöffnet werden</string>
    <string name="settings_oauth">Wieder anmelden</string>
    <string name="settings_oauth_summary">Erneut mit OAuth anmelden</string>
    <string name="settings_username_key">Benutzername</string>
+2 −1
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@
    <string name="login_google_account">Cuenta Google</string>
    <string name="ok">OK</string>
    <string name="login_oauth_couldnt_obtain_auth_code">No se pudo obtener el código de autorización</string>
    <string name="login_oauth_couldnt_open_authorization">No se pudo abrir la página de autorización</string>
    <string name="login_failed">Error al iniciar sesión, inténtalo más tarde</string>
    <string name="login_google_unexpected_warnings">Puede que recibas advertencias inesperadas y/o tengas que crear tu propio ID de cliente.</string>
    <string name="login_nextcloud_login_flow_text">Esto iniciará el flujo de inicio de sesión de Nextcloud en un navegador web.</string>
+2 −1
Original line number Diff line number Diff line
@@ -494,6 +494,7 @@
    <string name="login_google_account">Compte Google</string>
    <string name="login_google">Se connecter avec Google</string>
    <string name="login_oauth_couldnt_obtain_auth_code">N\'a pas pu obtenir le code d\'autorisation</string>
    <string name="login_oauth_couldnt_open_authorization">Impossible d\'ouvrir la page d\'autorisation</string>
    <string name="settings_username_key">nom d\'utilisateur</string>
    <string name="collection_properties_sync_time">Dernièrement synchronisé :</string>
    <string name="collection_properties_sync_time_never">Jamais synchronisé</string>
Loading