@@ -351,52 +351,22 @@ private void showBackupCancelDialog() {
351351 */
352352 private void showDestructiveCancelDialog () {
353353 if (!isAdded ()) return ;
354- final float density = getResources ().getDisplayMetrics ().density ;
355- // ADFA-5339 pattern: a MaterialCheckBox as a dialog's custom view sits flush-left; a holder padded by
356- // dialogPreferredPadding (the title/message inset) with the checkbox's own left padding at 0 lines it
357- // up with the text above.
358- final com .google .android .material .checkbox .MaterialCheckBox box =
359- new com .google .android .material .checkbox .MaterialCheckBox (requireContext ());
360- box .setText (R .string .k2go_br_cancel_extract_ack );
361- box .setCompoundDrawablePadding (Math .round (8 * density ));
362- final int pad = dialogContentPadding ();
363- final android .widget .FrameLayout holder = new android .widget .FrameLayout (requireContext ());
364- holder .setPadding (pad , Math .round (8 * density ), pad , 0 );
365- holder .addView (box );
366- final androidx .appcompat .app .AlertDialog d =
367- new com .google .android .material .dialog .MaterialAlertDialogBuilder (requireContext ())
368- .setTitle (R .string .k2go_br_cancel_title )
369- .setMessage (R .string .k2go_br_cancel_extract_body )
370- .setView (holder )
371- .setPositiveButton (R .string .k2go_br_cancel_confirm , null ) // click set below to gate dismiss
372- .setNegativeButton (R .string .k2go_br_cancel_keep , null )
373- .show ();
374- final android .widget .Button confirm = d .getButton (androidx .appcompat .app .AlertDialog .BUTTON_POSITIVE );
375- confirm .setTextColor (ContextCompat .getColor (requireContext (), R .color .btn_danger )); // same red as BrandDialog DESTRUCTIVE
376- // K2GO-384: keep the button ENABLED and validate on click -- an inert disabled button gives no
377- // feedback; a snackbar tells the user why nothing happened until they acknowledge.
378- confirm .setOnClickListener (v -> {
379- if (!box .isChecked ()) {
380- Snackbars .make (requireActivity ().findViewById (android .R .id .content ),
381- R .string .k2go_br_cancel_extract_need_ack ).show ();
382- return ;
383- }
384- // K2GO-384: the destructive kill ends as FAILED with the "damaged" message (non-empty), so the
385- // terminal shows -- the user sees "the next launch will start recovery" (no CANCELLED short-circuit).
386- if (cancel != null ) cancel .setEnabled (false );
387- sendToService (DeepOpService .ACTION_FORCE_CANCEL );
388- d .dismiss ();
389- });
390- }
391-
392- /** The dialog's horizontal content inset (title/message use it); a custom view must match it to line up
393- * (ADFA-5339). */
394- private int dialogContentPadding () {
395- android .util .TypedValue tv = new android .util .TypedValue ();
396- if (requireContext ().getTheme ().resolveAttribute (androidx .appcompat .R .attr .dialogPreferredPadding , tv , true )) {
397- return android .util .TypedValue .complexToDimensionPixelSize (tv .data , getResources ().getDisplayMetrics ());
398- }
399- return Math .round (24 * getResources ().getDisplayMetrics ().density ); // Material default
354+ // K2GO-384: a checkbox-gated destructive confirm. The acknowledgement is required (the shared dialog
355+ // blocks the RED confirm and shows the inline "please tick" note until it is checked); the red comes
356+ // from BrandDialog's DESTRUCTIVE role.
357+ new BrandDialog (requireContext ())
358+ .setTitle (R .string .k2go_br_cancel_title )
359+ .setMessage (R .string .k2go_br_cancel_extract_body )
360+ .setCheckbox (R .string .k2go_br_cancel_extract_ack , false )
361+ .requireCheckbox (R .string .k2go_br_cancel_extract_need_ack )
362+ .setDestructive (R .string .k2go_br_cancel_confirm , checked -> {
363+ // K2GO-384: the destructive kill ends as FAILED with the "damaged" message (non-empty), so
364+ // the terminal shows -- the user sees "the next launch will start recovery".
365+ if (cancel != null ) cancel .setEnabled (false );
366+ sendToService (DeepOpService .ACTION_FORCE_CANCEL );
367+ })
368+ .setNegative (R .string .k2go_br_cancel_keep , null )
369+ .show ();
400370 }
401371
402372 /** K2GO-384: Cancel is shown while the current pass is cancellable (PAUSABLE copy or ABORTABLE
0 commit comments