Refactoring

pull/146/head
M66B 6 years ago
parent b77ea55641
commit 1a8ae5a5f1

@ -120,9 +120,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivState.setImageResource(R.drawable.baseline_cloud_off_24); ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(folder.synchronize || folder.state != null ? View.VISIBLE : View.INVISIBLE); ivState.setVisibility(folder.synchronize || folder.state != null ? View.VISIBLE : View.INVISIBLE);
String name = (folder.display == null String name = folder.getDisplayName(context);
? Helper.localizeFolderName(context, folder.name)
: folder.display);
if (folder.unseen > 0) if (folder.unseen > 0)
tvName.setText(context.getString(R.string.title_folder_unseen, name, folder.unseen)); tvName.setText(context.getString(R.string.title_folder_unseen, name, folder.unseen));
else else

@ -1467,12 +1467,8 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
PopupMenu popupMenu = new PopupMenu(context, anchor); PopupMenu popupMenu = new PopupMenu(context, anchor);
int order = 0; int order = 0;
for (EntityFolder folder : folders) { for (EntityFolder folder : folders)
String name = (folder.display == null popupMenu.getMenu().add(Menu.NONE, folder.id.intValue(), order++, folder.getDisplayName(context));
? Helper.localizeFolderName(context, folder.name)
: folder.display);
popupMenu.getMenu().add(Menu.NONE, folder.id.intValue(), order++, name);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018 by Marcel Bokhorst (M66B) Copyright 2018 by Marcel Bokhorst (M66B)
*/ */
import android.content.Context;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -132,6 +134,10 @@ public class EntityFolder implements Serializable {
public EntityFolder() { public EntityFolder() {
} }
String getDisplayName(Context context) {
return (display == null ? Helper.localizeFolderName(context, name) : display);
}
boolean isOutgoing() { boolean isOutgoing() {
return isOutgoing(this.type); return isOutgoing(this.type);
} }

@ -781,12 +781,8 @@ public class FragmentMessages extends FragmentEx {
PopupMenu popupMenu = new PopupMenu(getContext(), popupAnchor); PopupMenu popupMenu = new PopupMenu(getContext(), popupAnchor);
int order = 0; int order = 0;
for (EntityFolder folder : folders) { for (EntityFolder folder : folders)
String name = (folder.display == null popupMenu.getMenu().add(Menu.NONE, folder.id.intValue(), order++, folder.getDisplayName(getContext()));
? Helper.localizeFolderName(getContext(), folder.name)
: folder.display);
popupMenu.getMenu().add(Menu.NONE, folder.id.intValue(), order++, name);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
@ -996,9 +992,7 @@ public class FragmentMessages extends FragmentEx {
if (folder == null) if (folder == null)
setSubtitle(null); setSubtitle(null);
else { else {
String name = (folder.display == null String name = folder.getDisplayName(getContext());
? Helper.localizeFolderName(getContext(), folder.name)
: folder.display);
if (folder.unseen > 0) if (folder.unseen > 0)
setSubtitle(getString(R.string.title_folder_unseen, name, folder.unseen)); setSubtitle(getString(R.string.title_folder_unseen, name, folder.unseen));
else else
@ -1601,10 +1595,9 @@ public class FragmentMessages extends FragmentEx {
private void moveUndo(final MessageTarget result) { private void moveUndo(final MessageTarget result) {
// Show undo snackbar // Show undo snackbar
String display = (result.target.display == null ? result.target.name : result.target.display);
final Snackbar snackbar = Snackbar.make( final Snackbar snackbar = Snackbar.make(
view, view,
getString(R.string.title_moving, Helper.localizeFolderName(getContext(), display)), getString(R.string.title_moving, result.target.getDisplayName(getContext())),
Snackbar.LENGTH_INDEFINITE); Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.title_undo, new View.OnClickListener() { snackbar.setAction(R.string.title_undo, new View.OnClickListener() {
@Override @Override

Loading…
Cancel
Save