Ask with warning

pull/187/head
M66B 5 years ago
parent bc20fe328e
commit 3800c98239

@ -732,6 +732,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
aargs.putString("question", context.getString(R.string.title_empty_spam_ask)); aargs.putString("question", context.getString(R.string.title_empty_spam_ask));
else else
throw new IllegalArgumentException("Invalid folder type=" + type); throw new IllegalArgumentException("Invalid folder type=" + type);
aargs.putBoolean("warning", true);
aargs.putString("remark", context.getString(R.string.title_empty_all)); aargs.putString("remark", context.getString(R.string.title_empty_all));
aargs.putLong("folder", folder.id); aargs.putLong("folder", folder.id);
aargs.putString("type", type); aargs.putString("type", type);
@ -800,6 +801,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putLong("id", folder.id); aargs.putLong("id", folder.id);
aargs.putString("question", context.getString(R.string.title_folder_delete)); aargs.putString("question", context.getString(R.string.title_folder_delete));
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);

@ -3833,6 +3833,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", context.getString(R.string.title_ask_delete)); aargs.putString("question", context.getString(R.string.title_ask_delete));
aargs.putLong("id", message.id); aargs.putLong("id", message.id);
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);
@ -4402,6 +4403,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", context.getString(R.string.title_ask_delete)); aargs.putString("question", context.getString(R.string.title_ask_delete));
aargs.putLong("id", message.id); aargs.putLong("id", message.id);
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);

@ -1635,6 +1635,7 @@ public class FragmentAccount extends FragmentBase {
private void onMenuDelete() { private void onMenuDelete() {
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_account_delete)); aargs.putString("question", getString(R.string.title_account_delete));
aargs.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);

@ -239,6 +239,7 @@ public class FragmentAnswer extends FragmentBase {
private void onActionDelete() { private void onActionDelete() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete_answer)); args.putString("question", getString(R.string.title_ask_delete_answer));
args.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(args); fragment.setArguments(args);

@ -1826,6 +1826,7 @@ public class FragmentCompose extends FragmentBase {
else { else {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_discard)); args.putString("question", getString(R.string.title_ask_discard));
args.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(args); fragment.setArguments(args);

@ -21,8 +21,10 @@ package eu.faircode.email;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -39,11 +41,16 @@ public class FragmentDialogAsk extends FragmentDialogBase {
@NonNull @NonNull
@Override @Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
String question = getArguments().getString("question"); Bundle args = getArguments();
String remark = getArguments().getString("remark"); String question = args.getString("question");
String notagain = getArguments().getString("notagain"); String remark = args.getString("remark");
String notagain = args.getString("notagain");
boolean warning = args.getBoolean("warning");
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null); final Context context = getContext();
final int colorError = Helper.resolveColor(context, R.attr.colorError);
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null);
TextView tvMessage = dview.findViewById(R.id.tvMessage); TextView tvMessage = dview.findViewById(R.id.tvMessage);
TextView tvRemark = dview.findViewById(R.id.tvRemark); TextView tvRemark = dview.findViewById(R.id.tvRemark);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain); CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
@ -53,11 +60,19 @@ public class FragmentDialogAsk extends FragmentDialogBase {
tvRemark.setVisibility(remark == null ? View.GONE : View.VISIBLE); tvRemark.setVisibility(remark == null ? View.GONE : View.VISIBLE);
cbNotAgain.setVisibility(notagain == null ? View.GONE : View.VISIBLE); cbNotAgain.setVisibility(notagain == null ? View.GONE : View.VISIBLE);
if (warning) {
Drawable w = context.getResources().getDrawable(R.drawable.twotone_warning_24, context.getTheme());
w.setBounds(0, 0, w.getIntrinsicWidth(), w.getIntrinsicHeight());
w.setTint(colorError);
tvMessage.setCompoundDrawablesRelative(w, null, null, null);
tvMessage.setCompoundDrawablePadding(Helper.dp2pixels(context, 12));
}
if (notagain != null) if (notagain != null)
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean(notagain, isChecked).apply(); prefs.edit().putBoolean(notagain, isChecked).apply();
} }
}); });

@ -385,6 +385,7 @@ public class FragmentFolder extends FragmentBase {
private void onMenuDelete() { private void onMenuDelete() {
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_folder_delete)); aargs.putString("question", getString(R.string.title_folder_delete));
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);

@ -1295,6 +1295,7 @@ public class FragmentIdentity extends FragmentBase {
private void onMenuDelete() { private void onMenuDelete() {
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_identity_delete)); aargs.putString("question", getString(R.string.title_identity_delete));
aargs.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);

@ -2195,6 +2195,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete)); args.putString("question", getString(R.string.title_ask_delete));
args.putLong("id", message.id); args.putLong("id", message.id);
args.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(args); ask.setArguments(args);
@ -3097,6 +3098,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
aargs.putString("question", getResources() aargs.putString("question", getResources()
.getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size())); .getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size()));
aargs.putLongArray("ids", Helper.toLongArray(ids)); aargs.putLongArray("ids", Helper.toLongArray(ids));
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);
@ -3373,6 +3375,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
aargs.putString("question", getResources() aargs.putString("question", getResources()
.getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size())); .getQuantityString(R.plurals.title_deleting_messages, ids.size(), ids.size()));
aargs.putLongArray("ids", Helper.toLongArray(ids)); aargs.putLongArray("ids", Helper.toLongArray(ids));
aargs.putBoolean("warning", true);
FragmentDialogAsk ask = new FragmentDialogAsk(); FragmentDialogAsk ask = new FragmentDialogAsk();
ask.setArguments(aargs); ask.setArguments(aargs);
@ -4132,6 +4135,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
account < 0 ? R.string.title_empty_spam_all_ask : R.string.title_empty_spam_ask)); account < 0 ? R.string.title_empty_spam_all_ask : R.string.title_empty_spam_ask));
else else
throw new IllegalArgumentException("Invalid folder type=" + type); throw new IllegalArgumentException("Invalid folder type=" + type);
aargs.putBoolean("warning", true);
aargs.putString("remark", getString(R.string.title_empty_all)); aargs.putString("remark", getString(R.string.title_empty_all));
aargs.putLong("account", account); aargs.putLong("account", account);
aargs.putString("type", type); aargs.putString("type", type);

@ -701,6 +701,7 @@ public class FragmentPop extends FragmentBase {
private void onMenuDelete() { private void onMenuDelete() {
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putString("question", getString(R.string.title_account_delete)); aargs.putString("question", getString(R.string.title_account_delete));
aargs.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(aargs); fragment.setArguments(aargs);

@ -947,6 +947,7 @@ public class FragmentRule extends FragmentBase {
private void onActionDelete() { private void onActionDelete() {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString("question", getString(R.string.title_ask_delete_rule)); args.putString("question", getString(R.string.title_ask_delete_rule));
args.putBoolean("warning", true);
FragmentDialogAsk fragment = new FragmentDialogAsk(); FragmentDialogAsk fragment = new FragmentDialogAsk();
fragment.setArguments(args); fragment.setArguments(args);

Loading…
Cancel
Save