summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/dialog
diff options
context:
space:
mode:
authorMartin Fietz <martin.fietz@gmail.com>2017-10-17 22:55:30 +0200
committerMartin Fietz <martin.fietz@gmail.com>2017-10-17 22:55:30 +0200
commite884e989c781a2527b737ff30f0fcadd23e791f5 (patch)
tree0bcfc92171c2b52be85e9d38641fde3b8662aee4 /app/src/main/java/de/danoeh/antennapod/dialog
parentb47dc10b2a4ef46bf5e61dcd0c4640265b033721 (diff)
parent014e34e912cfcd9fae84643a8ab2a61872c18559 (diff)
downloadAntennaPod-e884e989c781a2527b737ff30f0fcadd23e791f5.zip
Merge branch 'develop'
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java15
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java4
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java17
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java44
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java57
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java4
6 files changed, 94 insertions, 47 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java
index 577a3ecbe..ac073141d 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java
@@ -225,6 +225,10 @@ public class EpisodesApplyActionFragment extends Fragment {
checkQueued(false);
resId = R.string.selected_not_queued_label;
break;
+ case R.id.check_has_media:
+ checkWithMedia();
+ resId = R.string.selected_has_media_label;
+ break;
case R.id.sort_title_a_z:
sortByTitle(false);
return true;
@@ -357,6 +361,17 @@ public class EpisodesApplyActionFragment extends Fragment {
refreshCheckboxes();
}
+ private void checkWithMedia() {
+ for (FeedItem episode : episodes) {
+ if(episode.hasMedia()) {
+ checkedIds.add(episode.getId());
+ } else {
+ checkedIds.remove(episode.getId());
+ }
+ }
+ refreshCheckboxes();
+ }
+
private void refreshTitles() {
titles.clear();
for(FeedItem episode : episodes) {
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java
index b875eaf62..a4e71c249 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java
@@ -35,9 +35,7 @@ public class GpodnetSetHostnameDialog {
}
dialog1.dismiss();
})
- .setNegativeButton(R.string.cancel_label, (dialog1, which) -> {
- dialog1.cancel();
- })
+ .setNegativeButton(R.string.cancel_label, (dialog1, which) -> dialog1.cancel())
.setNeutralButton(R.string.pref_gpodnet_sethostname_use_default_host, (dialog1, which) -> {
GpodnetPreferences.setHostname(GpodnetService.DEFAULT_BASE_HOST);
dialog1.dismiss();
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java
index 98a4b5356..0bd75b5b0 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java
@@ -18,10 +18,6 @@ import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.internal.MDButton;
-import com.squareup.okhttp.Credentials;
-import com.squareup.okhttp.OkHttpClient;
-import com.squareup.okhttp.Request;
-import com.squareup.okhttp.Response;
import java.io.IOException;
import java.net.InetSocketAddress;
@@ -33,6 +29,10 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
import de.danoeh.antennapod.core.service.download.ProxyConfig;
+import okhttp3.Credentials;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
@@ -258,10 +258,11 @@ public class ProxyDialog {
SocketAddress address = InetSocketAddress.createUnresolved(host, portValue);
Proxy.Type proxyType = Proxy.Type.valueOf(type.toUpperCase());
Proxy proxy = new Proxy(proxyType, address);
- OkHttpClient client = AntennapodHttpClient.newHttpClient();
- client.setConnectTimeout(10, TimeUnit.SECONDS);
- client.setProxy(proxy);
- client.interceptors().clear();
+ OkHttpClient.Builder builder = AntennapodHttpClient.newBuilder()
+ .connectTimeout(10, TimeUnit.SECONDS)
+ .proxy(proxy);
+ builder.interceptors().clear();
+ OkHttpClient client = builder.build();
if(!TextUtils.isEmpty(username)) {
String credentials = Credentials.basic(username, password);
client.interceptors().add(chain -> {
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java
new file mode 100644
index 000000000..31a544582
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/RenameFeedDialog.java
@@ -0,0 +1,44 @@
+package de.danoeh.antennapod.dialog;
+
+import android.app.Activity;
+import android.text.InputType;
+
+import com.afollestad.materialdialogs.MaterialDialog;
+
+import java.lang.ref.WeakReference;
+
+import de.danoeh.antennapod.core.feed.Feed;
+import de.danoeh.antennapod.core.storage.DBWriter;
+
+public class RenameFeedDialog {
+
+ private final WeakReference<Activity> activityRef;
+ private final Feed feed;
+
+ public RenameFeedDialog(Activity activity, Feed feed) {
+ this.activityRef = new WeakReference<>(activity);
+ this.feed = feed;
+ }
+
+ public void show() {
+ Activity activity = activityRef.get();
+ if(activity == null) {
+ return;
+ }
+ new MaterialDialog.Builder(activity)
+ .title(de.danoeh.antennapod.core.R.string.rename_feed_label)
+ .inputType(InputType.TYPE_CLASS_TEXT)
+ .input(feed.getTitle(), feed.getTitle(), true, (dialog, input) -> {
+ feed.setCustomTitle(input.toString());
+ DBWriter.setFeedCustomTitle(feed);
+ dialog.dismiss();
+ })
+ .neutralText(de.danoeh.antennapod.core.R.string.reset)
+ .onNeutral((dialog, which) -> dialog.getInputEditText().setText(feed.getFeedTitle()))
+ .negativeText(de.danoeh.antennapod.core.R.string.cancel_label)
+ .onNegative((dialog, which) -> dialog.dismiss())
+ .autoDismiss(false)
+ .show();
+ }
+
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
index 8a13a75d9..7d6a66a54 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
@@ -1,7 +1,7 @@
package de.danoeh.antennapod.dialog;
import android.content.Context;
-import android.content.SharedPreferences;
+import android.support.design.widget.Snackbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@@ -9,6 +9,7 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
@@ -16,36 +17,27 @@ import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
-import java.util.concurrent.TimeUnit;
-
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.core.event.MessageEvent;
+import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
+import de.greenrobot.event.EventBus;
public abstract class SleepTimerDialog {
private static final String TAG = SleepTimerDialog.class.getSimpleName();
- private static final int DEFAULT_SPINNER_POSITION = 1;
-
private Context context;
- private String PREF_NAME = "SleepTimerDialog";
- private String PREF_VALUE = "LastValue";
- private String PREF_TIME_UNIT = "LastTimeUnit";
- private String PREF_VIBRATE = "Vibrate";
- private String PREF_SHAKE_TO_RESET = "ShakeToReset";
- private SharedPreferences prefs;
private MaterialDialog dialog;
private EditText etxtTime;
private Spinner spTimeUnit;
private CheckBox cbShakeToReset;
private CheckBox cbVibrate;
+ private CheckBox chAutoEnable;
- private TimeUnit[] units = { TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS };
-
- public SleepTimerDialog(Context context) {
+ protected SleepTimerDialog(Context context) {
this.context = context;
- prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
}
public MaterialDialog createNewDialog() {
@@ -58,7 +50,7 @@ public abstract class SleepTimerDialog {
builder.onPositive((dialog, which) -> {
try {
savePreferences();
- long input = readTimeMillis();
+ long input = SleepTimerPreferences.timerMillis();
onTimerSet(input, cbShakeToReset.isChecked(), cbVibrate.isChecked());
dialog.dismiss();
} catch (NumberFormatException e) {
@@ -75,8 +67,9 @@ public abstract class SleepTimerDialog {
spTimeUnit = (Spinner) view.findViewById(R.id.spTimeUnit);
cbShakeToReset = (CheckBox) view.findViewById(R.id.cbShakeToReset);
cbVibrate = (CheckBox) view.findViewById(R.id.cbVibrate);
+ chAutoEnable = (CheckBox) view.findViewById(R.id.chAutoEnable);
- etxtTime.setText(prefs.getString(PREF_VALUE, "15"));
+ etxtTime.setText(SleepTimerPreferences.lastTimerValue());
etxtTime.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
@@ -104,12 +97,17 @@ public abstract class SleepTimerDialog {
android.R.layout.simple_spinner_item, spinnerContent);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spTimeUnit.setAdapter(spinnerAdapter);
- int selection = prefs.getInt(PREF_TIME_UNIT, DEFAULT_SPINNER_POSITION);
- spTimeUnit.setSelection(selection);
+ spTimeUnit.setSelection(SleepTimerPreferences.lastTimerTimeUnit());
- cbShakeToReset.setChecked(prefs.getBoolean(PREF_SHAKE_TO_RESET, true));
- cbVibrate.setChecked(prefs.getBoolean(PREF_VIBRATE, true));
+ cbShakeToReset.setChecked(SleepTimerPreferences.shakeToReset());
+ cbVibrate.setChecked(SleepTimerPreferences.vibrate());
+ chAutoEnable.setChecked(SleepTimerPreferences.autoEnable());
+ chAutoEnable.setOnCheckedChangeListener((compoundButton, isChecked) -> {
+ SleepTimerPreferences.setAutoEnable(isChecked);
+ int messageString = isChecked ? R.string.sleep_timer_enabled_label : R.string.sleep_timer_disabled_label;
+ EventBus.getDefault().post(new MessageEvent(context.getString(messageString)));
+ });
return dialog;
}
@@ -125,19 +123,12 @@ public abstract class SleepTimerDialog {
public abstract void onTimerSet(long millis, boolean shakeToReset, boolean vibrate);
- private long readTimeMillis() {
- TimeUnit selectedUnit = units[spTimeUnit.getSelectedItemPosition()];
- long value = Long.parseLong(etxtTime.getText().toString());
- return selectedUnit.toMillis(value);
- }
-
private void savePreferences() {
- prefs.edit()
- .putString(PREF_VALUE, etxtTime.getText().toString())
- .putInt(PREF_TIME_UNIT, spTimeUnit.getSelectedItemPosition())
- .putBoolean(PREF_SHAKE_TO_RESET, cbShakeToReset.isChecked())
- .putBoolean(PREF_VIBRATE, cbVibrate.isChecked())
- .apply();
+ SleepTimerPreferences.setLastTimer(etxtTime.getText().toString(),
+ spTimeUnit.getSelectedItemPosition());
+ SleepTimerPreferences.setShakeToReset(cbShakeToReset.isChecked());
+ SleepTimerPreferences.setVibrate(cbVibrate.isChecked());
+ SleepTimerPreferences.setAutoEnable(chAutoEnable.isChecked());
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
index 2bf9c4e7a..6a975fe49 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
@@ -95,9 +95,7 @@ public class VariableSpeedDialog {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.set_playback_speed_label);
builder.setMultiChoiceItems(R.array.playback_speed_values,
- speedChecked, (dialog, which, isChecked) -> {
- speedChecked[which] = isChecked;
- });
+ speedChecked, (dialog, which, isChecked) -> speedChecked[which] = isChecked);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setPositiveButton(android.R.string.ok,
(dialog, which) -> {