Skip to content

Commit

Permalink
InformationBlockView is now more configurable
Browse files Browse the repository at this point in the history
It now has three optional elements: a title, a description, and a button.
  • Loading branch information
TommyDL-Infomaniak committed Jun 7, 2024
1 parent aafc8c5 commit 8dee4e6
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 38 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ android {
// buildConfigField 'String', 'MAIL_API_PREPROD', '"https://mail.preprod.dev.infomaniak.ch"'
buildConfigField 'String', 'SHOP_URL', '"https://ik.me"'
buildConfigField 'String', 'CHATBOT_URL', '"https://www.infomaniak.com/chatbot"'
buildConfigField 'String', 'FAQ_URL', '"https://www.infomaniak.com/fr/support/faq/admin2/service-mail"'
buildConfigField 'String', 'MANAGE_SIGNATURES_URL', '"https://mail.infomaniak.com/0/settings/signatures"'

buildConfigField 'String', 'BUGTRACKER_MAIL_BUCKET_ID', '"app_mail"'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme.Pink"
android:usesCleartextTraffic="true"
android:usesCleartextTraffic="false"
tools:targetApi="UPSIDE_DOWN_CAKE">

<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class AiPropositionFragment : Fragment() {
}

private fun displayError(status: PropositionStatus) {
binding.errorBlock.setText(status.errorRes!!)
binding.errorBlock.setTitle(status.errorRes!!)
setUiVisibilityState(UiState.ERROR)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
*/
package com.infomaniak.mail.ui.noValidMailboxes

import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import com.infomaniak.lib.core.ui.WebViewActivity
import com.infomaniak.lib.core.utils.safeBinding
import com.infomaniak.lib.core.utils.safeNavigate
import com.infomaniak.mail.BuildConfig
import com.infomaniak.mail.MatomoMail.ADD_MAILBOX_NAME
import com.infomaniak.mail.MatomoMail.trackNoValidMailboxesEvent
import com.infomaniak.mail.R
Expand Down Expand Up @@ -57,6 +60,8 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)

noValidMailboxesBlock.description = resources.getQuantityString(R.plurals.lockedMailboxDescription, 2)

setupAdapters()
setupListeners()

Expand All @@ -76,6 +81,11 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
}

