diff --git a/app/src/acad/res/values/strings.xml b/app/src/acad/res/values/strings.xml index ced6117..2589934 100644 --- a/app/src/acad/res/values/strings.xml +++ b/app/src/acad/res/values/strings.xml @@ -7,6 +7,7 @@ set_video_quality_choice set_video_cache_choice + La vidéo ne peut pas être fédérée ! Locale Locale Découvrir diff --git a/app/src/full/res/values/strings.xml b/app/src/full/res/values/strings.xml index 10d2451..a3cd5f0 100644 --- a/app/src/full/res/values/strings.xml +++ b/app/src/full/res/values/strings.xml @@ -6,7 +6,7 @@ set_video_quality_choice set_video_cache_choice - + The video cannot be federated! Home Local Discover diff --git a/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java b/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java index 477c26e..a16cc16 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/InstancePickerActivity.java @@ -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> 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 categories = new LinkedHashMap<>(peertubeInformation.getCategories()); checkedItemsCategory = new boolean[categories.size()]; itemsLabelCategory = new String[categories.size()]; diff --git a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java index 4eb9981..373decd 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/PeertubeActivity.java @@ -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(); + } } }); diff --git a/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java b/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java index b7f2768..5ff0a53 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/SepiaSearchActivity.java @@ -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(){ diff --git a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java index 2f95df8..d40ccd2 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java +++ b/app/src/main/java/app/fedilab/fedilabtube/client/data/VideoData.java @@ -81,6 +81,8 @@ public class VideoData { private int duration; @SerializedName("embedPath") private String embedPath; + @SerializedName("embedUrl") + private String embedUrl; @SerializedName("files") private List 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 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); diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java index da4c4ac..3573093 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/PeertubeAdapter.java @@ -262,6 +262,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter { 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 { 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());