mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Fix issue #154
This commit is contained in:
		| @@ -44,7 +44,7 @@ android { | ||||
|             applicationId "app.fedilab.fedilabtube" | ||||
|             resValue "string", "app_name", "TubeAcad" | ||||
|             resValue "string", "app_id", "app.fedilab.fedilabtube" | ||||
|             buildConfigField "String", "version", "\"fdroid_peertube_apps_educ\"" | ||||
|             buildConfigField "String", "version", "\"fdroid_acad\"" | ||||
|             buildConfigField "boolean", "full_instances", "false" | ||||
|             buildConfigField "boolean", "google_restriction", "false" | ||||
|             buildConfigField "boolean", "surfing_mode", "false" | ||||
| @@ -55,7 +55,7 @@ android { | ||||
|             applicationId "app.fedilab.fedilabtube" | ||||
|             resValue "string", "app_name", "TubeAcad" | ||||
|             resValue "string", "app_id", "app.fedilab.fedilabtube" | ||||
|             buildConfigField "String", "version", "\"google_peertube_apps_educ\"" | ||||
|             buildConfigField "String", "version", "\"google_acad\"" | ||||
|             buildConfigField "boolean", "full_instances", "false" | ||||
|             buildConfigField "boolean", "google_restriction", "true" | ||||
|             buildConfigField "boolean", "surfing_mode", "false" | ||||
|   | ||||
| @@ -74,6 +74,10 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager; | ||||
| import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.RecyclerView; | ||||
|  | ||||
| import com.bumptech.glide.Glide; | ||||
| import com.bumptech.glide.load.resource.bitmap.CenterCrop; | ||||
| import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||||
| import com.bumptech.glide.request.RequestOptions; | ||||
| import com.github.se_bastiaan.torrentstream.StreamStatus; | ||||
| import com.github.se_bastiaan.torrentstream.Torrent; | ||||
| import com.github.se_bastiaan.torrentstream.TorrentOptions; | ||||
| @@ -127,7 +131,9 @@ import app.fedilab.fedilabtube.client.data.AccountData.Account; | ||||
| import app.fedilab.fedilabtube.client.data.CaptionData.Caption; | ||||
| import app.fedilab.fedilabtube.client.data.CommentData; | ||||
| import app.fedilab.fedilabtube.client.data.CommentData.Comment; | ||||
| import app.fedilab.fedilabtube.client.data.InstanceData; | ||||
| import app.fedilab.fedilabtube.client.data.PlaylistData; | ||||
| import app.fedilab.fedilabtube.client.data.PluginData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoData; | ||||
| import app.fedilab.fedilabtube.client.entities.Error; | ||||
| import app.fedilab.fedilabtube.client.entities.File; | ||||
| @@ -317,10 +323,8 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd | ||||
|             sepiaSearch = b.getBoolean("sepia_search", false); | ||||
|             peertube = b.getParcelable("video"); | ||||
|         } | ||||
|         new Thread(() -> { | ||||
|             String videoId = peertube != null ? peertube.getUuid() : videoUuid; | ||||
|             new RetrofitPeertubeAPI(PeertubeActivity.this).postView(videoId); | ||||
|         }).start(); | ||||
|  | ||||
|  | ||||
|         willPlayFromIntent = manageIntentUrl(intent); | ||||
|  | ||||
|         binding.peertubeDescriptionMore.setOnClickListener(v -> { | ||||
| @@ -674,6 +678,35 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd | ||||
|         } | ||||
|         CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class); | ||||
|         captionsViewModel.getCaptions(sepiaSearch ? peertubeInstance : null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions); | ||||
|  | ||||
|         //Post view count | ||||
|         new Thread(() -> { | ||||
|             String videoId = peertube != null ? peertube.getUuid() : videoUuid; | ||||
|             new RetrofitPeertubeAPI(PeertubeActivity.this).postView(videoId); | ||||
|         }).start(); | ||||
|         //manage plugin | ||||
|         new Thread(() -> { | ||||
|             String videoInstance = peertubeInstance != null ? peertubeInstance : peertube.getAccount().getHost(); | ||||
|             InstanceData.InstanceConfig instanceConfig = new RetrofitPeertubeAPI(PeertubeActivity.this, videoInstance, null).getConfigInstance(); | ||||
|             if (instanceConfig != null && instanceConfig.getPlugin() != null && instanceConfig.getPlugin().getRegistered() != null) { | ||||
|                 for (PluginData.PluginInfo pluginInfo : instanceConfig.getPlugin().getRegistered()) { | ||||
|                     if (pluginInfo.getName().compareTo("player-watermark") == 0) { | ||||
|                         PluginData.WaterMark getWaterMark = new RetrofitPeertubeAPI(PeertubeActivity.this, videoInstance, null).getWaterMark(); | ||||
|                         if (getWaterMark != null && getWaterMark.getDescription() != null && getWaterMark.getDescription().getWatermarkImageUrl() != null) { | ||||
|                             Handler mainHandler = new Handler(Looper.getMainLooper()); | ||||
|                             Runnable myRunnable = () -> { | ||||
|                                 Glide.with(binding.watermark.getContext()) | ||||
|                                         .asDrawable() | ||||
|                                         .load(getWaterMark.getDescription().getWatermarkImageUrl()) | ||||
|                                         .into(binding.watermark); | ||||
|                                 binding.watermark.setVisibility(View.VISIBLE); | ||||
|                             }; | ||||
|                             mainHandler.post(myRunnable); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }).start(); | ||||
|         new Thread(() -> { | ||||
|             try { | ||||
|                 RetrofitPeertubeAPI api; | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import app.fedilab.fedilabtube.client.data.CommentData; | ||||
| import app.fedilab.fedilabtube.client.data.InstanceData; | ||||
| import app.fedilab.fedilabtube.client.data.NotificationData; | ||||
| import app.fedilab.fedilabtube.client.data.PlaylistData; | ||||
| import app.fedilab.fedilabtube.client.data.PluginData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoPlaylistData; | ||||
| import app.fedilab.fedilabtube.client.entities.CaptionsParams; | ||||
| @@ -70,6 +71,9 @@ public interface PeertubeService { | ||||
|     @GET(".well-known/nodeinfo") | ||||
|     Call<WellKnownNodeinfo> getWellKnownNodeinfo(); | ||||
|  | ||||
|     @GET("plugins/peertube-plugin-player-watermark/public-settings") | ||||
|     Call<PluginData.WaterMark> waterMark(); | ||||
|  | ||||
|     //Instance info | ||||
|     @GET("config/about") | ||||
|     Call<InstanceData.InstanceInfo> configAbout(); | ||||
|   | ||||
| @@ -55,6 +55,7 @@ import app.fedilab.fedilabtube.client.data.CommentData; | ||||
| import app.fedilab.fedilabtube.client.data.InstanceData; | ||||
| import app.fedilab.fedilabtube.client.data.NotificationData; | ||||
| import app.fedilab.fedilabtube.client.data.PlaylistData; | ||||
| import app.fedilab.fedilabtube.client.data.PluginData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoPlaylistData; | ||||
| import app.fedilab.fedilabtube.client.entities.AccountCreation; | ||||
| @@ -267,6 +268,9 @@ public class RetrofitPeertubeAPI { | ||||
|      * POST a view count for a video | ||||
|      */ | ||||
|     public void postView(String videoUuid) { | ||||
|         if (videoUuid == null) { | ||||
|             return; | ||||
|         } | ||||
|         PeertubeService peertubeService = init(); | ||||
|         Call<String> postViewCall = peertubeService.postView(videoUuid); | ||||
|         try { | ||||
| @@ -729,6 +733,26 @@ public class RetrofitPeertubeAPI { | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Get watermark info | ||||
|      * | ||||
|      * @return PluginData.WaterMark | ||||
|      */ | ||||
|     public PluginData.WaterMark getWaterMark() { | ||||
|  | ||||
|         PeertubeService peertubeService = init(); | ||||
|         Call<PluginData.WaterMark> waterMarkCall = peertubeService.waterMark(); | ||||
|         try { | ||||
|             Response<PluginData.WaterMark> response = waterMarkCall.execute(); | ||||
|             if (response.isSuccessful() && response.body() != null) { | ||||
|                 return response.body(); | ||||
|             } | ||||
|         } catch (IOException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get video quota | ||||
|      * | ||||
|   | ||||
| @@ -1,5 +1,18 @@ | ||||
| package app.fedilab.fedilabtube.client.data; | ||||
|  | ||||
| /* Copyright 2020 Thomas Schneider | ||||
|  * | ||||
|  * This file is a part of TubeLab | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it under the terms of the | ||||
|  * GNU General Public License as published by the Free Software Foundation; either version 3 of the | ||||
|  * License, or (at your option) any later version. | ||||
|  * | ||||
|  * TubeLab 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 General | ||||
|  * Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with TubeLab; if not, | ||||
|  * see <http://www.gnu.org/licenses>. */ | ||||
| import android.os.Parcel; | ||||
| import android.os.Parcelable; | ||||
| import android.text.SpannableStringBuilder; | ||||
| @@ -366,6 +379,16 @@ public class InstanceData { | ||||
|     public static class InstanceConfig { | ||||
|         @SerializedName("user") | ||||
|         private User user; | ||||
|         @SerializedName("plugin") | ||||
|         private PluginData.Plugin plugin; | ||||
|  | ||||
|         public PluginData.Plugin getPlugin() { | ||||
|             return plugin; | ||||
|         } | ||||
|  | ||||
|         public void setPlugin(PluginData.Plugin plugin) { | ||||
|             this.plugin = plugin; | ||||
|         } | ||||
|  | ||||
|         public User getUser() { | ||||
|             return user; | ||||
| @@ -376,6 +399,7 @@ public class InstanceData { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public static class User { | ||||
|         @SerializedName("videoQuota") | ||||
|         private long videoQuota; | ||||
|   | ||||
| @@ -0,0 +1,125 @@ | ||||
| package app.fedilab.fedilabtube.client.data; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /* Copyright 2020 Thomas Schneider | ||||
|  * | ||||
|  * This file is a part of TubeLab | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it under the terms of the | ||||
|  * GNU General Public License as published by the Free Software Foundation; either version 3 of the | ||||
|  * License, or (at your option) any later version. | ||||
|  * | ||||
|  * TubeLab 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 General | ||||
|  * Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with TubeLab; if not, | ||||
|  * see <http://www.gnu.org/licenses>. */ | ||||
| @SuppressWarnings("ALL") | ||||
| public class PluginData { | ||||
|  | ||||
|     public static class Plugin { | ||||
|         @SerializedName("registered") | ||||
|         private List<PluginInfo> registered; | ||||
|         @SerializedName("registeredExternalAuths") | ||||
|         private List<PluginInfo> registeredExternalAuths; | ||||
|         @SerializedName("registeredIdAndPassAuths") | ||||
|         private List<PluginInfo> registeredIdAndPassAuths; | ||||
|  | ||||
|         public List<PluginInfo> getRegistered() { | ||||
|             return registered; | ||||
|         } | ||||
|  | ||||
|         public void setRegistered(List<PluginInfo> registered) { | ||||
|             this.registered = registered; | ||||
|         } | ||||
|  | ||||
|         public List<PluginInfo> getRegisteredExternalAuths() { | ||||
|             return registeredExternalAuths; | ||||
|         } | ||||
|  | ||||
|         public void setRegisteredExternalAuths(List<PluginInfo> registeredExternalAuths) { | ||||
|             this.registeredExternalAuths = registeredExternalAuths; | ||||
|         } | ||||
|  | ||||
|         public List<PluginInfo> getRegisteredIdAndPassAuths() { | ||||
|             return registeredIdAndPassAuths; | ||||
|         } | ||||
|  | ||||
|         public void setRegisteredIdAndPassAuths(List<PluginInfo> registeredIdAndPassAuths) { | ||||
|             this.registeredIdAndPassAuths = registeredIdAndPassAuths; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static class WaterMark { | ||||
|         @SerializedName("publicSettings") | ||||
|         private PublicSettings description; | ||||
|  | ||||
|         public PublicSettings getDescription() { | ||||
|             return description; | ||||
|         } | ||||
|  | ||||
|         public void setDescription(PublicSettings description) { | ||||
|             this.description = description; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static class PublicSettings { | ||||
|         @SerializedName("watermark-image-url") | ||||
|         private String watermarkImageUrl; | ||||
|         @SerializedName("watermark-target-url") | ||||
|         private String watermarkTargetUrl; | ||||
|  | ||||
|         public String getWatermarkImageUrl() { | ||||
|             return watermarkImageUrl; | ||||
|         } | ||||
|  | ||||
|         public void setWatermarkImageUrl(String watermarkImageUrl) { | ||||
|             this.watermarkImageUrl = watermarkImageUrl; | ||||
|         } | ||||
|  | ||||
|         public String getWatermarkTargetUrl() { | ||||
|             return watermarkTargetUrl; | ||||
|         } | ||||
|  | ||||
|         public void setWatermarkTargetUrl(String watermarkTargetUrl) { | ||||
|             this.watermarkTargetUrl = watermarkTargetUrl; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static class PluginInfo { | ||||
|         @SerializedName("description") | ||||
|         private String description; | ||||
|         @SerializedName("name") | ||||
|         private String name; | ||||
|         @SerializedName("version") | ||||
|         private String version; | ||||
|  | ||||
|         public String getDescription() { | ||||
|             return description; | ||||
|         } | ||||
|  | ||||
|         public void setDescription(String description) { | ||||
|             this.description = description; | ||||
|         } | ||||
|  | ||||
|         public String getName() { | ||||
|             return name; | ||||
|         } | ||||
|  | ||||
|         public void setName(String name) { | ||||
|             this.name = name; | ||||
|         } | ||||
|  | ||||
|         public String getVersion() { | ||||
|             return version; | ||||
|         } | ||||
|  | ||||
|         public void setVersion(String version) { | ||||
|             this.version = version; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -49,7 +49,6 @@ | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent"> | ||||
|  | ||||
|                 <com.github.vkay94.dtpv.DoubleTapPlayerView | ||||
|                     android:id="@+id/doubleTapPlayerView" | ||||
|                     android:animateLayoutChanges="true" | ||||
| @@ -67,6 +66,15 @@ | ||||
|                     app:yt_playerView="@+id/doubleTapPlayerView" | ||||
|                     android:gravity="center" /> | ||||
|  | ||||
|                 <ImageView | ||||
|                     android:id="@+id/watermark" | ||||
|                     android:layout_width="100dp" | ||||
|                     android:layout_height="40dp" | ||||
|                     android:layout_gravity="top|start" | ||||
|                     android:contentDescription="@string/watermark" | ||||
|                     android:scaleType="fitCenter" | ||||
|                     android:visibility="gone" /> | ||||
|  | ||||
|                 <androidx.constraintlayout.widget.ConstraintLayout | ||||
|                     android:id="@+id/cast_controller" | ||||
|                     android:layout_width="match_parent" | ||||
|   | ||||
| @@ -448,4 +448,5 @@ | ||||
|     <string name="remote_account">Account from another network!</string> | ||||
|     <string name="instance_not_availabe">Instance is not available!</string> | ||||
|     <string name="max_tag_size">The video should not have more than 5 tags!</string> | ||||
|     <string name="watermark">Watermark</string> | ||||
| </resources> | ||||
		Reference in New Issue
	
	Block a user