Added button to stop previewed episode
This commit is contained in:
parent
44f35cb1f1
commit
82188995e5
|
@ -32,17 +32,20 @@ import de.danoeh.antennapod.core.ClientConfig;
|
|||
import de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.core.event.DownloadEvent;
|
||||
import de.danoeh.antennapod.core.event.FeedListUpdateEvent;
|
||||
import de.danoeh.antennapod.core.event.PlayerStatusEvent;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.feed.FeedPreferences;
|
||||
import de.danoeh.antennapod.core.feed.VolumeAdaptionSetting;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.glide.FastBlurTransformation;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
import de.danoeh.antennapod.core.service.download.Downloader;
|
||||
import de.danoeh.antennapod.core.service.download.HttpDownloader;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
|
@ -51,9 +54,11 @@ import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult;
|
|||
import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException;
|
||||
import de.danoeh.antennapod.core.util.DownloadError;
|
||||
import de.danoeh.antennapod.core.util.FileNameGenerator;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.Optional;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.URLChecker;
|
||||
import de.danoeh.antennapod.core.util.playback.RemoteMedia;
|
||||
import de.danoeh.antennapod.core.util.syndication.FeedDiscoverer;
|
||||
import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText;
|
||||
import de.danoeh.antennapod.dialog.AuthenticationDialog;
|
||||
|
@ -99,6 +104,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
private ListView listView;
|
||||
private Button subscribeButton;
|
||||
private ProgressBar progressBar;
|
||||
private Button stopPreviewButton;
|
||||
|
||||
private Disposable download;
|
||||
private Disposable parser;
|
||||
|
@ -405,6 +411,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
TextView description = header.findViewById(R.id.txtvDescription);
|
||||
|
||||
subscribeButton = findViewById(R.id.butSubscribe);
|
||||
stopPreviewButton = findViewById(R.id.butStopPreview);
|
||||
|
||||
if (StringUtils.isNotBlank(feed.getImageUrl())) {
|
||||
Glide.with(this)
|
||||
|
@ -449,6 +456,11 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
stopPreviewButton.setOnClickListener(v -> {
|
||||
PlaybackPreferences.writeNoMediaPlaying();
|
||||
IntentUtils.sendLocalBroadcast(this, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||
});
|
||||
|
||||
final int MAX_LINES_COLLAPSED = 10;
|
||||
description.setMaxLines(MAX_LINES_COLLAPSED);
|
||||
description.setOnClickListener(v -> {
|
||||
|
@ -568,6 +580,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void playbackStateChanged(PlayerStatusEvent event) {
|
||||
boolean isPlayingPreview =
|
||||
PlaybackPreferences.getCurrentlyPlayingMediaType() == RemoteMedia.PLAYABLE_TYPE_REMOTE_MEDIA;
|
||||
stopPreviewButton.setVisibility(isPlayingPreview ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if a FeedDiscoveryDialog is shown, false otherwise (e.g., due to no feed found).
|
||||
|
|
|
@ -70,13 +70,6 @@ public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
|
|||
return;
|
||||
}
|
||||
Playable playable = new RemoteMedia(item);
|
||||
if (PlaybackPreferences.getCurrentlyPlayingMediaType() == RemoteMedia.PLAYABLE_TYPE_REMOTE_MEDIA) {
|
||||
PlaybackPreferences.writeNoMediaPlaying();
|
||||
IntentUtils.sendLocalBroadcast(getContext(), PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||
holder.preview.setText(R.string.preview_episode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!NetworkUtils.isStreamingAllowed()) {
|
||||
new StreamingConfirmationDialog(getContext(), playable).show();
|
||||
return;
|
||||
|
@ -87,7 +80,6 @@ public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
|
|||
.startWhenPrepared(true)
|
||||
.callEvenIfRunning(true)
|
||||
.start();
|
||||
holder.preview.setText(R.string.stop_playback);
|
||||
|
||||
if (playable.getMediaType() == MediaType.VIDEO) {
|
||||
getContext().startActivity(PlaybackService.getPlayerActivityIntent(getContext(), playable));
|
||||
|
@ -103,11 +95,7 @@ public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
|
|||
holder.description.setTag(Boolean.TRUE);
|
||||
|
||||
holder.preview.setVisibility(item.getMedia() != null ? View.VISIBLE : View.GONE);
|
||||
if (PlaybackPreferences.getCurrentlyPlayingMediaType() == RemoteMedia.PLAYABLE_TYPE_REMOTE_MEDIA) {
|
||||
holder.preview.setText(R.string.stop_playback);
|
||||
} else {
|
||||
holder.preview.setText(R.string.preview_episode);
|
||||
}
|
||||
holder.preview.setText(R.string.preview_episode);
|
||||
}
|
||||
});
|
||||
return convertView;
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:text="@string/preview_episode"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -124,6 +124,17 @@
|
|||
android:focusable="false"
|
||||
android:text="@string/subscribe_label"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/butStopPreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:focusable="false"
|
||||
android:text="@string/stop_preview"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -668,6 +668,7 @@
|
|||
<string name="subscribe_label">Subscribe</string>
|
||||
<string name="subscribing_label">Subscribing…</string>
|
||||
<string name="preview_episode">Preview</string>
|
||||
<string name="stop_preview">Stop preview</string>
|
||||
|
||||
<!-- Content descriptions for image buttons -->
|
||||
<string name="rewind_label">Rewind</string>
|
||||
|
|
Loading…
Reference in New Issue