mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Fix some issues + check if video is federated for Sepia search
This commit is contained in:
		@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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()];
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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(){
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user