From 2b89e24a4b191345d8f733513bcf9adaa7338260 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Mon, 26 Sep 2016 20:18:32 +0200 Subject: [PATCH] make download dialog use radio button --- .../newpipe/download/DownloadDialog.java | 20 ++++++++++--------- app/src/main/res/layout/dialog_url.xml | 10 ++++++++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index c7018ae1d..57dd4bd85 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -19,8 +19,8 @@ import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.CheckBox; import android.widget.EditText; +import android.widget.RadioButton; import android.widget.SeekBar; import android.widget.TextView; @@ -175,13 +175,15 @@ public class DownloadDialog extends DialogFragment { protected void checkDownloadOptions(){ View view = getView(); Bundle arguments = getArguments(); - CheckBox audio = (CheckBox) view.findViewById(R.id.audio); - CheckBox video = (CheckBox) view.findViewById(R.id.video); + RadioButton audioButton = (RadioButton) view.findViewById(R.id.audio_button); + RadioButton videoButton = (RadioButton) view.findViewById(R.id.video_button); if(arguments.getString(AUDIO_URL) == null) { - audio.setVisibility(View.GONE); + audioButton.setVisibility(View.GONE); + videoButton.setChecked(true); } else if(arguments.getString(VIDEO_URL) == null) { - video.setVisibility(View.GONE); + videoButton.setVisibility(View.GONE); + audioButton.setChecked(true); } } @@ -211,15 +213,15 @@ public class DownloadDialog extends DialogFragment { Bundle arguments = getArguments(); final EditText name = (EditText) view.findViewById(R.id.file_name); final SeekBar threads = (SeekBar) view.findViewById(R.id.threads); - CheckBox audio = (CheckBox) view.findViewById(R.id.audio); - CheckBox video = (CheckBox) view.findViewById(R.id.video); + RadioButton audioButton = (RadioButton) view.findViewById(R.id.audio_button); + RadioButton videoButton = (RadioButton) view.findViewById(R.id.video_button); String fName = name.getText().toString().trim(); // todo: add timeout? would be bad if the thread gets locked dueto this. while (mBinder == null); - if(audio.isChecked()){ + if(audioButton.isChecked()){ int res = mManager.startMission( arguments.getString(AUDIO_URL), fName + arguments.getString(FILE_SUFFIX_AUDIO), @@ -227,7 +229,7 @@ public class DownloadDialog extends DialogFragment { mBinder.onMissionAdded(mManager.getMission(res)); } - if(video.isChecked()){ + if(videoButton.isChecked()){ int res = mManager.startMission( arguments.getString(VIDEO_URL), fName + arguments.getString(FILE_SUFFIX_VIDEO), diff --git a/app/src/main/res/layout/dialog_url.xml b/app/src/main/res/layout/dialog_url.xml index fb61888fd..33df882be 100644 --- a/app/src/main/res/layout/dialog_url.xml +++ b/app/src/main/res/layout/dialog_url.xml @@ -58,15 +58,21 @@ android:layout_marginBottom="24dp" android:gravity="left" android:orientation="horizontal"> - + - +