From ca67319093da9827e376b3a193fbaa8a84e1642f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolo=CC=80=20Tosi?= Date: Tue, 16 Jan 2024 18:19:26 +0100 Subject: [PATCH] Fixed mail and jobs offering links on unauthorized login error page --- .idea/deploymentTargetDropDown.xml | 5 ++- .../onboarding/AuthorizationErrorFragment.kt | 43 ++++++++++++++++--- .../it/bz/noi/community/utils/TextUtils.kt | 15 +++++++ app/src/main/res/values-de/strings.xml | 18 +++++--- app/src/main/res/values-en/strings.xml | 15 ++++++- app/src/main/res/values-it/strings.xml | 18 +++++--- app/src/main/res/values/constants.xml | 12 ++++++ app/src/main/res/values/strings.xml | 15 ++++++- app/src/main/res/values/themes.xml | 2 +- 9 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/values/constants.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 8577582..0003733 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -2,6 +2,9 @@ + + + @@ -15,7 +18,7 @@ - + diff --git a/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt b/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt index 4d5170e..fa9f822 100644 --- a/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt +++ b/app/src/main/java/it/bz/noi/community/ui/onboarding/AuthorizationErrorFragment.kt @@ -4,25 +4,28 @@ package it.bz.noi.community.ui.onboarding +import android.content.Intent +import android.net.Uri import android.os.Bundle -import android.util.Log +import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.activity.addCallback import androidx.appcompat.app.AppCompatActivity -import androidx.fragment.app.Fragment -import androidx.fragment.app.activityViewModels +import androidx.core.content.ContextCompat +import androidx.core.text.buildSpannedString import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import androidx.navigation.fragment.findNavController -import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.firebase.crashlytics.FirebaseCrashlytics import it.bz.noi.community.R import it.bz.noi.community.databinding.FragmentAuthorizationErrorBinding import it.bz.noi.community.oauth.AuthManager import it.bz.noi.community.oauth.AuthStateStatus -import it.bz.noi.community.utils.Status +import it.bz.noi.community.utils.addClickableSpan +import it.bz.noi.community.utils.addLinkSpan import it.bz.noi.community.utils.getAppVersion import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @@ -64,6 +67,36 @@ class AuthorizationErrorFragment : BaseOnboardingFragment() { binding.appVersion.tvAppVersion.text = getAppVersion() + binding.message.apply { + movementMethod = LinkMovementMethod.getInstance() + text = buildSpannedString { + append(getString(R.string.outsider_user_body)) + val jobsSnippet = getString(R.string.outsider_user_body_link_1_part) + addClickableSpan(jobsSnippet) { + try { + startActivity(Intent(Intent.ACTION_VIEW).apply { + data = Uri.parse(getString(R.string.url_jobs_noi_techpark)) + }) + } catch (ex: Exception) { + FirebaseCrashlytics.getInstance().recordException(ex) + } + } + addLinkSpan(jobsSnippet, ContextCompat.getColor(requireContext(), R.color.secondary_color)) + + val emailSnippet = getString(R.string.community_email_address_link) + addClickableSpan(emailSnippet) { + try { + startActivity(Intent(Intent.ACTION_SENDTO).apply { + data = Uri.parse(getString(R.string.community_email_address)) + }) + } catch (ex: Exception) { + FirebaseCrashlytics.getInstance().recordException(ex) + } + } + addLinkSpan(emailSnippet, ContextCompat.getColor(requireContext(), R.color.secondary_color)) + } + } + viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.status.collectLatest { status -> diff --git a/app/src/main/java/it/bz/noi/community/utils/TextUtils.kt b/app/src/main/java/it/bz/noi/community/utils/TextUtils.kt index bd7831f..30ff934 100644 --- a/app/src/main/java/it/bz/noi/community/utils/TextUtils.kt +++ b/app/src/main/java/it/bz/noi/community/utils/TextUtils.kt @@ -6,8 +6,10 @@ package it.bz.noi.community.utils import android.text.SpannableStringBuilder import android.text.style.ClickableSpan +import android.text.style.ForegroundColorSpan import android.text.style.URLSpan import android.view.View +import androidx.annotation.ColorInt fun SpannableStringBuilder.addClickableSpan(substring: String, onClick: () -> Unit) { val start = indexOf(substring).takeIf { @@ -26,6 +28,19 @@ fun SpannableStringBuilder.addClickableSpan(substring: String, onClick: () -> Un ) } +fun SpannableStringBuilder.addLinkSpan(substring: String, @ColorInt color: Int) { + val start = indexOf(substring).takeIf { + it >= 0 + } ?: return + val end = start + substring.length + setSpan( + ForegroundColorSpan(color), + start, + end, + SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE + ) +} + fun SpannableStringBuilder.addLinkSpan(substring: String, url: String) { val start = indexOf(substring).takeIf { it >= 0 diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index afdb5fb..de79610 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -4,6 +4,14 @@ SPDX-FileCopyrightText: NOI Techpark SPDX-License-Identifier: CC0-1.0 --> + + Hallo %1$s (%2$s), du verfügst nicht über die Berechtigung, diese App zu nutzen. Bitte kontaktiere dein Personalbüro, um mehr zu erfahren. Hallo, du hast ein gültiges Open Data Hub- oder NOI-Konto und bist eingeloggt, aber dir fehlen die Berechtigungen für den Zugriff auf die Community App. Schreib an community@noi.bz.it, um mehr zu erfahren. @@ -104,15 +112,14 @@ SPDX-License-Identifier: CC0-1.0 Datenschutzrichtlinie Oh no! Hoppla, das hat leider nicht geklappt! - Die angegebene E-Mail-Adresse scheint in unserer Datenbank nicht auf. -\n -\nDiese App ist den Mitgliedern der NOI-Community vorbehalten. Wenn du Teil davon bist, prüfe bitte die angegebene E-Mail-Adresse und versuch es noch einmal oder schreib eine E-Mail an community@noi.bz.it. - + Die angegebene E-Mail-Adresse scheint in unserer Datenbank nicht auf. \n \nDiese App ist den Mitgliedern der NOI-Community vorbehalten. Wenn du Teil davon bist, prüfe bitte die angegebene E-Mail-Adresse und versuch es noch einmal. Klappt es dann immer noch nicht, schreib uns bitte eine E-Mail an community@noi.bz.it. \n \nDu möchtest auch zur NOI-Community gehören? Hier geht’s zu unseren Job-Angeboten. + Job-Angeboten Hallo! Deine Anmeldung war erfolgreich - Herzlich willkommen in der NOI-Community App! \n\nNeu im NOI? Schau dich in unserem Community Manual um, wo wir nützliche Infos für dich zusammengetragen haben. + Herzlich willkommen in der NOI-Community App! \n \nNeu im NOI? Schau dich in unserem Community Manual um, wo wir nützliche Infos für dich zusammengetragen haben. Du findest es unter \"more\" im Menüpunkt \"Come on Board\". Diese Nachricht nicht mehr anzeigen Alles klar + Jobs https://noi.bz.it/de https://noi.bz.it/de/privacy-cookie-policy https://noi.bz.it/de/unternehmen @@ -132,4 +139,5 @@ SPDX-License-Identifier: CC0-1.0 https://forms.office.com/Pages/ResponsePage.aspx?id=R_WstlLDCEenJewOZixdERIOZ0hE1k5LlWwUM_AXhdlUQUVFR0c1MThYUUw3T1lTMFJZNjkxU05SWi4u&embed=true https://play.google.com/store/apps/details?id=it.bz.noi.community https://noi.bz.it/de/datenschutz-app + https://noi.bz.it/de/jobs-noi-techpark diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 6cda99f..505f254 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -4,6 +4,14 @@ SPDX-FileCopyrightText: NOI Techpark SPDX-License-Identifier: CC0-1.0 --> + + Hi %1$s (%2$s), you are not authorised to use this app. Please contact your HR office for more information. Hi, you have a valid Open Data Hub- or NOI-Account and you are logged in, but you miss the permissions to access the Community App. Please write to community@noi.bz.it to learn more. @@ -104,12 +112,14 @@ SPDX-License-Identifier: CC0-1.0 Privacy policy Oh no! Oops, that didn\'t work! - The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again, or send an e-mail to community@noi.bz.it. + The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! + here Hello! Your registration has been successful - Welcome to the NOI-Community App!\n\nNew to NOI? Take a look at our Community Manual, where we have compiled useful information for you. + Welcome to the NOI-Community App!\n\nNew to NOI? Take a look at our Community Manual, where we have compiled useful information for you. You can find it in the \"More\" menu, under \"Come on Board\". Don\'t show again Understood + Jobs https://noi.bz.it/en https://noi.bz.it/en/privacy-cookie-policy https://noi.bz.it/en/companies @@ -129,4 +139,5 @@ SPDX-License-Identifier: CC0-1.0 https://forms.office.com/Pages/ResponsePage.aspx?id=R_WstlLDCEenJewOZixdERIOZ0hE1k5LlWwUM_AXhdlUQUVFR0c1MThYUUw3T1lTMFJZNjkxU05SWi4u&embed=true https://play.google.com/store/apps/details?id=it.bz.noi.community https://noi.bz.it/en/privacy-app + https://noi.bz.it/en/jobs-noi-techpark diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 1f6f5b7..8f8ae6d 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -4,6 +4,14 @@ SPDX-FileCopyrightText: NOI Techpark SPDX-License-Identifier: CC0-1.0 --> + + Ciao %1$s (%2$s),\nnon sei autorizzato all\'uso dell\'app.\n\nPer saperne di più contatta il tuo ufficio personale. Ciao, hai un account Open Data Hub o NOI valido e sei loggato, ma non hai i permessi per accedere alla Community App. Scrivi a community@noi.bz.it per saperne di più. @@ -104,15 +112,14 @@ SPDX-License-Identifier: CC0-1.0 Informativa sulla privacy Oh no! Ops, qualcosa è andato storto! - L\'indirizzo e-mail inserito non è presente nel nostro database. -\n -\nQuesta app è riservata ai membri della NOI-Community. Se ne fai parte, controlla l\'indirizzo e-mail inserito e riprova oppure invia un\'e-mail a community@noi.bz.it. -\n + L\'indirizzo e-mail inserito non è presente nel nostro database. \n \nQuesta app è riservata ai membri della NOI-Community. Se ne fai parte, controlla l\'indirizzo e-mail inserito e riprova. Se il problema persiste, invia un\'e-mail a community@noi.bz.it. \n \nVorresti entrare a far parte della NOI-Community? Clicca qui per le nostre offerte di lavoro. + offerte di lavoro Ciao! La tua registrazione è andata a buon fine - Ti diamo il benvenuto nell\'app della NOI-\nCommunity!\n\nQui al NOl è tutto nuovo per te? Dai un\'occhiata al nostro Community Manual, dove abbiamo raccolto informazioni utili per te. + Ti diamo il benvenuto nell\'app della NOI-\nCommunity!\n\nQui al NOI è tutto nuovo per te? Dai un’occhiata al nostro Community Manual, dove abbiamo raccolto informazioni utili per te. Lo trovi in \"More\" sotto \"Come on Board\". Grazie, non mostratemelo più Ho capito + Jobs https://noi.bz.it/it https://noi.bz.it/it/privacy-cookie-policy https://noi.bz.it/it/aziende @@ -132,4 +139,5 @@ SPDX-License-Identifier: CC0-1.0 https://forms.office.com/Pages/ResponsePage.aspx?id=R_WstlLDCEenJewOZixdERIOZ0hE1k5LlWwUM_AXhdlUQUVFR0c1MThYUUw3T1lTMFJZNjkxU05SWi4u&embed=true https://play.google.com/store/apps/details?id=it.bz.noi.community https://noi.bz.it/it/privacy-app + https://noi.bz.it/it/jobs-noi-techpark diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml new file mode 100644 index 0000000..ae749e5 --- /dev/null +++ b/app/src/main/res/values/constants.xml @@ -0,0 +1,12 @@ + + + + + + community@noi.bz.it + mailto:community@noi.bz.it + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6cda99f..98bb02a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,6 +4,14 @@ SPDX-FileCopyrightText: NOI Techpark SPDX-License-Identifier: CC0-1.0 --> + + Hi %1$s (%2$s), you are not authorised to use this app. Please contact your HR office for more information. Hi, you have a valid Open Data Hub- or NOI-Account and you are logged in, but you miss the permissions to access the Community App. Please write to community@noi.bz.it to learn more. @@ -104,12 +112,14 @@ SPDX-License-Identifier: CC0-1.0 Privacy policy Oh no! Oops, that didn\'t work! - The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again, or send an e-mail to community@noi.bz.it. + The e-mail address you provided does not exist in our database. \n \nThis app is reserved for members of the NOI-Community. If you are one of them, please check the e-mail address you entered and try again. It it still doesn’t work, please email us at community@noi.bz.it. \n \nWant to join the NOI-Community? Click here for our job offers! + here Hello! Your registration has been successful - Welcome to the NOI-Community App!\n\nNew to NOI? Take a look at our Community Manual, where we have compiled useful information for you. + Welcome to the NOI-Community App!\n\nNew to NOI? Take a look at our Community Manual, where we have compiled useful information for you. You can find it in the \"More\" menu, under \"Come on Board\". Don\'t show again Understood + Jobs https://noi.bz.it/en https://noi.bz.it/en/privacy-cookie-policy https://noi.bz.it/en/companies @@ -129,4 +139,5 @@ SPDX-License-Identifier: CC0-1.0 https://forms.office.com/Pages/ResponsePage.aspx?id=R_WstlLDCEenJewOZixdERIOZ0hE1k5LlWwUM_AXhdlUQUVFR0c1MThYUUw3T1lTMFJZNjkxU05SWi4u&embed=true https://play.google.com/store/apps/details?id=it.bz.noi.community https://noi.bz.it/en/privacy-app + https://noi.bz.it/en/jobs-noi-techpark diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 776d414..0d34097 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -12,8 +12,8 @@ SPDX-License-Identifier: CC0-1.0 @color/background_color @color/background_color @color/primary_color - @color/primary_color @color/background_color + @color/primary_color @color/primary_color @color/background_color