mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-06-05 21:09:11 +02:00
some fixes
This commit is contained in:
@ -195,7 +195,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
Toasty.error(AllPlaylistsActivity.this, getString(R.string.error_channel_mandatory), Toast.LENGTH_LONG).show();
|
Toasty.error(AllPlaylistsActivity.this, getString(R.string.error_channel_mandatory), Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
if (privacyToSend != null) {
|
if (privacyToSend != null) {
|
||||||
playlistElement.setPrivacy((int) privacyItem.getId());
|
playlistElement.setPrivacy(privacyItem.getId());
|
||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
String playlistId;
|
String playlistId;
|
||||||
@ -310,7 +310,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
if (playlistToEdit != null) {
|
if (playlistToEdit != null) {
|
||||||
Item privacy = playlistToEdit.getPrivacy();
|
Item privacy = playlistToEdit.getPrivacy();
|
||||||
if (privacy.getId() > 0) {
|
if (privacy.getId() > 0) {
|
||||||
set_upload_privacy.setSelection((int) privacy.getId() - 1);
|
set_upload_privacy.setSelection(privacy.getId() - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_upload_privacy.setSelection(2);
|
set_upload_privacy.setSelection(2);
|
||||||
@ -345,7 +345,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
Item privacy = playlistToEdit.getPrivacy();
|
Item privacy = playlistToEdit.getPrivacy();
|
||||||
|
|
||||||
if (privacy.getId() > 0) {
|
if (privacy.getId() > 0) {
|
||||||
set_upload_privacy.setSelection((int) privacy.getId() - 1);
|
set_upload_privacy.setSelection(privacy.getId() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLISTS
|
|||||||
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved {
|
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved {
|
||||||
|
|
||||||
public static String video_id;
|
public static String video_id;
|
||||||
private String peertubeInstance, videoId;
|
private String peertubeInstance, videoId, videoUuid;
|
||||||
private FullScreenMediaController.fullscreen fullscreen;
|
private FullScreenMediaController.fullscreen fullscreen;
|
||||||
private RelativeLayout loader;
|
private RelativeLayout loader;
|
||||||
private TextView peertube_view_count, peertube_playlist, peertube_bookmark, peertube_like_count, peertube_dislike_count, peertube_description, peertube_title, more_actions;
|
private TextView peertube_view_count, peertube_playlist, peertube_bookmark, peertube_like_count, peertube_dislike_count, peertube_description, peertube_title, more_actions;
|
||||||
@ -150,7 +150,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
private ImageView send;
|
private ImageView send;
|
||||||
private TextView add_comment_read;
|
private TextView add_comment_read;
|
||||||
private EditText add_comment_write;
|
private EditText add_comment_write;
|
||||||
private List<String> playlistForVideo;
|
private List<PlaylistExist> playlistForVideo;
|
||||||
private List<Playlist> playlists;
|
private List<Playlist> playlists;
|
||||||
private PlaylistsVM playlistsViewModel;
|
private PlaylistsVM playlistsViewModel;
|
||||||
private boolean playInMinimized;
|
private boolean playInMinimized;
|
||||||
@ -231,6 +231,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (b != null) {
|
if (b != null) {
|
||||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||||
videoId = b.getString("video_id", null);
|
videoId = b.getString("video_id", null);
|
||||||
|
videoUuid = b.getString("video_uuid", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||||
@ -276,7 +277,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
webview_video.getSettings().setAppCacheEnabled(true);
|
webview_video.getSettings().setAppCacheEnabled(true);
|
||||||
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
webview_video.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||||
webview_video.setWebViewClient(new MastalabWebViewClient(PeertubeActivity.this));
|
webview_video.setWebViewClient(new MastalabWebViewClient(PeertubeActivity.this));
|
||||||
webview_video.loadUrl("https://" + peertubeInstance + "/videos/embed/" + videoId);
|
webview_video.loadUrl("https://" + peertubeInstance + "/videos/embed/" + videoUuid);
|
||||||
} else {
|
} else {
|
||||||
webview_video.setVisibility(View.GONE);
|
webview_video.setVisibility(View.GONE);
|
||||||
playerView.setVisibility(View.VISIBLE);
|
playerView.setVisibility(View.VISIBLE);
|
||||||
@ -307,7 +308,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||||
if (!flag_loading) {
|
if (!flag_loading) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
|
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,6 +348,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (b != null) {
|
if (b != null) {
|
||||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||||
videoId = b.getString("video_id", null);
|
videoId = b.getString("video_id", null);
|
||||||
|
videoUuid = b.getString("video_uuid", null);
|
||||||
playVideo();
|
playVideo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,9 +370,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
peertube_playlist.setVisibility(View.VISIBLE);
|
peertube_playlist.setVisibility(View.VISIBLE);
|
||||||
peertube_bookmark.setVisibility(View.GONE);
|
peertube_bookmark.setVisibility(View.GONE);
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||||
feedsViewModel.getVideo(videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
|
feedsViewModel.getVideo(videoUuid).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||||
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
||||||
captionsViewModel.getCaptions(videoId).observe(PeertubeActivity.this, this::manageCaptions);
|
captionsViewModel.getCaptions(videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void change() {
|
public void change() {
|
||||||
@ -543,18 +545,20 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
|
|
||||||
peertube_playlist.setOnClickListener(v -> {
|
peertube_playlist.setOnClickListener(v -> {
|
||||||
if (playlists != null && videoId != null) {
|
if (playlists != null && videoUuid != null) {
|
||||||
PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist);
|
PopupMenu popup = new PopupMenu(PeertubeActivity.this, peertube_playlist);
|
||||||
|
|
||||||
for (Playlist playlist : playlists) {
|
for (Playlist playlist : playlists) {
|
||||||
String title = null;
|
String title = null;
|
||||||
boolean isPresent = false;
|
boolean isPresent = false;
|
||||||
String elementId = null;
|
String elementId = null;
|
||||||
for (String playlistId : playlistForVideo) {
|
PlaylistExist playlistExistTarget = null;
|
||||||
if (playlist.getId().compareTo(playlistId) == 0) {
|
for (PlaylistExist playlistExist : playlistForVideo) {
|
||||||
|
if (playlist.getId().compareTo(playlistExist.getPlaylistId()) == 0) {
|
||||||
title = "✔ " + playlist.getDisplayName();
|
title = "✔ " + playlist.getDisplayName();
|
||||||
isPresent = true;
|
isPresent = true;
|
||||||
elementId = playlistId;
|
playlistExistTarget = playlistExist;
|
||||||
|
elementId = playlistExist.getPlaylistElementId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,6 +568,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title);
|
MenuItem item = popup.getMenu().add(0, 0, Menu.NONE, title);
|
||||||
boolean finalIsPresent = isPresent;
|
boolean finalIsPresent = isPresent;
|
||||||
String finalElementId = elementId;
|
String finalElementId = elementId;
|
||||||
|
PlaylistExist finalPlaylistExistTarget = playlistExistTarget;
|
||||||
item.setOnMenuItemClickListener(item1 -> {
|
item.setOnMenuItemClickListener(item1 -> {
|
||||||
item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
|
||||||
item1.setActionView(new View(PeertubeActivity.this));
|
item1.setActionView(new View(PeertubeActivity.this));
|
||||||
@ -581,11 +586,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (finalIsPresent) {
|
if (finalIsPresent) {
|
||||||
item1.setTitle(playlist.getDisplayName());
|
item1.setTitle(playlist.getDisplayName());
|
||||||
playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, playlist, finalElementId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.DELETE_VIDEOS, apiResponse3));
|
playlistsViewModel.manage(PlaylistsVM.action.DELETE_VIDEOS, playlist, finalElementId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.DELETE_VIDEOS, apiResponse3));
|
||||||
playlistForVideo.remove(playlist.getId());
|
playlistForVideo.remove(finalPlaylistExistTarget);
|
||||||
} else {
|
} else {
|
||||||
item1.setTitle("✔ " + playlist.getDisplayName());
|
item1.setTitle("✔ " + playlist.getDisplayName());
|
||||||
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, videoId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, videoUuid).observe(PeertubeActivity.this, apiResponse3 -> addElement(playlist.getId(), apiResponse3));
|
||||||
playlistForVideo.add(playlist.getId());
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -597,7 +601,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
if (peertube.isCommentsEnabled()) {
|
if (peertube.isCommentsEnabled()) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||||
write_comment_container.setVisibility(View.VISIBLE);
|
write_comment_container.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -672,7 +676,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
playerView.setPlayer(player);
|
playerView.setPlayer(player);
|
||||||
loader.setVisibility(View.GONE);
|
loader.setVisibility(View.GONE);
|
||||||
|
|
||||||
if( apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) {
|
if (apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) {
|
||||||
if (video_cache == 0) {
|
if (video_cache == 0) {
|
||||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
||||||
Util.getUserAgent(PeertubeActivity.this, null), null);
|
Util.getUserAgent(PeertubeActivity.this, null), null);
|
||||||
@ -684,7 +688,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this)));
|
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this)));
|
||||||
}
|
}
|
||||||
player.prepare(videoSource);
|
player.prepare(videoSource);
|
||||||
}else{
|
} else {
|
||||||
HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(new DefaultHttpDataSourceFactory(System.getProperty("http.agent")))
|
HlsMediaSource hlsMediaSource = new HlsMediaSource.Factory(new DefaultHttpDataSourceFactory(System.getProperty("http.agent")))
|
||||||
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl()));
|
.createMediaSource(Uri.parse(apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl()));
|
||||||
player.prepare(hlsMediaSource);
|
player.prepare(hlsMediaSource);
|
||||||
@ -783,7 +787,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
itemsKeyLanguage[which]);
|
itemsKeyLanguage[which]);
|
||||||
|
|
||||||
|
|
||||||
if( apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) {
|
if (apiResponse.getPeertubes().get(0).getFiles() != null && apiResponse.getPeertubes().get(0).getFiles().size() > 0) {
|
||||||
if (video_cache == 0) {
|
if (video_cache == 0) {
|
||||||
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(PeertubeActivity.this,
|
||||||
Util.getUserAgent(PeertubeActivity.this, null), null);
|
Util.getUserAgent(PeertubeActivity.this, null), null);
|
||||||
@ -984,7 +988,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoId, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
||||||
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
||||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
||||||
@ -1045,10 +1049,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
private void initResolution() {
|
private void initResolution() {
|
||||||
PlayerControlView controlView = playerView.findViewById(R.id.exo_controller);
|
PlayerControlView controlView = playerView.findViewById(R.id.exo_controller);
|
||||||
resolution = controlView.findViewById(R.id.resolution);
|
resolution = controlView.findViewById(R.id.resolution);
|
||||||
if( peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
if (peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
||||||
resolution.setText(String.format("%s", Helper.defaultFile(PeertubeActivity.this, peertube.getFiles()).getResolutions().getLabel()));
|
resolution.setText(String.format("%s", Helper.defaultFile(PeertubeActivity.this, peertube.getFiles()).getResolutions().getLabel()));
|
||||||
resolution.setOnClickListener(v -> displayResolution());
|
resolution.setOnClickListener(v -> displayResolution());
|
||||||
}else{
|
} else {
|
||||||
resolution.setVisibility(View.GONE);
|
resolution.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1089,6 +1093,15 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addElement(String playlistId, APIResponse apiResponse) {
|
||||||
|
if (apiResponse != null && apiResponse.getActionReturn() != null) {
|
||||||
|
PlaylistExist playlistExist = new PlaylistExist();
|
||||||
|
playlistExist.setPlaylistId(playlistId);
|
||||||
|
playlistExist.setPlaylistElementId(apiResponse.getActionReturn());
|
||||||
|
playlistForVideo.add(playlistExist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void manageVIewVideosExist(APIResponse apiResponse) {
|
public void manageVIewVideosExist(APIResponse apiResponse) {
|
||||||
if (apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
|
if (apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
|
||||||
Map<String, List<PlaylistExist>> videoIds = apiResponse.getVideoExistPlaylist();
|
Map<String, List<PlaylistExist>> videoIds = apiResponse.getVideoExistPlaylist();
|
||||||
@ -1096,9 +1109,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, List<PlaylistExist>> pair = it.next();
|
Map.Entry<String, List<PlaylistExist>> pair = it.next();
|
||||||
List<PlaylistExist> playlistExistVideo = pair.getValue();
|
List<PlaylistExist> playlistExistVideo = pair.getValue();
|
||||||
for (PlaylistExist playlistExist : playlistExistVideo) {
|
playlistForVideo.addAll(playlistExistVideo);
|
||||||
playlistForVideo.add(playlistExist.getPlaylistId());
|
|
||||||
}
|
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,12 +457,12 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
videoParams.setDescription(description);
|
videoParams.setDescription(description);
|
||||||
videoParams.setNsfw(isNSFW1);
|
videoParams.setNsfw(isNSFW1);
|
||||||
videoParams.setCommentsEnabled(commentEnabled1);
|
videoParams.setCommentsEnabled(commentEnabled1);
|
||||||
videoParams.setCategory((int) finalCategoryToSend.getId());
|
videoParams.setCategory(finalCategoryToSend.getId());
|
||||||
videoParams.setLicence(String.valueOf(finalLicenseToSend.getId()));
|
videoParams.setLicence(String.valueOf(finalLicenseToSend.getId()));
|
||||||
videoParams.setLanguage(finalLanguageToSend.getId());
|
videoParams.setLanguage(finalLanguageToSend.getId());
|
||||||
|
|
||||||
videoParams.setChannelId(channelToSendId);
|
videoParams.setChannelId(channelToSendId);
|
||||||
videoParams.setPrivacy((int) finalPrivacyToSend.getId());
|
videoParams.setPrivacy(finalPrivacyToSend.getId());
|
||||||
List<String> tags = p_video_tags.getTags();
|
List<String> tags = p_video_tags.getTags();
|
||||||
videoParams.setTags(tags);
|
videoParams.setTags(tags);
|
||||||
set_upload_submit.setEnabled(false);
|
set_upload_submit.setEnabled(false);
|
||||||
|
@ -39,7 +39,6 @@ import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
|
|||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
|
|
||||||
import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_LIST_VIDEOS;
|
import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_LIST_VIDEOS;
|
||||||
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.VIDEOS_IN_PLAYLIST;
|
|
||||||
|
|
||||||
|
|
||||||
public class PlaylistsActivity extends AppCompatActivity {
|
public class PlaylistsActivity extends AppCompatActivity {
|
||||||
|
@ -545,10 +545,10 @@ public class RetrofitPeertubeAPI {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String lang = Locale.getDefault().getLanguage();
|
String lang = Locale.getDefault().getLanguage();
|
||||||
if( lang.contains("-")) {
|
if (lang.contains("-")) {
|
||||||
if( !lang.split("-")[0].trim().toLowerCase().startsWith("zh")){
|
if (!lang.split("-")[0].trim().toLowerCase().startsWith("zh")) {
|
||||||
lang = lang.split("-")[0];
|
lang = lang.split("-")[0];
|
||||||
}else {
|
} else {
|
||||||
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
|
lang = lang.split("-")[0] + "-" + lang.split("-")[1].toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,33 +183,33 @@ public class VideoData {
|
|||||||
public String getFileUrl(String resolution, Context context) {
|
public String getFileUrl(String resolution, Context context) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING;
|
boolean streamService = sharedpreferences.getInt(Helper.SET_VIDEO_MODE, Helper.VIDEO_MODE_NORMAL) == Helper.VIDEO_MODE_STREAMING;
|
||||||
if(files != null && files.size() > 0) {
|
if (files != null && files.size() > 0) {
|
||||||
if (resolution != null) {
|
if (resolution != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
if (file.getResolutions().getLabel().compareTo(resolution) == 0) {
|
||||||
if (streamService) {
|
if (streamService) {
|
||||||
return file.getMagnetUri();
|
return file.getMagnetUri();
|
||||||
} else {
|
} else {
|
||||||
return file.getFileUrl();
|
return file.getFileUrl();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file = Helper.defaultFile(context, files);
|
File file = Helper.defaultFile(context, files);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
if (streamService) {
|
if (streamService) {
|
||||||
return file.getMagnetUri();
|
return file.getMagnetUri();
|
||||||
} else {
|
} else {
|
||||||
return file.getFileUrl();
|
return file.getFileUrl();
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}else if(streamingPlaylists != null && streamingPlaylists.size() > 0){
|
} else if (streamingPlaylists != null && streamingPlaylists.size() > 0) {
|
||||||
return streamingPlaylists.get(0).getPlaylistUrl();
|
return streamingPlaylists.get(0).getPlaylistUrl();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.VIDEOS_I
|
|||||||
|
|
||||||
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
|
public AllVideoRemoved allVideoRemoved;
|
||||||
private List<VideoData.Video> videos;
|
private List<VideoData.Video> videos;
|
||||||
private Context context;
|
private Context context;
|
||||||
private TimelineVM.TimelineType timelineType;
|
private TimelineVM.TimelineType timelineType;
|
||||||
@ -75,12 +76,6 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
this.timelineType = VIDEOS_IN_PLAYLIST;
|
this.timelineType = VIDEOS_IN_PLAYLIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AllVideoRemoved allVideoRemoved;
|
|
||||||
|
|
||||||
public interface AllVideoRemoved{
|
|
||||||
void onAllVideoRemoved();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PeertubeAdapter(List<VideoData.Video> videos) {
|
public PeertubeAdapter(List<VideoData.Video> videos) {
|
||||||
this.videos = videos;
|
this.videos = videos;
|
||||||
}
|
}
|
||||||
@ -150,15 +145,16 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
holder.more_actions.setOnClickListener(view -> {
|
holder.more_actions.setOnClickListener(view -> {
|
||||||
PopupMenu popup = new PopupMenu(context, holder.more_actions);
|
PopupMenu popup = new PopupMenu(context, holder.more_actions);
|
||||||
popup.getMenuInflater()
|
popup.getMenuInflater()
|
||||||
.inflate(R.menu.video_drawer_menu, popup.getMenu());
|
.inflate(R.menu.video_drawer_menu, popup.getMenu());
|
||||||
if (timelineType == MY_VIDEOS) {
|
if (timelineType == MY_VIDEOS) {
|
||||||
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
popup.getMenu().findItem(R.id.action_report).setVisible(false);
|
||||||
}else {
|
} else {
|
||||||
popup.getMenu().findItem(R.id.action_edit).setVisible(false);
|
popup.getMenu().findItem(R.id.action_edit).setVisible(false);
|
||||||
if( timelineType != VIDEOS_IN_PLAYLIST) {
|
if (timelineType != VIDEOS_IN_PLAYLIST) {
|
||||||
popup.getMenu().findItem(R.id.action_remove_playlist).setVisible(false);
|
popup.getMenu().findItem(R.id.action_remove_playlist).setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,7 +184,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
break;
|
break;
|
||||||
case R.id.action_report:
|
case R.id.action_report:
|
||||||
androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(context);
|
androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(context);
|
||||||
LayoutInflater inflater1 = ((Activity)context).getLayoutInflater();
|
LayoutInflater inflater1 = ((Activity) context).getLayoutInflater();
|
||||||
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(context), false);
|
View dialogView = inflater1.inflate(R.layout.popup_report, new LinearLayout(context), false);
|
||||||
dialogBuilder.setView(dialogView);
|
dialogBuilder.setView(dialogView);
|
||||||
EditText report_content = dialogView.findViewById(R.id.report_content);
|
EditText report_content = dialogView.findViewById(R.id.report_content);
|
||||||
@ -218,14 +214,16 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
holder.bottom_container.setOnClickListener(v -> {
|
holder.bottom_container.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("video_id", video.getUuid());
|
b.putString("video_id", video.getId());
|
||||||
|
b.putString("video_uuid", video.getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
holder.peertube_video_image.setOnClickListener(v -> {
|
holder.peertube_video_image.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("video_id", video.getUuid());
|
b.putString("video_id", video.getId());
|
||||||
|
b.putString("video_uuid", video.getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -242,13 +240,17 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
return videos.size();
|
return videos.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) {
|
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) {
|
||||||
if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
||||||
Toasty.success(context, context.getString(R.string.successful_video_report), Toasty.LENGTH_LONG).show();
|
Toasty.success(context, context.getString(R.string.successful_video_report), Toasty.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface AllVideoRemoved {
|
||||||
|
void onAllVideoRemoved();
|
||||||
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
LinearLayout main_container, bottom_container;
|
LinearLayout main_container, bottom_container;
|
||||||
ImageView peertube_profile, peertube_video_image;
|
ImageView peertube_profile, peertube_video_image;
|
||||||
|
@ -109,6 +109,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("peertube_instance", finalAccountAction1.getHost());
|
b.putString("peertube_instance", finalAccountAction1.getHost());
|
||||||
b.putString("video_id", notification.getComment().getVideo().getId());
|
b.putString("video_id", notification.getComment().getVideo().getId());
|
||||||
|
b.putString("video_uuid", notification.getComment().getVideo().getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -143,6 +144,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("peertube_instance", Helper.getLiveInstance(context));
|
b.putString("peertube_instance", Helper.getLiveInstance(context));
|
||||||
b.putString("video_id", notification.getVideo().getId());
|
b.putString("video_id", notification.getVideo().getId());
|
||||||
|
b.putString("video_uuid", notification.getVideo().getUuid());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
@ -585,7 +585,7 @@ public class Helper {
|
|||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public static File defaultFile(Context context, List<File> files) {
|
public static File defaultFile(Context context, List<File> files) {
|
||||||
if( files == null || files.size() == 0) {
|
if (files == null || files.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
Reference in New Issue
Block a user