mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-02-07 23:58:42 +01:00
Last fixes
This commit is contained in:
parent
48fe22c8db
commit
c774dcee96
@ -215,7 +215,7 @@ public class AccountActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
AlertDialog.Builder builderSingle = new AlertDialog.Builder(AccountActivity.this);
|
AlertDialog.Builder builderSingle = new AlertDialog.Builder(AccountActivity.this);
|
||||||
builderSingle.setTitle(getString(R.string.list_of_accounts));
|
builderSingle.setTitle(getString(R.string.list_of_accounts));
|
||||||
if( accounts != null) {
|
if (accounts != null) {
|
||||||
final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(AccountActivity.this, accounts);
|
final OwnAccountsAdapter accountsListAdapter = new OwnAccountsAdapter(AccountActivity.this, accounts);
|
||||||
final Account[] accountArray = new Account[accounts.size()];
|
final Account[] accountArray = new Account[accounts.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -354,7 +354,7 @@ public class AllPlaylistsActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
idChannel = channelId[position];
|
idChannel = channelId[position];
|
||||||
if( position > 0 ) {
|
if (position > 0) {
|
||||||
selectedChannel = myChannels.get(position - 1);
|
selectedChannel = myChannels.get(position - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,12 +98,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams);
|
||||||
if( token == null) {
|
if (token == null) {
|
||||||
runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, account));
|
runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, account));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UserMe userMe = new RetrofitPeertubeAPI(MainActivity.this, instance, token.getAccess_token()).verifyCredentials();
|
UserMe userMe = new RetrofitPeertubeAPI(MainActivity.this, instance, token.getAccess_token()).verifyCredentials();
|
||||||
if( userMe != null && userMe.getAccount() != null) {
|
if (userMe != null && userMe.getAccount() != null) {
|
||||||
new AccountDAO(MainActivity.this, db).updateAccount(userMe.getAccount());
|
new AccountDAO(MainActivity.this, db).updateAccount(userMe.getAccount());
|
||||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||||
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
editor.putString(Helper.PREF_KEY_ID, account.getId());
|
||||||
@ -113,7 +113,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Set<String> videoLanguageServerSet = new TreeSet<>(videoLanguageServer);
|
Set<String> videoLanguageServerSet = new TreeSet<>(videoLanguageServer);
|
||||||
videoLanguageServerSet.addAll(videoLanguageServer);
|
videoLanguageServerSet.addAll(videoLanguageServer);
|
||||||
Set<String> videoLanguageLocal = sharedpreferences.getStringSet(getString(R.string.set_video_language_choice), null);
|
Set<String> videoLanguageLocal = sharedpreferences.getStringSet(getString(R.string.set_video_language_choice), null);
|
||||||
if( videoLanguageServerSet.size() > 0 && videoLanguageLocal != null) {
|
if (videoLanguageServerSet.size() > 0 && videoLanguageLocal != null) {
|
||||||
videoLanguageServer.addAll(videoLanguageLocal);
|
videoLanguageServer.addAll(videoLanguageLocal);
|
||||||
}
|
}
|
||||||
editor.putStringSet(getString(R.string.set_video_language_choice), videoLanguageServerSet);
|
editor.putStringSet(getString(R.string.set_video_language_choice), videoLanguageServerSet);
|
||||||
|
@ -86,7 +86,9 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
@ -154,7 +156,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
private List<Caption> captions;
|
private List<Caption> captions;
|
||||||
private TextView no_action_text;
|
private TextView no_action_text;
|
||||||
private String max_id;
|
private String max_id;
|
||||||
private RecyclerView lv_comments;
|
private RecyclerView lv_comments;
|
||||||
private boolean flag_loading;
|
private boolean flag_loading;
|
||||||
|
|
||||||
private List<Comment> comments;
|
private List<Comment> comments;
|
||||||
@ -197,7 +199,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
if( Helper.isLoggedIn(PeertubeActivity.this)) {
|
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
||||||
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
||||||
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp);
|
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp);
|
||||||
}
|
}
|
||||||
@ -255,7 +257,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
getWindow().setAttributes(attrs);
|
getWindow().setAttributes(attrs);
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
||||||
peertube_information_container.setVisibility(View.GONE);
|
peertube_information_container.setVisibility(View.GONE);
|
||||||
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
} else {
|
} else {
|
||||||
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
WindowManager.LayoutParams attrs = getWindow().getAttributes();
|
||||||
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
||||||
@ -303,7 +305,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(videoId, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,11 +365,6 @@ 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);
|
||||||
List<String> videoIds = new ArrayList<>();
|
|
||||||
videoIds.add(videoId);
|
|
||||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
|
||||||
playlistsViewModel.videoExists(videoIds).observe(PeertubeActivity.this, this::manageVIewVideosExist);
|
|
||||||
}
|
|
||||||
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(videoId).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||||
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
||||||
@ -513,7 +510,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
peertube = apiResponse.getPeertubes().get(0);
|
peertube = apiResponse.getPeertubes().get(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_comment_read.setOnClickListener(v -> {
|
add_comment_read.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this)) {
|
||||||
add_comment_read.setVisibility(View.GONE);
|
add_comment_read.setVisibility(View.GONE);
|
||||||
@ -545,7 +541,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
|
|
||||||
peertube_playlist.setOnClickListener(v -> {
|
peertube_playlist.setOnClickListener(v -> {
|
||||||
if (playlists != null && peertube.getId() != null) {
|
if (playlists != null && videoId != 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) {
|
||||||
@ -586,7 +582,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
playlistForVideo.remove(playlist.getId());
|
playlistForVideo.remove(playlist.getId());
|
||||||
} else {
|
} else {
|
||||||
item1.setTitle("✔ " + playlist.getDisplayName());
|
item1.setTitle("✔ " + playlist.getDisplayName());
|
||||||
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, peertube.getId()).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
playlistsViewModel.manage(PlaylistsVM.action.ADD_VIDEOS, playlist, videoId).observe(PeertubeActivity.this, apiResponse3 -> manageVIewPlaylists(PlaylistsVM.action.ADD_VIDEOS, apiResponse3));
|
||||||
playlistForVideo.add(playlist.getId());
|
playlistForVideo.add(playlist.getId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -846,7 +842,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -931,7 +926,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(PeertubeActivity.this, android.R.layout.select_dialog_item);
|
||||||
for (File file : peertube.getFiles()) {
|
for (File file : peertube.getFiles()) {
|
||||||
if (file.getResolutions() != null) {
|
if (file.getResolutions() != null) {
|
||||||
if( file.getResolutions().getLabel().compareTo("0p") != 0) {
|
if (file.getResolutions().getLabel().compareTo("0p") != 0) {
|
||||||
arrayAdapter.add(file.getResolutions().getLabel());
|
arrayAdapter.add(file.getResolutions().getLabel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1026,10 +1021,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
fullScreenButton.setOnClickListener(v -> {
|
fullScreenButton.setOnClickListener(v -> {
|
||||||
if (!fullScreenMode) {
|
if (!fullScreenMode) {
|
||||||
openFullscreenDialog();
|
openFullscreenDialog();
|
||||||
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
}else {
|
} else {
|
||||||
closeFullscreenDialog();
|
closeFullscreenDialog();
|
||||||
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
handler.postDelayed(() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR), 2000);
|
handler.postDelayed(() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR), 2000);
|
||||||
|
|
||||||
@ -1074,19 +1069,23 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
|
||||||
|
|
||||||
if (actionType == GET_PLAYLISTS && apiResponse != null) {
|
if (actionType == GET_PLAYLISTS && apiResponse != null) {
|
||||||
playlists = apiResponse.getPlaylists();
|
playlists = apiResponse.getPlaylists();
|
||||||
|
playlistsViewModel.videoExists(videoId).observe(PeertubeActivity.this, this::manageVIewVideosExist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manageVIewVideosExist(APIResponse apiResponse) {
|
public void manageVIewVideosExist(APIResponse apiResponse) {
|
||||||
playlistForVideo = new ArrayList<>();
|
if (apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
|
||||||
if( apiResponse.getError() == null && apiResponse.getVideoExistPlaylist() != null) {
|
Map<String, List<PlaylistExist>> videoIds = apiResponse.getVideoExistPlaylist();
|
||||||
|
Iterator<Map.Entry<String, List<PlaylistExist>>> it = videoIds.entrySet().iterator();
|
||||||
List<PlaylistExist.VideoId> videoIds = apiResponse.getVideoExistPlaylist();
|
while (it.hasNext()) {
|
||||||
for(PlaylistExist.VideoId videoId: videoIds) {
|
Map.Entry<String, List<PlaylistExist>> pair = it.next();
|
||||||
playlistForVideo.add(videoId.getPlaylistId());
|
List<PlaylistExist> playlistExistVideo = pair.getValue();
|
||||||
|
for (PlaylistExist playlistExist : playlistExistVideo) {
|
||||||
|
playlistForVideo.add(playlistExist.getPlaylistId());
|
||||||
|
}
|
||||||
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import app.fedilab.fedilabtube.client.data.VideoData;
|
|||||||
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
|
import app.fedilab.fedilabtube.client.data.VideoPlaylistData.VideoPlaylist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Error;
|
import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
import app.fedilab.fedilabtube.client.entities.OverviewVideo;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistExist.VideoId;
|
import app.fedilab.fedilabtube.client.entities.PlaylistExist;
|
||||||
import app.fedilab.fedilabtube.client.entities.Rating;
|
import app.fedilab.fedilabtube.client.entities.Rating;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "RedundantSuppression"})
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
@ -41,7 +41,7 @@ public class APIResponse {
|
|||||||
private String actionReturn = null;
|
private String actionReturn = null;
|
||||||
private Rating rating;
|
private Rating rating;
|
||||||
private OverviewVideo overviewVideo = null;
|
private OverviewVideo overviewVideo = null;
|
||||||
private List<VideoId> videoExistPlaylist = null;
|
private Map<String, List<PlaylistExist>> videoExistPlaylist = null;
|
||||||
private List<VideoData.Video> peertubes = null;
|
private List<VideoData.Video> peertubes = null;
|
||||||
private List<CommentData.Comment> comments = null;
|
private List<CommentData.Comment> comments = null;
|
||||||
private List<Block> muted;
|
private List<Block> muted;
|
||||||
@ -240,11 +240,11 @@ public class APIResponse {
|
|||||||
this.videoPlaylist = videoPlaylist;
|
this.videoPlaylist = videoPlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VideoId> getVideoExistPlaylist() {
|
public Map<String, List<PlaylistExist>> getVideoExistPlaylist() {
|
||||||
return videoExistPlaylist;
|
return videoExistPlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoExistPlaylist(List<VideoId> videoExistPlaylist) {
|
public void setVideoExistPlaylist(Map<String, List<PlaylistExist>> videoExistPlaylist) {
|
||||||
this.videoExistPlaylist = videoExistPlaylist;
|
this.videoExistPlaylist = videoExistPlaylist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ public interface PeertubeService {
|
|||||||
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
|
Call<VideoPlaylistData> getVideosPlayList(@Header("Authorization") String credentials, @Path("id") String id);
|
||||||
|
|
||||||
@GET("users/me/video-playlists/videos-exist")
|
@GET("users/me/video-playlists/videos-exist")
|
||||||
Call<PlaylistExist> getVideoExistsInPlaylist(@Header("Authorization") String credentials, @Query("videoIds") List<String> videoIds);
|
Call<Map<String, List<PlaylistExist>>> getVideoExistsInPlaylist(@Header("Authorization") String credentials, @Query("videoIds") String videoIds);
|
||||||
|
|
||||||
@Multipart
|
@Multipart
|
||||||
@POST("video-playlists")
|
@POST("video-playlists")
|
||||||
@ -264,7 +264,7 @@ public interface PeertubeService {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST("video-playlists/{id}/videos")
|
@POST("video-playlists/{id}/videos")
|
||||||
Call<String> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Field("videoId") String videoId);
|
Call<VideoPlaylistData.PlaylistElement> addVideoInPlaylist(@Header("Authorization") String credentials, @Path("id") String id, @Field("videoId") String videoId);
|
||||||
|
|
||||||
|
|
||||||
@DELETE("video-playlists/{id}")
|
@DELETE("video-playlists/{id}")
|
||||||
|
@ -1060,14 +1060,14 @@ public class RetrofitPeertubeAPI {
|
|||||||
* @param videoIds List<String> ids of videos
|
* @param videoIds List<String> ids of videos
|
||||||
* @return APIResponse
|
* @return APIResponse
|
||||||
*/
|
*/
|
||||||
public APIResponse getVideosExist(List<String> videoIds) {
|
public APIResponse getVideosExist(String videoIds) {
|
||||||
PeertubeService peertubeService = init();
|
PeertubeService peertubeService = init();
|
||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Call<PlaylistExist> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
|
Call<Map<String, List<PlaylistExist>>> videoExistsInPlaylist = peertubeService.getVideoExistsInPlaylist(getToken(), videoIds);
|
||||||
Response<PlaylistExist> response = videoExistsInPlaylist.execute();
|
Response<Map<String, List<PlaylistExist>>> response = videoExistsInPlaylist.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setVideoExistPlaylist(response.body().getVideoId());
|
apiResponse.setVideoExistPlaylist(response.body());
|
||||||
} else {
|
} else {
|
||||||
setError(apiResponse, response.code(), response.errorBody());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
}
|
||||||
@ -1111,7 +1111,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
} else {
|
} else {
|
||||||
setError(apiResponse, response.code(), response.errorBody());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
|
} else if (type == PlaylistsVM.action.GET_LIST_VIDEOS) {
|
||||||
Call<VideoPlaylistData> videosPlayList = peertubeService.getVideosPlayList(getToken(), playlistId);
|
Call<VideoPlaylistData> videosPlayList = peertubeService.getVideosPlayList(getToken(), playlistId);
|
||||||
Response<VideoPlaylistData> response = videosPlayList.execute();
|
Response<VideoPlaylistData> response = videosPlayList.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
@ -1128,10 +1128,10 @@ public class RetrofitPeertubeAPI {
|
|||||||
setError(apiResponse, response.code(), response.errorBody());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
}
|
||||||
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
|
} else if (type == PlaylistsVM.action.ADD_VIDEOS) {
|
||||||
Call<String> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
|
Call<VideoPlaylistData.PlaylistElement> stringCall = peertubeService.addVideoInPlaylist(getToken(), playlistId, videoId);
|
||||||
Response<String> response = stringCall.execute();
|
Response<VideoPlaylistData.PlaylistElement> response = stringCall.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
apiResponse.setActionReturn(response.body());
|
apiResponse.setActionReturn(response.body().getVideoPlaylistElement().getId());
|
||||||
} else {
|
} else {
|
||||||
setError(apiResponse, response.code(), response.errorBody());
|
setError(apiResponse, response.code(), response.errorBody());
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,19 @@ public class VideoPlaylistData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PlaylistElement {
|
||||||
|
@SerializedName("videoPlaylistElement")
|
||||||
|
private VideoPlaylistCreationItem videoPlaylistElement;
|
||||||
|
|
||||||
|
public VideoPlaylistCreationItem getVideoPlaylistElement() {
|
||||||
|
return videoPlaylistElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoPlaylistElement(VideoPlaylistCreationItem videoPlaylistElement) {
|
||||||
|
this.videoPlaylistElement = videoPlaylistElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class VideoPlaylistCreationItem {
|
public static class VideoPlaylistCreationItem {
|
||||||
@SerializedName("id")
|
@SerializedName("id")
|
||||||
String id;
|
String id;
|
||||||
|
@ -16,61 +16,48 @@ package app.fedilab.fedilabtube.client.entities;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"unused", "RedundantSuppression"})
|
||||||
public class PlaylistExist {
|
public class PlaylistExist {
|
||||||
|
|
||||||
@SerializedName("videoId")
|
@SerializedName("playlistElementId")
|
||||||
private List<VideoId> videoId;
|
private String playlistElementId;
|
||||||
|
@SerializedName("playlistId")
|
||||||
|
private String playlistId;
|
||||||
|
@SerializedName("startTimestamp")
|
||||||
|
private long startTimestamp;
|
||||||
|
@SerializedName("stopTimestamp")
|
||||||
|
private long stopTimestamp;
|
||||||
|
|
||||||
public List<VideoId> getVideoId() {
|
public String getPlaylistElementId() {
|
||||||
return videoId;
|
return playlistElementId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoId(List<VideoId> videoId) {
|
public void setPlaylistElementId(String playlistElementId) {
|
||||||
this.videoId = videoId;
|
this.playlistElementId = playlistElementId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VideoId {
|
public String getPlaylistId() {
|
||||||
@SerializedName("playlistElementId")
|
return playlistId;
|
||||||
private String playlistElementId;
|
}
|
||||||
@SerializedName("playlistId")
|
|
||||||
private String playlistId;
|
|
||||||
@SerializedName("startTimestamp")
|
|
||||||
private long startTimestamp;
|
|
||||||
@SerializedName("stopTimestamp")
|
|
||||||
private long stopTimestamp;
|
|
||||||
|
|
||||||
public String getPlaylistElementId() {
|
public void setPlaylistId(String playlistId) {
|
||||||
return playlistElementId;
|
this.playlistId = playlistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlaylistElementId(String playlistElementId) {
|
public long getStartTimestamp() {
|
||||||
this.playlistElementId = playlistElementId;
|
return startTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlaylistId() {
|
public void setStartTimestamp(long startTimestamp) {
|
||||||
return playlistId;
|
this.startTimestamp = startTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlaylistId(String playlistId) {
|
public long getStopTimestamp() {
|
||||||
this.playlistId = playlistId;
|
return stopTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartTimestamp() {
|
public void setStopTimestamp(long stopTimestamp) {
|
||||||
return startTimestamp;
|
this.stopTimestamp = stopTimestamp;
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartTimestamp(long startTimestamp) {
|
|
||||||
this.startTimestamp = startTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStopTimestamp() {
|
|
||||||
return stopTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStopTimestamp(long stopTimestamp) {
|
|
||||||
this.stopTimestamp = stopTimestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ 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());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -140,7 +140,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
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());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
@ -108,7 +108,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
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().getUuid());
|
b.putString("video_id", notification.getComment().getVideo().getId());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -142,11 +142,11 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
Intent intent = new Intent(context, PeertubeActivity.class);
|
Intent intent = new Intent(context, PeertubeActivity.class);
|
||||||
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().getUuid());
|
b.putString("video_id", notification.getVideo().getId());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
}else if (notification.getVideoAbuse() != null && notification.getVideoAbuse().getVideo() != null) {
|
} else if (notification.getVideoAbuse() != null && notification.getVideoAbuse().getVideo() != null) {
|
||||||
message = context.getString(R.string.peertube_video_abuse, notification.getVideoAbuse().getVideo().getName());
|
message = context.getString(R.string.peertube_video_abuse, notification.getVideoAbuse().getVideo().getName());
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
|
holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY));
|
||||||
|
@ -44,6 +44,14 @@ import es.dmoral.toasty.Toasty;
|
|||||||
|
|
||||||
public class DisplayNotificationsFragment extends Fragment {
|
public class DisplayNotificationsFragment extends Fragment {
|
||||||
|
|
||||||
|
//Peertube notification type
|
||||||
|
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
|
||||||
|
public static int NEW_REPORT = 3;
|
||||||
|
public static int BLACKLIST_ON_MY_VIDEO = 4;
|
||||||
|
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
|
||||||
|
public static int MY_VIDEO_PUBLISHED = 6;
|
||||||
|
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
|
||||||
|
public static int MY_VIDEO_IMPORT_ERROR = 8;
|
||||||
private boolean flag_loading;
|
private boolean flag_loading;
|
||||||
private Context context;
|
private Context context;
|
||||||
private PeertubeNotificationsListAdapter peertubeNotificationsListAdapter;
|
private PeertubeNotificationsListAdapter peertubeNotificationsListAdapter;
|
||||||
@ -56,16 +64,6 @@ public class DisplayNotificationsFragment extends Fragment {
|
|||||||
private RecyclerView lv_notifications;
|
private RecyclerView lv_notifications;
|
||||||
private View rootView;
|
private View rootView;
|
||||||
|
|
||||||
//Peertube notification type
|
|
||||||
public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
|
|
||||||
public static int NEW_REPORT = 3;
|
|
||||||
public static int BLACKLIST_ON_MY_VIDEO = 4;
|
|
||||||
public static int UNBLACKLIST_ON_MY_VIDEO = 5;
|
|
||||||
public static int MY_VIDEO_PUBLISHED = 6;
|
|
||||||
public static int MY_VIDEO_IMPORT_SUCCESS = 7;
|
|
||||||
public static int MY_VIDEO_IMPORT_ERROR = 8;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||||||
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
|
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
|
||||||
assert set_video_cache_choice != null;
|
assert set_video_cache_choice != null;
|
||||||
final int progress = set_video_cache_choice.getValue();
|
final int progress = set_video_cache_choice.getValue();
|
||||||
set_video_cache_choice.setSummary(getActivity().getString(R.string.video_cache_value, progress*10));
|
set_video_cache_choice.setSummary(getActivity().getString(R.string.video_cache_value, progress * 10));
|
||||||
editor.putInt(Helper.SET_VIDEO_CACHE, progress*10);
|
editor.putInt(Helper.SET_VIDEO_CACHE, progress * 10);
|
||||||
}
|
}
|
||||||
if (key.compareTo(getString(R.string.set_video_minimize_choice)) == 0) {
|
if (key.compareTo(getString(R.string.set_video_minimize_choice)) == 0) {
|
||||||
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
||||||
@ -171,7 +171,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared
|
|||||||
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
|
SeekBarPreference set_video_cache_choice = findPreference(getString(R.string.set_video_cache_choice));
|
||||||
int video_cache = sharedpref.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
int video_cache = sharedpref.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
||||||
assert set_video_cache_choice != null;
|
assert set_video_cache_choice != null;
|
||||||
set_video_cache_choice.setValue(video_cache/10);
|
set_video_cache_choice.setValue(video_cache / 10);
|
||||||
|
|
||||||
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
boolean minimized = sharedpref.getBoolean(getString(R.string.set_video_minimize_choice), true);
|
||||||
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
SwitchPreference set_video_minimize_choice = findPreference(getString(R.string.set_video_minimize_choice));
|
||||||
|
@ -386,7 +386,7 @@ public class Helper {
|
|||||||
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
|
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault());
|
||||||
df.applyPattern(df.toPattern().replaceAll("[^\\p{Alpha}]*y+[^\\p{Alpha}]*", ""));
|
df.applyPattern(df.toPattern().replaceAll("[^\\p{Alpha}]*y+[^\\p{Alpha}]*", ""));
|
||||||
return df.format(dateToot);
|
return df.format(dateToot);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
} else if (days > 0)
|
} else if (days > 0)
|
||||||
@ -699,18 +699,18 @@ public class Helper {
|
|||||||
* @param files List<File>
|
* @param files List<File>
|
||||||
* @return File
|
* @return File
|
||||||
*/
|
*/
|
||||||
public static File defaultFile(Context context, List<File> files){
|
public static File defaultFile(Context context, List<File> files) {
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
int video_quality = sharedpreferences.getInt(Helper.SET_QUALITY_MODE, Helper.QUALITY_HIGH);
|
||||||
if( video_quality == QUALITY_HIGH) {
|
if (video_quality == QUALITY_HIGH) {
|
||||||
return files.get(0);
|
return files.get(0);
|
||||||
}else if( video_quality == QUALITY_LOW) {
|
} else if (video_quality == QUALITY_LOW) {
|
||||||
return files.get(files.size() -1);
|
return files.get(files.size() - 1);
|
||||||
}else{
|
} else {
|
||||||
if( files.size() < 3) {
|
if (files.size() < 3) {
|
||||||
return files.get(files.size() -1);
|
return files.get(files.size() - 1);
|
||||||
}else{
|
} else {
|
||||||
int middle = files.size()/2 -1;
|
int middle = files.size() / 2 - 1;
|
||||||
return files.get(middle);
|
return files.get(middle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ public class AccountDAO {
|
|||||||
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
account.setClient_secret(c.getString(c.getColumnIndex(Sqlite.COL_CLIENT_SECRET)));
|
||||||
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
account.setRefresh_token(c.getString(c.getColumnIndex(Sqlite.COL_REFRESH_TOKEN)));
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
c.close();
|
c.close();
|
||||||
|
|
||||||
//User is returned
|
//User is returned
|
||||||
return account;
|
return account;
|
||||||
@ -348,5 +348,4 @@ public class AccountDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,12 @@ import androidx.lifecycle.AndroidViewModel;
|
|||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.APIResponse;
|
import app.fedilab.fedilabtube.client.APIResponse;
|
||||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
import app.fedilab.fedilabtube.client.data.AccountData.Account;
|
||||||
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
|
||||||
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
|
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
import app.fedilab.fedilabtube.sqlite.AccountDAO;
|
||||||
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
@ -53,13 +50,13 @@ public class PlaylistsVM extends AndroidViewModel {
|
|||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> videoExists(List<String> videoIds) {
|
public LiveData<APIResponse> videoExists(String videoIds) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
checkVideosExist(videoIds);
|
checkVideosExist(videoIds);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkVideosExist(List<String> videoIds) {
|
private void checkVideosExist(String videoIds) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
APIResponse apiResponse = new RetrofitPeertubeAPI(_mContext).getVideosExist(videoIds);
|
APIResponse apiResponse = new RetrofitPeertubeAPI(_mContext).getVideosExist(videoIds);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user