Added print dialog

This commit is contained in:
M66B
2020-11-22 08:55:50 +01:00
parent 6d431f51c7
commit 13c2ee5b30
2 changed files with 83 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ import android.Manifest;
import android.animation.Animator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -4750,10 +4751,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return;
}
args.putString("question", context.getString(R.string.title_ask_show_html));
args.putString("notagain", "print_html_confirmed");
FragmentDialogAsk ask = new FragmentDialogAsk();
FragmentDialogPrint ask = new FragmentDialogPrint();
ask.setArguments(args);
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_PRINT);
ask.show(parentFragment.getParentFragmentManager(), "message:print");
@@ -6598,4 +6596,41 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return view;
}
}
public static class FragmentDialogPrint extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Bundle args = getArguments();
final Context context = getContext();
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_print, null);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean("print_html_confirmed", 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) {
sendResult(Activity.RESULT_OK);
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
sendResult(Activity.RESULT_CANCELED);
}
})
.create();
}
}
}