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