diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt index 01900ab0f0b..f29845d9eda 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt @@ -8,6 +8,7 @@ * @author Abel García de Prada * @author Juan Carlos Garrote Gascón * @author Aitor Ballesteros Pavon + * @author Jorge Aguado Recio * * Copyright (C) 2024 ownCloud GmbH. * @@ -321,11 +322,56 @@ abstract class DrawerActivity : ToolbarActivity() { } + userQuota.state == "exceeded" -> { + getAccountQuotaBar()?.run { + isVisible = true + progress = 100 + } + getAccountQuotaText()?.run { + text = String.format( + getString(R.string.drawer_exceeded_quota), + DisplayUtils.bytesToHumanReadable(userQuota.used, context), + DisplayUtils.bytesToHumanReadable(userQuota.total, context), + userQuota.getRelative() + ) + } + } + userQuota.available == 0L -> { // Quota 0, guest users getAccountQuotaBar()?.isVisible = false getAccountQuotaText()?.text = getString(R.string.drawer_unavailable_used_storage) } + userQuota.state == "nearing" -> { + getAccountQuotaBar()?.run { + isVisible = true + progress = ceil(userQuota.getRelative()).toInt() + } + getAccountQuotaText()?.run { + text = String.format( + getString(R.string.drawer_nearing_quota), + DisplayUtils.bytesToHumanReadable(userQuota.used, context), + DisplayUtils.bytesToHumanReadable(userQuota.total, context), + userQuota.getRelative() + ) + } + } + + userQuota.state == "critical" -> { + getAccountQuotaBar()?.run { + isVisible = true + progress = ceil(userQuota.getRelative()).toInt() + } + getAccountQuotaText()?.run { + text = String.format( + getString(R.string.drawer_critical_quota), + DisplayUtils.bytesToHumanReadable(userQuota.used, context), + DisplayUtils.bytesToHumanReadable(userQuota.total, context), + userQuota.getRelative() + ) + } + } + else -> { // Limited quota // Update progress bar rounding up to next int. Example: quota is 0.54 => 1 getAccountQuotaBar()?.run { @@ -335,7 +381,7 @@ abstract class DrawerActivity : ToolbarActivity() { getAccountQuotaText()?.text = String.format( getString(R.string.drawer_quota), DisplayUtils.bytesToHumanReadable(userQuota.used, this), - DisplayUtils.bytesToHumanReadable(userQuota.getTotal(), this), + DisplayUtils.bytesToHumanReadable(userQuota.total, this), userQuota.getRelative() ) } diff --git a/owncloudApp/src/main/res/values/strings.xml b/owncloudApp/src/main/res/values/strings.xml index 330de68d944..592c91d9331 100644 --- a/owncloudApp/src/main/res/values/strings.xml +++ b/owncloudApp/src/main/res/values/strings.xml @@ -30,6 +30,9 @@ Open Loading quota %1$s of %2$s used (%3$s %%) + %1$s of %2$s used (%3$s %%)\nThe quota is exceeded + %1$s of %2$s used (%3$s %%)\nClose to the quota limit + %1$s of %2$s used (%3$s %%)\nVery close to the quota limit %1$s in use No storage usage information available Feedback