diff options
Diffstat (limited to 'app')
10 files changed, 196 insertions, 19 deletions
diff --git a/app/build.gradle b/app/build.gradle index 43aab39fe..6fb84c29a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -141,11 +141,11 @@ dependencies { implementation "androidx.appcompat:appcompat:1.1.0" implementation "androidx.preference:preference:1.1.0" implementation "androidx.gridlayout:gridlayout:1.0.0" - implementation "androidx.recyclerview:recyclerview:1.0.0" + implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0" implementation "androidx.media:media:1.1.0" implementation "androidx.work:work-runtime:$workManagerVersion" - implementation "com.google.android.material:material:1.0.0" + implementation "com.google.android.material:material:1.1.0" annotationProcessor "androidx.annotation:annotation:1.1.0" compileOnly "com.google.android.wearable:wearable:$wearableSupportVersion" implementation "org.apache.commons:commons-lang3:$commonslangVersion" diff --git a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java index 12227d258..45994d218 100644 --- a/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java +++ b/app/src/androidTest/java/de/test/antennapod/playback/PlaybackTest.java @@ -5,9 +5,25 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.view.View; + import androidx.test.filters.LargeTest; import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.rule.ActivityTestRule; + +import org.awaitility.Awaitility; +import org.hamcrest.Matcher; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.TimeUnit; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.feed.FeedItem; @@ -24,19 +40,6 @@ import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.test.antennapod.EspressoTestUtils; import de.test.antennapod.IgnoreOnCi; import de.test.antennapod.ui.UITestUtils; -import org.awaitility.Awaitility; -import org.hamcrest.Matcher; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.TimeUnit; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; @@ -54,6 +57,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -194,6 +198,18 @@ public class PlaybackTest { } @Test + public void testPlayingItemAddsToQueue() throws Exception { + uiTestUtils.addLocalFeedData(true); + activityTestRule.launchActivity(new Intent()); + DBWriter.clearQueue().get(); + List<FeedItem> queue = DBReader.getQueue(); + assertEquals(0, queue.size()); + startLocalPlayback(); + Awaitility.await().atMost(1, TimeUnit.SECONDS).until( + () -> 1 == DBReader.getQueue().size()); + } + + @Test public void testContinousPlaybackOffSingleEpisode() throws Exception { setContinuousPlaybackPreference(false); uiTestUtils.addLocalFeedData(true); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FeedPreferenceSkipDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FeedPreferenceSkipDialog.java new file mode 100644 index 000000000..0e5a064eb --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FeedPreferenceSkipDialog.java @@ -0,0 +1,48 @@ +package de.danoeh.antennapod.dialog; + +import android.content.Context; +import android.view.View; +import android.widget.EditText; +import androidx.appcompat.app.AlertDialog; +import de.danoeh.antennapod.R; + +/** + * Displays a dialog with a username and password text field and an optional checkbox to save username and preferences. + */ +public abstract class FeedPreferenceSkipDialog extends AlertDialog.Builder { + + public FeedPreferenceSkipDialog(Context context, int skipIntroInitialValue, + int skipEndInitialValue) { + super(context); + setTitle(R.string.pref_feed_skip); + View rootView = View.inflate(context, R.layout.feed_pref_skip_dialog, null); + setView(rootView); + + final EditText etxtSkipIntro = rootView.findViewById(R.id.etxtSkipIntro); + final EditText etxtSkipEnd = rootView.findViewById(R.id.etxtSkipEnd); + + etxtSkipIntro.setText(String.valueOf(skipIntroInitialValue)); + etxtSkipEnd.setText(String.valueOf(skipEndInitialValue)); + + setNegativeButton(R.string.cancel_label, null); + setPositiveButton(R.string.confirm_label, (dialog, which) + -> { + int skipIntro; + int skipEnding; + try { + skipIntro = Integer.parseInt(etxtSkipIntro.getText().toString()); + } catch (NumberFormatException e) { + skipIntro = 0; + } + + try { + skipEnding = Integer.parseInt(etxtSkipEnd.getText().toString()); + } catch (NumberFormatException e) { + skipEnding = 0; + } + onConfirmed(skipIntro, skipEnding); + }); + } + + protected abstract void onConfirmed(int skipIntro, int skipEndig); +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java index 23b8b7f19..8251e8716 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedSettingsFragment.java @@ -17,6 +17,7 @@ import androidx.preference.PreferenceFragmentCompat; import androidx.preference.SwitchPreference; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.dialog.ConfirmationDialog; +import de.danoeh.antennapod.core.event.settings.SkipIntroEndingChangedEvent; import de.danoeh.antennapod.core.event.settings.SpeedPresetChangedEvent; import de.danoeh.antennapod.core.event.settings.VolumeAdaptionChangedEvent; import de.danoeh.antennapod.core.feed.Feed; @@ -28,6 +29,7 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.dialog.AuthenticationDialog; import de.danoeh.antennapod.dialog.EpisodeFilterDialog; +import de.danoeh.antennapod.dialog.FeedPreferenceSkipDialog; import io.reactivex.Maybe; import io.reactivex.MaybeOnSubscribe; import io.reactivex.android.schedulers.AndroidSchedulers; @@ -99,6 +101,7 @@ public class FeedSettingsFragment extends Fragment { private static final CharSequence PREF_EPISODE_FILTER = "episodeFilter"; private static final CharSequence PREF_SCREEN = "feedSettingsScreen"; private static final String PREF_FEED_PLAYBACK_SPEED = "feedPlaybackSpeed"; + private static final String PREF_AUTO_SKIP = "feedAutoSkip"; private static final DecimalFormat SPEED_FORMAT = new DecimalFormat("0.00", DecimalFormatSymbols.getInstance(Locale.US)); @@ -142,6 +145,7 @@ public class FeedSettingsFragment extends Fragment { setupAuthentificationPreference(); setupEpisodeFilterPreference(); setupPlaybackSpeedPreference(); + setupFeedAutoSkipPreference(); updateAutoDeleteSummary(); updateVolumeReductionValue(); @@ -159,6 +163,26 @@ public class FeedSettingsFragment extends Fragment { } } + private void setupFeedAutoSkipPreference() { + findPreference(PREF_AUTO_SKIP).setOnPreferenceClickListener(preference -> { + new FeedPreferenceSkipDialog(getContext(), + feedPreferences.getFeedSkipIntro(), + feedPreferences.getFeedSkipEnding()) { + @Override + protected void onConfirmed(int skipIntro, int skipEnding) { + feedPreferences.setFeedSkipIntro(skipIntro); + feedPreferences.setFeedSkipEnding(skipEnding); + feed.savePreferences(); + EventBus.getDefault().post( + new SkipIntroEndingChangedEvent(feedPreferences.getFeedSkipIntro(), + feedPreferences.getFeedSkipEnding(), + feed.getId())); + } + }.show(); + return false; + }); + } + private void setupPlaybackSpeedPreference() { ListPreference feedPlaybackSpeedPreference = findPreference(PREF_FEED_PLAYBACK_SPEED); diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java index dbfa2f4ca..d3900353a 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java @@ -5,6 +5,7 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import de.danoeh.antennapod.BuildConfig; +import de.danoeh.antennapod.CrashReportWriter; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences.EnqueueLocation; @@ -25,6 +26,7 @@ public class PreferenceUpgrader { if (oldVersion != newVersion) { AutoUpdateManager.restartUpdateAlarm(context); + CrashReportWriter.getFile().delete(); upgrade(oldVersion); upgraderPrefs.edit().putInt(PREF_CONFIGURED_VERSION, newVersion).apply(); diff --git a/app/src/main/res/layout/feed_item_list_fragment.xml b/app/src/main/res/layout/feed_item_list_fragment.xml index e607ac216..38496dd4f 100644 --- a/app/src/main/res/layout/feed_item_list_fragment.xml +++ b/app/src/main/res/layout/feed_item_list_fragment.xml @@ -15,6 +15,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" + app:scrimAnimationDuration="200" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView @@ -22,7 +23,7 @@ style="@style/BigBlurryBackground" android:background="@color/image_readability_tint" android:layout_width="match_parent" - android:layout_height="256dp" + android:layout_height="232dp" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.6"/> diff --git a/app/src/main/res/layout/feed_pref_skip_dialog.xml b/app/src/main/res/layout/feed_pref_skip_dialog.xml new file mode 100644 index 000000000..db76a3426 --- /dev/null +++ b/app/src/main/res/layout/feed_pref_skip_dialog.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/labelSkipIntro" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="24dp" + android:layout_marginRight="24dp" + android:text="@string/pref_feed_skip_intro" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <EditText + android:id="@+id/etxtSkipIntro" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="24dp" + android:autofillHints="@string/pref_feed_skip_intro" + android:cursorVisible="true" + android:focusable="true" + android:focusableInTouchMode="true" + android:inputType="number" + android:maxLength="5" + android:minWidth="150dp" + android:text="30" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_marginRight="24dp" + android:text="@string/time_seconds" /> + + </LinearLayout> + + <TextView + android:id="@+id/labelSkipEnd" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginLeft="24dp" + android:layout_marginRight="24dp" + android:text="@string/pref_feed_skip_ending" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" > + + <EditText + android:id="@+id/etxtSkipEnd" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="24dp" + android:cursorVisible="true" + android:focusable="true" + android:autofillHints="@string/pref_feed_skip_ending" + android:focusableInTouchMode="true" + android:inputType="number" + android:maxLength="5" + android:minWidth="150dp" + android:text="30" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="8dp" + android:layout_marginRight="24dp" + android:text="@string/time_seconds" /> + </LinearLayout> + +</LinearLayout> diff --git a/app/src/main/res/layout/feedinfo.xml b/app/src/main/res/layout/feedinfo.xml index e3efa72ce..d2e077be1 100644 --- a/app/src/main/res/layout/feedinfo.xml +++ b/app/src/main/res/layout/feedinfo.xml @@ -15,6 +15,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" + app:scrimAnimationDuration="200" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <ImageView @@ -22,7 +23,7 @@ style="@style/BigBlurryBackground" android:background="@color/image_readability_tint" android:layout_width="match_parent" - android:layout_height="256dp" + android:layout_height="232dp" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.6"/> diff --git a/app/src/main/res/layout/nav_listitem.xml b/app/src/main/res/layout/nav_listitem.xml index f03ebc09f..2b7bc5715 100644 --- a/app/src/main/res/layout/nav_listitem.xml +++ b/app/src/main/res/layout/nav_listitem.xml @@ -51,6 +51,8 @@ android:layout_toStartOf="@id/txtvCount" android:layout_marginLeft="@dimen/list_vertical_padding" android:layout_marginStart="@dimen/list_vertical_padding" + android:layout_marginRight="@dimen/list_vertical_padding" + android:layout_marginEnd="@dimen/list_vertical_padding" android:layout_alignWithParentIfMissing="true" android:lines="1" android:text="{fa-exclamation-circle}" diff --git a/app/src/main/res/xml/feed_settings.xml b/app/src/main/res/xml/feed_settings.xml index a9effdeeb..9a3a4f438 100644 --- a/app/src/main/res/xml/feed_settings.xml +++ b/app/src/main/res/xml/feed_settings.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen - xmlns:android="http://schemas.android.com/apk/res/android" - android:key="feedSettingsScreen"> + xmlns:android="http://schemas.android.com/apk/res/android" + android:key="feedSettingsScreen"> <SwitchPreference android:key="keepUpdated" @@ -21,6 +21,11 @@ android:title="@string/playback_speed" android:summary="@string/pref_feed_playback_speed_sum"/> + <Preference + android:key="skipping" + android:summary="@string/pref_feed_skip_sum" + android:title="@string/pref_feed_skip" /> + <ListPreference android:entries="@array/spnAutoDeleteItems" android:entryValues="@array/spnAutoDeleteValues" |