Show account usage on start screen

This commit is contained in:
M66B
2020-10-29 11:06:50 +01:00
parent 5a36462feb
commit 70b868cc41
2 changed files with 20 additions and 1 deletions

View File

@@ -95,6 +95,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private ImageView ivState;
private TextView tvHost;
private TextView tvLast;
private TextView tvUsage;
private TextView tvQuota;
private TextView tvMaxSize;
private TextView tvIdentity;
@@ -121,6 +122,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
ivState = itemView.findViewById(R.id.ivState);
tvHost = itemView.findViewById(R.id.tvHost);
tvLast = itemView.findViewById(R.id.tvLast);
tvUsage = itemView.findViewById(R.id.tvUsage);
tvQuota = itemView.findViewById(R.id.tvQuota);
tvMaxSize = itemView.findViewById(R.id.tvMaxSize);
tvIdentity = itemView.findViewById(R.id.tvIdentity);
@@ -195,6 +197,11 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
"/" + account.keep_alive_ok +
"/" + account.keep_alive_failed +
"/" + account.keep_alive_succeeded : "")));
Integer percent = null;
if (!settings && account.quota_usage != null && account.quota_limit != null)
percent = Math.round((float) account.quota_usage * 100 / account.quota_limit);
tvUsage.setText(percent == null ? null : NF.format(percent) + "%");
tvUsage.setVisibility(percent == null ? View.GONE : View.VISIBLE);
tvQuota.setText(context.getString(R.string.title_storage_quota,
(account.quota_usage == null ? "-" : Helper.humanReadableByteCount(account.quota_usage)),
(account.quota_limit == null ? "-" : Helper.humanReadableByteCount(account.quota_limit))));