summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java131
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java39
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java4
5 files changed, 5 insertions, 173 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java b/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java
deleted file mode 100644
index 09730ee4e..000000000
--- a/app/src/androidTest/java/de/test/antennapod/ui/SpeedChangeTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package de.test.antennapod.ui;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import androidx.preference.PreferenceManager;
-import androidx.test.rule.ActivityTestRule;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import de.danoeh.antennapod.R;
-import de.danoeh.antennapod.activity.MainActivity;
-import de.danoeh.antennapod.model.feed.FeedItem;
-import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
-import de.danoeh.antennapod.core.preferences.UserPreferences;
-import de.danoeh.antennapod.core.service.playback.PlayerStatus;
-import de.danoeh.antennapod.core.storage.DBReader;
-import de.danoeh.antennapod.core.util.playback.PlaybackController;
-import de.danoeh.antennapod.fragment.QueueFragment;
-import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter;
-import de.test.antennapod.EspressoTestUtils;
-import de.test.antennapod.IgnoreOnCi;
-import org.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.action.ViewActions.click;
-import static androidx.test.espresso.assertion.ViewAssertions.matches;
-import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
-import static androidx.test.espresso.matcher.ViewMatchers.withId;
-import static androidx.test.espresso.matcher.ViewMatchers.withText;
-import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
-import static de.test.antennapod.EspressoTestUtils.waitForView;
-
-/**
- * User interface tests for changing the playback speed.
- */
-@RunWith(AndroidJUnit4.class)
-@IgnoreOnCi
-public class SpeedChangeTest {
-
- @Rule
- public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class, false, false);
- private UITestUtils uiTestUtils;
- private String[] availableSpeeds;
- private PlaybackController controller;
-
- @Before
- public void setUp() throws Exception {
- EspressoTestUtils.clearPreferences();
- EspressoTestUtils.clearDatabase();
- EspressoTestUtils.setLastNavFragment(QueueFragment.TAG);
-
- Context context = getInstrumentation().getTargetContext();
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- prefs.edit().putBoolean(UserPreferences.PREF_FOLLOW_QUEUE, true).commit();
-
- uiTestUtils = new UITestUtils(context);
- uiTestUtils.setup();
- uiTestUtils.setMediaFileName("30sec.mp3");
- uiTestUtils.addLocalFeedData(true);
-
- List<FeedItem> queue = DBReader.getQueue();
- PlaybackPreferences.writeMediaPlaying(queue.get(0).getMedia(), PlayerStatus.PAUSED, false);
- availableSpeeds = new String[] {"1.00", "2.00", "3.00"};
- UserPreferences.setPlaybackSpeedArray(Arrays.asList(1.0f, 2.0f, 3.0f));
-
- EspressoTestUtils.tryKillPlaybackService();
- activityRule.launchActivity(new Intent().putExtra(MainActivityStarter.EXTRA_OPEN_PLAYER, true));
- controller = new PlaybackController(activityRule.getActivity()) {
- @Override
- public void loadMediaInfo() {
- // Do nothing
- }
- };
- controller.init();
- controller.getMedia(); // To load media
- }
-
- @After
- public void tearDown() throws Exception {
- uiTestUtils.tearDown();
- controller.release();
- }
-
- @Test
- public void testChangeSpeedServiceNotRunning() {
- clickThroughSpeeds();
- }
-
- @Test
- public void testChangeSpeedPlaying() {
- onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000));
- controller.playPause();
- Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> controller.getStatus() == PlayerStatus.PLAYING);
- clickThroughSpeeds();
- }
-
- @Test
- public void testChangeSpeedPaused() {
- onView(isRoot()).perform(waitForView(withId(R.id.butPlay), 1000));
- controller.playPause();
- Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> controller.getStatus() == PlayerStatus.PLAYING);
- controller.playPause();
- Awaitility.await().atMost(5, TimeUnit.SECONDS).until(()
- -> controller.getStatus() == PlayerStatus.PAUSED);
- clickThroughSpeeds();
- }
-
- private void clickThroughSpeeds() {
- onView(isRoot()).perform(waitForView(withText(availableSpeeds[0]), 1000));
- onView(withId(R.id.txtvPlaybackSpeed)).check(matches(withText(availableSpeeds[0])));
- onView(withId(R.id.butPlaybackSpeed)).perform(click());
- onView(isRoot()).perform(waitForView(withText(availableSpeeds[1]), 1000));
- onView(withId(R.id.txtvPlaybackSpeed)).check(matches(withText(availableSpeeds[1])));
- onView(withId(R.id.butPlaybackSpeed)).perform(click());
- onView(isRoot()).perform(waitForView(withText(availableSpeeds[2]), 1000));
- onView(withId(R.id.txtvPlaybackSpeed)).check(matches(withText(availableSpeeds[2])));
- onView(withId(R.id.butPlaybackSpeed)).perform(click());
- onView(isRoot()).perform(waitForView(withText(availableSpeeds[0]), 1000));
- onView(withId(R.id.txtvPlaybackSpeed)).check(matches(withText(availableSpeeds[0])));
- }
-}
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
index c6927c69f..6011872cf 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java
@@ -131,8 +131,8 @@ public class VariableSpeedDialog extends DialogFragment {
});
holder.chip.setOnClickListener(v -> {
if (controller != null) {
+ dismiss();
controller.setPlaybackSpeed(speed);
- notifyDataSetChanged();
}
});
}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
index 21a1d2039..ca6d28d67 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
@@ -75,7 +75,6 @@ public class AudioPlayerFragment extends Fragment implements
public static final int POS_COVER = 0;
public static final int POS_DESCRIPTION = 1;
private static final int NUM_CONTENT_FRAGMENTS = 2;
- private static final float EPSILON = 0.001f;
PlaybackSpeedIndicatorView butPlaybackSpeed;
TextView txtvPlaybackSpeed;
@@ -136,7 +135,7 @@ public class AudioPlayerFragment extends Fragment implements
setupLengthTextView();
setupControlButtons();
- setupPlaybackSpeedButton();
+ butPlaybackSpeed.setOnClickListener(v -> new VariableSpeedDialog().show(getChildFragmentManager(), null));
sbPosition.setOnSeekBarChangeListener(this);
pager = root.findViewById(R.id.pager);
@@ -244,40 +243,6 @@ public class AudioPlayerFragment extends Fragment implements
});
}
- private void setupPlaybackSpeedButton() {
- butPlaybackSpeed.setOnClickListener(v -> {
- if (controller == null) {
- return;
- }
- List<Float> availableSpeeds = UserPreferences.getPlaybackSpeedArray();
- float currentSpeed = controller.getCurrentPlaybackSpeedMultiplier();
-
- int newSpeedIndex = 0;
- while (newSpeedIndex < availableSpeeds.size()
- && availableSpeeds.get(newSpeedIndex) < currentSpeed + EPSILON) {
- newSpeedIndex++;
- }
-
- float newSpeed;
- if (availableSpeeds.size() == 0) {
- newSpeed = 1.0f;
- } else if (newSpeedIndex == availableSpeeds.size()) {
- newSpeed = availableSpeeds.get(0);
- } else {
- newSpeed = availableSpeeds.get(newSpeedIndex);
- }
-
- controller.setPlaybackSpeed(newSpeed);
- loadMediaInfo();
- });
- butPlaybackSpeed.setOnLongClickListener(v -> {
- new VariableSpeedDialog().show(getChildFragmentManager(), null);
- return true;
- });
- butPlaybackSpeed.setVisibility(View.VISIBLE);
- txtvPlaybackSpeed.setVisibility(View.VISIBLE);
- }
-
protected void updatePlaybackSpeedButton(Playable media) {
if (butPlaybackSpeed == null || controller == null) {
return;
@@ -286,8 +251,6 @@ public class AudioPlayerFragment extends Fragment implements
String speedStr = new DecimalFormat("0.00").format(speed);
txtvPlaybackSpeed.setText(speedStr);
butPlaybackSpeed.setSpeed(speed);
- butPlaybackSpeed.setVisibility(View.VISIBLE);
- txtvPlaybackSpeed.setVisibility(View.VISIBLE);
}
private void loadMediaInfo() {
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
index 31681252a..a89ad204b 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
@@ -500,7 +500,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
}
private void onFragmentLoaded(final boolean restoreScrollPosition) {
- if (queue != null && queue.size() > 0) {
+ if (queue != null) {
if (recyclerAdapter == null) {
MainActivity activity = (MainActivity) getActivity();
recyclerAdapter = new QueueRecyclerAdapter(activity, swipeActions);
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
index b8b39c578..50c7c1ae5 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
@@ -31,8 +31,8 @@ import it.xabaras.android.recyclerview.swipedecorator.RecyclerViewSwipeDecorator
public class SwipeActions extends ItemTouchHelper.SimpleCallback implements LifecycleObserver {
public static final String PREF_NAME = "SwipeActionsPrefs";
- public static final String KEY_PREFIX_SWIPEACTIONS = "PrefSwipeActions6543";
- public static final String KEY_PREFIX_NO_ACTION = "PrefNoSwipeAction6543";
+ public static final String KEY_PREFIX_SWIPEACTIONS = "PrefSwipeActions";
+ public static final String KEY_PREFIX_NO_ACTION = "PrefNoSwipeAction";
public static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
Arrays.asList(new AddToQueueSwipeAction(), new RemoveFromInboxSwipeAction(),