package de.danoeh.antennapod.dialog;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import androidx.appcompat.app.AlertDialog;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.playback.Playable;
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;

public class StreamingConfirmationDialog {
    private final Context context;
    private final Playable playable;

    public StreamingConfirmationDialog(Context context, Playable playable) {
        this.context = context;
        this.playable = playable;
    }

    public void show() {
        View view = View.inflate(context, R.layout.checkbox_do_not_show_again, null);
        CheckBox checkDoNotShowAgain = view.findViewById(R.id.checkbox_do_not_show_again);

        new AlertDialog.Builder(context)
                .setTitle(R.string.stream_label)
                .setMessage(R.string.confirm_mobile_streaming_notification_message)
                .setView(view)
                .setPositiveButton(R.string.stream_label, (dialog, which) -> {
                    if (checkDoNotShowAgain.isChecked()) {
                        UserPreferences.setAllowMobileStreaming(true);
                    }
                    new PlaybackServiceStarter(context, playable)
                            .callEvenIfRunning(true)
                            .startWhenPrepared(true)
                            .shouldStream(true)
                            .shouldStreamThisTime(true)
                            .start();
                })
                .setNegativeButton(R.string.cancel_label, null)
                .show();
    }
}

@@ -67,66 +67,8 @@
 xt;%0A
-import android.view.View;%0Aimport android.widget.CheckBox;%0A
 impo
@@ -623,186 +623,8 @@
 ) %7B%0A
-        View view = View.inflate(context, R.layout.checkbox_do_not_show_again, null);%0A        CheckBox checkDoNotShowAgain = view.findViewById(R.id.checkbox_do_not_show_again);%0A%0A
     
@@ -797,39 +797,8 @@
 ge)%0A
-                .setView(view)%0A
     
@@ -870,17 +870,25 @@
 ich) -%3E 
-%7B
+stream())
 %0A       
@@ -900,156 +900,336 @@
     
-    if (checkDoNotShowAgain.isChecked()) %7B%0A                        UserPreferences.setAllowMobileStreaming(true);%0A                    %7D%0A            
+.setNegativeButton(R.string.confirm_mobile_streaming_button_always, (dialog, which) -%3E %7B%0A                    UserPreferences.setAllowMobileStreaming(true);%0A                    stream();%0A                %7D)%0A                .setNeutralButton(R.string.cancel_label, null)%0A                .show();%0A    %7D%0A%0A    private void stream() %7B%0A
     
@@ -1294,28 +1294,16 @@
         
-           
- 
 .callEve
@@ -1331,36 +1331,24 @@
             
-         
-   
 .startWhenPr
@@ -1372,36 +1372,24 @@
             
-       
-     
 .shouldStrea
@@ -1392,36 +1392,24 @@
 tream(true)%0A
-            
             
@@ -1460,134 +1460,14 @@
     
-   
-         .start();%0A                %7D)%0A                .setNegativeButton(R.string.cancel_label, null)%0A                .show
+.start
 ();%0A

Make mobile streaming dialog easier to understand