From f082611b0279848ce75452e0d2c7938841a148b9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 17 Mar 2023 17:28:20 +0100 Subject: [PATCH] some changes with resolution --- .../peertube/activities/PeertubeActivity.java | 16 +++++++++++++--- .../android/peertube/client/data/VideoData.java | 11 ++++++----- .../android/peertube/client/entities/Item.java | 4 ++++ .../main/res/layouts/mastodon/values/strings.xml | 1 + 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java index ede1e240..2c41ebb1 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeActivity.java @@ -611,7 +611,7 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis } captions = null; } - currentResolution = null; + currentResolution = getString(R.string.auto); show_more_content = null; currentCaption = "null"; binding.peertubeDescriptionMore.setVisibility(View.GONE); @@ -1767,8 +1767,18 @@ public class PeertubeActivity extends BasePeertubeActivity implements CommentLis case RESOLUTION: binding.subMenuTitle.setText(R.string.pickup_resolution); int position = 0; - for (File file : peertube.getFiles()) { - if (file.getResolutions() != null) { + for (File file : peertube.getAllFile(PeertubeActivity.this)) { + + if (file.getResolutions() == null) { + MenuItemView item = new MenuItemView(); + item.setId(0); + item.setLabel(file.getResolutions().getLabel()); + if (file.getResolutions().getLabel().compareTo(currentResolution) == 0) { + item.setSelected(true); + } + items.add(item); + position++; + } else if (file.getResolutions() != null) { if (file.getResolutions().getLabel().compareTo("0p") != 0) { MenuItemView item = new MenuItemView(); item.setId(position); diff --git a/app/src/main/java/app/fedilab/android/peertube/client/data/VideoData.java b/app/src/main/java/app/fedilab/android/peertube/client/data/VideoData.java index 35102752..55d9bb25 100644 --- a/app/src/main/java/app/fedilab/android/peertube/client/data/VideoData.java +++ b/app/src/main/java/app/fedilab/android/peertube/client/data/VideoData.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import app.fedilab.android.R; import app.fedilab.android.peertube.client.entities.File; import app.fedilab.android.peertube.client.entities.Item; import app.fedilab.android.peertube.client.entities.ItemStr; @@ -150,13 +151,13 @@ public class VideoData implements Serializable { } else if (streamingPlaylists != null) { List files = new ArrayList<>(); for (StreamingPlaylists streamingPlaylists : streamingPlaylists) { + File file = new File(); + file.setResolutions(new Item(0, context.getString(R.string.auto))); + file.setFileUrl(streamingPlaylists.getPlaylistUrl()); + file.setFileDownloadUrl(streamingPlaylists.getPlaylistUrl()); + files.add(file); if (streamingPlaylists.getFiles().size() > 0) { files.addAll(streamingPlaylists.getFiles()); - } else { - File file = new File(); - file.setFileUrl(streamingPlaylists.getPlaylistUrl()); - file.setFileDownloadUrl(streamingPlaylists.getPlaylistUrl()); - files.add(file); } } return files; diff --git a/app/src/main/java/app/fedilab/android/peertube/client/entities/Item.java b/app/src/main/java/app/fedilab/android/peertube/client/entities/Item.java index 3ff20eca..ab253347 100644 --- a/app/src/main/java/app/fedilab/android/peertube/client/entities/Item.java +++ b/app/src/main/java/app/fedilab/android/peertube/client/entities/Item.java @@ -30,6 +30,10 @@ public class Item implements Serializable { public Item() { } + public Item(int id, String label) { + this.id = id; + this.label = label; + } public int getId() { return id; diff --git a/app/src/main/res/layouts/mastodon/values/strings.xml b/app/src/main/res/layouts/mastodon/values/strings.xml index 78554f9e..0d6b2421 100644 --- a/app/src/main/res/layouts/mastodon/values/strings.xml +++ b/app/src/main/res/layouts/mastodon/values/strings.xml @@ -2,4 +2,5 @@ + Auto \ No newline at end of file