Layout improvements

pull/50/head
M66B 6 years ago
parent 692e54b5eb
commit 71165e2010

@ -108,7 +108,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
ivStatus.setVisibility(View.VISIBLE);
}
ivDelete.setVisibility(readonly ? View.INVISIBLE : View.VISIBLE);
ivDelete.setVisibility(readonly ? View.GONE : View.VISIBLE);
if (attachment.progress != null)
progressbar.setProgress(attachment.progress);

@ -96,15 +96,16 @@ public class FragmentCompose extends FragmentEx {
private EditText etBody;
private BottomNavigationView bottom_navigation;
private ProgressBar pbWait;
private Group grpReady;
private Group grpHeader;
private Group grpAddresses;
private Group grpAttachments;
private Group grpMessage;
private AdapterAttachment adapter;
private long working = -1;
private boolean free = false;
private boolean addresses;
private boolean autosave = true;
private static final int ATTACHMENT_BUFFER_SIZE = 8192; // bytes
@ -130,10 +131,10 @@ public class FragmentCompose extends FragmentEx {
etBody = view.findViewById(R.id.etBody);
bottom_navigation = view.findViewById(R.id.bottom_navigation);
pbWait = view.findViewById(R.id.pbWait);
grpReady = view.findViewById(R.id.grpReady);
grpHeader = view.findViewById(R.id.grpHeader);
grpAddresses = view.findViewById(R.id.grpAddresses);
grpAttachments = view.findViewById(R.id.grpAttachments);
grpMessage = view.findViewById(R.id.grpMessage);
// Wire controls
@ -183,6 +184,7 @@ public class FragmentCompose extends FragmentEx {
getActivity().invalidateOptionsMenu();
grpHeader.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
if (hasFocus) {
addresses = (grpAddresses.getVisibility() != View.GONE);
grpAddresses.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE);
}
@ -199,7 +201,8 @@ public class FragmentCompose extends FragmentEx {
free = false;
getActivity().invalidateOptionsMenu();
grpHeader.setVisibility(View.VISIBLE);
if (addresses)
grpAddresses.setVisibility(View.VISIBLE);
if (rvAttachment.getAdapter().getItemCount() > 0)
grpAttachments.setVisibility(View.VISIBLE);
@ -230,14 +233,15 @@ public class FragmentCompose extends FragmentEx {
setHasOptionsMenu(true);
// Initialize
spFrom.setEnabled(false);
//grpFrom.setVisibility(View.GONE);
grpHeader.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
grpMessage.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
Helper.setViewsEnabled(view, false);
getActivity().invalidateOptionsMenu();
spFrom.setEnabled(false);
Helper.setViewsEnabled(view, false);
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CONTACTS)
== PackageManager.PERMISSION_GRANTED) {
@ -347,7 +351,7 @@ public class FragmentCompose extends FragmentEx {
@Override
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.menu_attachment).setVisible(working >= 0);
menu.findItem(R.id.menu_attachment).setVisible(!free && working >= 0);
menu.findItem(R.id.menu_attachment).setEnabled(etBody.isEnabled());
menu.findItem(R.id.menu_addresses).setVisible(!free && working >= 0);
}
@ -678,11 +682,6 @@ public class FragmentCompose extends FragmentEx {
String action = getArguments().getString("action");
Log.i(Helper.TAG, "Loaded draft id=" + draft.id + " action=" + action);
getActivity().invalidateOptionsMenu();
pbWait.setVisibility(View.GONE);
grpAddresses.setVisibility("reply_all".equals(action) ? View.VISIBLE : View.GONE);
grpReady.setVisibility(View.VISIBLE);
etTo.setText(draft.to == null ? null : TextUtils.join(", ", draft.to));
etCc.setText(draft.cc == null ? null : TextUtils.join(", ", draft.cc));
etBcc.setText(draft.bcc == null ? null : TextUtils.join(", ", draft.bcc));
@ -690,15 +689,20 @@ public class FragmentCompose extends FragmentEx {
etBody.setText(TextUtils.isEmpty(draft.body) ? null : Html.fromHtml(draft.body));
getActivity().invalidateOptionsMenu();
Helper.setViewsEnabled(view, true);
pbWait.setVisibility(View.GONE);
grpHeader.setVisibility(View.VISIBLE);
grpAddresses.setVisibility("reply_all".equals(action) ? View.VISIBLE : View.GONE);
grpMessage.setVisibility(View.VISIBLE);
if ("reply".equals(action) || "reply_all".equals(action)) {
etBody.requestFocus();
etBody.setSelection(0);
} else if ("forward".equals(action))
etTo.requestFocus();
Helper.setViewsEnabled(view, true);
getActivity().invalidateOptionsMenu();
DB db = DB.getInstance(getContext());
db.identity().liveIdentities(true).removeObservers(getViewLifecycleOwner());
@ -756,7 +760,6 @@ public class FragmentCompose extends FragmentEx {
}
spFrom.setEnabled(true);
//grpFrom.setVisibility(View.VISIBLE);
}
});

@ -84,10 +84,10 @@ public class FragmentMessage extends FragmentEx {
private FloatingActionButton fab;
private BottomNavigationView bottom_navigation;
private ProgressBar pbWait;
private Group grpReady;
private Group grpHeader;
private Group grpAddresses;
private Group grpAttachments;
private Group grpMessage;
private boolean free = false;
private AdapterAttachment adapter;
@ -121,10 +121,10 @@ public class FragmentMessage extends FragmentEx {
fab = view.findViewById(R.id.fab);
bottom_navigation = view.findViewById(R.id.bottom_navigation);
pbWait = view.findViewById(R.id.pbWait);
grpReady = view.findViewById(R.id.grpReady);
grpHeader = view.findViewById(R.id.grpHeader);
grpAddresses = view.findViewById(R.id.grpAddresses);
grpAttachments = view.findViewById(R.id.grpAttachments);
grpMessage = view.findViewById(R.id.grpMessage);
setHasOptionsMenu(true);
@ -200,6 +200,8 @@ public class FragmentMessage extends FragmentEx {
});
fab.setOnClickListener(new View.OnClickListener() {
private boolean addresses;
@Override
public void onClick(View view) {
free = (top_navigation.getVisibility() != View.GONE);
@ -207,10 +209,13 @@ public class FragmentMessage extends FragmentEx {
grpHeader.setVisibility(free ? View.GONE : View.VISIBLE);
if (free) {
fab.setImageResource(R.drawable.baseline_fullscreen_exit_24);
addresses = (grpAddresses.getVisibility() != View.GONE);
grpAddresses.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE);
} else {
fab.setImageResource(R.drawable.baseline_fullscreen_24);
if (addresses)
grpAddresses.setVisibility(View.VISIBLE);
if (rvAttachment.getAdapter().getItemCount() > 0)
grpAttachments.setVisibility(View.VISIBLE);
}
@ -242,12 +247,12 @@ public class FragmentMessage extends FragmentEx {
});
// Initialize
grpHeader.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE);
grpMessage.setVisibility(View.GONE);
tvCount.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
top_navigation.setVisibility(View.GONE);
bottom_navigation.setVisibility(View.GONE);
grpReady.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
rvAttachment.setHasFixedSize(false);
@ -287,7 +292,6 @@ public class FragmentMessage extends FragmentEx {
tvSubject.setText(message.subject);
tvCount.setText(Integer.toString(message.count));
tvCount.setVisibility(message.count > 1 ? View.VISIBLE : View.GONE);
tvReplyTo.setText(message.reply == null ? null : MessageHelper.getFormattedAddresses(message.reply, true));
tvCc.setText(message.cc == null ? null : MessageHelper.getFormattedAddresses(message.cc, true));
@ -305,7 +309,6 @@ public class FragmentMessage extends FragmentEx {
tvTime.setTextColor(colorUnseen);
tvError.setText(message.error);
tvError.setVisibility(message.error == null ? View.GONE : View.VISIBLE);
MenuItem actionSeen = top_navigation.getMenu().findItem(R.id.action_seen);
actionSeen.setIcon(message.ui_seen
@ -368,7 +371,10 @@ public class FragmentMessage extends FragmentEx {
}
pbWait.setVisibility(View.GONE);
grpReady.setVisibility(View.VISIBLE);
grpHeader.setVisibility(View.VISIBLE);
grpMessage.setVisibility(View.VISIBLE);
tvCount.setVisibility(message.count > 1 ? View.VISIBLE : View.GONE);
tvError.setVisibility(message.error == null ? View.GONE : View.VISIBLE);
}
});
@ -412,8 +418,7 @@ public class FragmentMessage extends FragmentEx {
}
private void onMenuAddresses() {
if (grpReady.getVisibility() == View.VISIBLE)
grpAddresses.setVisibility(grpAddresses.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
grpAddresses.setVisibility(grpAddresses.getVisibility() == View.GONE ? View.VISIBLE : View.GONE);
}
private void onActionThread(long id) {

@ -133,7 +133,7 @@
android:scrollbars="vertical"
app:layout_constrainedHeight="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="150dp"
app:layout_constraintHeight_max="90dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
@ -194,12 +194,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpReady"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="etTo,ivToAdd,etSubject,vSeparator,scroll,bottom_navigation" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpHeader"
android:layout_width="0dp"
@ -217,4 +211,10 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorAttachments,rvAttachment" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpMessage"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="scroll,bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -180,7 +180,7 @@
android:scrollbars="vertical"
app:layout_constrainedHeight="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_max="150dp"
app:layout_constraintHeight_max="90dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
@ -270,17 +270,11 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpReady"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvTime,tvSubject,tvCount,scroll,fab" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpHeader"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvTime,tvSubject,tvCount,top_navigation" />
app:constraint_referenced_ids="tvFrom,tvToTitle,tvTo,tvTime,tvSubject,top_navigation" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpAddresses"
@ -293,4 +287,10 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorAttachments,rvAttachment" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpMessage"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="scroll,fab,bottom_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save