Storage space warning settings/accounts

This commit is contained in:
M66B 2022-04-22 22:08:44 +02:00
parent 0a46b9113d
commit e35cbf2c90
4 changed files with 16 additions and 6 deletions

View File

@ -262,14 +262,22 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
account.backoff_until == null ? "-" : DTF.format(account.backoff_until)));
tvBackoff.setVisibility(account.backoff_until == null || !settings ? View.GONE : View.VISIBLE);
Integer percent = (settings ? null : account.getQuotaPercentage());
tvUsage.setText(percent == null ? null : NF.format(percent) + "%");
tvUsage.setVisibility(percent == null || compact ? View.GONE : View.VISIBLE);
Integer percent = account.getQuotaPercentage();
boolean warning = (percent != null && percent > EntityAccount.QUOTA_WARNING);
tvUsage.setText(settings || percent == null ? null : NF.format(percent) + "%");
tvUsage.setVisibility(settings || percent == null || (compact && !warning) ? 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))));
tvQuota.setVisibility(settings && (account.quota_usage != null || account.quota_limit != null) ? View.VISIBLE : View.GONE);
tvUsage.setTextColor(warning ? colorWarning : textColorSecondary);
tvUsage.setTypeface(warning ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
tvQuota.setTextColor(warning ? colorWarning : textColorSecondary);
tvQuota.setTypeface(warning ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
tvMaxSize.setText(account.max_size == null ? null : Helper.humanReadableByteCount(account.max_size));
tvMaxSize.setVisibility(settings && account.max_size != null && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
if (tvMaxSize.getVisibility() == View.VISIBLE)

View File

@ -76,8 +76,6 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
private NumberFormat NF = NumberFormat.getNumberInstance();
private DateFormat TF;
private static final int QUOTA_WARNING = 95; // percent
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
private View view;
private ImageView ivItem;
@ -182,7 +180,7 @@ public class AdapterNavAccountFolder extends RecyclerView.Adapter<AdapterNavAcco
ivWarning.setImageResource(R.drawable.twotone_warning_24);
ivWarning.setVisibility(expanded ? View.VISIBLE : View.GONE);
view.setBackgroundColor(expanded ? Color.TRANSPARENT : colorWarning);
} else if (percent != null && percent > QUOTA_WARNING && account.folderName == null) {
} else if (percent != null && percent > EntityAccount.QUOTA_WARNING && account.folderName == null) {
ivWarning.setImageResource(R.drawable.twotone_disc_full_24);
ivWarning.setVisibility(expanded ? View.VISIBLE : View.GONE);
view.setBackgroundColor(expanded ? Color.TRANSPARENT : colorWarning);

View File

@ -60,6 +60,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
static final int DEFAULT_POLL_INTERVAL = 15; // minutes
static final int DEFAULT_MAX_MESSAGES = 250; // POP3
static final int QUOTA_WARNING = 95; // percent
static final int TYPE_IMAP = 0;
static final int TYPE_POP = 1;

View File

@ -204,6 +204,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:drawablePadding="6dp"
android:drawableTint="?attr/colorWarning"
android:ellipsize="start"
android:singleLine="true"
android:text="123/456 MB"