summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java28
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java18
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java12
-rw-r--r--app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java11
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java16
-rw-r--r--core/src/main/res/values/strings.xml2
9 files changed, 60 insertions, 35 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java
index 4feaefe28..de9f4d504 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/TagSettingsDialog.java
@@ -24,6 +24,8 @@ public class TagSettingsDialog extends DialogFragment {
public static final String TAG = "TagSettingsDialog";
private static final String ARG_FEED_PREFERENCES = "feed_preferences";
private List<String> displayedTags;
+ private EditTagsDialogBinding viewBinding;
+ private TagSelectionAdapter adapter;
public static TagSettingsDialog newInstance(FeedPreferences preferences) {
TagSettingsDialog fragment = new TagSettingsDialog();
@@ -40,29 +42,22 @@ public class TagSettingsDialog extends DialogFragment {
displayedTags = new ArrayList<>(preferences.getTags());
displayedTags.remove(FeedPreferences.TAG_ROOT);
- EditTagsDialogBinding viewBinding = EditTagsDialogBinding.inflate(getLayoutInflater());
+ viewBinding = EditTagsDialogBinding.inflate(getLayoutInflater());
viewBinding.tagsRecycler.setLayoutManager(new GridLayoutManager(getContext(), 2));
viewBinding.tagsRecycler.addItemDecoration(new ItemOffsetDecoration(getContext(), 4));
- TagSelectionAdapter adapter = new TagSelectionAdapter();
+ adapter = new TagSelectionAdapter();
adapter.setHasStableIds(true);
viewBinding.tagsRecycler.setAdapter(adapter);
viewBinding.rootFolderCheckbox.setChecked(preferences.getTags().contains(FeedPreferences.TAG_ROOT));
-
- viewBinding.newTagButton.setOnClickListener(v -> {
- String name = viewBinding.newTagEditText.getText().toString().trim();
- if (TextUtils.isEmpty(name) || displayedTags.contains(name)) {
- return;
- }
- displayedTags.add(name);
- viewBinding.newTagEditText.setText("");
- adapter.notifyDataSetChanged();
- });
+ viewBinding.newTagButton.setOnClickListener(v ->
+ addTag(viewBinding.newTagEditText.getText().toString().trim()));
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
dialog.setView(viewBinding.getRoot());
dialog.setTitle(R.string.feed_folders_label);
dialog.setPositiveButton(android.R.string.ok, (d, input) -> {
+ addTag(viewBinding.newTagEditText.getText().toString().trim());
preferences.getTags().clear();
preferences.getTags().addAll(displayedTags);
if (viewBinding.rootFolderCheckbox.isChecked()) {
@@ -74,6 +69,15 @@ public class TagSettingsDialog extends DialogFragment {
return dialog.create();
}
+ private void addTag(String name) {
+ if (TextUtils.isEmpty(name) || displayedTags.contains(name)) {
+ return;
+ }
+ displayedTags.add(name);
+ viewBinding.newTagEditText.setText("");
+ adapter.notifyDataSetChanged();
+ }
+
public class TagSelectionAdapter extends RecyclerView.Adapter<TagSelectionAdapter.ViewHolder> {
@Override
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 144ec1e66..d5807cd90 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
@@ -98,6 +98,7 @@ public class AudioPlayerFragment extends Fragment implements
private boolean hasChapters = false;
private boolean seekedToChapterStart = false;
private int currentChapterIndex = -1;
+ private int duration;
private TabLayoutMediator tabLayoutMediator;
@Override
@@ -195,10 +196,9 @@ public class AudioPlayerFragment extends Fragment implements
if (hasChapters) {
List<Chapter> chapters = media.getChapters();
dividerPos = new float[chapters.size()];
- float duration = media.getDuration();
for (int i = 0; i < chapters.size(); i++) {
- dividerPos[i] = chapters.get(i).getStart() / duration;
+ dividerPos[i] = chapters.get(i).getStart() / (float) duration;
}
}
@@ -418,6 +418,8 @@ public class AudioPlayerFragment extends Fragment implements
return;
}
+ duration = controller.getDuration();
+
if (media != null && media.getChapters() != null) {
setHasChapters(media.getChapters().size() > 0);
currentChapterIndex = ChapterUtils.getCurrentChapterIndex(media, controller.getPosition());
@@ -425,7 +427,7 @@ public class AudioPlayerFragment extends Fragment implements
setHasChapters(false);
currentChapterIndex = -1;
}
- updatePosition(new PlaybackPositionEvent(controller.getPosition(), controller.getDuration()));
+ updatePosition(new PlaybackPositionEvent(controller.getPosition(), duration));
updatePlaybackSpeedButton(media);
setChapterDividers(media);
setupOptionsMenu(media);
@@ -482,8 +484,11 @@ public class AudioPlayerFragment extends Fragment implements
} else {
txtvLength.setText(Converter.getDurationStringLong(duration));
}
- float progress = ((float) event.getPosition()) / event.getDuration();
- sbPosition.setProgress((int) (progress * sbPosition.getMax()));
+
+ if (!sbPosition.isPressed()) {
+ float progress = ((float) event.getPosition()) / event.getDuration();
+ sbPosition.setProgress((int) (progress * sbPosition.getMax()));
+ }
}
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -496,6 +501,7 @@ public class AudioPlayerFragment extends Fragment implements
if (controller == null || txtvLength == null) {
return;
}
+
if (fromUser) {
float prog = progress / ((float) seekBar.getMax());
TimeSpeedConverter converter = new TimeSpeedConverter(controller.getCurrentPlaybackSpeedMultiplier());
@@ -515,6 +521,8 @@ public class AudioPlayerFragment extends Fragment implements
} else {
txtvSeek.setText(Converter.getDurationStringLong(position));
}
+ } else if (duration != controller.getDuration()) {
+ updateUi(controller.getMedia());
}
}
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 5b53949e4..1fda42d41 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
@@ -490,19 +490,13 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
final int position = viewHolder.getAdapterPosition();
Log.d(TAG, "remove(" + position + ")");
final FeedItem item = queue.get(position);
- final boolean isRead = item.isPlayed();
- DBWriter.markItemPlayed(FeedItem.PLAYED, false, item.getId());
DBWriter.removeQueueItem(getActivity(), true, item);
((MainActivity) getActivity()).showSnackbarAbovePlayer(
- item.hasMedia() ? R.string.marked_as_read_label : R.string.marked_as_read_no_media_label,
+ getResources().getQuantityString(R.plurals.removed_from_queue_batch_label, 1, 1),
Snackbar.LENGTH_LONG)
- .setAction(getString(R.string.undo), v -> {
- DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false);
- if (!isRead) {
- DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId());
- }
- });
+ .setAction(getString(R.string.undo), v ->
+ DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false));
}
@Override
diff --git a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java
index e14b000a7..ba7acb847 100644
--- a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java
+++ b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java
@@ -118,6 +118,14 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar {
canvas.drawRect(left, top, right, bottom, paintBackground);
+ if (progressSecondary > 0 && progressSecondary < width) {
+ if (right < progressSecondary) {
+ canvas.drawRect(left, top, right, bottom, paintBackground);
+ } else if (progressSecondary > left) {
+ canvas.drawRect(left, top, progressSecondary, bottom, paintBackground);
+ }
+ }
+
if (right < progressPrimary) {
currChapter = i + 1;
canvas.drawRect(left, top, right, bottom, paintProgressPrimary);
@@ -125,9 +133,6 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar {
canvas.drawRect(leftCurr, topExpanded, rightCurr, bottomExpanded, paintBackground);
canvas.drawRect(leftCurr, topExpanded, progressPrimary, bottomExpanded, paintProgressPrimary);
} else {
- if (progressSecondary > leftCurr) {
- canvas.drawRect(leftCurr, top, progressSecondary, bottom, paintBackground);
- }
canvas.drawRect(leftCurr, top, progressPrimary, bottom, paintProgressPrimary);
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java
index 14286d850..0394b754a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java
@@ -29,7 +29,7 @@ public class NSDublinCore extends Namespace {
String second = state.getSecondTag().getName();
if (DATE.equals(top) && ITEM.equals(second)) {
String content = state.getContentBuf().toString();
- currentItem.setPubDate(DateUtils.parse(content));
+ currentItem.setPubDate(DateUtils.parseOrNullIfFuture(content));
}
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java
index 87423b6b1..50c2dc118 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSRSS20.java
@@ -124,7 +124,7 @@ public class NSRSS20 extends Namespace {
state.getCurrentItem().setLink(content);
}
} else if (PUBDATE.equals(top) && ITEM.equals(second) && state.getCurrentItem() != null) {
- state.getCurrentItem().setPubDate(DateUtils.parse(content));
+ state.getCurrentItem().setPubDate(DateUtils.parseOrNullIfFuture(content));
} else if (URL.equals(top) && IMAGE.equals(second) && CHANNEL.equals(third)) {
// prefer itunes:image
if (state.getFeed() != null && state.getFeed().getImageUrl() == null) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java
index 7c5ed2d30..6d459075a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/NSAtom.java
@@ -205,9 +205,9 @@ public class NSAtom extends Namespace {
state.getCurrentItem().setDescriptionIfLonger(textElement.getProcessedContent());
} else if (UPDATED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null &&
state.getCurrentItem().getPubDate() == null) {
- state.getCurrentItem().setPubDate(DateUtils.parse(content));
+ state.getCurrentItem().setPubDate(DateUtils.parseOrNullIfFuture(content));
} else if (PUBLISHED.equals(top) && ENTRY.equals(second) && state.getCurrentItem() != null) {
- state.getCurrentItem().setPubDate(DateUtils.parse(content));
+ state.getCurrentItem().setPubDate(DateUtils.parseOrNullIfFuture(content));
} else if (IMAGE_LOGO.equals(top) && state.getFeed() != null && state.getFeed().getImageUrl() == null) {
state.getFeed().setImageUrl(content);
} else if (IMAGE_ICON.equals(top) && state.getFeed() != null) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java
index 196583bcd..a0b9fbef9 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java
@@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.util;
import android.content.Context;
import android.util.Log;
+import androidx.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import java.text.DateFormat;
@@ -122,6 +123,21 @@ public class DateUtils {
return null;
}
+ /**
+ * Parses the date but if the date is in the future, returns null.
+ */
+ @Nullable
+ public static Date parseOrNullIfFuture(final String input) {
+ Date date = parse(input);
+ if (date == null) {
+ return null;
+ }
+ Date now = new Date();
+ if (date.after(now)) {
+ return null;
+ }
+ return date;
+ }
/**
* Takes a string of the form [HH:]MM:SS[.mmm] and converts it to
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index a037ac7a4..7da4cf39c 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -197,9 +197,7 @@
<string name="remove_new_flag_label">Remove \"new\" flag</string>
<string name="removed_new_flag_label">Removed \"new\" flag</string>
<string name="mark_read_label">Mark as played</string>
- <string name="marked_as_read_label">Marked as played</string>
<string name="mark_read_no_media_label">Mark as read</string>
- <string name="marked_as_read_no_media_label">Marked as read</string>
<string name="play_this_to_seek_position">To jump to positions, you need to play the episode</string>
<plurals name="marked_read_batch_label">
<item quantity="one">%d episode marked as played.</item>