Rearranged send dialog

pull/162/head
M66B 6 years ago
parent 5c85304090
commit ed18649822

@ -3428,30 +3428,32 @@ public class FragmentCompose extends FragmentBase {
final int[] sendDelayedValues = getResources().getIntArray(R.array.sendDelayedValues);
final String[] sendDelayedNames = getResources().getStringArray(R.array.sendDelayedNames);
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_send, null);
final ViewGroup dview = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.dialog_send, null);
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
final TextView tvTo = dview.findViewById(R.id.tvTo);
final TextView tvVia = dview.findViewById(R.id.tvVia);
final CheckBox cbPlainOnly = dview.findViewById(R.id.cbPlainOnly);
final CheckBox cbEncrypt = dview.findViewById(R.id.cbEncrypt);
final Spinner spPriority = dview.findViewById(R.id.spPriority);
final TextView tvSendAt = dview.findViewById(R.id.tvSendAt);
final ImageButton ibSendAt = dview.findViewById(R.id.ibSendAt);
final Spinner spPriority = dview.findViewById(R.id.spPriority);
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
final TextView tvNotAgain = dview.findViewById(R.id.tvNotAgain);
tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE);
tvRemindAttachment.setVisibility(remind_attachment ? View.VISIBLE : View.GONE);
tvTo.setText(null);
tvVia.setText(null);
tvSendAt.setText(null);
spPriority.setTag(1);
spPriority.setSelection(1);
tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE);
tvRemindAttachment.setVisibility(remind_attachment ? View.VISIBLE : View.GONE);
tvSendAt.setText(null);
cbNotAgain.setChecked(!send_dialog);
cbNotAgain.setVisibility(dialog ? View.VISIBLE : View.GONE);
tvNotAgain.setVisibility(cbNotAgain.isChecked() && send_dialog ? View.VISIBLE : View.GONE);
Helper.setViewsEnabled(dview, false);
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -3459,44 +3461,6 @@ public class FragmentCompose extends FragmentBase {
}
});
DB db = DB.getInstance(getContext());
db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() {
@Override
public void onChanged(TupleMessageEx draft) {
if (draft == null) {
dismiss();
return;
}
int plus = (draft.cc == null ? 0 : draft.cc.length) +
(draft.bcc == null ? 0 : draft.bcc.length);
tvTo.setText(MessageHelper.formatAddressesShort(draft.to) + (plus > 0 ? " +" + plus : ""));
tvVia.setText(draft.identityEmail);
cbPlainOnly.setChecked(draft.plain_only != null && draft.plain_only);
cbEncrypt.setChecked(draft.encrypt != null && draft.encrypt);
if (draft.ui_snoozed == null) {
if (send_delayed == 0)
tvSendAt.setText(getString(R.string.title_now));
else
for (int pos = 0; pos < sendDelayedValues.length; pos++)
if (sendDelayedValues[pos] == send_delayed) {
tvSendAt.setText(getString(R.string.title_after, sendDelayedNames[pos]));
break;
}
} else {
DateFormat DTF = Helper.getDateTimeInstance(getContext(), SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
DateFormat D = new SimpleDateFormat("E");
tvSendAt.setText(D.format(draft.ui_snoozed) + " " + DTF.format(draft.ui_snoozed));
}
int priority = (draft.priority == null ? 1 : draft.priority);
spPriority.setTag(priority);
spPriority.setSelection(priority);
}
});
cbPlainOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -3551,20 +3515,6 @@ public class FragmentCompose extends FragmentBase {
}
});
ibSendAt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle args = new Bundle();
args.putString("title", getString(R.string.title_send_at));
args.putLong("id", id);
FragmentDialogDuration fragment = new FragmentDialogDuration();
fragment.setArguments(args);
fragment.setTargetFragment(FragmentDialogSend.this, 1);
fragment.show(getFragmentManager(), "send:snooze");
}
});
spPriority.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -3606,6 +3556,60 @@ public class FragmentCompose extends FragmentBase {
}
});
ibSendAt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle args = new Bundle();
args.putString("title", getString(R.string.title_send_at));
args.putLong("id", id);
FragmentDialogDuration fragment = new FragmentDialogDuration();
fragment.setArguments(args);
fragment.setTargetFragment(FragmentDialogSend.this, 1);
fragment.show(getFragmentManager(), "send:snooze");
}
});
DB db = DB.getInstance(getContext());
db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() {
@Override
public void onChanged(TupleMessageEx draft) {
if (draft == null) {
dismiss();
return;
}
int plus = (draft.cc == null ? 0 : draft.cc.length) +
(draft.bcc == null ? 0 : draft.bcc.length);
tvTo.setText(MessageHelper.formatAddressesShort(draft.to) + (plus > 0 ? " +" + plus : ""));
tvVia.setText(draft.identityEmail);
cbPlainOnly.setChecked(draft.plain_only != null && draft.plain_only);
cbEncrypt.setChecked(draft.encrypt != null && draft.encrypt);
int priority = (draft.priority == null ? 1 : draft.priority);
spPriority.setTag(priority);
spPriority.setSelection(priority);
if (draft.ui_snoozed == null) {
if (send_delayed == 0)
tvSendAt.setText(getString(R.string.title_now));
else
for (int pos = 0; pos < sendDelayedValues.length; pos++)
if (sendDelayedValues[pos] == send_delayed) {
tvSendAt.setText(getString(R.string.title_after, sendDelayedNames[pos]));
break;
}
} else {
DateFormat DTF = Helper.getDateTimeInstance(getContext(), SimpleDateFormat.MEDIUM, SimpleDateFormat.SHORT);
DateFormat D = new SimpleDateFormat("E");
tvSendAt.setText(D.format(draft.ui_snoozed) + " " + DTF.format(draft.ui_snoozed));
}
Helper.setViewsEnabled(dview, true);
}
});
return new AlertDialog.Builder(getContext())
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

@ -20,15 +20,37 @@
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvToTitle"
android:id="@+id/tvRemindSubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/title_to"
android:text="@string/title_subject_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
<TextView
android:id="@+id/tvRemindAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_attachment_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindSubject" />
<TextView
android:id="@+id/tvToTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_to"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindAttachment" />
<TextView
android:id="@+id/tvViaTitle"
android:layout_width="wrap_content"
@ -88,6 +110,26 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPlainOnly" />
<TextView
android:id="@+id/tvPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_send_priority"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbEncrypt" />
<Spinner
android:id="@+id/spPriority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:entries="@array/priorityNames"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPriority" />
<TextView
android:id="@+id/tvSendTitle"
android:layout_width="0dp"
@ -97,7 +139,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/ibSendAt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cbEncrypt" />
app:layout_constraintTop_toBottomOf="@+id/spPriority" />
<TextView
android:id="@+id/tvSendAt"
@ -117,53 +159,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/title_send_at"
android:tag="disable"
android:tooltipText="@string/title_send_at"
app:layout_constraintBottom_toBottomOf="@id/tvSendAt"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/baseline_timelapse_24" />
<TextView
android:id="@+id/tvPriority"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_send_priority"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ibSendAt" />
<Spinner
android:id="@+id/spPriority"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:entries="@array/priorityNames"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPriority" />
<TextView
android:id="@+id/tvRemindSubject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_subject_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spPriority" />
<TextView
android:id="@+id/tvRemindAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_attachment_reminder"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindSubject" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
@ -172,7 +173,7 @@
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvRemindAttachment" />
app:layout_constraintTop_toBottomOf="@id/ibSendAt" />
<TextView
android:id="@+id/tvNotAgain"

Loading…
Cancel
Save