mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
f3f80b46c0
commit
0d56d9f79d
|
@ -192,8 +192,8 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
|
|||
"/" + account.keep_alive_failed +
|
||||
"/" + account.keep_alive_succeeded : "")));
|
||||
tvQuota.setText(context.getString(R.string.title_storage_quota,
|
||||
(account.quota_usage == null ? "-" : Helper.humanReadableByteCount(account.quota_usage, true)),
|
||||
(account.quota_limit == null ? "-" : Helper.humanReadableByteCount(account.quota_limit, true))));
|
||||
(account.quota_usage == null ? "-" : Helper.humanReadableByteCount(account.quota_usage)),
|
||||
(account.quota_limit == null ? "-" : Helper.humanReadableByteCount(account.quota_limit))));
|
||||
tvQuota.setVisibility(account.quota_usage != null || account.quota_limit != null ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvIdentity.setVisibility(account.identities > 0 || !settings ? View.GONE : View.VISIBLE);
|
||||
|
|
|
@ -127,7 +127,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
|
|||
tvName.setText(attachment.name);
|
||||
|
||||
if (attachment.size != null)
|
||||
tvSize.setText(Helper.humanReadableByteCount(attachment.size, true));
|
||||
tvSize.setText(Helper.humanReadableByteCount(attachment.size));
|
||||
tvSize.setVisibility(attachment.size == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (attachment.available) {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class AdapterAttachmentEML extends RecyclerView.Adapter<AdapterAttachment
|
|||
tvName.setText(apart.attachment.name);
|
||||
|
||||
if (apart.attachment.size != null)
|
||||
tvSize.setText(Helper.humanReadableByteCount(apart.attachment.size, true));
|
||||
tvSize.setText(Helper.humanReadableByteCount(apart.attachment.size));
|
||||
tvSize.setVisibility(apart.attachment.size == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -162,7 +162,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
|
|||
tvLast.setText(context.getString(R.string.title_last_connected,
|
||||
(identity.last_connected == null ? "-" : DTF.format(identity.last_connected))));
|
||||
|
||||
tvMaxSize.setText(identity.max_size == null ? null : Helper.humanReadableByteCount(identity.max_size, true));
|
||||
tvMaxSize.setText(identity.max_size == null ? null : Helper.humanReadableByteCount(identity.max_size));
|
||||
tvMaxSize.setVisibility(identity.max_size == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
tvError.setText(identity.error);
|
||||
|
|
|
@ -984,7 +984,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
else
|
||||
tvFrom.setText(MessageHelper.formatAddresses(senders, name_email, false));
|
||||
tvFrom.setPaintFlags(tvFrom.getPaintFlags() & ~Paint.UNDERLINE_TEXT_FLAG);
|
||||
tvSize.setText(message.totalSize == null ? null : Helper.humanReadableByteCount(message.totalSize, true));
|
||||
tvSize.setText(message.totalSize == null ? null : Helper.humanReadableByteCount(message.totalSize));
|
||||
tvSize.setVisibility(
|
||||
message.totalSize != null && ("size".equals(sort) || "attachments".equals(sort))
|
||||
? View.VISIBLE : View.GONE);
|
||||
|
@ -1372,7 +1372,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvExpand.setVisibility(View.GONE);
|
||||
else {
|
||||
tvExpand.setText(context.getString(R.string.title_expand_warning,
|
||||
message.size == null ? "?" : Helper.humanReadableByteCount(message.size, true)));
|
||||
message.size == null ? "?" : Helper.humanReadableByteCount(message.size)));
|
||||
tvExpand.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -1670,9 +1670,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvSizeEx.setVisibility(!show_addresses || (message.size == null && message.total == null) ? View.GONE : View.VISIBLE);
|
||||
StringBuilder size = new StringBuilder();
|
||||
size
|
||||
.append(message.size == null ? "-" : Helper.humanReadableByteCount(message.size, true))
|
||||
.append(message.size == null ? "-" : Helper.humanReadableByteCount(message.size))
|
||||
.append("/")
|
||||
.append(message.total == null ? "-" : Helper.humanReadableByteCount(message.total, true));
|
||||
.append(message.total == null ? "-" : Helper.humanReadableByteCount(message.total));
|
||||
tvSizeEx.setText(size.toString());
|
||||
|
||||
tvLanguageTitle.setVisibility(
|
||||
|
|
|
@ -737,7 +737,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
flags.add(TextUtils.join(", ", with_types));
|
||||
if (with_size != null)
|
||||
flags.add(context.getString(R.string.title_search_flag_size,
|
||||
Helper.humanReadableByteCount(with_size, true)));
|
||||
Helper.humanReadableByteCount(with_size)));
|
||||
return (query == null ? "" : query)
|
||||
+ (flags.size() > 0 ? " +" : "")
|
||||
+ TextUtils.join(",", flags);
|
||||
|
|
|
@ -5179,7 +5179,8 @@ public class FragmentCompose extends FragmentBase {
|
|||
tvAddressError.setVisibility(address_error == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
tvRemindSize.setText(getString(R.string.title_size_reminder,
|
||||
Helper.humanReadableByteCount(size, true), Helper.humanReadableByteCount(max_size, true)));
|
||||
Helper.humanReadableByteCount(size),
|
||||
Helper.humanReadableByteCount(max_size)));
|
||||
tvRemindSize.setVisibility(remind_size ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvRemindTo.setVisibility(send_reminders && remind_to ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -6693,7 +6693,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
if (!TextUtils.isEmpty(attachment.name))
|
||||
footer.appendText(" " + attachment.name);
|
||||
if (attachment.size != null)
|
||||
footer.appendText(" " + Helper.humanReadableByteCount(attachment.size, true));
|
||||
footer.appendText(" " + Helper.humanReadableByteCount(attachment.size));
|
||||
footer.appendElement("br");
|
||||
}
|
||||
|
||||
|
|
|
@ -439,7 +439,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
tvFtsIndexed.setText(getString(R.string.title_advanced_fts_indexed,
|
||||
stats.fts,
|
||||
stats.total,
|
||||
Helper.humanReadableByteCount(FtsDbHelper.size(getContext()), true)));
|
||||
Helper.humanReadableByteCount(FtsDbHelper.size(getContext()))));
|
||||
last = stats;
|
||||
}
|
||||
});
|
||||
|
@ -561,8 +561,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
tvMemoryClass.setText(getString(R.string.title_advanced_memory_class, class_mb + " MB"));
|
||||
|
||||
tvStorageSpace.setText(getString(R.string.title_advanced_storage_space,
|
||||
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace(), true),
|
||||
Helper.humanReadableByteCount(Helper.getTotalStorageSpace(), true)));
|
||||
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace()),
|
||||
Helper.humanReadableByteCount(Helper.getTotalStorageSpace())));
|
||||
tvFingerprint.setText(Helper.getFingerprint(getContext()));
|
||||
|
||||
grpDebug.setVisibility(swDebug.isChecked() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -697,7 +697,11 @@ public class Helper {
|
|||
|
||||
private static final DecimalFormat df = new DecimalFormat("@@");
|
||||
|
||||
static String humanReadableByteCount(long bytes, boolean si) {
|
||||
static String humanReadableByteCount(long bytes) {
|
||||
return humanReadableByteCount(bytes, true);
|
||||
}
|
||||
|
||||
private static String humanReadableByteCount(long bytes, boolean si) {
|
||||
int unit = si ? 1000 : 1024;
|
||||
if (bytes < unit) return bytes + " B";
|
||||
int exp = (int) (Math.log(bytes) / Math.log(unit));
|
||||
|
|
|
@ -1093,8 +1093,8 @@ public class Log {
|
|||
sb.append(String.format("Memory class: %d\r\n", am.getMemoryClass()));
|
||||
|
||||
sb.append(String.format("Storage space: %s/%s\r\n",
|
||||
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace(), true),
|
||||
Helper.humanReadableByteCount(Helper.getTotalStorageSpace(), true)));
|
||||
Helper.humanReadableByteCount(Helper.getAvailableStorageSpace()),
|
||||
Helper.humanReadableByteCount(Helper.getTotalStorageSpace())));
|
||||
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
long hused = (rt.totalMemory() - rt.freeMemory()) / 1024L;
|
||||
|
|
|
@ -264,13 +264,13 @@ public class WorkerCleanup extends Worker {
|
|||
long available = Helper.getAvailableStorageSpace();
|
||||
if (size > 0 && size * 2.5 < available) {
|
||||
Log.i("Running VACUUM" +
|
||||
" size=" + Helper.humanReadableByteCount(size, true) +
|
||||
"/" + Helper.humanReadableByteCount(available, true));
|
||||
" size=" + Helper.humanReadableByteCount(size) +
|
||||
"/" + Helper.humanReadableByteCount(available));
|
||||
db.getOpenHelper().getWritableDatabase().execSQL("VACUUM;");
|
||||
} else
|
||||
Log.w("Insufficient space for VACUUM" +
|
||||
" size=" + Helper.humanReadableByteCount(size, true) +
|
||||
"/" + Helper.humanReadableByteCount(available, true));
|
||||
" size=" + Helper.humanReadableByteCount(size) +
|
||||
"/" + Helper.humanReadableByteCount(available));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue