mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-04 06:20:26 +00:00
Refactoring
This commit is contained in:
parent
2e9c48bf10
commit
9ce6111979
1 changed files with 39 additions and 35 deletions
|
@ -347,41 +347,7 @@ public class FragmentCompose extends FragmentEx {
|
|||
break;
|
||||
|
||||
case R.id.action_send:
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean autosend = prefs.getBoolean("autosend", false);
|
||||
if (autosend) {
|
||||
onAction(action);
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
String to = etTo.getText().toString();
|
||||
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to));
|
||||
if (ato.length == 0)
|
||||
throw new IllegalArgumentException(getString(R.string.title_to_missing));
|
||||
|
||||
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null);
|
||||
final TextView tvMessage = dview.findViewById(R.id.tvMessage);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
tvMessage.setText(getString(R.string.title_ask_send,
|
||||
MessageHelper.getFormattedAddresses(ato, false)));
|
||||
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cbNotAgain.isChecked())
|
||||
prefs.edit().putBoolean("autosend", true).apply();
|
||||
onAction(action);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
} catch (Throwable ex) {
|
||||
onAction(action);
|
||||
}
|
||||
onActionSend();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -874,6 +840,44 @@ public class FragmentCompose extends FragmentEx {
|
|||
.show();
|
||||
}
|
||||
|
||||
private void onActionSend() {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean autosend = prefs.getBoolean("autosend", false);
|
||||
if (autosend) {
|
||||
onAction(R.id.action_send);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String to = etTo.getText().toString();
|
||||
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to));
|
||||
if (ato.length == 0)
|
||||
throw new IllegalArgumentException(getString(R.string.title_to_missing));
|
||||
|
||||
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null);
|
||||
final TextView tvMessage = dview.findViewById(R.id.tvMessage);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
tvMessage.setText(getString(R.string.title_ask_send,
|
||||
MessageHelper.getFormattedAddresses(ato, false)));
|
||||
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cbNotAgain.isChecked())
|
||||
prefs.edit().putBoolean("autosend", true).apply();
|
||||
onAction(R.id.action_send);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
} catch (Throwable ex) {
|
||||
onAction(R.id.action_send);
|
||||
}
|
||||
}
|
||||
|
||||
private void onEncrypt() {
|
||||
if (Helper.isPro(getContext())) {
|
||||
if (pgpService.isBound())
|
||||
|
|
Loading…
Reference in a new issue