Layout improvement

pull/50/head
M66B 6 years ago
parent 5df36d89e6
commit af4ab0aeda

@ -315,9 +315,12 @@ public class FragmentMessage extends FragmentEx {
// Message gone (moved, deleted) // Message gone (moved, deleted)
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
getFragmentManager().popBackStack(); getFragmentManager().popBackStack();
} else { return;
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName)); }
setSubtitle(Helper.localizeFolderName(getContext(), message.folderName));
if (savedInstanceState == null) {
tvFrom.setText(message.from == null ? null : MessageHelper.getFormattedAddresses(message.from, true)); tvFrom.setText(message.from == null ? null : MessageHelper.getFormattedAddresses(message.from, true));
tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent))); tvTime.setText(message.sent == null ? null : df.format(new Date(message.sent)));
tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true)); tvTo.setText(message.to == null ? null : MessageHelper.getFormattedAddresses(message.to, true));
@ -329,105 +332,105 @@ public class FragmentMessage extends FragmentEx {
tvCc.setText(message.cc == null ? null : MessageHelper.getFormattedAddresses(message.cc, true)); tvCc.setText(message.cc == null ? null : MessageHelper.getFormattedAddresses(message.cc, true));
tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true)); tvBcc.setText(message.bcc == null ? null : MessageHelper.getFormattedAddresses(message.bcc, true));
int typeface = (message.ui_seen ? Typeface.NORMAL : Typeface.BOLD);
tvFrom.setTypeface(null, typeface);
tvTime.setTypeface(null, typeface);
tvSubject.setTypeface(null, typeface);
tvCount.setTypeface(null, typeface);
int colorUnseen = Helper.resolveColor(getContext(), message.ui_seen
? android.R.attr.textColorSecondary : R.attr.colorUnread);
tvFrom.setTextColor(colorUnseen);
tvTime.setTextColor(colorUnseen);
tvError.setText(message.error); tvError.setText(message.error);
} else {
free = savedInstanceState.getBoolean("free");
grpAddresses.setTag(savedInstanceState.getInt("addresses"));
rvAttachment.setTag(savedInstanceState.getInt("attachments"));
}
MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen); Bundle args = new Bundle();
actionSeen.setIcon(message.ui_seen args.putLong("id", message.id);
? R.drawable.baseline_visibility_off_24
: R.drawable.baseline_visibility_24);
actionSeen.setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen);
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Spanned>() { new SimpleTask<Spanned>() {
@Override @Override
protected Spanned onLoad(Context context, Bundle args) throws Throwable { protected Spanned onLoad(Context context, Bundle args) throws Throwable {
String body = EntityMessage.read(context, args.getLong("id")); String body = EntityMessage.read(context, args.getLong("id"));
return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false)); return Html.fromHtml(HtmlHelper.sanitize(getContext(), body, false));
} }
@Override @Override
protected void onLoaded(Bundle args, Spanned body) { protected void onLoaded(Bundle args, Spanned body) {
tvBody.setText(body); tvBody.setText(body);
grpMessage.setVisibility(View.VISIBLE); grpMessage.setVisibility(View.VISIBLE);
if (!free)
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
} }
}.load(FragmentMessage.this, args); }.load(FragmentMessage.this, args);
db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner()); int typeface = (message.ui_seen ? Typeface.NORMAL : Typeface.BOLD);
db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() { tvFrom.setTypeface(null, typeface);
@Override tvTime.setTypeface(null, typeface);
public void onChanged(@Nullable List<TupleFolderEx> folders) { tvSubject.setTypeface(null, typeface);
if (folders == null) tvCount.setTypeface(null, typeface);
folders = new ArrayList<>();
int colorUnseen = Helper.resolveColor(getContext(), message.ui_seen
boolean inInbox = EntityFolder.INBOX.equals(message.folderType); ? android.R.attr.textColorSecondary : R.attr.colorUnread);
boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType); tvFrom.setTextColor(colorUnseen);
boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType); tvTime.setTextColor(colorUnseen);
//boolean inDafts = EntityFolder.DRAFTS.equals(message.folderType);
boolean inTrash = EntityFolder.TRASH.equals(message.folderType); MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen);
boolean inJunk = EntityFolder.JUNK.equals(message.folderType); actionSeen.setIcon(message.ui_seen
//boolean inSent = EntityFolder.SENT.equals(message.folderType); ? R.drawable.baseline_visibility_off_24
: R.drawable.baseline_visibility_24);
boolean hasTrash = false; actionSeen.setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen);
boolean hasJunk = false;
boolean hasArchive = false; db.folder().liveFolders(message.account).removeObservers(getViewLifecycleOwner());
boolean hasUser = false; db.folder().liveFolders(message.account).observe(getViewLifecycleOwner(), new Observer<List<TupleFolderEx>>() {
if (folders != null) @Override
for (EntityFolder folder : folders) { public void onChanged(@Nullable List<TupleFolderEx> folders) {
if (EntityFolder.TRASH.equals(folder.type)) if (folders == null)
hasTrash = true; folders = new ArrayList<>();
else if (EntityFolder.JUNK.equals(folder.type))
hasJunk = true; boolean inInbox = EntityFolder.INBOX.equals(message.folderType);
else if (EntityFolder.ARCHIVE.equals(folder.type)) boolean inOutbox = EntityFolder.OUTBOX.equals(message.folderType);
hasArchive = true; boolean inArchive = EntityFolder.ARCHIVE.equals(message.folderType);
else if (EntityFolder.USER.equals(folder.type)) //boolean inDafts = EntityFolder.DRAFTS.equals(message.folderType);
hasUser = true; boolean inTrash = EntityFolder.TRASH.equals(message.folderType);
} boolean inJunk = EntityFolder.JUNK.equals(message.folderType);
//boolean inSent = EntityFolder.SENT.equals(message.folderType);
boolean hasTrash = false;
boolean hasJunk = false;
boolean hasArchive = false;
boolean hasUser = false;
if (folders != null)
for (EntityFolder folder : folders) {
if (EntityFolder.TRASH.equals(folder.type))
hasTrash = true;
else if (EntityFolder.JUNK.equals(folder.type))
hasJunk = true;
else if (EntityFolder.ARCHIVE.equals(folder.type))
hasArchive = true;
else if (EntityFolder.USER.equals(folder.type))
hasUser = true;
}
bottom_navigation.setTag(inTrash || !hasTrash); bottom_navigation.setTag(inTrash || !hasTrash);
top_navigation.getMenu().findItem(R.id.action_thread).setVisible(message.count > 1); top_navigation.getMenu().findItem(R.id.action_thread).setVisible(message.count > 1);
top_navigation.getMenu().findItem(R.id.action_seen).setVisible(!inOutbox); top_navigation.getMenu().findItem(R.id.action_seen).setVisible(!inOutbox);
top_navigation.getMenu().findItem(R.id.action_edit).setVisible(inTrash); top_navigation.getMenu().findItem(R.id.action_edit).setVisible(inTrash);
top_navigation.getMenu().findItem(R.id.action_forward).setVisible(!inOutbox); top_navigation.getMenu().findItem(R.id.action_forward).setVisible(!inOutbox);
top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!inOutbox && message.cc != null); top_navigation.getMenu().findItem(R.id.action_reply_all).setVisible(!inOutbox && message.cc != null);
if (!free)
top_navigation.setVisibility(View.VISIBLE); top_navigation.setVisibility(View.VISIBLE);
bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(message.uid != null && !inOutbox && !inArchive && !inJunk && hasJunk); bottom_navigation.getMenu().findItem(R.id.action_spam).setVisible(message.uid != null && !inOutbox && !inArchive && !inJunk && hasJunk);
bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(message.uid != null && !inOutbox && hasTrash); bottom_navigation.getMenu().findItem(R.id.action_trash).setVisible(message.uid != null && !inOutbox && hasTrash);
bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(message.uid != null && !inOutbox && (!inInbox || hasUser)); bottom_navigation.getMenu().findItem(R.id.action_move).setVisible(message.uid != null && !inOutbox && (!inInbox || hasUser));
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inOutbox && !inArchive && hasArchive); bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(message.uid != null && !inOutbox && !inArchive && hasArchive);
bottom_navigation.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox); bottom_navigation.getMenu().findItem(R.id.action_reply).setVisible(!inOutbox);
bottom_navigation.setVisibility(View.VISIBLE); bottom_navigation.setVisibility(View.VISIBLE);
}
});
if (savedInstanceState != null) {
free = savedInstanceState.getBoolean("free");
grpAddresses.setTag(savedInstanceState.getInt("addresses"));
rvAttachment.setTag(savedInstanceState.getInt("attachments"));
} }
});
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
grpHeader.setVisibility(free ? View.GONE : View.VISIBLE); grpHeader.setVisibility(free ? View.GONE : View.VISIBLE);
if (free) if (free)
grpAddresses.setVisibility(View.GONE); grpAddresses.setVisibility(View.GONE);
tvCount.setVisibility(!free && message.count > 1 ? View.VISIBLE : View.GONE); tvCount.setVisibility(!free && message.count > 1 ? View.VISIBLE : View.GONE);
tvError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE); tvError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE);
}
} }
}); });

