Collapsible composer attachments

master
M66B 2 weeks ago
parent e81d2dd3b5
commit 3da2792d1a

@ -219,6 +219,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
put("Bozze", new TypeScore(EntityFolder.DRAFTS, 100));
put("Szkice lokalne", new TypeScore(EntityFolder.DRAFTS, 100)); // Polish
put("Wersje robocze", new TypeScore(EntityFolder.DRAFTS, 100)); // Polish
put("draftbox", new TypeScore(EntityFolder.DRAFTS, 50)); // mailo.com
put("trash", new TypeScore(EntityFolder.TRASH, 100));
put("Deleted", new TypeScore(EntityFolder.TRASH, 100));

@ -259,6 +259,7 @@ public class FragmentCompose extends FragmentBase {
private EditText etSubject;
private ImageButton ibCcBcc;
private ImageButton ibRemoveAttachments;
private ImageButton ibExpanderAttachments;
private RecyclerView rvAttachment;
private TextView tvNoInternetAttachments;
private TextView tvDsn;
@ -293,6 +294,7 @@ public class FragmentCompose extends FragmentBase {
private Group grpReferenceHint;
private ContentResolver resolver;
private TwoStateOwner ownerAttachment;
private AdapterAttachment adapter;
private MarkwonEditorTextWatcher markwonWatcher;
@ -420,6 +422,7 @@ public class FragmentCompose extends FragmentBase {
etSubject = view.findViewById(R.id.etSubject);
ibCcBcc = view.findViewById(R.id.ibCcBcc);
ibRemoveAttachments = view.findViewById(R.id.ibRemoveAttachments);
ibExpanderAttachments = view.findViewById(R.id.ibExpanderAttachments);
rvAttachment = view.findViewById(R.id.rvAttachment);
tvNoInternetAttachments = view.findViewById(R.id.tvNoInternetAttachments);
tvDsn = view.findViewById(R.id.tvDsn);
@ -1518,6 +1521,19 @@ public class FragmentCompose extends FragmentBase {
}
});
ownerAttachment = new TwoStateOwner(getViewLifecycleOwner(), "attachments");
ownerAttachment.start();
ibExpanderAttachments.setVisibility(View.GONE);
ibExpanderAttachments.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean hide_attachments = !Boolean.TRUE.equals(ibExpanderAttachments.getTag());
ibExpanderAttachments.setTag(hide_attachments);
ibExpanderAttachments.setImageLevel(hide_attachments ? 1 /* more */ : 0 /* less */);
ownerAttachment.restart();
}
});
rvAttachment.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvAttachment.setLayoutManager(llm);
@ -6681,14 +6697,16 @@ public class FragmentCompose extends FragmentBase {
for (EntityAttachment attachment : last_attachments)
map.put(attachment.id, attachment);
db.attachment().liveAttachments(data.draft.id).observe(getViewLifecycleOwner(),
db.attachment().liveAttachments(data.draft.id).observe(ownerAttachment,
new Observer<List<EntityAttachment>>() {
@Override
public void onChanged(@Nullable List<EntityAttachment> attachments) {
if (attachments == null)
attachments = new ArrayList<>();
List<EntityAttachment> a = new ArrayList<>(attachments);
boolean hide_attachments = Boolean.TRUE.equals(ibExpanderAttachments.getTag());
List<EntityAttachment> a = (hide_attachments ? new ArrayList<>() : new ArrayList<>(attachments));
rvAttachment.post(new Runnable() {
@Override
public void run() {
@ -6719,7 +6737,9 @@ public class FragmentCompose extends FragmentBase {
}
});
ibRemoveAttachments.setVisibility(attachments.size() > 2 ? View.VISIBLE : View.GONE);
ibRemoveAttachments.setVisibility(attachments.size() > 2 && !hide_attachments ? View.VISIBLE : View.GONE);
ibExpanderAttachments.setVisibility(attachments.size() > 1 ? View.VISIBLE : View.GONE);
ibExpanderAttachments.setImageLevel(hide_attachments ? 1 /* more */ : 0 /* less */);
grpAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
boolean downloading = false;

@ -265,13 +265,26 @@
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments"
app:srcCompat="@drawable/twotone_delete_24" />
<ImageButton
android:id="@+id/ibExpanderAttachments"
android:layout_width="0dp"
android:layout_height="36dp"
android:layout_marginTop="6dp"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/title_legend_expander"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorAttachments"
app:srcCompat="@drawable/expander" />
<eu.faircode.email.FixedRecyclerView
android:id="@+id/rvAttachment"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ibRemoveAttachments"
app:layout_constraintTop_toBottomOf="@+id/ibExpanderAttachments"
app:layout_goneMarginTop="6dp" />
<TextView

Loading…
Cancel
Save