mirror of https://github.com/M66B/FairEmail.git
Allow set don't ask again
This commit is contained in:
parent
450a82c72b
commit
84028c17fb
|
@ -2042,9 +2042,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
|
||||
private void onShowImages(final TupleMessageEx message) {
|
||||
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_show_images, null);
|
||||
final TextView tvTracking = dview.findViewById(R.id.tvTracking);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_show_images, null);
|
||||
TextView tvTracking = dview.findViewById(R.id.tvTracking);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean disable_tracking = prefs.getBoolean("disable_tracking", true);
|
||||
|
@ -2060,21 +2060,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
TextUtils.join(", ", froms)));
|
||||
}
|
||||
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (Address address : message.from) {
|
||||
String from = ((InternetAddress) address).getAddress();
|
||||
editor.putBoolean(from + ".show_images", isChecked);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: dialog fragment
|
||||
final Dialog dialog = new AlertDialog.Builder(context)
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cbNotAgain.isChecked()) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
for (Address address : message.from) {
|
||||
String from = ((InternetAddress) address).getAddress();
|
||||
editor.putBoolean(from + ".show_images", true);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
properties.setValue("images", message.id, true);
|
||||
onShowImagesConfirmed(message);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -38,25 +39,30 @@ public class FragmentDialogAsk extends FragmentDialogBase {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final String question = getArguments().getString("question");
|
||||
final String notagain = getArguments().getString("notagain");
|
||||
String question = getArguments().getString("question");
|
||||
String notagain = getArguments().getString("notagain");
|
||||
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_again, null);
|
||||
TextView tvMessage = dview.findViewById(R.id.tvMessage);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
tvMessage.setText(question);
|
||||
cbNotAgain.setVisibility(notagain == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (notagain != null)
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean(notagain, isChecked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (notagain != null && cbNotAgain.isChecked()) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean(notagain, true).apply();
|
||||
}
|
||||
sendResult(Activity.RESULT_OK);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -69,6 +69,7 @@ import android.webkit.WebViewClient;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
@ -4676,9 +4677,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_error_reporting, null);
|
||||
final Button btnInfo = dview.findViewById(R.id.btnInfo);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_error_reporting, null);
|
||||
Button btnInfo = dview.findViewById(R.id.btnInfo);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
|
||||
btnInfo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -4687,6 +4688,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
}
|
||||
});
|
||||
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("crash_reports_asked", isChecked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
|
@ -4694,20 +4703,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("crash_reports", true).apply();
|
||||
if (cbNotAgain.isChecked())
|
||||
prefs.edit().putBoolean("crash_reports_asked", true).apply();
|
||||
Log.setCrashReporting(true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (cbNotAgain.isChecked()) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
prefs.edit().putBoolean("crash_reports_asked", true).apply();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue