Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyDL-Infomaniak authored and KevinBoulongne committed Jun 11, 2024
1 parent 680335e commit a6f7508
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class LockedMailboxBottomSheetDialog : InformationBottomSheetDialog() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)

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 @@ -50,9 +50,7 @@ class AiEngineChoiceFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setSystemBarsColors(statusBarColor = R.color.backgroundColor)

choiceBinding.informationBlock.setDescription(R.string.aiEngineWarning)


binding.toolbar.setNavigationOnClickListener { findNavController().popBackStack() }

sharedUtils.manageAiEngineSettings(this, choiceBinding.radioGroup, "promptAiEngine") {
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.setDescription(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 @@ -58,10 +58,6 @@ class NoValidMailboxesFragment : Fragment(), MailboxListFragment {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) = with(binding) {
super.onViewCreated(view, savedInstanceState)

noValidMailboxesBlock.setTitle(R.string.lockedMailboxScreenTitle)
noValidMailboxesBlock.setDescription(R.string.lockedMailboxScreenDescription)
noValidMailboxesBlock.setButton(R.string.readFAQ)

setupAdapters()
setupListeners()

Expand Down
48 changes: 29 additions & 19 deletions app/src/main/java/com/infomaniak/mail/views/InformationBlockView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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.isVisible
import com.infomaniak.lib.core.utils.getAttributes
import com.infomaniak.mail.R
Expand All @@ -39,11 +38,26 @@ class InformationBlockView @JvmOverloads constructor(
private var onActionClicked: (() -> Unit)? = null
private var onCloseClicked: (() -> Unit)? = null

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

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

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

var icon: Drawable?
get() = binding.icon.compoundDrawablesRelative[0]
Expand All @@ -53,7 +67,18 @@ class InformationBlockView @JvmOverloads constructor(

init {
attrs?.getAttributes(context, R.styleable.InformationBlockView) {
binding.informationTitle.apply {
val text = getString(R.styleable.InformationBlockView_title)
if (!text.isNullOrBlank()) title = text
}
binding.informationDescription.apply {
val text = getString(R.styleable.InformationBlockView_description)
if (!text.isNullOrBlank()) description = text
}
binding.informationButton.apply {
val text = getString(R.styleable.InformationBlockView_button)
if (!text.isNullOrBlank()) buttonLabel = text

setOnClickListener { onActionClicked?.invoke() }
}
icon = getDrawable(R.styleable.InformationBlockView_icon)
Expand All @@ -71,19 +96,4 @@ class InformationBlockView @JvmOverloads constructor(
fun setOnCloseListener(listener: () -> Unit) {
onCloseClicked = listener
}

fun setTitle(@StringRes textRes: Int) {
title = context.getText(textRes)
binding.informationTitle.isVisible = true
}

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

fun setButton(@StringRes buttonRes: Int) {
button = context.getText(buttonRes)
binding.informationButton.isVisible = true
}
}
6 changes: 3 additions & 3 deletions app/src/main/res/layout/fragment_no_valid_mailboxes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandard"
android:layout_marginTop="@dimen/marginLarge"
app:button="@string/readFAQ"
app:description="@string/lockedMailboxScreenDescription"
app:icon="@drawable/ic_warning"
app:layout_constraintTop_toBottomOf="@id/logo"
app:showCloseIcon="false"
tools:button="@string/readFAQ"
tools:description="@string/lockedMailboxScreenDescription"
tools:title="@string/lockedMailboxScreenTitle" />
app:title="@string/lockedMailboxScreenTitle" />

<TextView
android:id="@+id/invalidPasswordTitle"
Expand Down
4 changes: 2 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 @@ -46,6 +46,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/marginStandardMedium"
app:icon="@drawable/ic_external_information"
tools:description="@string/aiEngineWarning" />
app:description="@string/aiEngineWarning"
app:icon="@drawable/ic_external_information" />
</merge>
23 changes: 11 additions & 12 deletions app/src/main/res/layout/view_information_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,36 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:showDividers="middle"
android:divider="@drawable/spacer_standard_medium"
android:orientation="vertical">
android:orientation="vertical"
android:showDividers="middle">

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

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

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

</LinearLayout>
</LinearLayout>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
<string name="lockedMailboxBottomSheetDescription">El acceso a su dirección de correo electrónico está bloqueado.\nPara más información, lea las preguntas frecuentes.</string>
<string name="lockedMailboxBottomSheetTitle">La dirección de correo electrónico %s está bloqueada</string>
<string name="lockedMailboxScreenDescription">Para más información:</string>
<string name="lockedMailboxScreenTitle">Algunos de sus buzones están bloqueados</string>
<string name="lockedMailboxScreenTitle">Algunas de sus direcciones de correo electrónico están bloqueadas</string>
<plurals name="lockedMailboxTitle">
<item quantity="one">Dirección de correo electrónico bloqueada</item>
<item quantity="other">Buzones de correo bloqueados</item>
Expand Down

0 comments on commit a6f7508

Please sign in to comment.