diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-12-04 21:40:34 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-12-04 21:40:34 +0100 |
commit | 17141db8a6ce65b19386b7bfd92d0a371b51bd6d (patch) | |
tree | 09e72cefeda09491f4d04ab0f1a1ce08fcf47e10 /app/src/main/java/de/danoeh/antennapod/dialog | |
parent | 4878a30d666fdb38fc1991b56ab347a04307e3c6 (diff) | |
download | AntennaPod-17141db8a6ce65b19386b7bfd92d0a371b51bd6d.zip |
Turn auto enable sleep timer on/off immediately
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java | 11 |
1 files changed, 10 insertions, 1 deletions
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 0ddee9f61..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,6 +1,7 @@ package de.danoeh.antennapod.dialog; import android.content.Context; +import android.support.design.widget.Snackbar; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; @@ -8,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,7 +18,9 @@ import com.afollestad.materialdialogs.DialogAction; import com.afollestad.materialdialogs.MaterialDialog; 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 { @@ -32,7 +36,7 @@ public abstract class SleepTimerDialog { private CheckBox chAutoEnable; - public SleepTimerDialog(Context context) { + protected SleepTimerDialog(Context context) { this.context = context; } @@ -99,6 +103,11 @@ public abstract class SleepTimerDialog { 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; } |