some improvements
This commit is contained in:
parent
9c676d8002
commit
9d599e8b57
|
@ -201,6 +201,9 @@
|
|||
<string name="all_of_these_tags">Tous ces labels</string>
|
||||
<string name="one_of_these_tags">Un de ces labels</string>
|
||||
<string name="apply_filter">Appliquer le filtre</string>
|
||||
|
||||
<string name="playback_speed">Vitesse du lecteur</string>
|
||||
<string name="normal">Normal</string>
|
||||
<string-array name="sort_by_array">
|
||||
<item>Meilleurs résultats</item>
|
||||
<item>Les plus récentes</item>
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
<color name="tag_color_text">#FAFAFA</color>
|
||||
<color name="positive_thumbs">#2b90d9</color>
|
||||
<color name="negative_thumbs">#F44336</color>
|
||||
|
||||
<color name="backgroundDark">#DD000000</color>
|
||||
<color name="red_1">#F44336</color>
|
||||
</resources>
|
|
@ -282,8 +282,8 @@
|
|||
<string name="send_comment">Send comment</string>
|
||||
<string name="all">All</string>
|
||||
<!-- end languages -->
|
||||
|
||||
|
||||
<string name="playback_speed">Playback speed</string>
|
||||
<string name="normal">Normal</string>
|
||||
<string name="delete_history">Delete videos history</string>
|
||||
<string name="delete_history_confirm">Are you sure you want to delete all your videos history?</string>
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ import android.view.WindowManager;
|
|||
import android.view.animation.Animation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
|
@ -76,6 +75,7 @@ import com.google.android.exoplayer2.C;
|
|||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.MediaItem;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector;
|
||||
|
@ -115,12 +115,13 @@ import app.fedilab.fedilabtube.client.data.CommentData.Comment;
|
|||
import app.fedilab.fedilabtube.client.data.PlaylistData;
|
||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||
import app.fedilab.fedilabtube.client.entities.File;
|
||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
|
||||
import app.fedilab.fedilabtube.client.entities.MenuItemView;
|
||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||
import app.fedilab.fedilabtube.client.entities.Report;
|
||||
import app.fedilab.fedilabtube.databinding.ActivityPeertubeBinding;
|
||||
import app.fedilab.fedilabtube.drawer.CommentListAdapter;
|
||||
import app.fedilab.fedilabtube.drawer.MenuAdapter;
|
||||
import app.fedilab.fedilabtube.drawer.MenuItemAdapter;
|
||||
import app.fedilab.fedilabtube.helper.CacheDataSourceFactory;
|
||||
import app.fedilab.fedilabtube.helper.Helper;
|
||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||
|
@ -148,7 +149,7 @@ import static app.fedilab.fedilabtube.helper.Helper.loadGiF;
|
|||
import static com.google.android.exoplayer2.Player.MEDIA_ITEM_TRANSITION_REASON_AUTO;
|
||||
|
||||
|
||||
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, TorrentListener, MenuAdapter.ItemClicked {
|
||||
public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved, Player.EventListener, VideoListener, TorrentListener, MenuAdapter.ItemClicked, MenuItemAdapter.ItemAction {
|
||||
|
||||
public static String video_id;
|
||||
public static List<String> playedVideos = new ArrayList<>();
|
||||
|
@ -178,7 +179,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
private String show_more_content;
|
||||
private videoOrientation videoOrientationType;
|
||||
private int initialOrientation;
|
||||
|
||||
private String currentResolution;
|
||||
|
||||
public static void hideKeyboard(Activity activity) {
|
||||
if (activity != null && activity.getWindow() != null) {
|
||||
|
@ -342,7 +343,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
if (mode != Helper.VIDEO_MODE_WEBVIEW) {
|
||||
binding.doubleTapPlayerView.setControllerShowTimeoutMs(1000);
|
||||
binding.doubleTapPlayerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
|
||||
// initFullscreenDialog();
|
||||
initControllerButtons();
|
||||
|
||||
binding.doubleTapPlayerView
|
||||
|
@ -406,15 +406,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
}
|
||||
binding.postCommentButton.setOnClickListener(v -> openPostComment(null, 0));
|
||||
|
||||
List<MenuItemVideo> menuItemVideos = new ArrayList<>();
|
||||
MenuItemVideo resolutionItem = new MenuItemVideo();
|
||||
resolutionItem.setIcon(R.drawable.ic_baseline_settings_24);
|
||||
resolutionItem.setTitle(getString(R.string.pickup_resolution));
|
||||
resolutionItem.setAction(MenuItemVideo.actionType.RESOLUTION);
|
||||
|
||||
MenuAdapter menuAdapter = new MenuAdapter(menuItemVideos);
|
||||
binding.mainOptionsVideo.setAdapter(menuAdapter);
|
||||
|
||||
}
|
||||
|
||||
private void manageVIewVideos(APIResponse apiResponse) {
|
||||
|
@ -545,6 +536,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
player.setPlayWhenReady(autoPlay);
|
||||
captions = null;
|
||||
}
|
||||
currentResolution = null;
|
||||
show_more_content = null;
|
||||
binding.peertubeDescriptionMore.setVisibility(View.GONE);
|
||||
if (autoFullscreen && autoPlay) {
|
||||
|
@ -831,9 +823,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
popup.getMenuInflater()
|
||||
.inflate(R.menu.main_video, popup.getMenu());
|
||||
|
||||
if (captions == null) {
|
||||
popup.getMenu().findItem(R.id.action_captions).setEnabled(false);
|
||||
}
|
||||
if (!isMyVideo) {
|
||||
popup.getMenu().findItem(R.id.action_edit).setVisible(false);
|
||||
}
|
||||
|
@ -887,63 +876,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
b.putString("video_id", peertube.getUuid());
|
||||
intent.putExtras(b);
|
||||
startActivity(intent);
|
||||
} else if (itemId == R.id.action_captions) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PeertubeActivity.this);
|
||||
if (captions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] itemsKeyLanguage = new String[captions.size() + 1];
|
||||
String[] itemsLabelLanguage = new String[captions.size() + 1];
|
||||
itemsLabelLanguage[0] = getString(R.string.none);
|
||||
itemsKeyLanguage[0] = "null";
|
||||
int i = 1;
|
||||
if (captions.size() > 0) {
|
||||
for (Caption caption : captions) {
|
||||
ItemStr lang = caption.getLanguage();
|
||||
itemsLabelLanguage[i] = lang.getLabel();
|
||||
itemsKeyLanguage[i] = lang.getId();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
dialogBuilder.setSingleChoiceItems(itemsLabelLanguage, i, (dialog, which) -> {
|
||||
|
||||
Uri uri = null;
|
||||
if (which > 0) {
|
||||
if (!sepiaSearch) {
|
||||
uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath());
|
||||
} else {
|
||||
uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath());
|
||||
}
|
||||
}
|
||||
long newPosition = player.getCurrentPosition();
|
||||
|
||||
if (player != null)
|
||||
player.release();
|
||||
|
||||
TrackSelector trackSelector = new DefaultTrackSelector(PeertubeActivity.this, new AdaptiveTrackSelection.Factory());
|
||||
player = new SimpleExoPlayer.Builder(PeertubeActivity.this).setTrackSelector(trackSelector).build();
|
||||
binding.mediaVideo.player(player);
|
||||
binding.doubleTapPlayerView.setPlayer(player);
|
||||
startStream(
|
||||
apiResponse.getPeertubes().get(0).getFileUrl(null, PeertubeActivity.this),
|
||||
null,
|
||||
true,
|
||||
newPosition,
|
||||
uri,
|
||||
itemsKeyLanguage[which]
|
||||
);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
dialogBuilder.setOnDismissListener(dialogInterface -> {
|
||||
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
|
||||
|
||||
AlertDialog alertDialog = dialogBuilder.create();
|
||||
alertDialog.setTitle(getString(R.string.pickup_captions));
|
||||
alertDialog.show();
|
||||
} else if (itemId == R.id.action_report) {
|
||||
AlertDialog alertDialog;
|
||||
AlertDialog.Builder dialogBuilder;
|
||||
|
@ -1143,7 +1075,12 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (binding.mainOptionsVideo.getVisibility() == View.VISIBLE) {
|
||||
|
||||
if (binding.videoParamsSubmenu.getVisibility() == View.VISIBLE) {
|
||||
closeSubMenuMenuOptions();
|
||||
return;
|
||||
}
|
||||
if (binding.videoParams.getVisibility() == View.VISIBLE) {
|
||||
closeMainMenuOptions();
|
||||
return;
|
||||
}
|
||||
|
@ -1175,42 +1112,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
}
|
||||
}
|
||||
|
||||
public void displayResolution() {
|
||||
AlertDialog.Builder builderSingle = new AlertDialog.Builder(PeertubeActivity.this);
|
||||
builderSingle.setTitle(R.string.pickup_resolution);
|
||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
||||
for (File file : peertube.getFiles()) {
|
||||
if (file.getResolutions() != null) {
|
||||
if (file.getResolutions().getLabel().compareTo("0p") != 0) {
|
||||
arrayAdapter.add(file.getResolutions().getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
|
||||
String res = Objects.requireNonNull(arrayAdapter.getItem(which)).substring(0, Objects.requireNonNull(arrayAdapter.getItem(which)).length() - 1);
|
||||
|
||||
binding.loader.setVisibility(View.VISIBLE);
|
||||
long position = player.getCurrentPosition();
|
||||
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||
TextView resolution = controlView.findViewById(R.id.resolution);
|
||||
resolution.setText(String.format("%sp", res));
|
||||
if (mode == Helper.VIDEO_MODE_NORMAL) {
|
||||
if (player != null)
|
||||
player.release();
|
||||
player = new SimpleExoPlayer.Builder(PeertubeActivity.this).build();
|
||||
binding.mediaVideo.player(player);
|
||||
binding.doubleTapPlayerView.setPlayer(player);
|
||||
binding.loader.setVisibility(View.GONE);
|
||||
startStream(
|
||||
peertube.getFileUrl(res, PeertubeActivity.this),
|
||||
peertube.getStreamingPlaylists().size() > 0 ? peertube.getStreamingPlaylists().get(0).getPlaylistUrl() : null,
|
||||
true, position, null, null);
|
||||
}
|
||||
|
||||
});
|
||||
builderSingle.show();
|
||||
}
|
||||
|
||||
private void toogleFullscreen(boolean fullscreen) {
|
||||
|
||||
|
@ -1282,12 +1183,39 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int height = displayMetrics.heightPixels;
|
||||
|
||||
List<MenuItemVideo> menuItemVideos = new ArrayList<>();
|
||||
if (peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
||||
MenuItemVideo resolutionItem = new MenuItemVideo();
|
||||
resolutionItem.setIcon(R.drawable.ic_baseline_high_quality_24);
|
||||
resolutionItem.setTitle(getString(R.string.pickup_resolution));
|
||||
resolutionItem.setAction(MenuItemVideo.actionType.RESOLUTION);
|
||||
menuItemVideos.add(resolutionItem);
|
||||
|
||||
}
|
||||
MenuItemVideo speedItem = new MenuItemVideo();
|
||||
speedItem.setIcon(R.drawable.ic_baseline_speed_24);
|
||||
speedItem.setTitle(getString(R.string.playback_speed));
|
||||
speedItem.setAction(MenuItemVideo.actionType.SPEED);
|
||||
menuItemVideos.add(speedItem);
|
||||
|
||||
if (captions != null) {
|
||||
MenuItemVideo captionItem = new MenuItemVideo();
|
||||
captionItem.setIcon(R.drawable.ic_baseline_subtitles_24);
|
||||
captionItem.setTitle(getString(R.string.captions));
|
||||
captionItem.setAction(MenuItemVideo.actionType.CAPTION);
|
||||
menuItemVideos.add(captionItem);
|
||||
}
|
||||
|
||||
MenuAdapter menuAdapter = new MenuAdapter(menuItemVideos);
|
||||
binding.mainOptionsVideo.setAdapter(menuAdapter);
|
||||
menuAdapter.itemClicked = this;
|
||||
binding.mainOptionsVideo.setLayoutManager(new LinearLayoutManager(PeertubeActivity.this));
|
||||
|
||||
TranslateAnimation animate = new TranslateAnimation(
|
||||
0,
|
||||
0,
|
||||
height,
|
||||
height - binding.videoParams.getHeight());
|
||||
0);
|
||||
animate.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
|
@ -1312,7 +1240,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
TranslateAnimation animate = new TranslateAnimation(
|
||||
0,
|
||||
0,
|
||||
height - binding.videoParams.getHeight(),
|
||||
0,
|
||||
height);
|
||||
animate.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
|
@ -1333,6 +1261,61 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
}
|
||||
|
||||
|
||||
public void openSubMenuMenuOptions() {
|
||||
binding.videoParamsSubmenu.setVisibility(View.VISIBLE);
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int height = displayMetrics.heightPixels;
|
||||
TranslateAnimation animate = new TranslateAnimation(
|
||||
0,
|
||||
0,
|
||||
height,
|
||||
0);
|
||||
animate.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
animate.setDuration(500);
|
||||
binding.videoParamsSubmenu.startAnimation(animate);
|
||||
}
|
||||
|
||||
public void closeSubMenuMenuOptions() {
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int height = displayMetrics.heightPixels;
|
||||
TranslateAnimation animate = new TranslateAnimation(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
height);
|
||||
animate.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
binding.videoParamsSubmenu.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
animate.setDuration(500);
|
||||
binding.videoParamsSubmenu.startAnimation(animate);
|
||||
}
|
||||
|
||||
|
||||
private void sendComment(Comment comment, int position) {
|
||||
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||
if (comment == null) {
|
||||
|
@ -1533,9 +1516,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
private void initResolution() {
|
||||
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||
TextView resolution = controlView.findViewById(R.id.resolution);
|
||||
currentResolution = Helper.defaultFile(PeertubeActivity.this, peertube.getFiles()).getResolutions().getLabel();
|
||||
if (peertube.getFiles() != null && peertube.getFiles().size() > 0) {
|
||||
resolution.setText(String.format("%s", Helper.defaultFile(PeertubeActivity.this, peertube.getFiles()).getResolutions().getLabel()));
|
||||
resolution.setOnClickListener(v -> displayResolution());
|
||||
resolution.setText(String.format("%s", currentResolution));
|
||||
} else {
|
||||
resolution.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -1702,6 +1685,119 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||
@Override
|
||||
public void onItemClicked(MenuItemVideo.actionType action) {
|
||||
|
||||
List<MenuItemView> items = new ArrayList<>();
|
||||
switch (action) {
|
||||
case RESOLUTION:
|
||||
binding.subMenuTitle.setText(R.string.pickup_resolution);
|
||||
int position = 0;
|
||||
for (File file : peertube.getFiles()) {
|
||||
if (file.getResolutions() != null) {
|
||||
if (file.getResolutions().getLabel().compareTo("0p") != 0) {
|
||||
MenuItemView item = new MenuItemView();
|
||||
item.setId(position);
|
||||
item.setLabel(file.getResolutions().getLabel());
|
||||
if (file.getResolutions().getLabel().compareTo(currentResolution) == 0) {
|
||||
item.setSelected(true);
|
||||
}
|
||||
items.add(item);
|
||||
position++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SPEED:
|
||||
binding.subMenuTitle.setText(R.string.playback_speed);
|
||||
items = new ArrayList<>();
|
||||
items.add(new MenuItemView(25, "0.25x", player.getPlaybackParameters().speed == 0.25));
|
||||
items.add(new MenuItemView(50, "0.5x", player.getPlaybackParameters().speed == 0.5));
|
||||
items.add(new MenuItemView(75, "0.75x", player.getPlaybackParameters().speed == 0.75));
|
||||
items.add(new MenuItemView(100, getString(R.string.normal), player.getPlaybackParameters().speed == 1));
|
||||
items.add(new MenuItemView(125, "1.25x", player.getPlaybackParameters().speed == 1.25));
|
||||
items.add(new MenuItemView(150, "1.5x", player.getPlaybackParameters().speed == 1.5));
|
||||
items.add(new MenuItemView(175, "1.75x", player.getPlaybackParameters().speed == 1.75));
|
||||
items.add(new MenuItemView(200, "2x", player.getPlaybackParameters().speed == 2.0));
|
||||
break;
|
||||
case CAPTION:
|
||||
binding.subMenuTitle.setText(R.string.pickup_captions);
|
||||
items = new ArrayList<>();
|
||||
items.add(new MenuItemView(-1, "null", getString(R.string.none)));
|
||||
int i = 0;
|
||||
for (Caption caption : captions) {
|
||||
items.add(new MenuItemView(i, caption.getLanguage().getId(), caption.getLanguage().getLabel()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (items != null) {
|
||||
MenuItemAdapter menuItemAdapter = new MenuItemAdapter(action, items);
|
||||
menuItemAdapter.itemAction = this;
|
||||
binding.subMenuRecycler.setAdapter(menuItemAdapter);
|
||||
binding.subMenuRecycler.setLayoutManager(new LinearLayoutManager(PeertubeActivity.this));
|
||||
openSubMenuMenuOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void which(MenuItemVideo.actionType action, MenuItemView item) {
|
||||
closeMainMenuOptions();
|
||||
switch (action) {
|
||||
case RESOLUTION:
|
||||
String res = item.getLabel();
|
||||
binding.loader.setVisibility(View.VISIBLE);
|
||||
long position = player.getCurrentPosition();
|
||||
PlayerControlView controlView = binding.doubleTapPlayerView.findViewById(R.id.exo_controller);
|
||||
TextView resolution = controlView.findViewById(R.id.resolution);
|
||||
currentResolution = res;
|
||||
resolution.setText(String.format("%s", res));
|
||||
if (mode == Helper.VIDEO_MODE_NORMAL) {
|
||||
if (player != null)
|
||||
player.release();
|
||||
player = new SimpleExoPlayer.Builder(PeertubeActivity.this).build();
|
||||
binding.mediaVideo.player(player);
|
||||
binding.doubleTapPlayerView.setPlayer(player);
|
||||
binding.loader.setVisibility(View.GONE);
|
||||
startStream(
|
||||
peertube.getFileUrl(res, PeertubeActivity.this),
|
||||
peertube.getStreamingPlaylists().size() > 0 ? peertube.getStreamingPlaylists().get(0).getPlaylistUrl() : null,
|
||||
true, position, null, null);
|
||||
}
|
||||
break;
|
||||
case SPEED:
|
||||
int speed = item.getId();
|
||||
float ratio = (float) speed / 100;
|
||||
PlaybackParameters param = new PlaybackParameters(ratio);
|
||||
if (player != null) {
|
||||
player.setPlaybackParameters(param);
|
||||
}
|
||||
break;
|
||||
case CAPTION:
|
||||
Uri uri = null;
|
||||
if (item.getId() != -1) {
|
||||
if (!sepiaSearch) {
|
||||
uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(item.getId()).getCaptionPath());
|
||||
} else {
|
||||
uri = Uri.parse("https://" + peertubeInstance + captions.get(item.getId()).getCaptionPath());
|
||||
}
|
||||
}
|
||||
long newPosition = player.getCurrentPosition();
|
||||
|
||||
if (player != null)
|
||||
player.release();
|
||||
|
||||
TrackSelector trackSelector = new DefaultTrackSelector(PeertubeActivity.this, new AdaptiveTrackSelection.Factory());
|
||||
player = new SimpleExoPlayer.Builder(PeertubeActivity.this).setTrackSelector(trackSelector).build();
|
||||
binding.mediaVideo.player(player);
|
||||
binding.doubleTapPlayerView.setPlayer(player);
|
||||
startStream(
|
||||
peertube.getFileUrl(null, PeertubeActivity.this),
|
||||
null,
|
||||
true,
|
||||
newPosition,
|
||||
uri,
|
||||
item.getStrId()
|
||||
);
|
||||
break;
|
||||
}
|
||||
closeSubMenuMenuOptions();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ public class MenuItemVideo {
|
|||
}
|
||||
|
||||
public enum actionType {
|
||||
RESOLUTION
|
||||
RESOLUTION,
|
||||
SPEED,
|
||||
CAPTION
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
package app.fedilab.fedilabtube.client.entities;
|
||||
/* Copyright 2020 Thomas Schneider
|
||||
*
|
||||
* This file is a part of TubeLab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||
public class MenuItemView {
|
||||
|
||||
private int id;
|
||||
private String strId;
|
||||
private String label;
|
||||
private boolean selected;
|
||||
|
||||
public MenuItemView() {
|
||||
}
|
||||
|
||||
public MenuItemView(int id, String label) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
selected = false;
|
||||
}
|
||||
|
||||
public MenuItemView(int id, String label, boolean selected) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public MenuItemView(String strId, String label, boolean selected) {
|
||||
this.strId = strId;
|
||||
this.label = label;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public MenuItemView(String strId, String label) {
|
||||
this.strId = strId;
|
||||
this.label = label;
|
||||
this.selected = false;
|
||||
}
|
||||
|
||||
public MenuItemView(int id, String strId, String label) {
|
||||
this.id = id;
|
||||
this.strId = strId;
|
||||
this.label = label;
|
||||
this.selected = false;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public String getStrId() {
|
||||
return strId;
|
||||
}
|
||||
|
||||
public void setStrId(String strId) {
|
||||
this.strId = strId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package app.fedilab.fedilabtube.drawer;
|
||||
/* Copyright 2020 Thomas Schneider
|
||||
*
|
||||
* This file is a part of TubeLab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.fedilabtube.client.MenuItemVideo;
|
||||
import app.fedilab.fedilabtube.client.entities.MenuItemView;
|
||||
import app.fedilab.fedilabtube.databinding.DrawerMenuItemBinding;
|
||||
|
||||
|
||||
public class MenuItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private final List<MenuItemView> items;
|
||||
public ItemAction itemAction;
|
||||
MenuItemVideo.actionType actionType;
|
||||
|
||||
public MenuItemAdapter(MenuItemVideo.actionType actionType, List<MenuItemView> items) {
|
||||
this.items = items;
|
||||
this.actionType = actionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
DrawerMenuItemBinding itemBinding = DrawerMenuItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||
return new ViewHolder(itemBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||
|
||||
|
||||
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||
|
||||
final MenuItemView item = items.get(i);
|
||||
|
||||
holder.binding.title.setText(item.getLabel());
|
||||
holder.binding.radio.setChecked(item.isSelected());
|
||||
holder.binding.itemMenuContainer.setOnClickListener(v -> itemAction.which(actionType, item));
|
||||
|
||||
}
|
||||
|
||||
public interface ItemAction {
|
||||
void which(MenuItemVideo.actionType actionType, MenuItemView item);
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
DrawerMenuItemBinding binding;
|
||||
|
||||
ViewHolder(DrawerMenuItemBinding itemView) {
|
||||
super(itemView.getRoot());
|
||||
binding = itemView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20.38,8.57l-1.23,1.85a8,8 0,0 1,-0.22 7.58L5.07,18A8,8 0,0 1,15.58 6.85l1.85,-1.23A10,10 0,0 0,3.35 19a2,2 0,0 0,1.72 1h13.85a2,2 0,0 0,1.74 -1,10 10,0 0,0 -0.27,-10.44zM10.59,15.41a2,2 0,0 0,2.83 0l5.66,-8.49 -8.49,5.66a2,2 0,0 0,0 2.83z" />
|
||||
</vector>
|
|
@ -25,6 +25,10 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -490,35 +494,56 @@
|
|||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<RelativeLayout
|
||||
android:id="@+id/video_params"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:colorBackground"
|
||||
android:background="?attr/backgroundView"
|
||||
android:minHeight="100dp"
|
||||
android:translationZ="2dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/main_options_video"
|
||||
android:layout_margin="30dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/video_params_suboptions"
|
||||
android:id="@+id/video_params_submenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:colorBackground"
|
||||
android:background="?attr/backgroundView"
|
||||
android:minHeight="300dp"
|
||||
android:translationZ="3dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/sub_options_video"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subMenuTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/subMenuRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="30dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/item_menu_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_icon"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/item_menu_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="start|center_vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/radio"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -11,11 +11,6 @@
|
|||
android:icon="@drawable/ic_baseline_cloud_download_24"
|
||||
android:title="@string/download"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_captions"
|
||||
android:icon="@drawable/ic_baseline_subtitles_24"
|
||||
android:title="@string/captions"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_edit"
|
||||
android:icon="@drawable/ic_baseline_edit_24"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<resources>
|
||||
|
||||
|
||||
<attr name="backgroundView" format="color" />
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
|
@ -8,7 +8,7 @@
|
|||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:textColor">?attr/colorOnBackground</item>
|
||||
|
||||
<item name="backgroundView">@color/backgroundDark</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
|
@ -16,7 +16,7 @@
|
|||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="backgroundView">@color/backgroundDark</item>
|
||||
<item name="android:textColor">?attr/colorOnBackground</item>
|
||||
</style>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<resources>
|
||||
|
||||
<attr name="backgroundView" format="color" />
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
|
@ -8,6 +8,7 @@
|
|||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:textColor">?attr/colorOnBackground</item>
|
||||
<item name="backgroundView">@color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
|
@ -15,8 +16,8 @@
|
|||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
|
||||
<item name="android:textColor">?attr/colorOnBackground</item>
|
||||
<item name="backgroundView">@color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="theme" parent="@style/ThemeOverlay.AppCompat.Dark"/>
|
||||
|
|
Loading…
Reference in New Issue