mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Add notifications for abuse reports
This commit is contained in:
		| @@ -216,6 +216,7 @@ | ||||
|     <string name="peertube_video_from_subscription"><![CDATA[<b>%1$s</b> published a new video: <b>%2$s</b>]]></string> | ||||
|     <string name="peertube_video_blacklist"><![CDATA[Your video <b>%1$s</b> has been blacklisted]]></string> | ||||
|     <string name="peertube_video_unblacklist"><![CDATA[Your video <b>%1$s</b> has been unblacklisted]]></string> | ||||
|     <string name="peertube_video_report_success"><![CDATA[ Your abuse <b>%1$s</b> has been accepted]]></string> | ||||
|     <string name="peertube_video_abuse"><![CDATA[New abuse report for video: <b>%1$s</b>]]></string> | ||||
|     <string name="add_public_comment">Add a public comment</string> | ||||
|     <string name="send_comment">Send comment</string> | ||||
|   | ||||
| @@ -46,6 +46,8 @@ public class NotificationData { | ||||
|         private CommentData.NotificationComment comment; | ||||
|         @SerializedName("videoAbuse") | ||||
|         private VideoAbuse videoAbuse; | ||||
|         @SerializedName("abuse") | ||||
|         private VideoAbuse.Abuse abuse; | ||||
|         @SerializedName("videoBlacklist") | ||||
|         private VideoBlacklist videoBlacklist; | ||||
|         @SerializedName("account") | ||||
| @@ -153,5 +155,13 @@ public class NotificationData { | ||||
|         public void setUpdatedAt(Date updatedAt) { | ||||
|             this.updatedAt = updatedAt; | ||||
|         } | ||||
|  | ||||
|         public VideoAbuse.Abuse getAbuse() { | ||||
|             return abuse; | ||||
|         } | ||||
|  | ||||
|         public void setAbuse(VideoAbuse.Abuse abuse) { | ||||
|             this.abuse = abuse; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| import app.fedilab.fedilabtube.client.data.CommentData; | ||||
| import app.fedilab.fedilabtube.client.data.VideoData; | ||||
|  | ||||
| @SuppressWarnings({"unused", "RedundantSuppression"}) | ||||
| @@ -41,4 +42,38 @@ public class VideoAbuse { | ||||
|     public void setVideo(VideoData.Video video) { | ||||
|         this.video = video; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public static class Abuse{ | ||||
|         @SerializedName("comment") | ||||
|         private CommentData.Comment comment; | ||||
|         @SerializedName("threadId") | ||||
|         private String threadId; | ||||
|         @SerializedName("id") | ||||
|         private String id; | ||||
|  | ||||
|         public CommentData.Comment getComment() { | ||||
|             return comment; | ||||
|         } | ||||
|  | ||||
|         public void setComment(CommentData.Comment comment) { | ||||
|             this.comment = comment; | ||||
|         } | ||||
|  | ||||
|         public String getThreadId() { | ||||
|             return threadId; | ||||
|         } | ||||
|  | ||||
|         public void setThreadId(String threadId) { | ||||
|             this.threadId = threadId; | ||||
|         } | ||||
|  | ||||
|         public String getId() { | ||||
|             return id; | ||||
|         } | ||||
|  | ||||
|         public void setId(String id) { | ||||
|             this.id = id; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -46,7 +46,7 @@ import app.fedilab.fedilabtube.helper.Helper; | ||||
| public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||||
|  | ||||
|     private Context context; | ||||
|     private List<Notification> notifications; | ||||
|     private final List<Notification> notifications; | ||||
|  | ||||
|     public PeertubeNotificationsListAdapter(List<Notification> notifications) { | ||||
|         this.notifications = notifications; | ||||
| @@ -121,7 +121,6 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc | ||||
|  | ||||
|             String message = ""; | ||||
|             if (notification.getVideo() != null) { | ||||
|  | ||||
|                 if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_PUBLISHED) { | ||||
|                     message = context.getString(R.string.peertube_video_published, notification.getVideo().getName()); | ||||
|                 } else if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_IMPORT_ERROR) { | ||||
| @@ -156,6 +155,14 @@ public class PeertubeNotificationsListAdapter extends RecyclerView.Adapter<Recyc | ||||
|                     holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY)); | ||||
|                 else | ||||
|                     holder.peertube_notif_message.setText(Html.fromHtml(message)); | ||||
|             }else if (notification.getAbuse() != null){ | ||||
|                 if (notification.getType() == DisplayNotificationsFragment.MY_VIDEO_REPPORT_SUCCESS) { | ||||
|                     message = context.getString(R.string.peertube_video_report_success, notification.getAbuse().getId()); | ||||
|                 } | ||||
|                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) | ||||
|                     holder.peertube_notif_message.setText(Html.fromHtml(message, Html.FROM_HTML_MODE_LEGACY)); | ||||
|                 else | ||||
|                     holder.peertube_notif_message.setText(Html.fromHtml(message)); | ||||
|             } | ||||
|         } | ||||
|         holder.peertube_notif_date.setText(Helper.dateDiff(context, notification.getCreatedAt())); | ||||
|   | ||||
| @@ -47,11 +47,12 @@ public class DisplayNotificationsFragment extends Fragment { | ||||
|  | ||||
|     //Peertube notification type | ||||
|     public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1; | ||||
|     public static int BLACKLIST_ON_MY_VIDEO = 4; | ||||
|     public static int UNBLACKLIST_ON_MY_VIDEO = 5; | ||||
|     public static int BLACKLIST_ON_MY_VIDEO = 4; | ||||
|     public static int MY_VIDEO_PUBLISHED = 6; | ||||
|     public static int MY_VIDEO_IMPORT_SUCCESS = 7; | ||||
|     public static int MY_VIDEO_IMPORT_ERROR = 8; | ||||
|     public static int MY_VIDEO_REPPORT_SUCCESS = 15; | ||||
|     private boolean flag_loading; | ||||
|     private Context context; | ||||
|     private PeertubeNotificationsListAdapter peertubeNotificationsListAdapter; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user