diff options
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java | 11 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java (renamed from app/src/main/java/de/danoeh/antennapod/dialog/TimeDialog.java) | 35 | ||||
-rw-r--r-- | app/src/main/res/layout-v14/time_dialog.xml | 35 | ||||
-rw-r--r-- | app/src/main/res/layout/time_dialog.xml | 33 | ||||
-rw-r--r-- | core/src/main/res/values/strings.xml | 3 |
5 files changed, 95 insertions, 22 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index 40a0d1801..e34b4dc67 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -31,7 +31,7 @@ import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.core.util.playback.MediaPlayerError; import de.danoeh.antennapod.core.util.playback.Playable; import de.danoeh.antennapod.core.util.playback.PlaybackController; -import de.danoeh.antennapod.dialog.TimeDialog; +import de.danoeh.antennapod.dialog.SleepTimerDialog; /** * Provides general features which are both needed for playing audio and video @@ -323,13 +323,10 @@ public abstract class MediaplayerActivity extends ActionBarActivity break; case R.id.set_sleeptimer_item: if (controller.serviceAvailable()) { - TimeDialog td = new TimeDialog(this, - R.string.set_sleeptimer_label, - R.string.set_sleeptimer_label) { - + SleepTimerDialog td = new SleepTimerDialog(this, 0, 0) { @Override - public void onTimeEntered(long millis) { - controller.setSleepTimer(millis); + public void onTimerSet(long millis, boolean shakeToReset, boolean vibrate) { + controller.setSleepTimer(millis, shakeToReset, vibrate); } }; td.show(); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/TimeDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java index 5c4d4c430..28364e4c4 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/TimeDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java @@ -9,13 +9,19 @@ import android.util.Log; import android.view.View; import android.view.Window; import android.view.inputmethod.InputMethodManager; -import android.widget.*; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.R; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; import java.util.concurrent.TimeUnit; -public abstract class TimeDialog extends Dialog { +import de.danoeh.antennapod.R; + +public abstract class SleepTimerDialog extends Dialog { + private static final String TAG = "TimeDialog"; private static final int DEFAULT_SPINNER_POSITION = 1; @@ -24,13 +30,14 @@ public abstract class TimeDialog extends Dialog { private EditText etxtTime; private Spinner spTimeUnit; + private CheckBox cbShakeToReset; + private CheckBox cbVibrate; private Button butConfirm; private Button butCancel; - private TimeUnit[] units = {TimeUnit.SECONDS, TimeUnit.MINUTES, - TimeUnit.HOURS}; + private TimeUnit[] units = { TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS }; - public TimeDialog(Context context, int titleTextId, int leftButtonTextId) { + public SleepTimerDialog(Context context, int titleTextId, int leftButtonTextId) { super(context); this.context = context; } @@ -46,13 +53,15 @@ public abstract class TimeDialog extends Dialog { setContentView(R.layout.time_dialog); etxtTime = (EditText) findViewById(R.id.etxtTime); spTimeUnit = (Spinner) findViewById(R.id.spTimeUnit); + cbShakeToReset = (CheckBox) findViewById(R.id.cbShakeToReset); + cbVibrate = (CheckBox) findViewById(R.id.cbVibrate); butConfirm = (Button) findViewById(R.id.butConfirm); butCancel = (Button) findViewById(R.id.butCancel); butConfirm.setText(R.string.set_sleeptimer_label); butCancel.setText(R.string.cancel_label); setTitle(R.string.set_sleeptimer_label); - ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>( + ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>( this.getContext(), android.R.layout.simple_spinner_item, spinnerContent); spinnerAdapter @@ -72,7 +81,7 @@ public abstract class TimeDialog extends Dialog { public void onClick(View v) { try { long input = readTimeMillis(); - onTimeEntered(input); + onTimerSet(input, cbShakeToReset.isChecked(), cbVibrate.isChecked()); dismiss(); } catch (NumberFormatException e) { e.printStackTrace(); @@ -117,17 +126,15 @@ public abstract class TimeDialog extends Dialog { private void checkInputLength(int length) { if (length > 0) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Length is larger than 0, enabling confirm button"); + Log.d(TAG, "Length is larger than 0, enabling confirm button"); butConfirm.setEnabled(true); } else { - if (BuildConfig.DEBUG) - Log.d(TAG, "Length is smaller than 0, disabling confirm button"); + Log.d(TAG, "Length is smaller than 0, disabling confirm button"); butConfirm.setEnabled(false); } } - public abstract void onTimeEntered(long millis); + public abstract void onTimerSet(long millis, boolean shakeToReset, boolean vibrate); private long readTimeMillis() { TimeUnit selectedUnit = units[spTimeUnit.getSelectedItemPosition()]; diff --git a/app/src/main/res/layout-v14/time_dialog.xml b/app/src/main/res/layout-v14/time_dialog.xml index 7fd4309d5..d7f6003f5 100644 --- a/app/src/main/res/layout-v14/time_dialog.xml +++ b/app/src/main/res/layout-v14/time_dialog.xml @@ -2,7 +2,7 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" > + android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" @@ -31,6 +31,39 @@ android:layout_marginTop="8dp" /> </LinearLayout> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center"> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:textSize="16sp" + android:text="@string/timer_about_to_expire_label"/> + + <CheckBox android:id="@+id/cbShakeToReset" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/shake_to_reset_label" + android:checked="true" /> + + <CheckBox android:id="@+id/cbVibrate" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/timer_vibration_label" + android:checked="true" /> + + </LinearLayout> + + </LinearLayout> + <RelativeLayout android:id="@+id/footer" android:layout_width="fill_parent" diff --git a/app/src/main/res/layout/time_dialog.xml b/app/src/main/res/layout/time_dialog.xml index a42f87781..213d38147 100644 --- a/app/src/main/res/layout/time_dialog.xml +++ b/app/src/main/res/layout/time_dialog.xml @@ -33,6 +33,39 @@ </LinearLayout> <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center"> + + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:textSize="16sp" + android:text="@string/timer_about_to_expire_label"/> + + <CheckBox android:id="@+id/cbShakeToReset" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/shake_to_reset_label" + android:checked="true" /> + + <CheckBox android:id="@+id/cbVibrate" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/timer_vibration_label" + android:checked="true" /> + + </LinearLayout> + + </LinearLayout> + + <LinearLayout style="@android:style/ButtonBar" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index c8fb83e46..f5ba1b636 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -385,6 +385,9 @@ <string name="sleep_timer_label">Sleep timer</string> <string name="time_left_label">Time left:\u0020</string> <string name="time_dialog_invalid_input">Invalid input, time has to be an integer</string> + <string name="timer_about_to_expire_label"><b>When timer is about to expire:</b></string> + <string name="shake_to_reset_label">Shake to reset timer</string> + <string name="timer_vibration_label">Vibrate</string> <string name="time_seconds">seconds</string> <string name="time_minutes">minutes</string> <string name="time_hours">hours</string> |