Ask for confirmation next time

pull/147/head
M66B 6 years ago
parent d54f85618a
commit 7119f537ce

@ -63,6 +63,7 @@ import android.view.ViewTreeObserver;
import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FilterQueryProvider;
import android.widget.ImageView;
@ -151,7 +152,6 @@ public class FragmentCompose extends FragmentEx {
private AdapterAttachment adapter;
private boolean pro;
private boolean autosend;
private long working = -1;
private State state = State.NONE;
@ -163,11 +163,7 @@ public class FragmentCompose extends FragmentEx {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pro = Helper.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
autosend = prefs.getBoolean("autosend", false);
}
@Override
@ -289,6 +285,8 @@ public class FragmentCompose extends FragmentEx {
onDelete();
break;
case R.id.action_send:
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean autosend = prefs.getBoolean("autosend", false);
if (autosend) {
onAction(action);
break;
@ -300,9 +298,15 @@ public class FragmentCompose extends FragmentEx {
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())
.setMessage(getString(R.string.title_ask_send,
MessageHelper.getFormattedAddresses(ato, false)))
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -310,6 +314,13 @@ public class FragmentCompose extends FragmentEx {
}
})
.setNegativeButton(android.R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("autosend", true).apply();
}
})
.show();
} catch (Throwable ex) {
onAction(action);

@ -42,6 +42,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.TextView;
@ -1943,24 +1944,38 @@ public class FragmentMessages extends FragmentEx {
if (result.target == null)
return;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("automove", false))
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("automove", false)) {
moveAskConfirmed(result);
else {
String title = getResources().getQuantityString(
R.plurals.title_moving_messages, result.ids.size(),
result.ids.size(), result.target.getDisplayName(getContext()));
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(title)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
moveAskConfirmed(result);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
return;
}
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(getResources().getQuantityString(
R.plurals.title_moving_messages,
result.ids.size(), result.ids.size(),
result.target.getDisplayName(getContext())));
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
moveAskConfirmed(result);
}
})
.setNegativeButton(android.R.string.cancel, null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (cbNotAgain.isChecked())
prefs.edit().putBoolean("automove", true).apply();
}
})
.show();
}
private void moveAskConfirmed(MessageTarget result) {

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp">
<TextView
android:id="@+id/tvMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_open_link"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:inputType="textUri|textMultiLine"
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessage" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -413,6 +413,7 @@
<string name="title_add">Add</string>
<string name="title_browse">Browse</string>
<string name="title_report">Report</string>
<string name="title_no_ask_again">Do not ask this again</string>
<string name="title_try">Try FairEmail, an open source, privacy friendly email app for Android</string>

Loading…
Cancel
Save