@ -202,7 +202,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
android:background="@color/darkColorSeparator" android:background="?attr/colorSeparator"
app:itemIconTint="@color/bottomnav_background" app:itemIconTint="@color/bottomnav_background"
app:itemTextColor="@color/bottomnav_background" app:itemTextColor="@color/bottomnav_background"
app:labelVisibilityMode="unlabeled" app:labelVisibilityMode="unlabeled"

@ -9,14 +9,14 @@
<color name="lightColorUnread">#000</color> <color name="lightColorUnread">#000</color>
<color name="lightColorItemSelected">#ccc</color> <color name="lightColorItemSelected">#ccc</color>
<color name="lightColorSeparator">#ffaaaaaa</color> <color name="lightColorSeparator">#aaa</color>
<color name="lightColorDrawerScrim">#99000000</color> <color name="lightColorDrawerScrim">#99000000</color>
<color name="lightColorDrawerText">#111</color> <color name="lightColorDrawerText">#111</color>
<color name="lightColorDrawerBackground">#eee</color> <color name="lightColorDrawerBackground">#eee</color>
<color name="darkColorUnread">#fff</color> <color name="darkColorUnread">#fff</color>
<color name="darkColorItemSelected">#555</color> <color name="darkColorItemSelected">#555</color>
<color name="darkColorSeparator">#ff878787</color> <color name="darkColorSeparator">#666</color>
<color name="darkColorDrawerScrim">#997f7f7f</color> <color name="darkColorDrawerScrim">#997f7f7f</color>
<color name="darkColorDrawerText">#fff</color> <color name="darkColorDrawerText">#fff</color>
<color name="darkColorDrawerBackground">#222</color> <color name="darkColorDrawerBackground">#222</color>

Loading…
Cancel
Save