summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh
diff options
context:
space:
mode:
authorTom Hennen <TomHennen@users.noreply.github.com>2015-04-10 18:15:19 -0400
committerTom Hennen <TomHennen@users.noreply.github.com>2015-04-10 18:15:19 -0400
commit001013ae9e0da2dea4bc7b04d4b83c90c55950e9 (patch)
tree61166b5474817b2a25a8d33b3b6aa801ef37ef92 /app/src/main/java/de/danoeh
parentb44e0dde5810fdbeb17e5e433bc4512ec60fdc2f (diff)
parent78a5700ded9f6cd1ac31e99203d628cc5a585b88 (diff)
downloadAntennaPod-001013ae9e0da2dea4bc7b04d4b83c90c55950e9.zip
Merge pull request #718 from mfietz/feature/forward-backward
Separate fast forward and rewind times
Diffstat (limited to 'app/src/main/java/de/danoeh')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java58
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java108
2 files changed, 120 insertions, 46 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java
index f056b107b..335958a40 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java
@@ -29,7 +29,6 @@ import com.squareup.picasso.Picasso;
import org.apache.commons.lang3.StringUtils;
-import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.ChapterListAdapter;
import de.danoeh.antennapod.adapter.NavListAdapter;
@@ -96,30 +95,25 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
FragmentTransaction fT = getSupportFragmentManager().beginTransaction();
if (coverFragment != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Removing cover fragment");
+ Log.d(TAG, "Removing cover fragment");
fT.remove(coverFragment);
}
if (descriptionFragment != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Removing description fragment");
+ Log.d(TAG, "Removing description fragment");
fT.remove(descriptionFragment);
}
if (chapterFragment != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Removing chapter fragment");
+ Log.d(TAG, "Removing chapter fragment");
fT.remove(chapterFragment);
}
if (currentlyShownFragment != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Removing currently shown fragment");
+ Log.d(TAG, "Removing currently shown fragment");
fT.remove(currentlyShownFragment);
}
for (int i = 0; i < detachedFragments.length; i++) {
Fragment f = detachedFragments[i];
if (f != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Removing detached fragment");
+ Log.d(TAG, "Removing detached fragment");
fT.remove(f);
}
}
@@ -152,8 +146,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
}
private void savePreferences() {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Saving preferences");
+ Log.d(TAG, "Saving preferences");
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
if (currentlyShownPosition >= 0 && controller != null
@@ -180,9 +173,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
@Override
protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState); would cause crash
- if (BuildConfig.DEBUG)
- Log.d(TAG, "onSaveInstanceState");
-
+ Log.d(TAG, "onSaveInstanceState");
}
@Override
@@ -205,8 +196,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
* @return true if restoreFromPrefernces changed the activity's state
*/
private boolean restoreFromPreferences() {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Restoring instance state");
+ Log.d(TAG, "Restoring instance state");
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
int savedPosition = prefs.getInt(PREF_KEY_SELECTED_FRAGMENT_POSITION,
-1);
@@ -220,15 +210,10 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
switchToFragment(savedPosition);
return true;
} else if (controller == null || controller.getMedia() == null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG,
- "Couldn't restore from preferences: controller or media was null");
+ Log.d(TAG, "Couldn't restore from preferences: controller or media was null");
} else {
- if (BuildConfig.DEBUG)
- Log.d(TAG,
- "Couldn't restore from preferences: savedPosition was -1 or saved identifier and playable identifier didn't match.\nsavedPosition: "
- + savedPosition + ", id: " + playableId
- );
+ Log.d(TAG, "Couldn't restore from preferences: savedPosition was -1 or saved identifier and playable identifier didn't match.\nsavedPosition: "
+ + savedPosition + ", id: " + playableId);
}
return false;
@@ -239,9 +224,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
super.onResume();
if (StringUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
Intent intent = getIntent();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Received VIEW intent: "
- + intent.getData().getPath());
+ Log.d(TAG, "Received VIEW intent: " + intent.getData().getPath());
ExternalMedia media = new ExternalMedia(intent.getData().getPath(),
MediaType.AUDIO);
Intent launchIntent = new Intent(this, PlaybackService.class);
@@ -269,8 +252,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
@Override
protected void onAwaitingVideoSurface() {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "onAwaitingVideoSurface was called in audio player -> switching to video player");
+ Log.d(TAG, "onAwaitingVideoSurface was called in audio player -> switching to video player");
startActivity(new Intent(this, VideoplayerActivity.class));
}
@@ -295,8 +277,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
* @param pos Must be POS_COVER, POS_DESCR, or POS_CHAPTERS
*/
private void switchToFragment(int pos) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Switching contentView to position " + pos);
+ Log.d(TAG, "Switching contentView to position " + pos);
if (currentlyShownPosition != pos && controller != null) {
Playable media = controller.getMedia();
if (media != null) {
@@ -354,9 +335,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
lastShownPosition = currentlyShownPosition;
currentlyShownPosition = pos;
if (detachedFragments[pos] != null) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Reattaching fragment at position "
- + pos);
+ Log.d(TAG, "Reattaching fragment at position " + pos);
ft.attach(detachedFragments[pos]);
} else {
ft.add(R.id.contentView, currentlyShownFragment);
@@ -630,9 +609,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
@Override
protected void onReloadNotification(int notificationCode) {
if (notificationCode == PlaybackService.EXTRA_CODE_VIDEO) {
- if (BuildConfig.DEBUG)
- Log.d(TAG,
- "ReloadNotification received, switching to Videoplayer now");
+ Log.d(TAG, "ReloadNotification received, switching to Videoplayer now");
finish();
startActivity(new Intent(this, VideoplayerActivity.class));
@@ -729,8 +706,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc
@Override
public void update(EventDistributor eventDistributor, Integer arg) {
if ((EventDistributor.FEED_LIST_UPDATE & arg) != 0) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Received contentUpdate Intent.");
+ Log.d(TAG, "Received contentUpdate Intent.");
loadData();
}
}
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 8edd4185c..1dd535f2a 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -12,6 +12,8 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+
+import android.view.View;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
@@ -46,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) {
@@ -222,7 +226,6 @@ public abstract class MediaplayerActivity extends ActionBarActivity
protected void onStop() {
super.onStop();
Log.d(TAG, "onStop()");
-
if (controller != null) {
controller.release();
}
@@ -373,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) {
@@ -381,8 +386,7 @@ 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");
}
}
}
@@ -426,7 +430,11 @@ 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);
+ txtvRev.setText(String.valueOf(UserPreferences.getRewindSecs()));
butFF = (ImageButton) findViewById(R.id.butFF);
+ txtvFF = (TextView) findViewById(R.id.txtvFF);
+ txtvFF.setText(String.valueOf(UserPreferences.getFastFowardSecs()));
// SEEKBAR SETUP
@@ -437,10 +445,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;
+ }
+ });
}
}