Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more customisation to InformationBlockView and change NoValidMailboxesFragment layout #1893

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .idea/navEditor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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"'
TommyDL-Infomaniak marked this conversation as resolved.
Show resolved Hide resolved
buildConfigField 'String', 'MANAGE_SIGNATURES_URL', '"https://mail.infomaniak.com/0/settings/signatures"'

buildConfigField 'String', 'BUGTRACKER_MAIL_BUCKET_ID', '"app_mail"'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme.Pink"
android:usesCleartextTraffic="true"
tools:replace="android:usesCleartextTraffic"
tools:targetApi="UPSIDE_DOWN_CAKE">

<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class LockedMailboxBottomSheetDialog : InformationBottomSheetDialog() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)

title.text = getString(R.string.blockedMailboxTitle, navigationArgs.lockedMailboxName)
description.text = resources.getQuantityText(R.plurals.lockedMailboxDescription, 1)
title.text = getString(R.string.lockedMailboxBottomSheetTitle, navigationArgs.lockedMailboxName)
description.text = getString(R.string.lockedMailboxBottomSheetDescription)
infoIllustration.setBackgroundResource(R.drawable.ic_invalid_mailbox)

actionButton.apply {
setText(R.string.buttonClose)
setText(R.string.externalDialogConfirmButton)
setOnClickListener { dismiss() }
}

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.description = getString(status.errorRes!!)
setUiVisibilityState(UiState.ERROR)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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.MatomoMail.ADD_MAILBOX_NAME
Expand Down Expand Up @@ -76,6 +77,11 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
}

private fun setupListeners() = with(binding) {
noValidMailboxesBlock.setOnActionClicked {
trackNoValidMailboxesEvent("readFAQ")
WebViewActivity.startActivity(requireContext(), getString(R.string.faqUrl))
}

changeAccountButton.setOnClickListener {
trackNoValidMailboxesEvent("switchAccount")
safeNavigate(NoValidMailboxesFragmentDirections.actionNoValidMailboxesFragmentToSwitchUserFragment())
Expand Down Expand Up @@ -109,9 +115,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 @@ -22,7 +22,7 @@ import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import androidx.annotation.StringRes
import androidx.core.view.isGone
import androidx.core.view.isVisible
import com.infomaniak.lib.core.utils.getAttributes
import com.infomaniak.mail.R
Expand All @@ -36,12 +36,34 @@ class InformationBlockView @JvmOverloads constructor(

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

private var onActionClicked: (() -> 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.apply {
text = value
isGone = value.isNullOrBlank()
}
}

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

var buttonLabel: CharSequence?
get() = binding.informationButton.text
set(value) {
binding.informationButton.apply {
text = value
isGone = value.isNullOrBlank()
}
}

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

init {
attrs?.getAttributes(context, R.styleable.InformationBlockView) {
text = getString(R.styleable.InformationBlockView_text)
title = getString(R.styleable.InformationBlockView_title)
description = getString(R.styleable.InformationBlockView_description)
buttonLabel = getString(R.styleable.InformationBlockView_buttonLabel)
binding.informationButton.setOnClickListener { onActionClicked?.invoke() }
icon = getDrawable(R.styleable.InformationBlockView_icon)
binding.closeButton.apply {
isVisible = getBoolean(R.styleable.InformationBlockView_showCloseIcon, false)
Expand All @@ -61,11 +86,11 @@ class InformationBlockView @JvmOverloads constructor(
}
}

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

fun setText(@StringRes textRes: Int) {
text = context.getText(textRes)
fun setOnCloseListener(listener: () -> Unit) {
onCloseClicked = listener
}
}
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:description="@string/aiErrorTooManyRequests"
tools:visibility="visible" />

<FrameLayout
Expand Down
21 changes: 14 additions & 7 deletions app/src/main/res/layout/fragment_no_valid_mailboxes.xml
TommyDL-Infomaniak marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,23 @@
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:buttonLabel="@string/readFAQ"
app:description="@string/lockedMailboxScreenDescription"
app:icon="@drawable/ic_warning"
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:showCloseIcon="false"
app:title="@string/lockedMailboxScreenTitle" />

<TextView
android:id="@+id/invalidPasswordTitle"
Expand All @@ -62,13 +65,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 Down Expand Up @@ -103,6 +107,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 All @@ -118,6 +123,7 @@
android:visibility="gone"
app:constraint_referenced_ids="lockedMailboxTitle,lockedMailboxesRecyclerView"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

Expand All @@ -143,4 +149,5 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 3 additions & 2 deletions app/src/main/res/layout/layout_ai_engine_choice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
</com.infomaniak.mail.ui.main.settings.SettingRadioGroupView>

<com.infomaniak.mail.views.InformationBlockView
android:id="@+id/informationBlock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/marginStandardMedium"
app:icon="@drawable/ic_external_information"
app:text="@string/aiEngineWarning" />
app:description="@string/aiEngineWarning"
app:icon="@drawable/ic_external_information" />
</merge>
Loading
Loading