diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-06-15 20:21:31 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-06-15 20:21:31 +0200 |
commit | 5ede220e639d3202b515cf29df28bc4c52d170bf (patch) | |
tree | efcaca81b5513a0b7e2824f6746e5cda60f1ba15 /src | |
parent | 45646d4c26bd23aa84948fa120efd464efcceec9 (diff) | |
download | AntennaPod-5ede220e639d3202b515cf29df28bc4c52d170bf.zip |
Replaced TimerDialog with HmsDialog from the BetterPickers-library
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/activity/MediaplayerActivity.java | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index fc70f4c05..c2d8d2c79 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -3,10 +3,13 @@ package de.danoeh.antennapod.activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; +import android.content.res.TypedArray; import android.graphics.PixelFormat; import android.media.AudioManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.Menu; @@ -16,6 +19,8 @@ import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; import android.widget.TextView; +import com.doomonafireball.betterpickers.hmspicker.HmsPickerBuilder; +import com.doomonafireball.betterpickers.hmspicker.HmsPickerDialogFragment; import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.dialog.TimeDialog; @@ -30,6 +35,7 @@ import de.danoeh.antennapod.util.StorageUtils; import de.danoeh.antennapod.util.playback.MediaPlayerError; import de.danoeh.antennapod.util.playback.Playable; import de.danoeh.antennapod.util.playback.PlaybackController; +import org.shredzone.flattr4j.model.User; /** * Provides general features which are both needed for playing audio and video @@ -312,16 +318,34 @@ 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) { - - @Override - public void onTimeEntered(long millis) { - controller.setSleepTimer(millis); - } - }; - td.show(); + int pickerStyle = (UserPreferences.getTheme() == R.style.Theme_AntennaPod_Light) ? + R.style.AntennaPodBetterPickerThemeLight : R.style.AntennaPodBetterPickerThemeDark; + if (Build.VERSION.SDK_INT > 10) { // TODO remove this as soon as dialog is shown correctly on 2.3 + HmsPickerBuilder hpb = new HmsPickerBuilder() + .setStyleResId(pickerStyle) + .setFragmentManager(getSupportFragmentManager()); + + hpb.addHmsPickerDialogHandler(new HmsPickerDialogFragment.HmsPickerDialogHandler() { + @Override + public void onDialogHmsSet(int ref, int hours, int minutes, int seconds) { + if (controller != null && controller.serviceAvailable()) { + controller.setSleepTimer((hours * 3600 + minutes * 60 + seconds) * 1000); + } + } + }); + hpb.show(); + } else { + TimeDialog td = new TimeDialog(this, + R.string.set_sleeptimer_label, + R.string.set_sleeptimer_label) { + + @Override + public void onTimeEntered(long millis) { + controller.setSleepTimer(millis); + } + }; + td.show(); + } break; } |