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 a6f7508 commit 3b25416
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 61 deletions.
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.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AiEngineChoiceFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setSystemBarsColors(statusBarColor = R.color.backgroundColor)

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

sharedUtils.manageAiEngineSettings(this, choiceBinding.radioGroup, "promptAiEngine") {
Expand Down
37 changes: 17 additions & 20 deletions app/src/main/java/com/infomaniak/mail/views/InformationBlockView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import com.infomaniak.lib.core.utils.getAttributes
import com.infomaniak.mail.R
Expand All @@ -41,22 +42,28 @@ class InformationBlockView @JvmOverloads constructor(
var title: CharSequence?
get() = binding.informationTitle.text
set(value) {
binding.informationTitle.text = value
binding.informationTitle.isVisible = true
binding.informationTitle.apply {
text = value
isGone = value.isNullOrBlank()
}
}

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

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

var icon: Drawable?
Expand All @@ -67,20 +74,10 @@ 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() }
}
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 Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_no_valid_mailboxes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandard"
android:layout_marginTop="@dimen/marginLarge"
app:button="@string/readFAQ"
app:buttonLabel="@string/readFAQ"
app:description="@string/lockedMailboxScreenDescription"
app:icon="@drawable/ic_warning"
app:layout_constraintTop_toBottomOf="@id/logo"
Expand Down Expand Up @@ -96,7 +96,7 @@
style="@style/BodyMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/marginStandard"
android:layout_marginHorizontal="@dimen/marginStandardMedium"
android:layout_marginTop="@dimen/marginStandard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
68 changes: 31 additions & 37 deletions app/src/main/res/layout/view_information_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,49 @@
android:layout_margin="@dimen/marginStandardMedium"
android:orientation="horizontal">

<TextView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginEnd="@dimen/alternativeMargin"
tools:drawableStartCompat="@drawable/ic_warning" />

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="horizontal">
android:layout_height="wrap_content"
android:divider="@drawable/spacer_standard_medium"
android:orientation="vertical"
android:showDividers="middle">

<TextView
android:id="@+id/icon"
android:id="@+id/informationTitle"
style="@style/BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/alternativeMargin"
tools:drawableStartCompat="@drawable/ic_warning" />
android:visibility="gone"
tools:text="@string/aiErrorTooManyRequests"
tools:visibility="visible" />

<LinearLayout
<TextView
android:id="@+id/informationDescription"
style="@style/Body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@drawable/spacer_standard_medium"
android:orientation="vertical"
android:showDividers="middle">
android:visibility="gone"
tools:text="@string/aiErrorTooManyRequests"
tools:visibility="visible" />

<TextView
android:id="@+id/informationTitle"
style="@style/BodyMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
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"
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"
tools:text="@string/buttonLogInDifferentAccount"
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"
tools:text="@string/buttonLogInDifferentAccount"
tools:visibility="visible" />

</LinearLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<declare-styleable name="InformationBlockView">
<attr name="title" />
<attr name="description" />
<attr name="button" format="string" />
<attr name="buttonLabel" format="string" />
<attr name="icon" />
<attr name="showCloseIcon" format="boolean" />
</declare-styleable>
Expand Down

0 comments on commit 3b25416

Please sign in to comment.