-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MyKSuite-04): Add storage banner (#2184)
- Loading branch information
Showing
14 changed files
with
255 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
app/src/main/java/com/infomaniak/mail/views/itemViews/MyKSuiteStorageBanner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Infomaniak Mail - Android | ||
* Copyright (C) 2025 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/>. | ||
*/ | ||
package com.infomaniak.mail.views.itemViews | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import androidx.annotation.ColorRes | ||
import androidx.annotation.StringRes | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.core.view.isGone | ||
import androidx.core.view.isVisible | ||
import com.infomaniak.mail.R | ||
import com.infomaniak.mail.databinding.ViewBannerMyKsuiteStorageBinding | ||
|
||
class MyKSuiteStorageBanner @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0, | ||
) : ConstraintLayout(context, attrs, defStyleAttr) { | ||
|
||
private val binding by lazy { ViewBannerMyKsuiteStorageBinding.inflate(LayoutInflater.from(context), this, true) } | ||
|
||
var storageLevel = StorageLevel.Normal | ||
set(value) { | ||
binding.root.isGone = value == StorageLevel.Normal | ||
if (value != StorageLevel.Normal) setStorageLevelUi(value) | ||
field = value | ||
} | ||
|
||
|
||
fun setupListener(onCloseButtonClicked: () -> Unit) { | ||
binding.closeButton.setOnClickListener { onCloseButtonClicked() } | ||
} | ||
|
||
private fun setStorageLevelUi(newStorageLevel: StorageLevel) = with(binding) { | ||
if (newStorageLevel == storageLevel) return@with | ||
|
||
title.text = context.getText(newStorageLevel.titleRes) | ||
description.text = context.getText(newStorageLevel.descriptionRes) | ||
alertIcon.setColorFilter(context.getColor(newStorageLevel.iconColorRes)) | ||
|
||
closeButton.isVisible = newStorageLevel == StorageLevel.Warning | ||
} | ||
|
||
enum class StorageLevel( | ||
@ColorRes val iconColorRes: Int, | ||
@StringRes val titleRes: Int, | ||
@StringRes val descriptionRes: Int, | ||
) { | ||
Normal( | ||
iconColorRes = ResourcesCompat.ID_NULL, | ||
titleRes = ResourcesCompat.ID_NULL, | ||
descriptionRes = ResourcesCompat.ID_NULL, | ||
), | ||
Warning( | ||
iconColorRes = R.color.orangeWarning, | ||
titleRes = R.string.myKSuiteQuotasAlertTitle, | ||
descriptionRes = R.string.myKSuiteQuotasAlertDescription, | ||
), | ||
Full( | ||
iconColorRes = R.color.redDestructiveAction, | ||
titleRes = R.string.myKSuiteQuotasAlertFullTitle, | ||
descriptionRes = R.string.myKSuiteQuotasAlertFullDescription, | ||
); | ||
|
||
companion object { | ||
const val WARNING_THRESHOLD = 85 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ Infomaniak Mail - Android | ||
~ Copyright (C) 2025 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/>. | ||
--> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@color/informationBlockBackground" | ||
android:paddingVertical="@dimen/marginStandardSmall" | ||
android:visibility="gone" | ||
tools:visibility="visible"> | ||
|
||
<ImageView | ||
android:id="@+id/alertIcon" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/marginStandardMedium" | ||
android:importantForAccessibility="no" | ||
android:src="@drawable/ic_warning" | ||
app:layout_constraintBottom_toBottomOf="@id/title" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="@id/title" | ||
tools:tint="@color/orange_light" /> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
style="@style/BodySmallMedium" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="@dimen/alternativeMargin" | ||
android:layout_marginEnd="@dimen/marginStandardVerySmall" | ||
app:layout_constraintEnd_toStartOf="@id/closeButton" | ||
app:layout_constraintStart_toEndOf="@id/alertIcon" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="@string/myKSuiteQuotasAlertTitle" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/closeButton" | ||
style="@style/IconButtonSmall" | ||
android:layout_marginEnd="@dimen/marginStandardSmall" | ||
app:icon="@drawable/ic_close_small" | ||
app:layout_constraintBottom_toBottomOf="@id/title" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@id/title" | ||
app:layout_constraintTop_toTopOf="@id/title" /> | ||
|
||
<TextView | ||
android:id="@+id/description" | ||
style="@style/Label" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/marginStandardVerySmall" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="@id/title" | ||
app:layout_constraintStart_toStartOf="@id/title" | ||
app:layout_constraintTop_toBottomOf="@id/title" | ||
tools:text="@string/myKSuiteQuotasAlertDescription" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.