Fix some issues + check if video is federated for Sepia search

This commit is contained in:
Thomas 2020-10-13 11:04:35 +02:00
parent 62af5c54aa
commit ab45c1f80c
8 changed files with 56 additions and 10 deletions

View File

@ -7,6 +7,7 @@
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
<string name="federation_issue">La vidéo ne peut pas être fédérée !</string>
<string name="title_home">Locale</string>
<string name="title_local">Locale</string>
<string name="title_discover">Découvrir</string>

View File

@ -6,7 +6,7 @@
<string name="set_video_quality_choice" translatable="false">set_video_quality_choice</string>
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
<string name="federation_issue">The video cannot be federated!</string>
<string name="title_home">Home</string>
<string name="title_local">Local</string>
<string name="title_discover">Discover</string>

View File

@ -117,7 +117,6 @@ public class InstancePickerActivity extends AppCompatActivity {
pickup_languages.setOnClickListener(v -> {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(InstancePickerActivity.this);
int i = 0;
if (languages.size() > 0) {
Iterator<Map.Entry<String, String>> it = languages.entrySet().iterator();
@ -175,7 +174,7 @@ public class InstancePickerActivity extends AppCompatActivity {
});
}
if (peertubeInformation != null && peertubeInformation.getLanguages() != null) {
if (peertubeInformation != null && peertubeInformation.getCategories() != null) {
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
checkedItemsCategory = new boolean[categories.size()];
itemsLabelCategory = new String[categories.size()];

View File

@ -114,6 +114,7 @@ import app.fedilab.fedilabtube.viewmodel.CaptionsVM;
import app.fedilab.fedilabtube.viewmodel.CommentVM;
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
import app.fedilab.fedilabtube.viewmodel.SearchVM;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import app.fedilab.fedilabtube.webview.CustomWebview;
import app.fedilab.fedilabtube.webview.MastalabWebChromeClient;
@ -226,6 +227,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
videoUuid = b.getString("video_uuid", null);
isMyVideo = b.getBoolean("isMyVideo", false);
sepiaSearch = b.getBoolean("sepia_search", false);
peertube = b.getParcelable("video");
}
@ -307,9 +309,23 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
}
});
playVideo();
if( peertube != null && sepiaSearch && peertube.getEmbedUrl() != null && Helper.isLoggedIn(PeertubeActivity.this)) {
SearchVM viewModelSearch = new ViewModelProvider(PeertubeActivity.this).get(SearchVM.class);
viewModelSearch.getVideos("0", peertube.getEmbedUrl()).observe(PeertubeActivity.this, this::manageVIewVideos);
}else {
playVideo();
}
}
private void manageVIewVideos(APIResponse apiResponse) {
if( apiResponse == null || apiResponse.getPeertubes() == null || apiResponse.getPeertubes().size() == 0) {
playVideo();
return;
}
peertube = apiResponse.getPeertubes().get(0);
sepiaSearch = false;
playVideo();
}
public void manageVIewComment(APIResponse apiResponse) {
flag_loading = false;
@ -521,7 +537,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
add_comment_write.requestFocus();
add_comment_write.setSelection(add_comment_write.getText().length());
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
if( sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
@ -538,7 +558,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
add_comment_read.requestFocus();
}
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
if( sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
@ -591,7 +615,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube_like_count.setText(String.valueOf(count));
changeColor();
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
if( sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
peertube_dislike_count.setOnClickListener(v -> {
@ -612,7 +640,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
peertube_dislike_count.setText(String.valueOf(count));
changeColor();
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
if( sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
}else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});

View File

@ -19,7 +19,6 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@ -315,7 +314,6 @@ public class SepiaSearchActivity extends AppCompatActivity {
apply_filter.setOnClickListener(v-> makeSearch());
searchBar.openSearch();
getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
private void makeSearch(){

View File

@ -81,6 +81,8 @@ public class VideoData {
private int duration;
@SerializedName("embedPath")
private String embedPath;
@SerializedName("embedUrl")
private String embedUrl;
@SerializedName("files")
private List<File> files;
@SerializedName("id")
@ -151,6 +153,7 @@ public class VideoData {
this.downloadEnabled = in.readByte() != 0;
this.duration = in.readInt();
this.embedPath = in.readString();
this.embedUrl = in.readString();
this.files = new ArrayList<>();
in.readList(this.files, File.class.getClassLoader());
this.id = in.readString();
@ -349,6 +352,14 @@ public class VideoData {
this.embedPath = embedPath;
}
public String getEmbedUrl() {
return embedUrl;
}
public void setEmbedUrl(String embedUrl) {
this.embedUrl = embedUrl;
}
public List<File> getFiles() {
return files;
}
@ -585,6 +596,7 @@ public class VideoData {
dest.writeByte(this.downloadEnabled ? (byte) 1 : (byte) 0);
dest.writeInt(this.duration);
dest.writeString(this.embedPath);
dest.writeString(this.embedUrl);
dest.writeList(this.files);
dest.writeString(this.id);
dest.writeByte(this.isLocal ? (byte) 1 : (byte) 0);

View File

@ -262,6 +262,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
b.putString("video_uuid", video.getUuid());
b.putBoolean("isMyVideo", ownVideos);
b.putBoolean("sepia_search", sepiaSearch);
b.putParcelable("video", video);
if( sepiaSearch) {
b.putString("peertube_instance", video.getAccount().getHost());
}
@ -272,6 +273,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putString("video_id", video.getId());
b.putParcelable("video", video);
b.putString("video_uuid", video.getUuid());
b.putBoolean("isMyVideo", ownVideos);
b.putBoolean("sepia_search", sepiaSearch);

View File

@ -107,6 +107,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
holder.peertube_notif_message.setOnClickListener(v -> {
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putParcelable("video", notification.getVideo());
b.putString("peertube_instance", finalAccountAction1.getHost());
b.putString("video_id", notification.getComment().getVideo().getId());
b.putString("video_uuid", notification.getComment().getVideo().getUuid());
@ -142,6 +143,7 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc
holder.peertube_notif_message.setOnClickListener(v -> {
Intent intent = new Intent(context, PeertubeActivity.class);
Bundle b = new Bundle();
b.putParcelable("video", notification.getVideo());
b.putString("peertube_instance", Helper.getLiveInstance(context));
b.putString("video_id", notification.getVideo().getId());
b.putString("video_uuid", notification.getVideo().getUuid());