mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Code clean
This commit is contained in:
		@@ -671,7 +671,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
 | 
			
		||||
        set_upload_submit.setEnabled(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("unused")
 | 
			
		||||
    @SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
    public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) {
 | 
			
		||||
        Intent intent = new Intent(PeertubeEditUploadActivity.this, MainActivity.class);
 | 
			
		||||
        intent.putExtra(Helper.INTENT_ACTION, Helper.RELOAD_MYVIDEOS);
 | 
			
		||||
 
 | 
			
		||||
@@ -55,7 +55,7 @@ import retrofit2.http.Path;
 | 
			
		||||
import retrofit2.http.Query;
 | 
			
		||||
import retrofit2.http.QueryMap;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public interface PeertubeService {
 | 
			
		||||
    @GET("instances")
 | 
			
		||||
    Call<InstanceData> getInstances(@QueryMap Map<String, String> params, @Query("nsfwPolicy[]") String nsfwPolicy, @Query("categoriesOr[]") List<Integer> categories, @Query("languagesOr[]") List<String> languages);
 | 
			
		||||
 
 | 
			
		||||
@@ -78,6 +78,7 @@ import retrofit2.Response;
 | 
			
		||||
import retrofit2.Retrofit;
 | 
			
		||||
import retrofit2.converter.gson.GsonConverterFactory;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class RetrofitPeertubeAPI {
 | 
			
		||||
 | 
			
		||||
    private String finalUrl;
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ import java.util.List;
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.Avatar;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class AccountData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class BlockData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class CaptionData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ import app.fedilab.fedilabtube.client.entities.Avatar;
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.ItemStr;
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.ViewsPerDay;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class ChannelData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class CommentData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class InstanceData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ import app.fedilab.fedilabtube.client.entities.VideoBlacklist;
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along with TubeLab; if not,
 | 
			
		||||
 * see <http://www.gnu.org/licenses>. */
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class NotificationData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import java.util.List;
 | 
			
		||||
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.Item;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class PlaylistData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ import app.fedilab.fedilabtube.client.entities.StreamingPlaylists;
 | 
			
		||||
import app.fedilab.fedilabtube.helper.Helper;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class VideoData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class VideoPlaylistData {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("total")
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along with TubeLab; if not,
 | 
			
		||||
 * see <http://www.gnu.org/licenses>. */
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class AccountCreation {
 | 
			
		||||
 | 
			
		||||
    private String username;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Actor {
 | 
			
		||||
    @SerializedName("type")
 | 
			
		||||
    private String type;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class ActorFollow {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("id")
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import java.util.Date;
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along with TubeLab; if not,
 | 
			
		||||
 * see <http://www.gnu.org/licenses>. */
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Avatar implements Parcelable {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class CaptionsParams {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("captionLanguage")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class ChannelParams {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("displayName")
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ import android.widget.Toast;
 | 
			
		||||
import app.fedilab.fedilabtube.R;
 | 
			
		||||
import es.dmoral.toasty.Toasty;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Error extends Throwable {
 | 
			
		||||
 | 
			
		||||
    private String error = null;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class File {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("fileDownloadUrl")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class InstanceParams {
 | 
			
		||||
 | 
			
		||||
    private boolean healthy = true;
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ import android.os.Parcelable;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Item implements Parcelable {
 | 
			
		||||
 | 
			
		||||
    public static final Parcelable.Creator<Item> CREATOR = new Parcelable.Creator<Item>() {
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ import android.os.Parcelable;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class ItemStr implements Parcelable {
 | 
			
		||||
 | 
			
		||||
    public static final Creator<ItemStr> CREATOR = new Creator<ItemStr>() {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class NotificationSettings {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("abuseAsModerator")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Oauth {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("client_id")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class OauthParams {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import java.util.List;
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.ChannelData.Channel;
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.VideoData.Video;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused"})
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class OverviewVideo {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("categories")
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
import java.util.LinkedHashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class PeertubeInformation {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class PlaylistParams {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("displayName")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Rating {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("videoId")
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ import java.util.List;
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along with TubeLab; if not,
 | 
			
		||||
 * see <http://www.gnu.org/licenses>. */
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Report {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("reason")
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class StreamingPlaylists {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("id")
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class Token {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("access_token")
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ import java.util.List;
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.AccountData.Account;
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.ChannelData;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class UserMe {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("account")
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.VideoData;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class VideoAbuse {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("id")
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
import app.fedilab.fedilabtube.client.data.VideoData;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class VideoBlacklist {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("id")
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class VideoParams {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("channelId")
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class ViewsPerDay {
 | 
			
		||||
 | 
			
		||||
    @SerializedName("date")
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ package app.fedilab.fedilabtube.client.entities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.annotations.SerializedName;
 | 
			
		||||
 | 
			
		||||
@SuppressWarnings("unused")
 | 
			
		||||
@SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
public class WellKnownNodeinfo {
 | 
			
		||||
    @SerializedName("reel")
 | 
			
		||||
    private String reel;
 | 
			
		||||
 
 | 
			
		||||
@@ -156,6 +156,7 @@ public class PlaylistAdapter extends BaseAdapter {
 | 
			
		||||
        return convertView;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
    public void manageVIewPlaylists(PlaylistsVM.action actionType, APIResponse apiResponse) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,6 @@ public class DisplayNotificationsFragment extends Fragment {
 | 
			
		||||
 | 
			
		||||
    //Peertube notification type
 | 
			
		||||
    public static int NEW_VIDEO_FROM_SUBSCRIPTION = 1;
 | 
			
		||||
    public static int NEW_REPORT = 3;
 | 
			
		||||
    public static int BLACKLIST_ON_MY_VIDEO = 4;
 | 
			
		||||
    public static int UNBLACKLIST_ON_MY_VIDEO = 5;
 | 
			
		||||
    public static int MY_VIDEO_PUBLISHED = 6;
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,6 @@ package app.fedilab.fedilabtube.fragment;
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.SharedPreferences;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.Handler;
 | 
			
		||||
import android.os.Looper;
 | 
			
		||||
@@ -61,12 +60,10 @@ import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.Item;
 | 
			
		||||
import app.fedilab.fedilabtube.client.entities.PlaylistParams;
 | 
			
		||||
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
 | 
			
		||||
import app.fedilab.fedilabtube.helper.Helper;
 | 
			
		||||
import app.fedilab.fedilabtube.viewmodel.ChannelsVM;
 | 
			
		||||
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
 | 
			
		||||
import es.dmoral.toasty.Toasty;
 | 
			
		||||
 | 
			
		||||
import static android.content.Context.MODE_PRIVATE;
 | 
			
		||||
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
 | 
			
		||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.DataType.MY_CHANNELS;
 | 
			
		||||
 | 
			
		||||
@@ -132,8 +129,6 @@ public class DisplayPlaylistsFragment extends Fragment {
 | 
			
		||||
                set_upload_channel = dialogView.findViewById(R.id.set_upload_channel);
 | 
			
		||||
                set_upload_privacy = dialogView.findViewById(R.id.set_upload_privacy);
 | 
			
		||||
 | 
			
		||||
                final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
 | 
			
		||||
                final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
 | 
			
		||||
                ChannelsVM viewModelC = new ViewModelProvider(this).get(ChannelsVM.class);
 | 
			
		||||
                viewModelC.get(MY_CHANNELS, null).observe(DisplayPlaylistsFragment.this.requireActivity(), this::manageVIewChannels);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,68 +0,0 @@
 | 
			
		||||
package app.fedilab.fedilabtube.helper;
 | 
			
		||||
/* 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.graphics.Canvas;
 | 
			
		||||
import android.graphics.Paint;
 | 
			
		||||
import android.text.Layout;
 | 
			
		||||
import android.text.style.LeadingMarginSpan;
 | 
			
		||||
import android.text.style.LineBackgroundSpan;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Original work from @heath-borders: https://stackoverflow.com/a/29114976/3197259
 | 
			
		||||
 */
 | 
			
		||||
public class CustomQuoteSpan implements LeadingMarginSpan, LineBackgroundSpan {
 | 
			
		||||
    private final int backgroundColor;
 | 
			
		||||
    private final int stripeColor;
 | 
			
		||||
    private final float stripeWidth;
 | 
			
		||||
    private final float gap;
 | 
			
		||||
 | 
			
		||||
    public CustomQuoteSpan(int backgroundColor, int stripeColor, float stripeWidth, float gap) {
 | 
			
		||||
        this.backgroundColor = backgroundColor;
 | 
			
		||||
        this.stripeColor = stripeColor;
 | 
			
		||||
        this.stripeWidth = stripeWidth;
 | 
			
		||||
        this.gap = gap;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getLeadingMargin(boolean first) {
 | 
			
		||||
        return (int) (stripeWidth + gap);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom,
 | 
			
		||||
                                  CharSequence text, int start, int end, boolean first, Layout layout) {
 | 
			
		||||
        Paint.Style style = p.getStyle();
 | 
			
		||||
        int paintColor = p.getColor();
 | 
			
		||||
 | 
			
		||||
        p.setStyle(Paint.Style.FILL);
 | 
			
		||||
        p.setColor(stripeColor);
 | 
			
		||||
 | 
			
		||||
        c.drawRect(x, top, x + dir * stripeWidth, bottom, p);
 | 
			
		||||
 | 
			
		||||
        p.setStyle(style);
 | 
			
		||||
        p.setColor(paintColor);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void drawBackground(@NotNull Canvas c, @NotNull Paint p, int left, int right, int top, int baseline, int bottom, @NotNull CharSequence text, int start, int end, int lnum) {
 | 
			
		||||
        int paintColor = p.getColor();
 | 
			
		||||
        p.setColor(backgroundColor);
 | 
			
		||||
        c.drawRect(left, top, right, bottom, p);
 | 
			
		||||
        p.setColor(paintColor);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,41 +0,0 @@
 | 
			
		||||
package app.fedilab.fedilabtube.helper;
 | 
			
		||||
/* 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 java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Work from https://stackoverflow.com/a/26420820
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
public class FileNameCleaner {
 | 
			
		||||
    private final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        Arrays.sort(illegalChars);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String cleanFileName(String badFileName) {
 | 
			
		||||
        StringBuilder cleanName = new StringBuilder();
 | 
			
		||||
        int len = badFileName.codePointCount(0, badFileName.length());
 | 
			
		||||
        for (int i = 0; i < len; i++) {
 | 
			
		||||
            int c = badFileName.codePointAt(i);
 | 
			
		||||
            if (Arrays.binarySearch(illegalChars, c) < 0) {
 | 
			
		||||
                cleanName.appendCodePoint(c);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return cleanName.toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -45,7 +45,7 @@ public class FullScreenMediaController extends MediaController {
 | 
			
		||||
        this.context = context;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("unused")
 | 
			
		||||
    @SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
    public FullScreenMediaController(Context context, Video peertube) {
 | 
			
		||||
        super(context);
 | 
			
		||||
        this.peertube = peertube;
 | 
			
		||||
@@ -104,7 +104,7 @@ public class FullScreenMediaController extends MediaController {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @SuppressWarnings("unused")
 | 
			
		||||
    @SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
    public void setResolutionVal(String resolutionVal) {
 | 
			
		||||
        this.resolutionVal = resolutionVal;
 | 
			
		||||
        if (resolution != null)
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@ import android.graphics.Bitmap;
 | 
			
		||||
import android.graphics.Color;
 | 
			
		||||
import android.net.Uri;
 | 
			
		||||
import android.os.Build;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.Environment;
 | 
			
		||||
import android.util.DisplayMetrics;
 | 
			
		||||
import android.util.TypedValue;
 | 
			
		||||
@@ -40,7 +39,6 @@ import android.widget.ImageView;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import androidx.appcompat.app.AlertDialog;
 | 
			
		||||
import androidx.browser.customtabs.CustomTabsIntent;
 | 
			
		||||
import androidx.core.content.ContextCompat;
 | 
			
		||||
 | 
			
		||||
import com.bumptech.glide.Glide;
 | 
			
		||||
@@ -49,12 +47,10 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
 | 
			
		||||
import com.bumptech.glide.request.RequestOptions;
 | 
			
		||||
 | 
			
		||||
import java.text.DateFormat;
 | 
			
		||||
import java.text.ParseException;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Locale;
 | 
			
		||||
import java.util.TimeZone;
 | 
			
		||||
import java.util.regex.Pattern;
 | 
			
		||||
 | 
			
		||||
import app.fedilab.fedilabtube.BuildConfig;
 | 
			
		||||
@@ -82,51 +78,34 @@ public class Helper {
 | 
			
		||||
    public static final int QUALITY_HIGH = 0;
 | 
			
		||||
    public static final int QUALITY_MEDIUM = 1;
 | 
			
		||||
    public static final int QUALITY_LOW = 2;
 | 
			
		||||
    public static final int VIDEO_MODE_TORRENT = 3;
 | 
			
		||||
    public static final int ADD_USER_INTENT = 5;
 | 
			
		||||
    public static final int VIDEO_UPLOADED_INTENT = 6;
 | 
			
		||||
    public static final String VIDEO_UPLOAD_ID = "VIDEO_UPLOAD_ID";
 | 
			
		||||
    public static final String SET_SHARE_DETAILS = "set_share_details";
 | 
			
		||||
    public static final int DEFAULT_VIDEO_CACHE_MB = 100;
 | 
			
		||||
    @SuppressWarnings({"unused", "RedundantSuppression"})
 | 
			
		||||
    public static final String TAG = "mastodon_etalab";
 | 
			
		||||
    public static final String ID = "id";
 | 
			
		||||
    public static final String CLIENT_ID = "client_id";
 | 
			
		||||
    public static final String CLIENT_SECRET = "client_secret";
 | 
			
		||||
    public static final String SCOPES = "scopes";
 | 
			
		||||
    public static final String WEBSITE = "website";
 | 
			
		||||
    public static final String WEBSITE_VALUE = "https://fedilab.app";
 | 
			
		||||
    public static final String CLIENT_NAME_VALUE = "TubeLab";
 | 
			
		||||
    public static final String OAUTH_SCOPES_PEERTUBE = "openid profile";
 | 
			
		||||
    public static final String PREF_KEY_OAUTH_TOKEN = "oauth_token";
 | 
			
		||||
    public static final String REDIRECT_URIS = "redirect_uris";
 | 
			
		||||
 | 
			
		||||
    public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
 | 
			
		||||
    public static final Pattern redirectPattern = Pattern.compile("externalAuthToken=(\\w+)&username=([\\w.-]+)");
 | 
			
		||||
    public static final String SET_VIDEO_CACHE = "set_video_cache";
 | 
			
		||||
    //Proxy
 | 
			
		||||
    public static final String SET_PROXY_ENABLED = "set_proxy_enabled";
 | 
			
		||||
    public static final String SET_PROXY_TYPE = "set_proxy_type";
 | 
			
		||||
    public static final String SET_PROXY_HOST = "set_proxy_host";
 | 
			
		||||
    public static final String SET_PROXY_PORT = "set_proxy_port";
 | 
			
		||||
    public static final String SET_PROXY_LOGIN = "set_proxy_login";
 | 
			
		||||
    public static final String SET_PROXY_PASSWORD = "set_proxy_password";
 | 
			
		||||
    public static final String INTENT_ACTION = "intent_action";
 | 
			
		||||
    public static final String PREF_KEY_ID = "userID";
 | 
			
		||||
    public static final String PREF_KEY_NAME = "my_user_name";
 | 
			
		||||
    public static final String PREF_IS_MODERATOR = "is_moderator";
 | 
			
		||||
    public static final String PREF_IS_ADMINISTRATOR = "is_administrator";
 | 
			
		||||
    public static final String PREF_INSTANCE = "instance";
 | 
			
		||||
    public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob";
 | 
			
		||||
    public static final int EXTERNAL_STORAGE_REQUEST_CODE = 84;
 | 
			
		||||
    public static final String SET_VIDEOS_PER_PAGE = "set_videos_per_page";
 | 
			
		||||
    public static final String VIDEO_ID = "video_id_update";
 | 
			
		||||
    public static final String CLIENT_NAME = "client_name";
 | 
			
		||||
    public static final String APP_PREFS = "app_prefs";
 | 
			
		||||
 | 
			
		||||
    public static final int VIDEOS_PER_PAGE = 40;
 | 
			
		||||
    public static final String SET_VIDEO_NSFW = "set_video_nsfw";
 | 
			
		||||
    public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser";
 | 
			
		||||
    public static final String SET_CUSTOM_TABS = "set_custom_tabs";
 | 
			
		||||
    public static final String INTENT_ADD_UPLOADED_MEDIA = "intent_add_uploaded_media";
 | 
			
		||||
    public static final String RECEIVE_ACTION = "receive_action";
 | 
			
		||||
    public static final String SET_UNFOLLOW_VALIDATION = "set_unfollow_validation";
 | 
			
		||||
@@ -268,42 +247,6 @@ public class Helper {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String instanceWithProtocol(Context context) {
 | 
			
		||||
        return "https://" + getLiveInstance(context);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convert String date from Mastodon
 | 
			
		||||
     *
 | 
			
		||||
     * @param date String
 | 
			
		||||
     * @return Date
 | 
			
		||||
     */
 | 
			
		||||
    public static Date mstStringToDate(String date) throws ParseException {
 | 
			
		||||
        if (date == null)
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
        String STRING_DATE_FORMAT;
 | 
			
		||||
        Locale local = Locale.getDefault();
 | 
			
		||||
        if (!date.contains("+")) {
 | 
			
		||||
            STRING_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
 | 
			
		||||
        } else { //GNU date format
 | 
			
		||||
            STRING_DATE_FORMAT = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
 | 
			
		||||
            local = Locale.ENGLISH;
 | 
			
		||||
        }
 | 
			
		||||
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(STRING_DATE_FORMAT, local);
 | 
			
		||||
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("gmt"));
 | 
			
		||||
        simpleDateFormat.setLenient(true);
 | 
			
		||||
        try {
 | 
			
		||||
            return simpleDateFormat.parse(date);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            String newdate = date.split("\\+")[0].trim();
 | 
			
		||||
            simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", local);
 | 
			
		||||
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("gmt"));
 | 
			
		||||
            simpleDateFormat.setLenient(true);
 | 
			
		||||
            return simpleDateFormat.parse(newdate);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convert a date in String -> format yyyy-MM-dd HH:mm:ss
 | 
			
		||||
     *
 | 
			
		||||
@@ -402,17 +345,6 @@ public class Helper {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convert a date in String -> format yyyy-MM-dd HH:mm:ss
 | 
			
		||||
     *
 | 
			
		||||
     * @param date Date
 | 
			
		||||
     * @return String
 | 
			
		||||
     */
 | 
			
		||||
    public static String shortDateToString(Date date) {
 | 
			
		||||
        SimpleDateFormat df = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
 | 
			
		||||
        return df.format(date);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static String withSuffix(long count) {
 | 
			
		||||
        if (count < 1000) return "" + count;
 | 
			
		||||
@@ -471,50 +403,6 @@ public class Helper {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Manage URLs to open (built-in or external app)
 | 
			
		||||
     *
 | 
			
		||||
     * @param context Context
 | 
			
		||||
     * @param url     String url to open
 | 
			
		||||
     */
 | 
			
		||||
    public static void openBrowser(Context context, String url) {
 | 
			
		||||
        SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
 | 
			
		||||
        boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
 | 
			
		||||
        if (embedded_browser) {
 | 
			
		||||
            Intent intent = new Intent(context, WebviewActivity.class);
 | 
			
		||||
            Bundle b = new Bundle();
 | 
			
		||||
            String finalUrl = url;
 | 
			
		||||
            if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
 | 
			
		||||
                finalUrl = "http://" + url;
 | 
			
		||||
            b.putString("url", finalUrl);
 | 
			
		||||
            intent.putExtras(b);
 | 
			
		||||
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
			
		||||
            context.startActivity(intent);
 | 
			
		||||
        } else {
 | 
			
		||||
            boolean custom_tabs = sharedpreferences.getBoolean(Helper.SET_CUSTOM_TABS, true);
 | 
			
		||||
            if (custom_tabs) {
 | 
			
		||||
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
 | 
			
		||||
                CustomTabsIntent customTabsIntent = builder.build();
 | 
			
		||||
                builder.setToolbarColor(ContextCompat.getColor(context, getColorPrimary()));
 | 
			
		||||
                try {
 | 
			
		||||
                    customTabsIntent.launchUrl(context, Uri.parse(url));
 | 
			
		||||
                } catch (Exception ignored) {
 | 
			
		||||
                    Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                Intent intent = new Intent(Intent.ACTION_VIEW);
 | 
			
		||||
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
			
		||||
                intent.setData(Uri.parse(url));
 | 
			
		||||
                try {
 | 
			
		||||
                    context.startActivity(intent);
 | 
			
		||||
                } catch (Exception e) {
 | 
			
		||||
                    Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @SuppressLint("SetJavaScriptEnabled")
 | 
			
		||||
    public static CustomWebview initializeWebview(Activity activity, int webviewId, View rootView) {
 | 
			
		||||
@@ -678,9 +566,6 @@ public class Helper {
 | 
			
		||||
        return BuildConfig.full_instances ? R.color.colorAccent_full : R.color.colorAccent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getColorPrimary() {
 | 
			
		||||
        return BuildConfig.full_instances ? R.color.colorPrimary_full : R.color.colorPrimary;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean isOwner(Context context, Account account) {
 | 
			
		||||
        SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
 | 
			
		||||
 
 | 
			
		||||
@@ -41,12 +41,6 @@ public class CaptionsVM extends AndroidViewModel {
 | 
			
		||||
        return apiResponseMutableLiveData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public LiveData<APIResponse> loadCaption(String url) {
 | 
			
		||||
        apiResponseMutableLiveData = new MutableLiveData<>();
 | 
			
		||||
        load(url);
 | 
			
		||||
        return apiResponseMutableLiveData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void loadCaptions(String videoId) {
 | 
			
		||||
        Context _mContext = getApplication().getApplicationContext();
 | 
			
		||||
        new Thread(() -> {
 | 
			
		||||
@@ -61,20 +55,4 @@ public class CaptionsVM extends AndroidViewModel {
 | 
			
		||||
            }
 | 
			
		||||
        }).start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void load(String url) {
 | 
			
		||||
        Context _mContext = getApplication().getApplicationContext();
 | 
			
		||||
        new Thread(() -> {
 | 
			
		||||
            try {
 | 
			
		||||
                RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(_mContext);
 | 
			
		||||
                APIResponse apiResponse = peertubeAPI.getCaptionContent(url);
 | 
			
		||||
                Handler mainHandler = new Handler(Looper.getMainLooper());
 | 
			
		||||
                Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
 | 
			
		||||
                mainHandler.post(myRunnable);
 | 
			
		||||
            } catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }).start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user