diff options
15 files changed, 8 insertions, 220 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java b/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java deleted file mode 100644 index 7e8fc1205..000000000 --- a/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.test.antennapod.util.event; - -import androidx.annotation.NonNull; - -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; - -import java.util.ArrayList; -import java.util.List; - -import de.danoeh.antennapod.event.FeedItemEvent; -import io.reactivex.functions.Consumer; - -/** - * Test helpers to listen {@link FeedItemEvent} and handle them accordingly - * - */ -public class FeedItemEventListener { - private final List<FeedItemEvent> events = new ArrayList<>(); - - /** - * Provides an listener subscribing to {@link FeedItemEvent} that the callers can use - * - * Note: it uses RxJava's version of {@link Consumer} because it allows exceptions to be thrown. - */ - public static void withFeedItemEventListener(@NonNull Consumer<FeedItemEventListener> consumer) - throws Exception { - FeedItemEventListener feedItemEventListener = new FeedItemEventListener(); - try { - EventBus.getDefault().register(feedItemEventListener); - consumer.accept(feedItemEventListener); - } finally { - EventBus.getDefault().unregister(feedItemEventListener); - } - } - - @Subscribe - public void onEvent(FeedItemEvent event) { - events.add(event); - } - - @NonNull - public List<? extends FeedItemEvent> getEvents() { - return events; - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java index d5c67c675..c87228cdd 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java @@ -11,7 +11,6 @@ import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomViewTarget; import com.bumptech.glide.request.transition.Transition; -import de.danoeh.antennapod.activity.MainActivity; import java.lang.ref.WeakReference; @@ -21,11 +20,9 @@ public class CoverLoader { private String fallbackUri; private ImageView imgvCover; private boolean textAndImageCombined; - private MainActivity activity; private TextView fallbackTitle; - public CoverLoader(MainActivity activity) { - this.activity = activity; + public CoverLoader() { } public CoverLoader withUri(String uri) { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java index 284f3e468..2961796c6 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java @@ -244,7 +244,7 @@ public class SubscriptionsRecyclerAdapter extends SelectableAdapter<Subscription count.setVisibility(View.GONE); } - CoverLoader coverLoader = new CoverLoader(mainActivityRef.get()); + CoverLoader coverLoader = new CoverLoader(); boolean textAndImageCombined; if (drawerItem.type == NavDrawerData.DrawerItem.Type.FEED) { Feed feed = ((NavDrawerData.FeedDrawerItem) drawerItem).feed; diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index 01d4a10f0..fe9b55a2e 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -129,7 +129,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { } if (coverHolder.getVisibility() == View.VISIBLE) { - new CoverLoader(activity) + new CoverLoader() .withUri(ImageResourceUtils.getEpisodeListImageLocation(item)) .withFallbackUri(item.getFeed().getImageUrl()) .withPlaceholderView(placeholder) @@ -225,7 +225,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder { itemView.setBackgroundResource(ThemeUtils.getDrawableFromAttr(activity, R.attr.selectableItemBackground)); placeholder.setText(""); if (coverHolder.getVisibility() == View.VISIBLE) { - new CoverLoader(activity) + new CoverLoader() .withResource(R.color.medium_gray) .withPlaceholderView(placeholder) .withCoverView(cover) diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java index 21a29a920..8d44f419e 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/HorizontalItemViewHolder.java @@ -58,7 +58,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder { card.setAlpha(1.0f); float density = activity.getResources().getDisplayMetrics().density; card.setCardBackgroundColor(SurfaceColors.getColorForElevation(activity, 1 * density)); - new CoverLoader(activity) + new CoverLoader() .withUri(ImageResourceUtils.getEpisodeListImageLocation(item)) .withFallbackUri(item.getFeed().getImageUrl()) .withCoverView(cover) @@ -102,7 +102,7 @@ public class HorizontalItemViewHolder extends RecyclerView.ViewHolder { public void bindDummy() { card.setAlpha(0.1f); - new CoverLoader(activity) + new CoverLoader() .withResource(android.R.color.transparent) .withCoverView(cover) .load(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java index 8ee47a147..48bbc3321 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java @@ -66,7 +66,6 @@ public class ExoPlayerWrapper { public static final int BUFFERING_STARTED = -1; public static final int BUFFERING_ENDED = -2; private static final String TAG = "ExoPlayerWrapper"; - public static final int ERROR_CODE_OFFSET = 1000; private final Context context; private final Disposable bufferingUpdateDisposable; diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/download/ConnectionStateMonitor.java b/core/src/main/java/de/danoeh/antennapod/core/util/download/ConnectionStateMonitor.java deleted file mode 100644 index a8d9437ee..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/download/ConnectionStateMonitor.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.danoeh.antennapod.core.util.download; - -import android.content.Context; -import android.net.ConnectivityManager; -import android.net.NetworkCapabilities; -import android.net.NetworkRequest; -import android.util.Log; - -public class ConnectionStateMonitor - extends ConnectivityManager.NetworkCallback - implements ConnectivityManager.OnNetworkActiveListener { - private static final String TAG = "ConnectionStateMonitor"; - final NetworkRequest networkRequest; - - public ConnectionStateMonitor() { - networkRequest = new NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) - .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) - .build(); - } - - @Override - public void onNetworkActive() { - Log.d(TAG, "ConnectionStateMonitor::onNetworkActive network connection changed"); - NetworkConnectionChangeHandler.networkChangedDetected(); - } - - public void enable(Context context) { - ConnectivityManager connectivityManager = - (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - connectivityManager.registerNetworkCallback(networkRequest, this); - connectivityManager.addDefaultNetworkActiveListener(this); - } - - public void disable(Context context) { - ConnectivityManager connectivityManager = - (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - connectivityManager.unregisterNetworkCallback(this); - connectivityManager.removeDefaultNetworkActiveListener(this); - } -}
\ No newline at end of file diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java deleted file mode 100644 index 8ca8bbf6c..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java +++ /dev/null @@ -1,36 +0,0 @@ -package de.danoeh.antennapod.core.util.playback; - -import android.content.Context; -import android.media.MediaPlayer; -import com.google.android.exoplayer2.ExoPlaybackException; -import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.service.playback.ExoPlayerWrapper; - -/** Utility class for MediaPlayer errors. */ -public class MediaPlayerError { - private MediaPlayerError(){} - - /** Get a human-readable string for a specific error code. */ - public static String getErrorString(Context context, int code) { - int resId; - switch (code) { - case MediaPlayer.MEDIA_ERROR_SERVER_DIED: - resId = R.string.playback_error_server_died; - break; - case MediaPlayer.MEDIA_ERROR_UNSUPPORTED: // fall-through - case ExoPlayerWrapper.ERROR_CODE_OFFSET + ExoPlaybackException.TYPE_RENDERER: - resId = R.string.playback_error_unsupported; - break; - case MediaPlayer.MEDIA_ERROR_TIMED_OUT: - resId = R.string.playback_error_timeout; - break; - case ExoPlayerWrapper.ERROR_CODE_OFFSET + ExoPlaybackException.TYPE_SOURCE: - resId = R.string.playback_error_source; - break; - default: - resId = R.string.playback_error_unknown; - break; - } - return context.getString(resId) + " (" + code + ")"; - } -} diff --git a/core/src/test/java/android/text/TextUtils.java b/core/src/test/java/android/text/TextUtils.java index eda31c3b5..709cb9e93 100644 --- a/core/src/test/java/android/text/TextUtils.java +++ b/core/src/test/java/android/text/TextUtils.java @@ -13,6 +13,7 @@ public class TextUtils { * @param b second CharSequence to check * @return true if a and b are equal */ + @SuppressWarnings("unused") public static boolean equals(CharSequence a, CharSequence b) { if (a == b) return true; int length; diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java index 6a7e51bac..3eed90ea8 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbTasksTest.java @@ -252,25 +252,4 @@ public class DbTasksTest { lastDate = item.getPubDate(); } } - - private Feed createSavedFeed(String title, int numFeedItems) { - final Feed feed = new Feed("url", null, title); - - if (numFeedItems > 0) { - List<FeedItem> items = new ArrayList<>(numFeedItems); - for (int i = 1; i <= numFeedItems; i++) { - FeedItem item = new FeedItem(0, "item " + i + " of " + title, "id" + title + i, "link", - new Date(), FeedItem.UNPLAYED, feed); - items.add(item); - } - feed.setItems(items); - } - - PodDBAdapter adapter = PodDBAdapter.getInstance(); - adapter.open(); - adapter.setCompleteFeed(feed); - adapter.close(); - return feed; - } - } diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java index e078d755a..25ea9330c 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java @@ -333,10 +333,6 @@ public class FeedItem implements Serializable { } } - public enum State { - UNREAD, IN_PROGRESS, READ, PLAYING - } - public long getFeedId() { return feedId; } diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java b/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java index 08504b445..f6c90341a 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java @@ -72,12 +72,4 @@ public enum SortOrder { public static String toCodeString(@Nullable SortOrder sortOrder) { return sortOrder != null ? Integer.toString(sortOrder.code) : null; } - - public static SortOrder[] valuesOf(String[] stringValues) { - SortOrder[] values = new SortOrder[stringValues.length]; - for (int i = 0; i < stringValues.length; i++) { - values[i] = SortOrder.valueOf(stringValues[i]); - } - return values; - } } diff --git a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java index 7873ae4fe..da23cd351 100644 --- a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java +++ b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java @@ -167,38 +167,6 @@ public class GpodnetService implements ISyncService { } /** - * Uploads the subscriptions of a specific device. - * <p/> - * This method requires authentication. - * - * @param deviceId The ID of the device whose subscriptions should be updated. - * @param subscriptions A list of feed URLs containing all subscriptions of the - * device. - * @throws IllegalArgumentException If username, deviceId or subscriptions is null. - * @throws GpodnetServiceAuthenticationException If there is an authentication error. - */ - public void uploadSubscriptions(@NonNull String deviceId, @NonNull List<String> subscriptions) - throws GpodnetServiceException { - requireLoggedIn(); - try { - URL url = new URI(baseScheme, null, baseHost, basePort, - String.format("/subscriptions/%s/%s.txt", username, deviceId), null, null).toURL(); - StringBuilder builder = new StringBuilder(); - for (String s : subscriptions) { - builder.append(s); - builder.append("\n"); - } - RequestBody body = RequestBody.create(TEXT, builder.toString()); - Request.Builder request = new Request.Builder().put(body).url(url); - executeRequest(request); - } catch (MalformedURLException | URISyntaxException e) { - e.printStackTrace(); - throw new GpodnetServiceException(e); - } - - } - - /** * Updates the subscription list of a specific device. * <p/> * This method requires authentication. diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java index 3d82cb32c..48793ff13 100644 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.ui.common; -import androidx.annotation.NonNull; import com.google.android.material.appbar.MaterialToolbar; import androidx.fragment.app.Fragment; import androidx.viewpager2.widget.ViewPager2; @@ -10,23 +9,8 @@ import androidx.viewpager2.widget.ViewPager2; * All items share the same general menu items and are just allowed to show/hide them. */ public abstract class PagedToolbarFragment extends Fragment { - private MaterialToolbar toolbar; - private ViewPager2 viewPager; - /** - * Invalidate the toolbar menu if the current child fragment is visible. - * @param child The fragment to invalidate - */ - public void invalidateOptionsMenuIfActive(@NonNull Fragment child) { - Fragment visibleChild = getChildFragmentManager().findFragmentByTag("f" + viewPager.getCurrentItem()); - if (visibleChild == child) { - visibleChild.onPrepareOptionsMenu(toolbar.getMenu()); - } - } - - protected void setupPagedToolbar(MaterialToolbar toolbar, ViewPager2 viewPager) { - this.toolbar = toolbar; - this.viewPager = viewPager; + protected void setupPagedToolbar(final MaterialToolbar toolbar, final ViewPager2 viewPager) { toolbar.setOnMenuItemClickListener(item -> { if (this.onOptionsItemSelected(item)) { diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 03044a79d..1ce509002 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -320,11 +320,6 @@ <!-- Mediaplayer messages --> <string name="playback_error_generic"><![CDATA[The media file could not be played.\n\n- Try deleting and re-downloading the episode.\n- Check your network connection, and make sure no VPN or login page is blocking access.\n- Try long-pressing and sharing the \"Media address\" to your web browser to see if it can be played there. If not, contact the podcast creators.]]></string> - <string name="playback_error_server_died">Server died</string> - <string name="playback_error_unsupported">Unsupported media type</string> - <string name="playback_error_timeout">Operation timed out</string> - <string name="playback_error_source">Unable to access media file</string> - <string name="playback_error_unknown">Unknown error</string> <string name="no_media_playing_label">No media playing</string> <string name="position_default_label" translatable="false">00:00:00</string> <string name="unknown_media_key">AntennaPod - Unknown media key: %1$d</string> |