Some fixes

This commit is contained in:
Thomas 2020-11-24 13:50:06 +01:00
parent 85b89507db
commit f7d44cb547
5 changed files with 95 additions and 29 deletions

View File

@ -304,6 +304,8 @@
<item>Moyenne</item>
<item>Faible</item>
</string-array>
<string name="nsfw_title_warning">Contenu explicite ou sensible</string>
<string name="nsfw_message_warning">Cette vidéo contient du contenu sensible. Êtes-vous sûr·e de vouloir la regarder ?</string>
<string name="set_autoplay_next_video_settings">Lecture automatique</string>
<string name="unfollow_confirm">Voulez-vous vous désabonner de ce compte ?</string>
<string name="no_playlist">Aucune liste de lecture !</string>

View File

@ -160,6 +160,9 @@
<string name="action_mute">Mute</string>
<string name="nsfw_title_warning">Mature or explicit content</string>
<string name="nsfw_message_warning">This video contains mature or explicit content. Are you sure you want to watch it?</string>
<string name="search">Search</string>
<string name="delete">Delete</string>

View File

@ -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:

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="@color/red_1"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z" />
</vector>

View File

@ -122,11 +122,32 @@
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/peertube_title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" />
android:orientation="horizontal">
<TextView
android:id="@+id/peertube_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/video_sensitive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:contentDescription="@string/sensitive_content"
android:gravity="center_horizontal"
android:src="@drawable/ic_sensitive_content"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -189,21 +210,8 @@
app:drawableTopCompat="@drawable/ic_baseline_thumb_down_alt_24"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/peertube_bookmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text=""
app:drawableTopCompat="@drawable/ic_baseline_bookmark_border_24" />
<TextView
<ImageView
android:id="@+id/peertube_playlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -214,11 +222,11 @@
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text=""
android:contentDescription="@string/playlists"
android:visibility="gone"
app:drawableTopCompat="@drawable/ic_baseline_list_24" />
android:src="@drawable/ic_baseline_list_24" />
<TextView
<ImageView
android:id="@+id/video_information"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -227,10 +235,10 @@
android:layout_marginLeft="10dp"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:drawablePadding="5dp"
android:gravity="center_horizontal"
android:text=""
app:drawableTopCompat="@drawable/ic_baseline_info_24" />
android:contentDescription="@string/information"
android:src="@drawable/ic_baseline_info_24" />
<LinearLayout
android:layout_width="0dp"