Refactoring

pull/180/head
M66B 5 years ago
parent 0352d69e84
commit ca904aa03b

@ -312,7 +312,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (account < 0 && !primary)
tvType.setText(folder.accountName);
else
tvType.setText(Helper.localizeFolderType(context, folder.type));
tvType.setText(EntityFolder.localizeType(context, folder.type));
tvTotal.setText(folder.total == null ? "" : NF.format(folder.total));

@ -95,10 +95,10 @@ public class AdapterNavUnified extends RecyclerView.Adapter<AdapterNavUnified.Vi
count = folder.unseen;
if (count == 0)
tvItem.setText(Helper.localizeFolderType(context, folder.type));
tvItem.setText(EntityFolder.localizeType(context, folder.type));
else
tvItem.setText(context.getString(R.string.title_name_count,
Helper.localizeFolderType(context, folder.type), NF.format(count)));
EntityFolder.localizeType(context, folder.type), NF.format(count)));
tvItem.setTextColor(count == 0 ? textColorSecondary : colorUnread);
tvItem.setTypeface(count == 0 ? Typeface.DEFAULT : Typeface.DEFAULT_BOLD);

@ -295,14 +295,14 @@ public class EntityFolder extends EntityOrder implements Serializable {
}
String getDisplayName(Context context) {
return (display == null ? Helper.localizeFolderName(context, name) : display);
return (display == null ? localizeName(context, name) : display);
}
String getDisplayName(Context context, EntityFolder parent) {
String n = name;
if (parent != null && name.startsWith(parent.name))
n = n.substring(parent.name.length() + 1);
return (display == null ? Helper.localizeFolderName(context, n) : display);
return (display == null ? localizeName(context, n) : display);
}
@Override
@ -432,6 +432,23 @@ public class EntityFolder extends EntityOrder implements Serializable {
}
}
static String localizeType(Context context, String type) {
int resid = context.getResources().getIdentifier(
"title_folder_" + type.toLowerCase(Locale.ROOT),
"string",
context.getPackageName());
return (resid > 0 ? context.getString(resid) : type);
}
static String localizeName(Context context, String name) {
if (name != null && "INBOX".equals(name.toUpperCase(Locale.ROOT)))
return context.getString(R.string.title_folder_inbox);
else if ("OUTBOX".equals(name))
return context.getString(R.string.title_folder_outbox);
else
return name;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof EntityFolder) {

@ -247,7 +247,7 @@ public class FragmentFolder extends FragmentBase {
int interval = args.getInt("interval", EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL);
etName.setText(folder == null ? null : folder.name);
etDisplay.setText(folder == null ? null : folder.display);
etDisplay.setHint(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name));
etDisplay.setHint(folder == null ? null : EntityFolder.localizeName(getContext(), folder.name));
btnColor.setColor(folder == null ? null : folder.color);
cbHide.setChecked(folder == null ? false : folder.hide);
cbUnified.setChecked(folder == null ? false : folder.unified);

@ -3841,7 +3841,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (type == null)
name = getString(R.string.title_folder_unified);
else
name = Helper.localizeFolderType(getContext(), type);
name = EntityFolder.localizeType(getContext(), type);
else {
name = (folders.size() > 0 ? folders.get(0).getDisplayName(getContext()) : "");
if (folders.size() == 1) {

@ -1066,7 +1066,7 @@ public class FragmentRule extends FragmentBase {
public AccountFolder(EntityAccount account, EntityFolder folder, Context context) {
this.account = account;
this.folder = folder;
this.name = account.name + "/" + Helper.localizeFolderName(context, folder.name);
this.name = account.name + "/" + EntityFolder.localizeName(context, folder.name);
}
@NonNull

@ -718,23 +718,6 @@ public class Helper {
return DateUtils.getRelativeTimeSpanString(context, millis);
}
static String localizeFolderType(Context context, String type) {
int resid = context.getResources().getIdentifier(
"title_folder_" + type.toLowerCase(Locale.ROOT),
"string",
context.getPackageName());
return (resid > 0 ? context.getString(resid) : type);
}
static String localizeFolderName(Context context, String name) {
if (name != null && "INBOX".equals(name.toUpperCase(Locale.ROOT)))
return context.getString(R.string.title_folder_inbox);
else if ("OUTBOX".equals(name))
return context.getString(R.string.title_folder_outbox);
else
return name;
}
static void linkPro(final TextView tv) {
if (ActivityBilling.isPro(tv.getContext()) && !BuildConfig.DEBUG)
hide(tv);

@ -68,7 +68,7 @@ public class TupleMessageEx extends EntityMessage {
String getFolderName(Context context) {
return (folderDisplay == null
? Helper.localizeFolderName(context, folderName)
? EntityFolder.localizeName(context, folderName)
: folderDisplay);
}

Loading…
Cancel
Save