summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java131
1 files changed, 113 insertions, 18 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 099e96be9..0cd388b9d 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -12,13 +12,13 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.view.Window;
+
+import android.view.View;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
-import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
@@ -48,7 +48,9 @@ public abstract class MediaplayerActivity extends ActionBarActivity
protected SeekBar sbPosition;
protected ImageButton butPlay;
protected ImageButton butRev;
+ protected TextView txtvRev;
protected ImageButton butFF;
+ protected TextView txtvFF;
private PlaybackController newPlaybackController() {
return new PlaybackController(this, false) {
@@ -167,8 +169,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity
chooseTheme();
super.onCreate(savedInstanceState);
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Creating Activity");
+ Log.d(TAG, "onCreate()");
StorageUtils.checkStorageAvailability(this);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
@@ -224,8 +225,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity
@Override
protected void onStop() {
super.onStop();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Activity stopped");
+ Log.d(TAG, "onStop()");
if (controller != null) {
controller.release();
}
@@ -234,8 +234,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity
@Override
protected void onDestroy() {
super.onDestroy();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Activity destroyed");
+ Log.d(TAG, "onDestroy()");
}
@Override
@@ -358,8 +357,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity
@Override
protected void onResume() {
super.onResume();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Resuming Activity");
+ Log.d(TAG, "onResume()");
StorageUtils.checkStorageAvailability(this);
controller.init();
}
@@ -378,6 +376,8 @@ public abstract class MediaplayerActivity extends ActionBarActivity
if (controller != null) {
int currentPosition = controller.getPosition();
int duration = controller.getDuration();
+ Log.d(TAG, "currentPosition " + Converter
+ .getDurationStringLong(currentPosition));
if (currentPosition != PlaybackService.INVALID_TIME
&& duration != PlaybackService.INVALID_TIME
&& controller.getMedia() != null) {
@@ -386,15 +386,13 @@ public abstract class MediaplayerActivity extends ActionBarActivity
txtvLength.setText(Converter.getDurationStringLong(duration));
updateProgressbarPosition(currentPosition, duration);
} else {
- Log.w(TAG,
- "Could not react to position observer update because of invalid time");
+ Log.w(TAG, "Could not react to position observer update because of invalid time");
}
}
}
private void updateProgressbarPosition(int position, int duration) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Updating progressbar info");
+ Log.d(TAG, "updateProgressbarPosition(" + position + ", " + duration +")");
float progress = ((float) position) / duration;
sbPosition.setProgress((int) (progress * sbPosition.getMax()));
}
@@ -406,8 +404,7 @@ public abstract class MediaplayerActivity extends ActionBarActivity
* FeedMedia object.
*/
protected boolean loadMediaInfo() {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Loading media info");
+ Log.d(TAG, "loadMediaInfo()");
Playable media = controller.getMedia();
if (media != null) {
txtvPosition.setText(Converter.getDurationStringLong((media
@@ -433,7 +430,15 @@ public abstract class MediaplayerActivity extends ActionBarActivity
txtvLength = (TextView) findViewById(R.id.txtvLength);
butPlay = (ImageButton) findViewById(R.id.butPlay);
butRev = (ImageButton) findViewById(R.id.butRev);
+ txtvRev = (TextView) findViewById(R.id.txtvRev);
+ if(txtvRev != null) {
+ txtvRev.setText(String.valueOf(UserPreferences.getRewindSecs()));
+ }
butFF = (ImageButton) findViewById(R.id.butFF);
+ txtvFF = (TextView) findViewById(R.id.txtvFF);
+ if(txtvFF != null) {
+ txtvFF.setText(String.valueOf(UserPreferences.getFastFowardSecs()));
+ }
// SEEKBAR SETUP
@@ -444,10 +449,100 @@ public abstract class MediaplayerActivity extends ActionBarActivity
butPlay.setOnClickListener(controller.newOnPlayButtonClickListener());
if (butFF != null) {
- butFF.setOnClickListener(controller.newOnFFButtonClickListener());
+ butFF.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int curr = controller.getPosition();
+ controller.seekTo(curr + UserPreferences.getFastFowardSecs() * 1000);
+ }
+ });
+ butFF.setOnLongClickListener(new View.OnLongClickListener() {
+
+ int choice;
+
+ @Override
+ public boolean onLongClick(View v) {
+ int checked = 0;
+ int rewindSecs = UserPreferences.getFastFowardSecs();
+ final int[] values = getResources().getIntArray(R.array.seek_delta_values);
+ final String[] choices = new String[values.length];
+ for(int i=0; i < values.length; i++) {
+ if (rewindSecs == values[i]) {
+ checked = i;
+ }
+ choices[i] = String.valueOf(values[i]) + " "
+ + getString(R.string.time_unit_seconds);
+ }
+ choice = values[checked];
+ AlertDialog.Builder builder = new AlertDialog.Builder(MediaplayerActivity.this);
+ builder.setTitle(R.string.pref_fast_forward);
+ builder.setSingleChoiceItems(choices, checked,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ choice = values[which];
+ }
+ });
+ builder.setNegativeButton(R.string.cancel_label, null);
+ builder.setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ UserPreferences.setPrefFastForwardSecs(choice);
+ txtvFF.setText(String.valueOf(choice));
+ }
+ });
+ builder.create().show();
+ return true;
+ }
+ });
}
if (butRev != null) {
- butRev.setOnClickListener(controller.newOnRevButtonClickListener());
+ butRev.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ int curr = controller.getPosition();
+ controller.seekTo(curr - UserPreferences.getRewindSecs() * 1000);
+ }
+ });
+ butRev.setOnLongClickListener(new View.OnLongClickListener() {
+
+ int choice;
+
+ @Override
+ public boolean onLongClick(View v) {
+ int checked = 0;
+ int rewindSecs = UserPreferences.getRewindSecs();
+ final int[] values = getResources().getIntArray(R.array.seek_delta_values);
+ final String[] choices = new String[values.length];
+ for(int i=0; i < values.length; i++) {
+ if (rewindSecs == values[i]) {
+ checked = i;
+ }
+ choices[i] = String.valueOf(values[i]) + " "
+ + getString(R.string.time_unit_seconds);
+ }
+ choice = values[checked];
+ AlertDialog.Builder builder = new AlertDialog.Builder(MediaplayerActivity.this);
+ builder.setTitle(R.string.pref_rewind);
+ builder.setSingleChoiceItems(choices, checked,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ choice = values[which];
+ }
+ });
+ builder.setNegativeButton(R.string.cancel_label, null);
+ builder.setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ UserPreferences.setPrefRewindSecs(choice);
+ txtvRev.setText(String.valueOf(choice));
+ }
+ });
+ builder.create().show();
+ return true;
+ }
+ });
}
}