show disk usage if no quota is set

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2018-08-14 15:03:59 +02:00 committed by AndyScherzinger
parent c2f0a72ce5
commit 0f9e95ad95
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 25 additions and 14 deletions

View file

@ -30,6 +30,7 @@ import android.accounts.AccountManagerFuture;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -800,21 +801,30 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
/** /**
* configured the quota to be displayed. * configured the quota to be displayed.
*
* @param usedSpace the used space * @param usedSpace the used space
* @param totalSpace the total space * @param totalSpace the total space
* @param relative the percentage of space already used * @param relative the percentage of space already used
* @param quotaValue {@link GetRemoteUserInfoOperation#SPACE_UNLIMITED} or other to determinate state
*/ */
private void setQuotaInformation(long usedSpace, long totalSpace, int relative) { private void setQuotaInformation(long usedSpace, long totalSpace, int relative, long quotaValue) {
updateQuotaLink();
if (GetRemoteUserInfoOperation.SPACE_UNLIMITED == quotaValue) {
mQuotaProgressBar.setProgress(0);
ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, Color.GRAY);
mQuotaTextPercentage.setText(String.format(
getString(R.string.drawer_quota_unlimited),
DisplayUtils.bytesToHumanReadable(usedSpace)));
} else {
mQuotaProgressBar.setProgress(relative); mQuotaProgressBar.setProgress(relative);
ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative)); ThemeUtils.colorHorizontalProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
updateQuotaLink();
mQuotaTextPercentage.setText(String.format( mQuotaTextPercentage.setText(String.format(
getString(R.string.drawer_quota), getString(R.string.drawer_quota),
DisplayUtils.bytesToHumanReadable(usedSpace), DisplayUtils.bytesToHumanReadable(usedSpace),
DisplayUtils.bytesToHumanReadable(totalSpace))); DisplayUtils.bytesToHumanReadable(totalSpace)));
}
showQuota(true); showQuota(true);
} }
@ -966,16 +976,16 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (quotaValue > 0 if (quotaValue > 0 || quotaValue == GetRemoteUserInfoOperation.SPACE_UNLIMITED
|| quotaValue == GetRemoteUserInfoOperation.QUOTA_LIMIT_INFO_NOT_AVAILABLE) { || quotaValue == GetRemoteUserInfoOperation.QUOTA_LIMIT_INFO_NOT_AVAILABLE) {
/** /*
* show quota in case * show quota in case
* it is available and calculated (> 0) or * it is available and calculated (> 0) or
* in case of legacy servers (==QUOTA_LIMIT_INFO_NOT_AVAILABLE) * in case of legacy servers (==QUOTA_LIMIT_INFO_NOT_AVAILABLE)
*/ */
setQuotaInformation(used, total, relative); setQuotaInformation(used, total, relative, quotaValue);
} else { } else {
/** /*
* quotaValue < 0 means special cases like * quotaValue < 0 means special cases like
* {@link RemoteGetUserQuotaOperation.SPACE_NOT_COMPUTED}, * {@link RemoteGetUserQuotaOperation.SPACE_NOT_COMPUTED},
* {@link RemoteGetUserQuotaOperation.SPACE_UNKNOWN} or * {@link RemoteGetUserQuotaOperation.SPACE_UNKNOWN} or

View file

@ -31,6 +31,7 @@
<string name="drawer_item_activities">Activities</string> <string name="drawer_item_activities">Activities</string>
<string name="drawer_item_notifications">Notifications</string> <string name="drawer_item_notifications">Notifications</string>
<string name="drawer_quota">%1$s of %2$s used</string> <string name="drawer_quota">%1$s of %2$s used</string>
<string name="drawer_quota_unlimited">%1$s used</string>
<string name="drawer_close">Close sidebar</string> <string name="drawer_close">Close sidebar</string>
<string name="drawer_open">Open sidebar</string> <string name="drawer_open">Open sidebar</string>
<string name="prefs_category_general">General</string> <string name="prefs_category_general">General</string>