From f7d44cb5477e90a3ae9e5b30fe70896da1f7ea53 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 24 Nov 2020 13:50:06 +0100 Subject: [PATCH] Some fixes --- app/src/acad/res/values/strings.xml | 2 + app/src/full/res/values/strings.xml | 3 + .../fedilab/fedilabtube/PeertubeActivity.java | 55 +++++++++++++++++-- .../res/drawable/ic_sensitive_content.xml | 10 ++++ app/src/main/res/layout/activity_peertube.xml | 54 ++++++++++-------- 5 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 app/src/main/res/drawable/ic_sensitive_content.xml diff --git a/app/src/acad/res/values/strings.xml b/app/src/acad/res/values/strings.xml index a957d27..897dc22 100644 --- a/app/src/acad/res/values/strings.xml +++ b/app/src/acad/res/values/strings.xml @@ -304,6 +304,8 @@ Moyenne Faible + Contenu explicite ou sensible + Cette vidéo contient du contenu sensible. Êtes-vous sûr·e de vouloir la regarder ? Lecture automatique Voulez-vous vous désabonner de ce compte ? Aucune liste de lecture ! diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml index 2acb26b..1fa8b3d 100644 --- a/app/src/full/res/values/strings.xml +++ b/app/src/full/res/values/strings.xml @@ -160,6 +160,9 @@ Mute + + Mature or explicit content + This video contains mature or explicit content. Are you sure you want to watch it? Search Delete diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 6746689..2e9bbdd 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -219,7 +219,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd @Override public void onStreamStarted(Torrent torrent) { - startStream(torrent.getVideoFile().getAbsolutePath(), null, autoPlay, -1, null, null); + startStream(torrent.getVideoFile().getAbsolutePath(), null, autoPlay, -1, null, null, true); } @Override @@ -325,6 +325,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd playInMinimized = false; } + if (peertube != null && peertube.isNsfw()) { + binding.videoSensitive.setVisibility(View.VISIBLE); + } else { + binding.videoSensitive.setVisibility(View.INVISIBLE); + } if (mode == Helper.VIDEO_MODE_WEBVIEW) { binding.webviewVideo.setVisibility(View.VISIBLE); binding.mediaVideo.setVisibility(View.GONE); @@ -436,6 +441,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd return; } peertube = apiResponse.getPeertubes().get(0); + if (peertube.isNsfw()) { + binding.videoSensitive.setVisibility(View.VISIBLE); + } else { + binding.videoSensitive.setVisibility(View.INVISIBLE); + } if (peertube.getUserHistory() != null) { player.seekTo(peertube.getUserHistory().getCurrentTime() * 1000); } @@ -595,7 +605,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd openFullscreenDialog(); } binding.peertubePlaylist.setVisibility(View.VISIBLE); - binding.peertubeBookmark.setVisibility(View.GONE); TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class); if (!isRemote) { feedsViewModel.getVideo(sepiaSearch ? peertubeInstance : null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo); @@ -810,6 +819,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd binding.writeCommentContainer.setVisibility(View.GONE); } + if (peertube.isNsfw()) { + binding.videoSensitive.setVisibility(View.VISIBLE); + } else { + binding.videoSensitive.setVisibility(View.INVISIBLE); + } + binding.peertubePlaylist.setOnClickListener(v -> { PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider(PeertubeActivity.this).get(PlaylistsVM.class); viewModelOwnerPlaylist.manage(PlaylistsVM.action.GET_PLAYLISTS, null, null).observe(PeertubeActivity.this, this::manageVIewPlaylists); @@ -1001,7 +1016,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd startStream( apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this), apiResponse.getPeertubes().get(0).getStreamingPlaylists().size() > 0 ? apiResponse.getPeertubes().get(0).getStreamingPlaylists().get(0).getPlaylistUrl() : null, - autoPlay, position, null, null); + autoPlay, position, null, null, true); player.prepare(); player.setPlayWhenReady(autoPlay); if (autoPlay) { @@ -1088,7 +1103,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd }); } - private void startStream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang) { + + private void stream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang) { if (videoURL != null && !videoURL.endsWith("m3u8")) { if (videoURL.endsWith(".torrent")) { torrentStream.startStream(videoURL); @@ -1145,6 +1161,32 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd } } + private void startStream(String videoURL, String streamingPlaylistsURLS, boolean autoPlay, long position, Uri subtitles, String lang, boolean promptNSFW) { + + SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); + String nsfwAction = sharedpreferences.getString(getString(R.string.set_video_sensitive_choice), Helper.BLUR); + if (promptNSFW && peertube != null && peertube.isNsfw() && (nsfwAction.compareTo(Helper.BLUR) == 0 || nsfwAction.compareTo(Helper.DO_NOT_LIST) == 0)) { + AlertDialog alertDialog; + AlertDialog.Builder dialogBuilder; + dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this); + dialogBuilder.setTitle(R.string.nsfw_title_warning); + dialogBuilder.setMessage(R.string.nsfw_message_warning); + dialogBuilder.setNegativeButton(R.string.no, (dialog, id) -> { + dialog.dismiss(); + finish(); + }); + dialogBuilder.setPositiveButton(R.string.play, (dialog, id) -> { + stream(videoURL, streamingPlaylistsURLS, autoPlay, position, subtitles, lang); + dialog.dismiss(); + }); + alertDialog = dialogBuilder.create(); + alertDialog.show(); + } else { + stream(videoURL, streamingPlaylistsURLS, autoPlay, position, subtitles, lang); + } + + } + @Override public void onConfigurationChanged(@NotNull Configuration newConfig) { super.onConfigurationChanged(newConfig); @@ -1512,7 +1554,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd startStream( peertube.getFileUrl(res, PeertubeActivity.this), peertube.getStreamingPlaylists().size() > 0 ? peertube.getStreamingPlaylists().get(0).getPlaylistUrl() : null, - true, position, null, null); + true, position, null, null, false); } break; case SPEED: @@ -1555,7 +1597,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd true, newPosition, uri, - item.getStrId() + item.getStrId(), + false ); break; case AUTONEXT: diff --git a/app/src/main/res/drawable/ic_sensitive_content.xml b/app/src/main/res/drawable/ic_sensitive_content.xml new file mode 100644 index 0000000..6571440 --- /dev/null +++ b/app/src/main/res/drawable/ic_sensitive_content.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/activity_peertube.xml b/app/src/main/res/layout/activity_peertube.xml index 45c96a6..0d7af4a 100644 --- a/app/src/main/res/layout/activity_peertube.xml +++ b/app/src/main/res/layout/activity_peertube.xml @@ -122,11 +122,32 @@ android:orientation="vertical" android:padding="10dp"> - + android:orientation="horizontal"> + + + + + - - + android:src="@drawable/ic_baseline_list_24" /> - + android:contentDescription="@string/information" + android:src="@drawable/ic_baseline_info_24" /> +