|
|
|
@ -143,6 +143,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
private boolean search;
|
|
|
|
|
private boolean avatars;
|
|
|
|
|
private boolean preview;
|
|
|
|
|
private boolean autohtml;
|
|
|
|
|
private boolean autoimages;
|
|
|
|
|
private boolean debug;
|
|
|
|
|
|
|
|
|
@ -438,22 +439,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
|
|
|
|
|
@SuppressLint("WrongConstant")
|
|
|
|
|
private void bindTo(int position, final TupleMessageEx message) {
|
|
|
|
|
final DB db = DB.getInstance(context);
|
|
|
|
|
final boolean show_expanded = properties.getValue("expanded", message.id);
|
|
|
|
|
boolean show_addresses = !properties.getValue("addresses", message.id);
|
|
|
|
|
boolean show_headers = properties.getValue("headers", message.id);
|
|
|
|
|
final boolean show_html = properties.getValue("html", message.id);
|
|
|
|
|
|
|
|
|
|
pbLoading.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
setDisplacement(0);
|
|
|
|
|
clearExpanded();
|
|
|
|
|
pbLoading.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
// Text size
|
|
|
|
|
if (textSize != 0) {
|
|
|
|
|
tvDay.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
|
|
|
tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
|
|
|
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
|
|
|
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Date header
|
|
|
|
|
if (message.day) {
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime(new Date());
|
|
|
|
@ -478,9 +476,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
}
|
|
|
|
|
grpDay.setVisibility(message.day ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
itemView.setAlpha(message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType)
|
|
|
|
|
? Helper.LOW_LIGHT : 1.0f);
|
|
|
|
|
// Selected / disabled
|
|
|
|
|
itemView.setActivated(selectionTracker != null && selectionTracker.isSelected(message.id));
|
|
|
|
|
itemView.setAlpha(
|
|
|
|
|
message.uid == null && !EntityFolder.OUTBOX.equals(message.folderType) ? Helper.LOW_LIGHT : 1.0f);
|
|
|
|
|
|
|
|
|
|
// Duplicate
|
|
|
|
|
if (viewType == ViewType.THREAD) {
|
|
|
|
|
ivFlagged.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
|
|
|
|
|
ivAvatar.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
|
|
|
|
@ -500,74 +501,47 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
tvError.setAlpha(message.duplicate ? Helper.LOW_LIGHT : 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean outgoing = (viewType != ViewType.THREAD && EntityFolder.isOutgoing(message.folderType));
|
|
|
|
|
|
|
|
|
|
final Address[] addresses = (outgoing ? message.to : message.from);
|
|
|
|
|
|
|
|
|
|
ContactInfo info = ContactInfo.get(context, addresses, true);
|
|
|
|
|
if (info == null) {
|
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
|
aargs.putLong("id", message.id);
|
|
|
|
|
aargs.putSerializable("addresses", addresses);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<ContactInfo>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPreExecute(Bundle args) {
|
|
|
|
|
ivAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE);
|
|
|
|
|
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected ContactInfo onExecute(Context context, Bundle args) {
|
|
|
|
|
Address[] addresses = (Address[]) args.getSerializable("addresses");
|
|
|
|
|
return ContactInfo.get(context, addresses, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, ContactInfo info) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
TupleMessageEx amessage = getMessage();
|
|
|
|
|
if (amessage == null || !amessage.id.equals(id))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
showContactInfo(info, message);
|
|
|
|
|
}
|
|
|
|
|
// Unseen
|
|
|
|
|
int typeface = (message.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL);
|
|
|
|
|
tvFrom.setTypeface(null, typeface);
|
|
|
|
|
tvSize.setTypeface(null, typeface);
|
|
|
|
|
tvTime.setTypeface(null, typeface);
|
|
|
|
|
tvSubject.setTypeface(null, typeface | Typeface.ITALIC);
|
|
|
|
|
tvCount.setTypeface(null, typeface);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(context, owner, aargs, "message:avatar");
|
|
|
|
|
} else
|
|
|
|
|
showContactInfo(info, message);
|
|
|
|
|
int colorUnseen = (message.unseen > 0 ? colorUnread : textColorSecondary);
|
|
|
|
|
tvFrom.setTextColor(colorUnseen);
|
|
|
|
|
tvSize.setTextColor(colorUnseen);
|
|
|
|
|
tvTime.setTextColor(colorUnseen);
|
|
|
|
|
|
|
|
|
|
// Account color
|
|
|
|
|
vwColor.setBackgroundColor(message.accountColor == null ? Color.TRANSPARENT : message.accountColor);
|
|
|
|
|
vwColor.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
ivExpander.setImageResource(show_expanded ? R.drawable.baseline_expand_less_24 : R.drawable.baseline_expand_more_24);
|
|
|
|
|
// Expander
|
|
|
|
|
boolean expanded = (viewType == ViewType.THREAD && properties.getValue("expanded", message.id));
|
|
|
|
|
ivExpander.setImageResource(expanded ? R.drawable.baseline_expand_less_24 : R.drawable.baseline_expand_more_24);
|
|
|
|
|
if (viewType == ViewType.THREAD && threading)
|
|
|
|
|
ivExpander.setVisibility(EntityFolder.DRAFTS.equals(message.folderType) ? View.INVISIBLE : View.VISIBLE);
|
|
|
|
|
else
|
|
|
|
|
ivExpander.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
bindFlagged(message);
|
|
|
|
|
|
|
|
|
|
// Line 1
|
|
|
|
|
tvSize.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
|
|
|
|
|
tvSize.setVisibility(message.size == null || message.content ? View.GONE : View.VISIBLE);
|
|
|
|
|
tvTime.setText(date && "time".equals(sort)
|
|
|
|
|
? tf.format(message.received)
|
|
|
|
|
: DateUtils.getRelativeTimeSpanString(context, message.received));
|
|
|
|
|
|
|
|
|
|
// Line 2
|
|
|
|
|
tvSubject.setText(message.subject);
|
|
|
|
|
|
|
|
|
|
// Line 3
|
|
|
|
|
ivDraft.setVisibility(message.drafts > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
ivSnoozed.setVisibility(message.ui_snoozed == null ? View.GONE : View.VISIBLE);
|
|
|
|
|
ivBrowsed.setVisibility(message.ui_browsed ? View.VISIBLE : View.GONE);
|
|
|
|
|
ivAnswered.setVisibility(message.ui_answered ? View.VISIBLE : View.GONE);
|
|
|
|
|
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
cbInline.setVisibility(View.GONE);
|
|
|
|
|
btnDownloadAttachments.setVisibility(View.GONE);
|
|
|
|
|
btnSaveAttachments.setVisibility(View.GONE);
|
|
|
|
|
tvNoInternetAttachments.setVisibility(View.GONE);
|
|
|
|
|
tvSubject.setText(message.subject);
|
|
|
|
|
|
|
|
|
|
if (viewType == ViewType.FOLDER)
|
|
|
|
|
tvFolder.setText(message.accountName);
|
|
|
|
@ -579,9 +553,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
}
|
|
|
|
|
tvFolder.setVisibility(viewType == ViewType.FOLDER && compact ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
tvPreview.setText(message.preview);
|
|
|
|
|
tvPreview.setVisibility(preview && !TextUtils.isEmpty(message.preview) ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
if (viewType == ViewType.THREAD || !threading) {
|
|
|
|
|
tvCount.setVisibility(View.GONE);
|
|
|
|
|
ivThread.setVisibility(View.GONE);
|
|
|
|
@ -590,6 +561,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
ivThread.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Starred
|
|
|
|
|
bindFlagged(message);
|
|
|
|
|
|
|
|
|
|
// Message text preview
|
|
|
|
|
tvPreview.setText(message.preview);
|
|
|
|
|
tvPreview.setVisibility(preview && !TextUtils.isEmpty(message.preview) ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
// Error / warning
|
|
|
|
|
String error = message.error;
|
|
|
|
|
if (message.warning != null)
|
|
|
|
|
if (error == null)
|
|
|
|
@ -616,57 +595,142 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
tvError.setVisibility(error == null ? View.GONE : View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Unseen
|
|
|
|
|
int typeface = (message.unseen > 0 ? Typeface.BOLD : Typeface.NORMAL);
|
|
|
|
|
tvFrom.setTypeface(null, typeface);
|
|
|
|
|
tvSize.setTypeface(null, typeface);
|
|
|
|
|
tvTime.setTypeface(null, typeface);
|
|
|
|
|
tvSubject.setTypeface(null, typeface | Typeface.ITALIC);
|
|
|
|
|
tvCount.setTypeface(null, typeface);
|
|
|
|
|
// Contact info
|
|
|
|
|
boolean outgoing = (viewType != ViewType.THREAD && EntityFolder.isOutgoing(message.folderType));
|
|
|
|
|
Address[] addresses = (outgoing ? message.to : message.from);
|
|
|
|
|
ContactInfo info = ContactInfo.get(context, addresses, true);
|
|
|
|
|
if (info == null) {
|
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
|
aargs.putLong("id", message.id);
|
|
|
|
|
aargs.putSerializable("addresses", addresses);
|
|
|
|
|
|
|
|
|
|
int colorUnseen = (message.unseen > 0 ? colorUnread : textColorSecondary);
|
|
|
|
|
tvFrom.setTextColor(colorUnseen);
|
|
|
|
|
tvSize.setTextColor(colorUnseen);
|
|
|
|
|
tvTime.setTextColor(colorUnseen);
|
|
|
|
|
new SimpleTask<ContactInfo>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPreExecute(Bundle args) {
|
|
|
|
|
Address[] addresses = (Address[]) args.getSerializable("addresses");
|
|
|
|
|
ivAvatar.setVisibility(avatars ? View.INVISIBLE : View.GONE);
|
|
|
|
|
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected ContactInfo onExecute(Context context, Bundle args) {
|
|
|
|
|
Address[] addresses = (Address[]) args.getSerializable("addresses");
|
|
|
|
|
return ContactInfo.get(context, addresses, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, ContactInfo info) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
TupleMessageEx amessage = getMessage();
|
|
|
|
|
if (amessage == null || !amessage.id.equals(id))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bindContactInfo(info, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grpExpanded.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.VISIBLE : View.GONE);
|
|
|
|
|
grpAddress.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses ? View.VISIBLE : View.GONE);
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(context, owner, aargs, "message:avatar");
|
|
|
|
|
} else
|
|
|
|
|
bindContactInfo(info, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindFlagged(TupleMessageEx message) {
|
|
|
|
|
int flagged = (message.count - message.unflagged);
|
|
|
|
|
ivFlagged.setImageResource(flagged > 0 ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24);
|
|
|
|
|
ivFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 ? colorAccent : textColorSecondary));
|
|
|
|
|
ivFlagged.setVisibility(message.uid == null ? View.INVISIBLE : View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void clearExpanded() {
|
|
|
|
|
grpAddress.setVisibility(View.GONE);
|
|
|
|
|
grpHeaders.setVisibility(View.GONE);
|
|
|
|
|
grpAttachments.setVisibility(View.GONE);
|
|
|
|
|
grpExpanded.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
ivSearchContact.setVisibility(View.GONE);
|
|
|
|
|
ivAddContact.setVisibility(View.GONE);
|
|
|
|
|
tvFlags.setVisibility(View.GONE);
|
|
|
|
|
tvKeywords.setVisibility(View.GONE);
|
|
|
|
|
ivSearchContact.setVisibility(
|
|
|
|
|
viewType == ViewType.THREAD && show_expanded && show_addresses &&
|
|
|
|
|
search && BuildConfig.DEBUG
|
|
|
|
|
? View.VISIBLE : View.GONE);
|
|
|
|
|
ivAddContact.setVisibility(
|
|
|
|
|
viewType == ViewType.THREAD && show_expanded && show_addresses &&
|
|
|
|
|
contacts && message.from != null && message.from.length > 0
|
|
|
|
|
? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
if (show_headers && show_expanded && message.headers == null) {
|
|
|
|
|
pbHeaders.setVisibility(internet ? View.VISIBLE : View.GONE);
|
|
|
|
|
tvNoInternetHeaders.setVisibility(internet ? View.GONE : View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
pbHeaders.setVisibility(View.GONE);
|
|
|
|
|
tvNoInternetHeaders.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rvImage.setVisibility(View.GONE);
|
|
|
|
|
cbInline.setVisibility(View.GONE);
|
|
|
|
|
btnDownloadAttachments.setVisibility(View.GONE);
|
|
|
|
|
btnSaveAttachments.setVisibility(View.GONE);
|
|
|
|
|
tvNoInternetAttachments.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
|
|
|
|
|
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
|
|
|
|
|
btnHtml.setVisibility(viewType == ViewType.THREAD && show_expanded && !show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
ibQuotes.setVisibility(viewType == ViewType.THREAD && show_expanded && !show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
ibImages.setVisibility(viewType == ViewType.THREAD && show_expanded && !show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
tvBody.setVisibility(viewType == ViewType.THREAD && show_expanded && !show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
vwBody.setVisibility(viewType == ViewType.THREAD && show_expanded && show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
btnHtml.setVisibility(View.GONE);
|
|
|
|
|
ibQuotes.setVisibility(View.GONE);
|
|
|
|
|
ibImages.setVisibility(View.GONE);
|
|
|
|
|
tvBody.setVisibility(View.GONE);
|
|
|
|
|
vwBody.setVisibility(View.GONE);
|
|
|
|
|
pbBody.setVisibility(View.GONE);
|
|
|
|
|
tvNoInternetBody.setVisibility(View.GONE);
|
|
|
|
|
rvImage.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindContactInfo(ContactInfo info, TupleMessageEx message) {
|
|
|
|
|
if (info.hasPhoto())
|
|
|
|
|
ivAvatar.setImageBitmap(info.getPhotoBitmap());
|
|
|
|
|
else
|
|
|
|
|
ivAvatar.setImageResource(R.drawable.baseline_person_24);
|
|
|
|
|
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
|
|
|
|
|
tvFrom.setText(info.getDisplayName(compact));
|
|
|
|
|
|
|
|
|
|
if (info.hasLookupUri()) {
|
|
|
|
|
boolean show_html = properties.getValue("html", message.id);
|
|
|
|
|
if (autohtml && !show_html)
|
|
|
|
|
properties.setValue("html", message.id, true);
|
|
|
|
|
|
|
|
|
|
boolean show_images = properties.getValue("images", message.id);
|
|
|
|
|
if (autoimages && !show_images)
|
|
|
|
|
properties.setValue("images", message.id, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (viewType == ViewType.THREAD) {
|
|
|
|
|
boolean show_expanded = properties.getValue("expanded", message.id);
|
|
|
|
|
if (show_expanded)
|
|
|
|
|
bindExpanded(message);
|
|
|
|
|
else
|
|
|
|
|
properties.setBody(message.id, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindExpanded(final TupleMessageEx message) {
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
boolean show_addresses = !properties.getValue("addresses", message.id);
|
|
|
|
|
boolean show_headers = properties.getValue("headers", message.id);
|
|
|
|
|
boolean show_html = properties.getValue("html", message.id);
|
|
|
|
|
|
|
|
|
|
grpExpanded.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
grpAddress.setVisibility(show_addresses ? View.VISIBLE : View.GONE);
|
|
|
|
|
ivSearchContact.setVisibility(show_addresses && search && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
|
|
|
|
ivAddContact.setVisibility(show_addresses && contacts && message.from != null && message.from.length > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
grpHeaders.setVisibility(show_headers ? View.VISIBLE : View.GONE);
|
|
|
|
|
if (show_headers && message.headers == null) {
|
|
|
|
|
pbHeaders.setVisibility(internet ? View.VISIBLE : View.GONE);
|
|
|
|
|
tvNoInternetHeaders.setVisibility(internet ? View.GONE : View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grpAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
bnvActions.setTag(null);
|
|
|
|
|
for (int i = 0; i < bnvActions.getMenu().size(); i++)
|
|
|
|
|
bnvActions.getMenu().getItem(i).setVisible(false);
|
|
|
|
|
|
|
|
|
|
if (show_expanded) {
|
|
|
|
|
ivExpanderAddress.setImageResource(show_addresses ? R.drawable.baseline_expand_less_24 : R.drawable.baseline_expand_more_24);
|
|
|
|
|
btnHtml.setVisibility(!show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
ibQuotes.setVisibility(!show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
ibImages.setVisibility(!show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
tvBody.setVisibility(!show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
vwBody.setVisibility(show_html ? View.INVISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
// Addresses
|
|
|
|
|
ivExpanderAddress.setImageResource(show_addresses ? R.drawable.baseline_expand_less_24 : R.drawable.baseline_expand_more_24);
|
|
|
|
|
tvFromEx.setText(MessageHelper.formatAddresses(message.from));
|
|
|
|
|
tvTo.setText(MessageHelper.formatAddresses(message.to));
|
|
|
|
|
tvReplyTo.setText(MessageHelper.formatAddresses(message.reply));
|
|
|
|
@ -681,11 +745,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
tvSizeEx.setVisibility(message.size == null ? View.GONE : View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
tvSubjectEx.setText(message.subject);
|
|
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
|
tvFlags.setText(message.flags);
|
|
|
|
|
tvFlags.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
// Keywords
|
|
|
|
|
tvKeywords.setText(TextUtils.join(" ", message.keywords));
|
|
|
|
|
tvKeywords.setVisibility(message.keywords.length > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
// Headers
|
|
|
|
|
if (show_headers && message.headers != null) {
|
|
|
|
|
SpannableStringBuilder ssb = new SpannableStringBuilder(message.headers);
|
|
|
|
|
int index = 0;
|
|
|
|
@ -702,29 +771,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
} else
|
|
|
|
|
tvHeaders.setText(null);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bnvActions.getMenu().size(); i++)
|
|
|
|
|
bnvActions.getMenu().getItem(i).setVisible(false);
|
|
|
|
|
|
|
|
|
|
if (textSize != 0)
|
|
|
|
|
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
|
|
|
|
|
|
|
|
|
Spanned body = properties.getBody(message.id);
|
|
|
|
|
tvBody.setText(body);
|
|
|
|
|
tvBody.setMovementMethod(null);
|
|
|
|
|
if (internet || message.content)
|
|
|
|
|
pbBody.setVisibility(View.VISIBLE);
|
|
|
|
|
else
|
|
|
|
|
tvNoInternetBody.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
if (body == null && message.content)
|
|
|
|
|
if (show_html)
|
|
|
|
|
onShowHtmlConfirmed(message);
|
|
|
|
|
else {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putSerializable("message", message);
|
|
|
|
|
bodyTask.execute(context, owner, args, "message:body");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attachments
|
|
|
|
|
List<EntityAttachment> attachments = idAttachments.get(message.id);
|
|
|
|
|
if (attachments != null)
|
|
|
|
|
adapterAttachment.set(attachments);
|
|
|
|
@ -782,6 +829,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
adapterImage.set(images);
|
|
|
|
|
rvImage.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
|
|
|
|
|
boolean show_html = properties.getValue("html", message.id);
|
|
|
|
|
if (message.content && !show_html) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putSerializable("message", message);
|
|
|
|
@ -792,7 +840,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
liveAttachments = db.attachment().liveAttachments(message.id);
|
|
|
|
|
liveAttachments.observe(owner, observerAttachments);
|
|
|
|
|
|
|
|
|
|
// Setup action
|
|
|
|
|
// Setup actions
|
|
|
|
|
Bundle sargs = new Bundle();
|
|
|
|
|
sargs.putLong("id", message.id);
|
|
|
|
|
sargs.putLong("account", message.account);
|
|
|
|
@ -858,30 +906,24 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
Helper.unexpectedError(context, owner, ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(context, owner, sargs, "message:actions");
|
|
|
|
|
} else
|
|
|
|
|
properties.setBody(message.id, null);
|
|
|
|
|
|
|
|
|
|
itemView.setActivated(selectionTracker != null && selectionTracker.isSelected(message.id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindFlagged(TupleMessageEx message) {
|
|
|
|
|
int flagged = (message.count - message.unflagged);
|
|
|
|
|
ivFlagged.setImageResource(flagged > 0 ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24);
|
|
|
|
|
ivFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 ? colorAccent : textColorSecondary));
|
|
|
|
|
ivFlagged.setVisibility(message.uid == null ? View.INVISIBLE : View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showContactInfo(ContactInfo info, TupleMessageEx message) {
|
|
|
|
|
if (info.hasPhoto())
|
|
|
|
|
ivAvatar.setImageBitmap(info.getPhotoBitmap());
|
|
|
|
|
// Message text
|
|
|
|
|
Spanned body = properties.getBody(message.id);
|
|
|
|
|
tvBody.setText(body);
|
|
|
|
|
tvBody.setMovementMethod(null);
|
|
|
|
|
if (internet || message.content)
|
|
|
|
|
pbBody.setVisibility(View.VISIBLE);
|
|
|
|
|
else
|
|
|
|
|
ivAvatar.setImageResource(R.drawable.baseline_person_24);
|
|
|
|
|
ivAvatar.setVisibility(avatars ? View.VISIBLE : View.GONE);
|
|
|
|
|
tvFrom.setText(info.getDisplayName(compact));
|
|
|
|
|
tvNoInternetBody.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
if (info.hasLookupUri() && autoimages &&
|
|
|
|
|
!properties.getValue("images", message.id))
|
|
|
|
|
onShowImagesConfirmed(message);
|
|
|
|
|
if (body == null && message.content)
|
|
|
|
|
if (show_html)
|
|
|
|
|
onShowHtmlConfirmed(message);
|
|
|
|
|
else {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putSerializable("message", message);
|
|
|
|
|
bodyTask.execute(context, owner, args, "message:body");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unbind() {
|
|
|
|
@ -1118,7 +1160,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
notifyItemChanged(pos);
|
|
|
|
|
|
|
|
|
|
if (expanded)
|
|
|
|
|
properties.scrollTo(pos, Math.round(tvBody.getY()));
|
|
|
|
|
properties.scrollTo(pos, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1244,6 +1286,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
|
|
pbBody.setVisibility(View.GONE);
|
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
|
|
|
Helper.view(context, owner, Uri.parse(url), true);
|
|
|
|
|
return true;
|
|
|
|
@ -2413,7 +2461,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|
|
|
|
this.avatars = (prefs.getBoolean("avatars", true) ||
|
|
|
|
|
prefs.getBoolean("identicons", false));
|
|
|
|
|
this.preview = prefs.getBoolean("preview", false);
|
|
|
|
|
this.autoimages = prefs.getBoolean("autoimages", false);
|
|
|
|
|
this.autohtml = prefs.getBoolean("autohtml", false);
|
|
|
|
|
this.autoimages = (!this.autohtml && prefs.getBoolean("autoimages", false));
|
|
|
|
|
this.debug = prefs.getBoolean("debug", false);
|
|
|
|
|
|
|
|
|
|
this.textSize = Helper.getTextSize(context, zoom);
|
|
|
|
|