private fun setupListeners() = with(binding) {
noValidMailboxesBlock.setOnInformationClicked {
trackNoValidMailboxesEvent("readFAQ")
context?.let { WebViewActivity.startActivity(it, Uri.parse(BuildConfig.FAQ_URL).toString()) }
}

changeAccountButton.setOnClickListener {
trackNoValidMailboxesEvent("switchAccount")
safeNavigate(NoValidMailboxesFragmentDirections.actionNoValidMailboxesFragmentToSwitchUserFragment())
Expand Down Expand Up @@ -109,9 +119,5 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {

invalidPasswordTitle.text = resources.getQuantityString(R.plurals.blockedPasswordTitle, count)
lockedMailboxTitle.text = lockedMailboxTitleString
noValidMailboxesEmptyState.apply {
title = lockedMailboxTitleString
description = resources.getQuantityText(R.plurals.lockedMailboxDescription, count)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,25 @@ class InformationBlockView @JvmOverloads constructor(

private val binding by lazy { ViewInformationBlockBinding.inflate(LayoutInflater.from(context), this, true) }

private var onInformationClicked: (() -> Unit)? = null
private var onCloseClicked: (() -> Unit)? = null

var text: CharSequence?
get() = binding.informationText.text
var title: CharSequence?
get() = binding.informationTitle.text
set(value) {
binding.informationText.text = value
binding.informationTitle.text = value
}

var description: CharSequence?
get() = binding.informationDescription.text
set(value) {
binding.informationDescription.text = value
}

var button: CharSequence?
get() = binding.informationButton.text
set(value) {
binding.informationButton.text = value
}

var icon: Drawable?
Expand All @@ -52,7 +65,19 @@ class InformationBlockView @JvmOverloads constructor(

init {
attrs?.getAttributes(context, R.styleable.InformationBlockView) {
text = getString(R.styleable.InformationBlockView_text)
binding.informationTitle.apply {
isVisible = getBoolean(R.styleable.InformationBlockView_showTitle, true)
text = getString(R.styleable.InformationBlockView_title)
}
binding.informationDescription.apply {
isVisible = getBoolean(R.styleable.InformationBlockView_showDescription, false)
text = getString(R.styleable.InformationBlockView_description)
}
binding.informationButton.apply {
isVisible = getBoolean(R.styleable.InformationBlockView_showButton, false)
text = getString(R.styleable.InformationBlockView_button)
setOnClickListener { onInformationClicked?.invoke() }
}
icon = getDrawable(R.styleable.InformationBlockView_icon)
binding.closeButton.apply {
isVisible = getBoolean(R.styleable.InformationBlockView_showCloseIcon, false)
Expand All @@ -61,11 +86,23 @@ class InformationBlockView @JvmOverloads constructor(
}
}

fun setOnInformationClicked(listener: () -> Unit) {
onInformationClicked = listener
}

fun setOnCloseListener(listener: () -> Unit) {
onCloseClicked = listener
}

fun setText(@StringRes textRes: Int) {
text = context.getText(textRes)
fun setTitle(@StringRes textRes: Int) {
title = context.getText(textRes)
}

fun setDescription(@StringRes descriptionRes: Int) {
description = context.getText(descriptionRes)
}

fun setButton(@StringRes buttonRes: Int) {
button = context.getText(buttonRes)
}
}
21 changes: 21 additions & 0 deletions app/src/main/res/drawable/spacer_standard_medium.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Infomaniak Mail - Android
~ Copyright (C) 2024 Infomaniak Network SA
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="16dp" />
</shape>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_ai_proposition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
android:visibility="gone"
app:icon="@drawable/ic_warning"
app:showCloseIcon="true"
tools:text="@string/aiErrorTooManyRequests"
tools:title="@string/aiErrorTooManyRequests"
tools:visibility="visible" />

<FrameLayout
Expand Down
24 changes: 16 additions & 8 deletions app/src/main/res/layout/fragment_no_valid_mailboxes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,26 @@
android:layout_marginTop="@dimen/marginStandard"
android:importantForAccessibility="no"
android:src="@drawable/ic_logo_infomaniak_mail"
app:layout_constraintBottom_toTopOf="@id/noValidMailboxesEmptyState"
app:layout_constraintBottom_toTopOf="@id/noValidMailboxesBlock"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<com.infomaniak.mail.ui.main.EmptyStateView
android:id="@+id/noValidMailboxesEmptyState"
<com.infomaniak.mail.views.InformationBlockView
android:id="@+id/noValidMailboxesBlock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandard"
android:layout_marginTop="@dimen/marginLarge"
app:icon="@drawable/ic_invalid_mailbox"
app:layout_constraintTop_toBottomOf="@id/logo"
tools:description="L’accès à vos adresses mail est actuellement bloqué. Nous vous invitons à contacter votre administrateur."
tools:title="Adresses bloquées" />
app:icon="@drawable/ic_warning"
app:showCloseIcon="false"
app:title="@string/lockedMailboxTitleIB"
app:showTitle="true"
tools:description="@string/lockedMailboxTitleIB"
app:showDescription="true"
app:button="@string/readFAQ"
app:showButton="true" />

<TextView
android:id="@+id/invalidPasswordTitle"
Expand All @@ -62,13 +68,14 @@
android:layout_marginTop="@dimen/marginLarge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/noValidMailboxesEmptyState"
app:layout_constraintTop_toBottomOf="@id/noValidMailboxesBlock"
tools:text="Mots de passe bloqués" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/invalidPasswordMailboxesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandardSmall"
android:layout_marginTop="@dimen/marginStandardMedium"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
Expand All @@ -92,7 +99,7 @@
style="@style/BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandardMedium"
android:layout_marginHorizontal="@dimen/marginStandard"
android:layout_marginTop="@dimen/marginStandard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -103,6 +110,7 @@
android:id="@+id/lockedMailboxesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandardSmall"
android:layout_marginTop="@dimen/marginStandardMedium"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_ai_engine_choice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@
android:layout_height="wrap_content"
android:layout_margin="@dimen/marginStandardMedium"
app:icon="@drawable/ic_external_information"
app:text="@string/aiEngineWarning" />
app:title="@string/aiEngineWarning" />
</merge>
33 changes: 29 additions & 4 deletions app/src/main/res/layout/view_information_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,45 @@
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/alternativeMargin"
tools:drawableStartCompat="@drawable/ic_warning" />

<TextView
android:id="@+id/informationText"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/alternativeMargin"
tools:text="@string/aiErrorTooManyRequests" />
android:layout_gravity="center_vertical"
android:showDividers="middle"
android:divider="@drawable/spacer_standard_medium"
android:orientation="vertical">

<TextView
android:id="@+id/informationTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BodyMedium"
tools:text="@string/aiErrorTooManyRequests" />

<TextView
android:id="@+id/informationDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Body.Secondary"
tools:text="@string/aiErrorTooManyRequests" />

<com.google.android.material.button.MaterialButton
android:id="@+id/informationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextButtonSecondary"
tools:text="@string/buttonLogInDifferentAccount" />

</LinearLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/closeButton"
style="@style/IconButtonSmall"
android:layout_marginStart="@dimen/alternativeMargin"
android:visibility="gone"
app:icon="@drawable/ic_close_small"
tools:visibility="visible" />
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,14 @@
<string name="inboxFolder">Posteingang</string>
<string name="loadingText">Laden…</string>
<plurals name="lockedMailboxDescription">
<item quantity="one">Der Zugriff auf Ihre E-Mail-Adresse ist derzeit gesperrt. Bitte wenden Sie sich an Ihren Administrator.</item>
<item quantity="other">Der Zugriff auf Ihre Mailboxen ist derzeit gesperrt. Bitte wenden Sie sich an Ihren Administrator.</item>
<item quantity="one">Der Zugriff auf Ihre E-Mail-Adresse ist derzeit gesperrt.\nFür weitere Informationen, FAQ lesen.</item>
<item quantity="other">Für weitere Informationen:</item>
</plurals>
<plurals name="lockedMailboxTitle">
<item quantity="one">Blockierte E-Mail-Adresse</item>
<item quantity="other">Gesperrte Mailadressen</item>
</plurals>
<string name="lockedMailboxTitleIB">Einige Ihrer Mailboxen sind blockiert</string>
<string name="manageSignatures">Meine Signaturen verwalten</string>
<string name="menuDrawerAdvancedActions">Erweiterte Aktionen</string>
<string name="menuDrawerMailboxStorage">%1$s / %2$s verwendet</string>
Expand Down Expand Up @@ -365,6 +366,7 @@
<string name="pickerNoSelection">Keine Auswahl</string>
<string name="popupDetachMailboxDescription">Sind Sie sicher, dass Sie die Adresse %s lösen möchten?</string>
<string name="popupDetachMailboxTitle">Adresse abtrennen</string>
<string name="readFAQ">FAQ lesen</string>
<string name="readMore">Mehr erfahren</string>
<string name="recentSearchesTitle">Letzte Suchen</string>
<string name="refreshTokenError">Sie wurden abgemeldet</string>
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,14 @@
<string name="inboxFolder">Bandeja de entrada</string>
<string name="loadingText">Cargando…</string>
<plurals name="lockedMailboxDescription">
<item quantity="one">El acceso a su dirección de correo electrónico está bloqueado. Póngase en contacto con su administrador.</item>
<item quantity="other">El acceso a sus buzones de correo está bloqueado. Póngase en contacto con su administrador.</item>
<item quantity="one">El acceso a su dirección de correo electrónico está bloqueado.\nPara más información, lea las preguntas frecuentes.</item>
<item quantity="other">Para más información:</item>
</plurals>
<plurals name="lockedMailboxTitle">
<item quantity="one">Dirección de correo electrónico bloqueada</item>
<item quantity="other">Buzones de correo bloqueados</item>
</plurals>
<string name="lockedMailboxTitleIB">Algunos de sus buzones están bloqueados</string>
<string name="manageSignatures">Gestionar mis firmas</string>
<string name="menuDrawerAdvancedActions">Acciones avanzadas</string>
<string name="menuDrawerMailboxStorage">%1$s / %2$s usado</string>
Expand Down Expand Up @@ -365,6 +366,7 @@
<string name="pickerNoSelection">Sin selección</string>
<string name="popupDetachMailboxDescription">¿Estás seguro de que quieres separar la dirección %s?</string>
<string name="popupDetachMailboxTitle">Separar dirección</string>
<string name="readFAQ">Lea las preguntas frecuentes</string>
<string name="readMore">Seguir leyendo</string>
<string name="recentSearchesTitle">Búsquedas recientes</string>
<string name="refreshTokenError">Ha sido desconectado</string>
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,16 @@
<string name="inboxFolder">Boîte de réception</string>
<string name="loadingText">Chargement…</string>
<plurals name="lockedMailboxDescription">
<item quantity="one">L’accès à votre adresse mail est actuellement bloqué. Nous vous invitons à contacter votre administrateur.</item>
<item quantity="other">L’accès à vos adresses mail est actuellement bloqué. Nous vous invitons à contacter votre administrateur.</item>
<item quantity="one">L’accès à votre adresse mail est actuellement bloqué.\nPour plus d’informations, consultez les FAQ.</item>
<item quantity="other">Pour plus d’informations :</item>
<item quantity="many">L’accès à votre adresse mail est actuellement bloqué. Nous vous invitons à contacter votre administrateur.</item>
</plurals>
<plurals name="lockedMailboxTitle">
<item quantity="one">Adresse mail bloquée</item>
<item quantity="other">Adresses mail bloquées</item>
<item quantity="many">Adresses mail bloquées</item>
</plurals>
<string name="lockedMailboxTitleIB">Certaines de vos adresses mail sont bloquées</string>
<string name="manageSignatures">Gérer mes signatures</string>
<string name="menuDrawerAdvancedActions">Actions avancées</string>
<string name="menuDrawerMailboxStorage">%1$s / %2$s utilisés</string>
Expand Down Expand Up @@ -373,6 +374,7 @@
<string name="pickerNoSelection">Aucune sélection</string>
<string name="popupDetachMailboxDescription">Êtes-vous sûr de vouloir détacher l’adresse %s ?</string>
<string name="popupDetachMailboxTitle">Détacher l’adresse</string>
<string name="readFAQ">Consulter les FAQ</string>
<string name="readMore">En savoir plus</string>
<string name="recentSearchesTitle">Recherches récentes</string>
<string name="refreshTokenError">Vous avez été déconnecté</string>
Expand Down
Loading

0 comments on commit 8dee4e6

Please sign in to comment.