Skip to content

Commit

Permalink
feat: updated drawer when the quota is exceeded, nearing or critical
Browse files Browse the repository at this point in the history
  • Loading branch information
joragua committed Oct 10, 2024
1 parent d0da23b commit acf0c49
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
)
}
Expand Down
3 changes: 3 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<string name="drawer_open">Open</string>
<string name="drawer_loading_quota">Loading quota</string>
<string name="drawer_quota">%1$s of %2$s used (%3$s %%)</string>
<string name="drawer_exceeded_quota">%1$s of %2$s used (%3$s %%)\nThe quota is exceeded</string>
<string name="drawer_nearing_quota">%1$s of %2$s used (%3$s %%)\nClose to the quota limit</string>
<string name="drawer_critical_quota">%1$s of %2$s used (%3$s %%)\nVery close to the quota limit</string>
<string name="drawer_unavailable_free_storage">%1$s in use</string>
<string name="drawer_unavailable_used_storage">No storage usage information available</string>
<string name="drawer_feedback">Feedback</string>
Expand Down

0 comments on commit acf0c49

Please sign in to comment.