Merge pull request #4324 from ByteHamster/streaming-confirmation-dialog

Make mobile streaming dialog easier to understand
This commit is contained in:
H. Lehmann 2020-07-27 14:27:56 +02:00 committed by GitHub
commit 8fa1a9c03c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,6 @@
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;
@ -19,25 +17,24 @@ public class StreamingConfirmationDialog {
}
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();
.setPositiveButton(R.string.stream_label, (dialog, which) -> stream())
.setNegativeButton(R.string.confirm_mobile_streaming_button_always, (dialog, which) -> {
UserPreferences.setAllowMobileStreaming(true);
stream();
})
.setNegativeButton(R.string.cancel_label, null)
.setNeutralButton(R.string.cancel_label, null)
.show();
}
private void stream() {
new PlaybackServiceStarter(context, playable)
.callEvenIfRunning(true)
.startWhenPrepared(true)
.shouldStream(true)
.shouldStreamThisTime(true)
.start();
}
}