From a399b12aeda6dceedc3dea5ee93e3ecb14e9ff02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Sch=C3=BCller?= Date: Sat, 20 Nov 2021 20:40:28 +0000 Subject: [PATCH] Load full description --- README.md | 2 +- .../fragment/VideoMetaDataFragment.java | 26 +++++++++++++++- .../schueller/peertube/model/Description.java | 30 +++++++++++++++++++ .../peertube/network/GetVideoDataService.java | 10 +++++-- app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/net/schueller/peertube/model/Description.java diff --git a/README.md b/README.md index adfa1b2..edc7f57 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ PeerTube is a federated video streaming platform that is community-owned and ad- This client comes preconfigured with one PeerTube server managed by the application creator - not the PeerTube project itself, which lists more on http://instances.joinpeertube.org/ - to allow you to have a taste of what the client is capable of. Choose your server to tune your experience! -Please note this is app is in beta and is still missing a lot of features. +Please note this app is in beta and is still missing a lot of features. ## Download diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java index 7061288..b51e304 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMetaDataFragment.java @@ -36,6 +36,7 @@ import android.widget.Toast; import com.mikepenz.iconics.Iconics; import com.squareup.picasso.Picasso; +import java.util.Objects; import net.schueller.peertube.R; import net.schueller.peertube.helper.APIUrlHelper; import net.schueller.peertube.helper.ErrorHelper; @@ -43,6 +44,7 @@ import net.schueller.peertube.helper.MetaDataHelper; import net.schueller.peertube.intents.Intents; import net.schueller.peertube.model.Account; import net.schueller.peertube.model.Avatar; +import net.schueller.peertube.model.Description; import net.schueller.peertube.model.Rating; import net.schueller.peertube.model.Video; import net.schueller.peertube.network.GetVideoDataService; @@ -210,7 +212,29 @@ public class VideoMetaDataFragment extends Fragment { // description TextView videoDescription = activity.findViewById(R.id.description); - videoDescription.setText(video.getDescription()); + String shortDescription = video.getDescription(); + if (shortDescription != null && Objects.requireNonNull(shortDescription).length() > 237) { + shortDescription += "\n" + getString(R.string.video_description_read_more); + videoDescription.setOnClickListener(v -> { + Call call = videoDataService.getVideoFullDescription(video.getUuid()); + call.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful() && response.body() != null) { + new Description(); + Description videoFullDescription; + videoFullDescription = response.body(); + videoDescription.setText(videoFullDescription.getDescription()); + } + } + @Override + public void onFailure(Call call, Throwable t) { + Toast.makeText(getContext(), getString(R.string.video_get_full_description_failed), Toast.LENGTH_SHORT).show(); + } + }); + }); + } + videoDescription.setText(shortDescription); // video privacy TextView videoPrivacy = activity.findViewById(R.id.video_privacy); diff --git a/app/src/main/java/net/schueller/peertube/model/Description.java b/app/src/main/java/net/schueller/peertube/model/Description.java new file mode 100644 index 0000000..2070a23 --- /dev/null +++ b/app/src/main/java/net/schueller/peertube/model/Description.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Stefan Schüller + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package net.schueller.peertube.model; + +public class Description { + + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } +} diff --git a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java index d4390cd..e61e168 100644 --- a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java +++ b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java @@ -16,6 +16,7 @@ */ package net.schueller.peertube.network; +import net.schueller.peertube.model.Description; import net.schueller.peertube.model.Rating; import net.schueller.peertube.model.Video; import net.schueller.peertube.model.VideoList; @@ -43,9 +44,9 @@ public interface GetVideoDataService { @Query("languageOneOf") Set languages ); - @GET("videos/{id}") + @GET("videos/{uuid}") Call