mirror of https://github.com/M66B/FairEmail.git
Made send dialog optional
This commit is contained in:
parent
73421032c1
commit
5fc374d1ac
|
@ -461,7 +461,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
onActionDiscard();
|
onActionDiscard();
|
||||||
break;
|
break;
|
||||||
case R.id.action_send:
|
case R.id.action_send:
|
||||||
onActionCheck();
|
onActionCheck(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
onAction(action);
|
onAction(action);
|
||||||
|
@ -935,6 +935,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
case R.id.menu_answer:
|
case R.id.menu_answer:
|
||||||
onMenuAnswer();
|
onMenuAnswer();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_send:
|
||||||
|
onActionCheck(true);
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
@ -1087,8 +1090,15 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onActionCheck() {
|
private void onActionCheck(boolean dialog) {
|
||||||
onAction(R.id.action_check);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
if (dialog)
|
||||||
|
prefs.edit().remove("send_dialog").apply();
|
||||||
|
boolean send_dialog = prefs.getBoolean("send_dialog", true);
|
||||||
|
|
||||||
|
Bundle extras = new Bundle();
|
||||||
|
extras.putBoolean("dialog", dialog || send_dialog);
|
||||||
|
onAction(R.id.action_check, extras);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onEncrypt() {
|
private void onEncrypt() {
|
||||||
|
@ -1755,6 +1765,10 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAction(int action) {
|
private void onAction(int action) {
|
||||||
|
onAction(action, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onAction(int action, Bundle extras) {
|
||||||
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
EntityIdentity identity = (EntityIdentity) spIdentity.getSelectedItem();
|
||||||
if (identity == null)
|
if (identity == null)
|
||||||
throw new IllegalArgumentException(getString(R.string.title_from_missing));
|
throw new IllegalArgumentException(getString(R.string.title_from_missing));
|
||||||
|
@ -1765,8 +1779,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putLong("id", working);
|
args.putLong("id", working);
|
||||||
args.putInt("action", action);
|
args.putInt("action", action);
|
||||||
args.putLong("account", identity == null ? -1 : identity.account);
|
args.putLong("account", identity.account);
|
||||||
args.putLong("identity", identity == null ? -1 : identity.id);
|
args.putLong("identity", identity.id);
|
||||||
args.putString("extra", etExtra.getText().toString().trim());
|
args.putString("extra", etExtra.getText().toString().trim());
|
||||||
args.putString("to", etTo.getText().toString().trim());
|
args.putString("to", etTo.getText().toString().trim());
|
||||||
args.putString("cc", etCc.getText().toString().trim());
|
args.putString("cc", etCc.getText().toString().trim());
|
||||||
|
@ -1774,6 +1788,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
args.putString("subject", etSubject.getText().toString().trim());
|
args.putString("subject", etSubject.getText().toString().trim());
|
||||||
args.putString("body", HtmlHelper.toHtml(etBody.getText()));
|
args.putString("body", HtmlHelper.toHtml(etBody.getText()));
|
||||||
args.putBoolean("empty", isEmpty());
|
args.putBoolean("empty", isEmpty());
|
||||||
|
if (extras != null)
|
||||||
|
args.putBundle("extras", extras);
|
||||||
|
|
||||||
Log.i("Run execute id=" + working);
|
Log.i("Run execute id=" + working);
|
||||||
actionLoader.execute(this, args, "compose:action:" + action);
|
actionLoader.execute(this, args, "compose:action:" + action);
|
||||||
|
@ -2902,10 +2918,17 @@ public class FragmentCompose extends FragmentBase {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|
||||||
} else if (action == R.id.action_check) {
|
} else if (action == R.id.action_check) {
|
||||||
FragmentDialogSend fragment = new FragmentDialogSend();
|
boolean dialog = args.getBundle("extras").getBoolean("dialog");
|
||||||
fragment.setArguments(args);
|
boolean remind_subject = args.getBoolean("remind_subject", false);
|
||||||
fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND);
|
boolean remind_attachment = args.getBoolean("remind_attachment", false);
|
||||||
fragment.show(getFragmentManager(), "compose:send");
|
|
||||||
|
if (dialog || remind_subject || remind_attachment) {
|
||||||
|
FragmentDialogSend fragment = new FragmentDialogSend();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setTargetFragment(FragmentCompose.this, REQUEST_SEND);
|
||||||
|
fragment.show(getFragmentManager(), "compose:send");
|
||||||
|
} else
|
||||||
|
onAction(R.id.action_send);
|
||||||
|
|
||||||
} else if (action == R.id.action_send) {
|
} else if (action == R.id.action_send) {
|
||||||
autosave = false;
|
autosave = false;
|
||||||
|
@ -3576,6 +3599,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
int send_delayed = prefs.getInt("send_delayed", 0);
|
int send_delayed = prefs.getInt("send_delayed", 0);
|
||||||
|
boolean send_dialog = prefs.getBoolean("send_dialog", true);
|
||||||
|
|
||||||
final int[] sendDelayedValues = getResources().getIntArray(R.array.sendDelayedValues);
|
final int[] sendDelayedValues = getResources().getIntArray(R.array.sendDelayedValues);
|
||||||
final String[] sendDelayedNames = getResources().getStringArray(R.array.sendDelayedNames);
|
final String[] sendDelayedNames = getResources().getStringArray(R.array.sendDelayedNames);
|
||||||
|
@ -3589,12 +3613,14 @@ public class FragmentCompose extends FragmentBase {
|
||||||
final ImageButton ibSendAt = dview.findViewById(R.id.ibSendAt);
|
final ImageButton ibSendAt = dview.findViewById(R.id.ibSendAt);
|
||||||
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
|
final TextView tvRemindSubject = dview.findViewById(R.id.tvRemindSubject);
|
||||||
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
|
final TextView tvRemindAttachment = dview.findViewById(R.id.tvRemindAttachment);
|
||||||
|
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||||
|
|
||||||
tvTo.setText(null);
|
tvTo.setText(null);
|
||||||
tvVia.setText(null);
|
tvVia.setText(null);
|
||||||
tvSendAt.setText(null);
|
tvSendAt.setText(null);
|
||||||
tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE);
|
tvRemindSubject.setVisibility(remind_subject ? View.VISIBLE : View.GONE);
|
||||||
tvRemindAttachment.setVisibility(remind_attachment ? View.VISIBLE : View.GONE);
|
tvRemindAttachment.setVisibility(remind_attachment ? View.VISIBLE : View.GONE);
|
||||||
|
cbNotAgain.setVisibility(send_dialog ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
DB db = DB.getInstance(getContext());
|
DB db = DB.getInstance(getContext());
|
||||||
db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() {
|
db.message().liveMessage(id).observe(getViewLifecycleOwner(), new Observer<TupleMessageEx>() {
|
||||||
|
@ -3699,6 +3725,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
getArguments().putBoolean("encrypt", cbEncrypt.isChecked());
|
getArguments().putBoolean("encrypt", cbEncrypt.isChecked());
|
||||||
|
if (cbNotAgain.isChecked())
|
||||||
|
prefs.edit().putBoolean("send_dialog", false).apply();
|
||||||
sendResult(Activity.RESULT_OK);
|
sendResult(Activity.RESULT_OK);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -141,5 +141,15 @@
|
||||||
android:textColor="?attr/colorWarning"
|
android:textColor="?attr/colorWarning"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvRemindSubject" />
|
app:layout_constraintTop_toBottomOf="@id/tvRemindSubject" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cbNotAgain"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_no_ask_again"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvRemindAttachment" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
|
@ -27,4 +27,9 @@
|
||||||
android:id="@+id/menu_answer"
|
android:id="@+id/menu_answer"
|
||||||
android:title="@string/title_insert_template"
|
android:title="@string/title_insert_template"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_send"
|
||||||
|
android:title="@string/title_send_with_options"
|
||||||
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -558,6 +558,7 @@
|
||||||
<string name="title_discard">Discard</string>
|
<string name="title_discard">Discard</string>
|
||||||
<string name="title_save">Save</string>
|
<string name="title_save">Save</string>
|
||||||
<string name="title_send">Send</string>
|
<string name="title_send">Send</string>
|
||||||
|
<string name="title_send_with_options">Send …</string>
|
||||||
<string name="title_send_at">Send at …</string>
|
<string name="title_send_at">Send at …</string>
|
||||||
<string name="title_no_server">No server found at \'%1$s\'</string>
|
<string name="title_no_server">No server found at \'%1$s\'</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue