mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Allow collapsing addresses
This commit is contained in:
parent
b9a9345ae7
commit
5865a13fa4
4 changed files with 97 additions and 22 deletions
|
@ -137,24 +137,25 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
private ImageView ivFlagged;
|
||||
private ImageView ivAvatar;
|
||||
private TextView tvFrom;
|
||||
private ImageView ivAddContact;
|
||||
private TextView tvSize;
|
||||
private TextView tvTime;
|
||||
private TextView tvTimeEx;
|
||||
private ImageView ivAttachments;
|
||||
private TextView tvSubject;
|
||||
private TextView tvPreview;
|
||||
private TextView tvFolder;
|
||||
private TextView tvCount;
|
||||
private ImageView ivThread;
|
||||
private TextView tvPreview;
|
||||
private TextView tvError;
|
||||
private ProgressBar pbLoading;
|
||||
|
||||
private ImageView ivExpanderAddress;
|
||||
private TextView tvFromEx;
|
||||
private ImageView ivAddContact;
|
||||
private TextView tvTo;
|
||||
private TextView tvReplyTo;
|
||||
private TextView tvCc;
|
||||
private TextView tvBcc;
|
||||
private TextView tvTimeEx;
|
||||
private TextView tvSubjectEx;
|
||||
|
||||
private TextView tvHeaders;
|
||||
|
@ -171,6 +172,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
private RecyclerView rvAttachment;
|
||||
private AdapterAttachment adapter;
|
||||
|
||||
private Group grpAddress;
|
||||
private Group grpHeaders;
|
||||
private Group grpAttachments;
|
||||
private Group grpExpanded;
|
||||
|
@ -199,6 +201,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
tvError = itemView.findViewById(R.id.tvError);
|
||||
pbLoading = itemView.findViewById(R.id.pbLoading);
|
||||
|
||||
ivExpanderAddress = itemView.findViewById(R.id.ivExpanderAddress);
|
||||
tvFromEx = itemView.findViewById(R.id.tvFromEx);
|
||||
tvTo = itemView.findViewById(R.id.tvTo);
|
||||
tvReplyTo = itemView.findViewById(R.id.tvReplyTo);
|
||||
|
@ -226,6 +229,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
adapter = new AdapterAttachment(context, owner, true);
|
||||
rvAttachment.setAdapter(adapter);
|
||||
|
||||
grpAddress = itemView.findViewById(R.id.grpAddress);
|
||||
grpHeaders = itemView.findViewById(R.id.grpHeaders);
|
||||
grpAttachments = itemView.findViewById(R.id.grpAttachments);
|
||||
grpExpanded = itemView.findViewById(R.id.grpExpanded);
|
||||
|
@ -235,6 +239,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
|
||||
private void wire() {
|
||||
itemView.setOnClickListener(this);
|
||||
ivExpanderAddress.setOnClickListener(this);
|
||||
ivAddContact.setOnClickListener(this);
|
||||
bnvActions.setOnNavigationItemSelectedListener(this);
|
||||
btnHtml.setOnClickListener(this);
|
||||
|
@ -243,6 +248,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
|
||||
private void unwire() {
|
||||
itemView.setOnClickListener(null);
|
||||
ivExpanderAddress.setOnClickListener(null);
|
||||
ivAddContact.setOnClickListener(null);
|
||||
bnvActions.setOnNavigationItemSelectedListener(null);
|
||||
btnHtml.setOnClickListener(null);
|
||||
|
@ -255,23 +261,26 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
ivFlagged.setVisibility(View.GONE);
|
||||
ivAvatar.setVisibility(View.GONE);
|
||||
tvFrom.setText(null);
|
||||
ivAddContact.setVisibility(View.GONE);
|
||||
tvSize.setText(null);
|
||||
tvTime.setText(null);
|
||||
ivAttachments.setVisibility(View.GONE);
|
||||
tvSubject.setText(null);
|
||||
tvPreview.setVisibility(View.GONE);
|
||||
tvFolder.setText(null);
|
||||
tvCount.setText(null);
|
||||
ivThread.setVisibility(View.GONE);
|
||||
tvPreview.setVisibility(View.GONE);
|
||||
tvError.setVisibility(View.GONE);
|
||||
pbLoading.setVisibility(View.VISIBLE);
|
||||
|
||||
ivAddContact.setVisibility(View.GONE);
|
||||
pbHeaders.setVisibility(View.GONE);
|
||||
bnvActions.setVisibility(View.GONE);
|
||||
vSeparatorBody.setVisibility(View.GONE);
|
||||
btnHtml.setVisibility(View.GONE);
|
||||
btnImages.setVisibility(View.GONE);
|
||||
pbBody.setVisibility(View.GONE);
|
||||
|
||||
grpAddress.setVisibility(View.GONE);
|
||||
grpHeaders.setVisibility(View.GONE);
|
||||
grpAttachments.setVisibility(View.GONE);
|
||||
grpExpanded.setVisibility(View.GONE);
|
||||
|
@ -280,6 +289,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
private void bindTo(int position, final TupleMessageEx message) {
|
||||
final DB db = DB.getInstance(context);
|
||||
final boolean show_expanded = properties.isExpanded(message.id);
|
||||
boolean show_addresses = properties.showAddresses(message.id);
|
||||
boolean show_headers = properties.showHeaders(message.id);
|
||||
|
||||
pbLoading.setVisibility(View.GONE);
|
||||
|
@ -389,7 +399,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
tvFrom.setTextColor(colorUnseen);
|
||||
tvTime.setTextColor(colorUnseen);
|
||||
|
||||
grpExpanded.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.VISIBLE : View.GONE);
|
||||
grpAddress.setVisibility(viewType == ViewType.THREAD && show_expanded && show_addresses ? View.VISIBLE : View.GONE);
|
||||
ivAddContact.setVisibility(viewType == ViewType.THREAD && show_expanded && contacts && message.from != null ? View.VISIBLE : View.GONE);
|
||||
pbHeaders.setVisibility(View.GONE);
|
||||
grpHeaders.setVisibility(show_headers && show_expanded ? View.VISIBLE : View.GONE);
|
||||
|
@ -399,6 +409,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
btnImages.setVisibility(View.GONE);
|
||||
pbBody.setVisibility(View.GONE);
|
||||
grpAttachments.setVisibility(message.attachments > 0 && show_expanded ? View.VISIBLE : View.GONE);
|
||||
grpExpanded.setVisibility(viewType == ViewType.THREAD && show_expanded ? View.VISIBLE : View.GONE);
|
||||
|
||||
db.folder().liveSystemFolders(message.account).removeObservers(owner);
|
||||
db.attachment().liveAttachments(message.id).removeObservers(owner);
|
||||
|
@ -406,6 +417,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
bnvActions.setTag(null);
|
||||
|
||||
if (show_expanded) {
|
||||
ivExpanderAddress.setImageResource(show_addresses ? R.drawable.baseline_expand_less_24 : R.drawable.baseline_expand_more_24);
|
||||
if (EntityFolder.DRAFTS.equals(message.folderType) ||
|
||||
EntityFolder.OUTBOX.equals(message.folderType) ||
|
||||
EntityFolder.SENT.equals(message.folderType))
|
||||
|
@ -513,7 +525,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
if (view.getId() == R.id.ivAddContact)
|
||||
onAddContact(message);
|
||||
else if (viewType == ViewType.THREAD) {
|
||||
if (view.getId() == R.id.btnHtml) {
|
||||
if (view.getId() == R.id.ivExpanderAddress)
|
||||
onToggleAddresses(pos, message);
|
||||
else if (view.getId() == R.id.btnHtml) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivityView.ACTION_VIEW_FULL)
|
||||
|
@ -522,7 +536,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
} else if (view.getId() == R.id.btnImages)
|
||||
onShowImages(message);
|
||||
else
|
||||
onExpandMessage(pos, message);
|
||||
onToggleMessage(pos, message);
|
||||
} else {
|
||||
if (EntityFolder.DRAFTS.equals(message.folderType))
|
||||
context.startActivity(
|
||||
|
@ -586,6 +600,18 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
}
|
||||
}
|
||||
|
||||
private void onToggleMessage(int pos, EntityMessage message) {
|
||||
boolean expanded = !properties.isExpanded(message.id);
|
||||
properties.setExpanded(message.id, expanded);
|
||||
notifyItemChanged(pos);
|
||||
}
|
||||
|
||||
private void onToggleAddresses(int pos, EntityMessage message) {
|
||||
boolean addresses = !properties.showAddresses(message.id);
|
||||
properties.setAddresses(message.id, addresses);
|
||||
notifyItemChanged(pos);
|
||||
}
|
||||
|
||||
private void onShowImages(EntityMessage message) {
|
||||
properties.setImages(message.id, true);
|
||||
btnImages.setEnabled(false);
|
||||
|
@ -595,12 +621,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
bodyTask.load(context, owner, args);
|
||||
}
|
||||
|
||||
private void onExpandMessage(int pos, EntityMessage message) {
|
||||
boolean expanded = !properties.isExpanded(message.id);
|
||||
properties.setExpanded(message.id, expanded);
|
||||
notifyItemChanged(pos);
|
||||
}
|
||||
|
||||
private SimpleTask<Spanned> bodyTask = new SimpleTask<Spanned>() {
|
||||
private String body = null;
|
||||
|
||||
|
@ -1468,12 +1488,16 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
|||
interface IProperties {
|
||||
void setExpanded(long id, boolean expand);
|
||||
|
||||
void setAddresses(long id, boolean show);
|
||||
|
||||
void setHeaders(long id, boolean show);
|
||||
|
||||
void setImages(long id, boolean show);
|
||||
|
||||
boolean isExpanded(long id);
|
||||
|
||||
boolean showAddresses(long id);
|
||||
|
||||
boolean showHeaders(long id);
|
||||
|
||||
boolean showImages(long id);
|
||||
|
|
|
@ -112,6 +112,7 @@ public class FragmentMessages extends FragmentEx {
|
|||
private int autoCount = 0;
|
||||
private boolean autoExpand = true;
|
||||
private List<Long> expanded = new ArrayList<>();
|
||||
private List<Long> addresses = new ArrayList<>();
|
||||
private List<Long> headers = new ArrayList<>();
|
||||
private List<Long> images = new ArrayList<>();
|
||||
|
||||
|
@ -224,6 +225,14 @@ public class FragmentMessages extends FragmentEx {
|
|||
expanded.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddresses(long id, boolean show) {
|
||||
if (show)
|
||||
addresses.remove(id);
|
||||
else
|
||||
addresses.add(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeaders(long id, boolean show) {
|
||||
if (show)
|
||||
|
@ -245,6 +254,11 @@ public class FragmentMessages extends FragmentEx {
|
|||
return expanded.contains(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showAddresses(long id) {
|
||||
return !addresses.contains(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showHeaders(long id) {
|
||||
return headers.contains(id);
|
||||
|
|
|
@ -234,6 +234,18 @@
|
|||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/paddingBottom" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivExpanderAddress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_expand_less_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFromExTitle"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -242,7 +254,7 @@
|
|||
android:text="@string/title_from"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFromEx"
|
||||
|
@ -255,7 +267,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivAddContact"
|
||||
app:layout_constraintStart_toEndOf="@id/tvFromExTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAddContact"
|
||||
|
@ -264,7 +276,7 @@
|
|||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_import_contacts_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvToTitle"
|
||||
|
@ -528,6 +540,12 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpAddress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvFromExTitle,tvFromEx,tvToTitle,tvTo,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc,tvTimeEx,tvSubjectEx" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpHeaders"
|
||||
android:layout_width="0dp"
|
||||
|
@ -544,6 +562,6 @@
|
|||
android:id="@+id/grpExpanded"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="vSeparatorAddress,tvFromExTitle,tvFromEx,tvToTitle,tvTo,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc,tvTimeEx,tvSubjectEx,tvBody" />
|
||||
app:constraint_referenced_ids="vSeparatorAddress,ivExpanderAddress,tvBody" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
|
@ -226,11 +226,24 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:background="?attr/colorSeparator"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/paddingBottom" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivExpanderAddress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_expand_less_24"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFromExTitle"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -239,7 +252,7 @@
|
|||
android:text="@string/title_from"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toEndOf="@id/vwColor"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFromEx"
|
||||
|
@ -252,7 +265,7 @@
|
|||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivAddContact"
|
||||
app:layout_constraintStart_toEndOf="@id/tvFromExTitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivAddContact"
|
||||
|
@ -261,7 +274,7 @@
|
|||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/baseline_import_contacts_24"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorAddress" />
|
||||
app:layout_constraintTop_toBottomOf="@id/ivExpanderAddress" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvToTitle"
|
||||
|
@ -525,6 +538,12 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpAddress"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvFromExTitle,tvFromEx,tvToTitle,tvTo,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc,tvTimeEx,tvSubjectEx" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpHeaders"
|
||||
android:layout_width="0dp"
|
||||
|
@ -541,6 +560,6 @@
|
|||
android:id="@+id/grpExpanded"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="vSeparatorAddress,tvFromExTitle,tvFromEx,tvToTitle,tvTo,tvReplyToTitle,tvReplyTo,tvCcTitle,tvCc,tvBccTitle,tvBcc,tvTimeEx,tvSubjectEx,tvBody" />
|
||||
app:constraint_referenced_ids="vSeparatorAddress,ivExpanderAddress,tvBody" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
Loading…
Reference in a new issue