mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Some improvements
This commit is contained in:
		| @@ -178,6 +178,7 @@ | ||||
|     <string name="report_account">Signaler le compte</string> | ||||
|     <string name="report_helper">Quelques explications concernant votre signalement…</string> | ||||
|     <string name="successful_report">Le compte a été signalé !</string> | ||||
|     <string name="successful_report_comment">Le commentaire a été signalé !</string> | ||||
|     <string name="successful_video_report">La vidéo a été signalée !</string> | ||||
|     <string name="report_comment_size">Veuillez préciser les raisons.</string> | ||||
|     <string name="all">Tout</string> | ||||
| @@ -203,6 +204,7 @@ | ||||
|     <string name="title_muted">Sourdine</string> | ||||
|     <string name="title_blocked">Bloqués</string> | ||||
|     <string name="no_muted">Aucun compte en sourdine !</string> | ||||
|     <string name="no_notifications">Aucune notification !</string> | ||||
|     <string name="action_mute">Mettre en sourdine</string> | ||||
|     <string name="action_unmute">Réactiver le compte</string> | ||||
|     <string name="muted_done">Le compte a été mis en sourdine !</string> | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|     <string name="instance_choice">Pick an instance</string> | ||||
|     <string name="not_valide_instance">This instance does not seem to be valid!</string> | ||||
|     <string name="no_videos">No videos!</string> | ||||
|     <string name="no_notifications">No notifications!</string> | ||||
|     <string name="favicon">Favicon</string> | ||||
|     <string name="open_with">Open with</string> | ||||
|     <string name="action_playlist_edit">Edit a playlist</string> | ||||
| @@ -229,6 +230,8 @@ | ||||
|     <string name="not_logged_in">You must be authenticated to proceed to this action!</string> | ||||
|  | ||||
|     <string name="successful_report">The account has been reported!</string> | ||||
|     <string name="successful_report_comment">The comment has been reported!</string> | ||||
|  | ||||
|  | ||||
|     <string name="successful_video_report">The video has been reported!</string> | ||||
|  | ||||
|   | ||||
| @@ -78,14 +78,10 @@ public class AccountActivity extends AppCompatActivity { | ||||
|  | ||||
|         SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); | ||||
|         SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); | ||||
|         String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); | ||||
|         String instance = Helper.getLiveInstance(AccountActivity.this); | ||||
|         String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); | ||||
|  | ||||
|         TextView instanceView = findViewById(R.id.instance); | ||||
|         Account account = new AccountDAO(AccountActivity.this, db).getUniqAccount(userId, instance); | ||||
|         if (account == null) { | ||||
|             account = new AccountDAO(AccountActivity.this, db).getUniqAccount(userId, Helper.getPeertubeUrl(instance)); | ||||
|         } | ||||
|         Account account = new AccountDAO(AccountActivity.this, db).getAccountByToken(token); | ||||
|  | ||||
|  | ||||
|         if (account == null) { | ||||
| @@ -241,6 +237,7 @@ public class AccountActivity extends AppCompatActivity { | ||||
|                 editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken()); | ||||
|                 editor.putString(Helper.PREF_INSTANCE, account.getHost()); | ||||
|                 editor.putString(Helper.PREF_KEY_ID, account.getId()); | ||||
|                 editor.putString(Helper.PREF_KEY_NAME, account.getUsername()); | ||||
|                 editor.apply(); | ||||
|                 dialog.dismiss(); | ||||
|                 Intent intent = new Intent(AccountActivity.this, MainActivity.class); | ||||
|   | ||||
| @@ -48,6 +48,8 @@ import app.fedilab.fedilabtube.client.data.AccountData.Account; | ||||
| import app.fedilab.fedilabtube.client.entities.Error; | ||||
| import app.fedilab.fedilabtube.client.entities.OauthParams; | ||||
| import app.fedilab.fedilabtube.client.entities.PeertubeInformation; | ||||
| import app.fedilab.fedilabtube.client.entities.Token; | ||||
| import app.fedilab.fedilabtube.client.entities.UserMe; | ||||
| import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo; | ||||
| import app.fedilab.fedilabtube.helper.Helper; | ||||
| import app.fedilab.fedilabtube.services.RetrieveInfoService; | ||||
| @@ -71,14 +73,14 @@ public class MainActivity extends AppCompatActivity { | ||||
|  | ||||
|  | ||||
|         BottomNavigationView navView = findViewById(R.id.nav_view); | ||||
|  | ||||
|         if (Helper.isLoggedIn(MainActivity.this)) { | ||||
|             navView.inflateMenu(R.menu.bottom_nav_menu_connected); | ||||
|             final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); | ||||
|             String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); | ||||
|             String tokenStr = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); | ||||
|             String instance = Helper.getLiveInstance(MainActivity.this); | ||||
|             SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); | ||||
|             Account account = new AccountDAO(MainActivity.this, db).getUniqAccount(userId, instance); | ||||
|  | ||||
|             Account account = new AccountDAO(MainActivity.this, db).getAccountByToken(tokenStr); | ||||
|             if (account != null) { | ||||
|                 OauthParams oauthParams = new OauthParams(); | ||||
|                 oauthParams.setGrant_type("refresh_token"); | ||||
| @@ -88,7 +90,19 @@ public class MainActivity extends AppCompatActivity { | ||||
|                 oauthParams.setAccess_token(account.getToken()); | ||||
|                 new Thread(() -> { | ||||
|                     try { | ||||
|                         new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams); | ||||
|                         Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams); | ||||
|                         if (token == null) { | ||||
|                             Helper.logoutCurrentUser(MainActivity.this, account); | ||||
|                             return; | ||||
|                         } | ||||
|                         UserMe userMe = new RetrofitPeertubeAPI(MainActivity.this, instance, token.getAccess_token()).verifyCredentials(); | ||||
|                         if (userMe != null && userMe.getAccount() != null) { | ||||
|                             new AccountDAO(MainActivity.this.getApplicationContext(), db).updateAccount(userMe.getAccount()); | ||||
|                             SharedPreferences.Editor editor = sharedpreferences.edit(); | ||||
|                             editor.putString(Helper.PREF_KEY_ID, account.getId()); | ||||
|                             editor.putString(Helper.PREF_KEY_NAME, account.getUsername()); | ||||
|                             editor.apply(); | ||||
|                         } | ||||
|                     } catch (Error error) { | ||||
|                         error.printStackTrace(); | ||||
|                     } | ||||
|   | ||||
| @@ -94,7 +94,7 @@ import app.fedilab.fedilabtube.client.data.CommentData.Comment; | ||||
| import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist; | ||||
| import app.fedilab.fedilabtube.client.data.VideoData; | ||||
| import app.fedilab.fedilabtube.client.entities.File; | ||||
| import app.fedilab.fedilabtube.client.entities.Item; | ||||
| import app.fedilab.fedilabtube.client.entities.ItemStr; | ||||
| import app.fedilab.fedilabtube.client.entities.Report; | ||||
| import app.fedilab.fedilabtube.drawer.CommentListAdapter; | ||||
| import app.fedilab.fedilabtube.helper.CacheDataSourceFactory; | ||||
| @@ -123,7 +123,7 @@ import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLISTS | ||||
| import static app.fedilab.fedilabtube.viewmodel.PlaylistsVM.action.GET_PLAYLIST_FOR_VIDEO; | ||||
|  | ||||
|  | ||||
| public class PeertubeActivity extends AppCompatActivity { | ||||
| public class PeertubeActivity extends AppCompatActivity implements CommentListAdapter.AllCommentRemoved { | ||||
|  | ||||
|     public static String video_id; | ||||
|     private String peertubeInstance, videoId; | ||||
| @@ -149,6 +149,7 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|     private boolean playInMinimized; | ||||
|     private boolean onStopCalled; | ||||
|     private List<Caption> captions; | ||||
|     private TextView no_action_text; | ||||
|  | ||||
|     public static void hideKeyboard(Activity activity) { | ||||
|         if (activity != null && activity.getWindow() != null) { | ||||
| @@ -185,10 +186,9 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|         ImageView my_pp = findViewById(R.id.my_pp); | ||||
|         SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); | ||||
|         SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); | ||||
|         String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); | ||||
|         String instance = Helper.getLiveInstance(PeertubeActivity.this); | ||||
|         Account account = new AccountDAO(PeertubeActivity.this, db).getUniqAccount(userId, instance); | ||||
|         Helper.loadGiF(PeertubeActivity.this, account != null && account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp); | ||||
|         String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); | ||||
|         Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token); | ||||
|         Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp); | ||||
|  | ||||
|  | ||||
|         if (Helper.isTablet(PeertubeActivity.this)) { | ||||
| @@ -303,10 +303,8 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|         peertube_playlist.setVisibility(View.VISIBLE); | ||||
|         peertube_bookmark.setVisibility(View.GONE); | ||||
|  | ||||
|  | ||||
|         TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class); | ||||
|         feedsViewModel.getVideo(videoId).observe(PeertubeActivity.this, this::manageVIewVideo); | ||||
|  | ||||
|         CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class); | ||||
|         captionsViewModel.getCaptions(videoId).observe(PeertubeActivity.this, this::manageCaptions); | ||||
|     } | ||||
| @@ -537,7 +535,7 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         no_action_text = findViewById(R.id.no_action_text); | ||||
|  | ||||
|         if (peertube.isCommentsEnabled()) { | ||||
|             CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class); | ||||
| @@ -546,7 +544,7 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|  | ||||
|         } else { | ||||
|             RelativeLayout no_action = findViewById(R.id.no_action); | ||||
|             TextView no_action_text = findViewById(R.id.no_action_text); | ||||
|  | ||||
|             no_action_text.setText(getString(R.string.comment_no_allowed_peertube)); | ||||
|             no_action.setVisibility(View.VISIBLE); | ||||
|             write_comment_container.setVisibility(View.GONE); | ||||
| @@ -689,9 +687,9 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|                         int i = 1; | ||||
|                         if (captions.size() > 0) { | ||||
|                             for (Caption caption : captions) { | ||||
|                                 Item lang = caption.getLanguage(); | ||||
|                                 itemsLabelLanguage[i] = String.valueOf(lang.getId()); | ||||
|                                 itemsKeyLanguage[i] = lang.getLabel(); | ||||
|                                 ItemStr lang = caption.getLanguage(); | ||||
|                                 itemsLabelLanguage[i] = lang.getLabel(); | ||||
|                                 itemsKeyLanguage[i] = lang.getId(); | ||||
|                                 i++; | ||||
|                             } | ||||
|                         } | ||||
| @@ -797,8 +795,9 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|             return; | ||||
|         } | ||||
|         List<Comment> comments = new ArrayList<>(); | ||||
|  | ||||
|         for (Comment comment : apiResponse.getComments()) { | ||||
|             if (comment.getDescription() != null && comment.getDescription().trim().length() > 0) { | ||||
|             if (comment.getText() != null && comment.getText().trim().length() > 0) { | ||||
|                 comments.add(comment); | ||||
|             } | ||||
|         } | ||||
| @@ -806,6 +805,7 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|         if (comments.size() > 0) { | ||||
|             lv_comments.setVisibility(View.VISIBLE); | ||||
|             CommentListAdapter commentListAdapter = new CommentListAdapter(comments); | ||||
|             commentListAdapter.allCommentRemoved = PeertubeActivity.this; | ||||
|             LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this); | ||||
|             lv_comments.setLayoutManager(mLayoutManager); | ||||
|             lv_comments.setNestedScrollingEnabled(false); | ||||
| @@ -1040,4 +1040,8 @@ public class PeertubeActivity extends AppCompatActivity { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onAllCommentRemoved() { | ||||
|         no_action_text.setVisibility(View.VISIBLE); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -35,6 +35,7 @@ import app.fedilab.fedilabtube.client.entities.PlaylistExist; | ||||
| import app.fedilab.fedilabtube.client.entities.Rating; | ||||
| import app.fedilab.fedilabtube.client.entities.Report; | ||||
| import app.fedilab.fedilabtube.client.entities.Token; | ||||
| import app.fedilab.fedilabtube.client.entities.UserMe; | ||||
| import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo; | ||||
| import okhttp3.MultipartBody; | ||||
| import okhttp3.RequestBody; | ||||
| @@ -45,6 +46,7 @@ import retrofit2.http.Field; | ||||
| import retrofit2.http.FormUrlEncoded; | ||||
| import retrofit2.http.GET; | ||||
| import retrofit2.http.Header; | ||||
| import retrofit2.http.Headers; | ||||
| import retrofit2.http.Multipart; | ||||
| import retrofit2.http.POST; | ||||
| import retrofit2.http.PUT; | ||||
| @@ -109,7 +111,7 @@ public interface PeertubeService { | ||||
|             @Field("grant_type") String grant_type); | ||||
|  | ||||
|     @GET("users/me") | ||||
|     Call<AccountData.Account> verifyCredentials(@Header("Authorization") String credentials); | ||||
|     Call<UserMe> verifyCredentials(@Header("Authorization") String credentials); | ||||
|  | ||||
|     //Timelines Authenticated | ||||
|     //Subscriber timeline | ||||
| @@ -138,7 +140,7 @@ public interface PeertubeService { | ||||
|  | ||||
|     //History | ||||
|     @GET("users/me/history/videos") | ||||
|     Call<VideoData> getHistory(@Query("start") String maxId); | ||||
|     Call<VideoData> getHistory(@Header("Authorization") String credentials, @Query("start") String maxId); | ||||
|  | ||||
|     //Search | ||||
|     @GET("search/videos") | ||||
| @@ -340,9 +342,18 @@ public interface PeertubeService { | ||||
|     @DELETE("videos/{id}/comments/{commentId}") | ||||
|     Call<String> deleteComment(@Header("Authorization") String credentials, @Path("id") String id, @Path("commentId") String commentId); | ||||
|  | ||||
|     @POST("abuse") | ||||
|     Call<String> report(@Header("Authorization") String credentials, @Body Report report); | ||||
|     @Headers({"Content-Type: application/json", "Cache-Control: max-age=640000"}) | ||||
|     @POST("abuses") | ||||
|     Call<String> report( | ||||
|             @Header("Authorization") String credentials, | ||||
|             @Body Report report); | ||||
|  | ||||
|     @POST("abuse") | ||||
|     Call<String> register(@Query("email") String email, @Query("password") String password, @Query("username") String username, @Query("displayName") String displayName); | ||||
|     @FormUrlEncoded | ||||
|     @POST("users/register") | ||||
|     Call<String> register( | ||||
|             @Field("email") String email, | ||||
|             @Field("password") String password, | ||||
|             @Field("username") String username, | ||||
|             @Field("displayName") String displayName | ||||
|     ); | ||||
| } | ||||
|   | ||||
| @@ -58,6 +58,7 @@ import app.fedilab.fedilabtube.client.entities.PlaylistParams; | ||||
| import app.fedilab.fedilabtube.client.entities.Rating; | ||||
| import app.fedilab.fedilabtube.client.entities.Report; | ||||
| import app.fedilab.fedilabtube.client.entities.Token; | ||||
| import app.fedilab.fedilabtube.client.entities.UserMe; | ||||
| import app.fedilab.fedilabtube.client.entities.VideoParams; | ||||
| import app.fedilab.fedilabtube.client.entities.WellKnownNodeinfo; | ||||
| import app.fedilab.fedilabtube.helper.Helper; | ||||
| @@ -107,7 +108,8 @@ public class RetrofitPeertubeAPI { | ||||
|                 instance = Helper.getPeertubeUrl(host); | ||||
|             } | ||||
|             try { | ||||
|                 account = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials(); | ||||
|                 UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials(); | ||||
|                 account = userMe.getAccount(); | ||||
|             } catch (Error error) { | ||||
|                 Error.displayError(activity, error); | ||||
|                 error.printStackTrace(); | ||||
| @@ -128,6 +130,7 @@ public class RetrofitPeertubeAPI { | ||||
|             boolean userExists = new AccountDAO(activity, db).userExist(account); | ||||
|             SharedPreferences.Editor editor = sharedpreferences.edit(); | ||||
|             editor.putString(Helper.PREF_KEY_ID, account.getId()); | ||||
|             editor.putString(Helper.PREF_KEY_NAME, account.getUsername()); | ||||
|             if (!host.startsWith("tube")) { | ||||
|                 editor.putString(Helper.PREF_INSTANCE, host); | ||||
|             } | ||||
| @@ -321,7 +324,7 @@ public class RetrofitPeertubeAPI { | ||||
|                 videoCall = peertubeService.getTrendingVideos(max_id, filter); | ||||
|                 break; | ||||
|             case HISTORY: | ||||
|                 videoCall = peertubeService.getHistory(max_id); | ||||
|                 videoCall = peertubeService.getHistory(getToken(), max_id); | ||||
|                 break; | ||||
|             case RECENT: | ||||
|                 videoCall = peertubeService.getRecentlyAddedVideos(max_id, filter); | ||||
| @@ -436,6 +439,7 @@ public class RetrofitPeertubeAPI { | ||||
|             Response<CaptionData> response = captions.execute(); | ||||
|             if (response.isSuccessful() && response.body() != null) { | ||||
|                 apiResponse.setCaptions(response.body().data); | ||||
|  | ||||
|             } else { | ||||
|                 setError(apiResponse, response.code(), response.errorBody()); | ||||
|             } | ||||
| @@ -627,12 +631,12 @@ public class RetrofitPeertubeAPI { | ||||
|      * Verifiy credential of the authenticated user *synchronously* | ||||
|      * @return Account | ||||
|      */ | ||||
|     public AccountData.Account verifyCredentials() throws Error { | ||||
|     public UserMe verifyCredentials() throws Error { | ||||
|         PeertubeService peertubeService = init(); | ||||
|         Call<AccountData.Account> accountCall = peertubeService.verifyCredentials("Bearer " + token); | ||||
|         Call<UserMe> accountCall = peertubeService.verifyCredentials("Bearer " + token); | ||||
|         APIResponse apiResponse = new APIResponse(); | ||||
|         try { | ||||
|             Response<AccountData.Account> response = accountCall.execute(); | ||||
|             Response<UserMe> response = accountCall.execute(); | ||||
|             if (response.isSuccessful() && response.body() != null) { | ||||
|                 return response.body(); | ||||
|             } else { | ||||
| @@ -701,7 +705,7 @@ public class RetrofitPeertubeAPI { | ||||
|         RequestBody name = RequestBody.create(MediaType.parse("text/plain"), videoParams.getName()); | ||||
|  | ||||
|         List<RequestBody> tags = null; | ||||
|         if( videoParams.getTags() != null && videoParams.getTags().size() >0 ) { | ||||
|         if (videoParams.getTags() != null && videoParams.getTags().size() > 0) { | ||||
|             tags = new ArrayList<>(); | ||||
|             for (String tag : videoParams.getTags()) { | ||||
|                 tags.add(RequestBody.create(MediaType.parse("text/plain"), tag)); | ||||
| @@ -777,6 +781,9 @@ public class RetrofitPeertubeAPI { | ||||
|             case PEERTUBEDELETEVIDEO: | ||||
|                 postCall = peertubeService.deleteVideo(getToken(), id); | ||||
|                 break; | ||||
|             case PEERTUBEDELETECOMMENT: | ||||
|                 postCall = peertubeService.deleteComment(getToken(), id, element); | ||||
|                 break; | ||||
|             case DELETE_CHANNEL: | ||||
|                 postCall = peertubeService.deleteChannel(getToken(), id); | ||||
|                 break; | ||||
| @@ -1342,6 +1349,7 @@ public class RetrofitPeertubeAPI { | ||||
|         PEERTUBEDELETEVIDEO, | ||||
|         REPORT_VIDEO, | ||||
|         REPORT_ACCOUNT, | ||||
|         REPORT_COMMENT, | ||||
|         DELETE_CHANNEL, | ||||
|         ADD_COMMENT, | ||||
|         REPLY, | ||||
|   | ||||
| @@ -18,7 +18,7 @@ import com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import app.fedilab.fedilabtube.client.entities.Item; | ||||
| import app.fedilab.fedilabtube.client.entities.ItemStr; | ||||
|  | ||||
| @SuppressWarnings("unused") | ||||
| public class CaptionData { | ||||
| @@ -32,7 +32,7 @@ public class CaptionData { | ||||
|         @SerializedName("captionPath") | ||||
|         private String captionPath; | ||||
|         @SerializedName("language") | ||||
|         private Item language; | ||||
|         private ItemStr language; | ||||
|  | ||||
|         public String getCaptionPath() { | ||||
|             return captionPath; | ||||
| @@ -42,11 +42,11 @@ public class CaptionData { | ||||
|             this.captionPath = captionPath; | ||||
|         } | ||||
|  | ||||
|         public Item getLanguage() { | ||||
|         public ItemStr getLanguage() { | ||||
|             return language; | ||||
|         } | ||||
|  | ||||
|         public void setLanguage(Item language) { | ||||
|         public void setLanguage(ItemStr language) { | ||||
|             this.language = language; | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -34,26 +34,28 @@ public class CommentData { | ||||
|         private AccountData.Account account; | ||||
|         @SerializedName("createdAt") | ||||
|         private Date createdAt; | ||||
|         @SerializedName("description") | ||||
|         private String description; | ||||
|         @SerializedName("displayName") | ||||
|         private String displayName; | ||||
|         @SerializedName("followersCount") | ||||
|         private int followersCount; | ||||
|         @SerializedName("followingCount") | ||||
|         private int followingCount; | ||||
|         @SerializedName("host") | ||||
|         private String host; | ||||
|         @SerializedName("hostRedundancyAllowed") | ||||
|         private boolean hostRedundancyAllowed; | ||||
|         @SerializedName("deletedAt") | ||||
|         private Date deletedAt; | ||||
|         @SerializedName("id") | ||||
|         private String id; | ||||
|         @SerializedName("name") | ||||
|         private String name; | ||||
|         @SerializedName("inReplyToCommentId") | ||||
|         private String inReplyToCommentId; | ||||
|         @SerializedName("isDeleted") | ||||
|         private boolean isDeleted; | ||||
|         @SerializedName("text") | ||||
|         private String text; | ||||
|         @SerializedName("threadId") | ||||
|         private String threadId; | ||||
|         @SerializedName("totalReplies") | ||||
|         private int totalReplies; | ||||
|         @SerializedName("totalRepliesFromVideoAuthor") | ||||
|         private int totalRepliesFromVideoAuthor; | ||||
|         @SerializedName("updatedAt") | ||||
|         private String updatedAt; | ||||
|         @SerializedName("url") | ||||
|         private String url; | ||||
|         @SerializedName("videoId") | ||||
|         private String videoId; | ||||
|  | ||||
|  | ||||
|         public AccountData.Account getAccount() { | ||||
| @@ -72,52 +74,12 @@ public class CommentData { | ||||
|             this.createdAt = createdAt; | ||||
|         } | ||||
|  | ||||
|         public String getDescription() { | ||||
|             return description; | ||||
|         public Date getDeletedAt() { | ||||
|             return deletedAt; | ||||
|         } | ||||
|  | ||||
|         public void setDescription(String description) { | ||||
|             this.description = description; | ||||
|         } | ||||
|  | ||||
|         public String getDisplayName() { | ||||
|             return displayName; | ||||
|         } | ||||
|  | ||||
|         public void setDisplayName(String displayName) { | ||||
|             this.displayName = displayName; | ||||
|         } | ||||
|  | ||||
|         public int getFollowersCount() { | ||||
|             return followersCount; | ||||
|         } | ||||
|  | ||||
|         public void setFollowersCount(int followersCount) { | ||||
|             this.followersCount = followersCount; | ||||
|         } | ||||
|  | ||||
|         public int getFollowingCount() { | ||||
|             return followingCount; | ||||
|         } | ||||
|  | ||||
|         public void setFollowingCount(int followingCount) { | ||||
|             this.followingCount = followingCount; | ||||
|         } | ||||
|  | ||||
|         public String getHost() { | ||||
|             return host; | ||||
|         } | ||||
|  | ||||
|         public void setHost(String host) { | ||||
|             this.host = host; | ||||
|         } | ||||
|  | ||||
|         public boolean isHostRedundancyAllowed() { | ||||
|             return hostRedundancyAllowed; | ||||
|         } | ||||
|  | ||||
|         public void setHostRedundancyAllowed(boolean hostRedundancyAllowed) { | ||||
|             this.hostRedundancyAllowed = hostRedundancyAllowed; | ||||
|         public void setDeletedAt(Date deletedAt) { | ||||
|             this.deletedAt = deletedAt; | ||||
|         } | ||||
|  | ||||
|         public String getId() { | ||||
| @@ -128,12 +90,52 @@ public class CommentData { | ||||
|             this.id = id; | ||||
|         } | ||||
|  | ||||
|         public String getName() { | ||||
|             return name; | ||||
|         public String getInReplyToCommentId() { | ||||
|             return inReplyToCommentId; | ||||
|         } | ||||
|  | ||||
|         public void setName(String name) { | ||||
|             this.name = name; | ||||
|         public void setInReplyToCommentId(String inReplyToCommentId) { | ||||
|             this.inReplyToCommentId = inReplyToCommentId; | ||||
|         } | ||||
|  | ||||
|         public boolean isDeleted() { | ||||
|             return isDeleted; | ||||
|         } | ||||
|  | ||||
|         public void setDeleted(boolean deleted) { | ||||
|             isDeleted = deleted; | ||||
|         } | ||||
|  | ||||
|         public String getText() { | ||||
|             return text; | ||||
|         } | ||||
|  | ||||
|         public void setText(String text) { | ||||
|             this.text = text; | ||||
|         } | ||||
|  | ||||
|         public String getThreadId() { | ||||
|             return threadId; | ||||
|         } | ||||
|  | ||||
|         public void setThreadId(String threadId) { | ||||
|             this.threadId = threadId; | ||||
|         } | ||||
|  | ||||
|         public int getTotalReplies() { | ||||
|             return totalReplies; | ||||
|         } | ||||
|  | ||||
|         public void setTotalReplies(int totalReplies) { | ||||
|             this.totalReplies = totalReplies; | ||||
|         } | ||||
|  | ||||
|         public int getTotalRepliesFromVideoAuthor() { | ||||
|             return totalRepliesFromVideoAuthor; | ||||
|         } | ||||
|  | ||||
|         public void setTotalRepliesFromVideoAuthor(int totalRepliesFromVideoAuthor) { | ||||
|             this.totalRepliesFromVideoAuthor = totalRepliesFromVideoAuthor; | ||||
|         } | ||||
|  | ||||
|         public String getUpdatedAt() { | ||||
| @@ -151,6 +153,14 @@ public class CommentData { | ||||
|         public void setUrl(String url) { | ||||
|             this.url = url; | ||||
|         } | ||||
|  | ||||
|         public String getVideoId() { | ||||
|             return videoId; | ||||
|         } | ||||
|  | ||||
|         public void setVideoId(String videoId) { | ||||
|             this.videoId = videoId; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static class NotificationComment { | ||||
|   | ||||
| @@ -5,6 +5,8 @@ import android.os.Parcelable; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| /* Copyright 2020 Thomas Schneider | ||||
|  * | ||||
|  * This file is a part of TubeLab | ||||
| @@ -22,7 +24,8 @@ import com.google.gson.annotations.SerializedName; | ||||
| @SuppressWarnings("unused") | ||||
| public class Avatar implements Parcelable { | ||||
|  | ||||
|     public static final Parcelable.Creator<Avatar> CREATOR = new Parcelable.Creator<Avatar>() { | ||||
|  | ||||
|     public static final Creator<Avatar> CREATOR = new Creator<Avatar>() { | ||||
|         @Override | ||||
|         public Avatar createFromParcel(Parcel source) { | ||||
|             return new Avatar(source); | ||||
| @@ -34,26 +37,28 @@ public class Avatar implements Parcelable { | ||||
|         } | ||||
|     }; | ||||
|     @SerializedName("createdAt") | ||||
|     private String createdAt; | ||||
|     private Date createdAt; | ||||
|     @SerializedName("path") | ||||
|     private String path; | ||||
|     @SerializedName("updatedAt") | ||||
|     private String updatedAt; | ||||
|     private Date updatedAt; | ||||
|  | ||||
|     public Avatar() { | ||||
|     } | ||||
|  | ||||
|     protected Avatar(Parcel in) { | ||||
|         this.createdAt = in.readString(); | ||||
|         long tmpCreatedAt = in.readLong(); | ||||
|         this.createdAt = tmpCreatedAt == -1 ? null : new Date(tmpCreatedAt); | ||||
|         this.path = in.readString(); | ||||
|         this.updatedAt = in.readString(); | ||||
|         long tmpUpdatedAt = in.readLong(); | ||||
|         this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt); | ||||
|     } | ||||
|  | ||||
|     public String getCreatedAt() { | ||||
|     public Date getCreatedAt() { | ||||
|         return createdAt; | ||||
|     } | ||||
|  | ||||
|     public void setCreatedAt(String createdAt) { | ||||
|     public void setCreatedAt(Date createdAt) { | ||||
|         this.createdAt = createdAt; | ||||
|     } | ||||
|  | ||||
| @@ -65,11 +70,11 @@ public class Avatar implements Parcelable { | ||||
|         this.path = path; | ||||
|     } | ||||
|  | ||||
|     public String getUpdatedAt() { | ||||
|     public Date getUpdatedAt() { | ||||
|         return updatedAt; | ||||
|     } | ||||
|  | ||||
|     public void setUpdatedAt(String updatedAt) { | ||||
|     public void setUpdatedAt(Date updatedAt) { | ||||
|         this.updatedAt = updatedAt; | ||||
|     } | ||||
|  | ||||
| @@ -80,8 +85,8 @@ public class Avatar implements Parcelable { | ||||
|  | ||||
|     @Override | ||||
|     public void writeToParcel(Parcel dest, int flags) { | ||||
|         dest.writeString(this.createdAt); | ||||
|         dest.writeLong(this.createdAt != null ? this.createdAt.getTime() : -1); | ||||
|         dest.writeString(this.path); | ||||
|         dest.writeString(this.updatedAt); | ||||
|         dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,162 @@ | ||||
| package app.fedilab.fedilabtube.client.entities; | ||||
| /* 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 com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| public class NotificationSettings { | ||||
|  | ||||
|     @SerializedName("abuseAsModerator") | ||||
|     private int abuseAsModerator; | ||||
|     @SerializedName("abuseNewMessage") | ||||
|     private int abuseNewMessage; | ||||
|     @SerializedName("abuseStateChange") | ||||
|     private int abuseStateChange; | ||||
|     @SerializedName("autoInstanceFollowing") | ||||
|     private int autoInstanceFollowing; | ||||
|     @SerializedName("blacklistOnMyVideo") | ||||
|     private int blacklistOnMyVideo; | ||||
|     @SerializedName("commentMention") | ||||
|     private int commentMention; | ||||
|     @SerializedName("myVideoImportFinished") | ||||
|     private int myVideoImportFinished; | ||||
|     @SerializedName("myVideoPublished") | ||||
|     private int myVideoPublished; | ||||
|     @SerializedName("newCommentOnMyVideo") | ||||
|     private int newCommentOnMyVideo; | ||||
|     @SerializedName("newFollow") | ||||
|     private int newFollow; | ||||
|     @SerializedName("newInstanceFollower") | ||||
|     private int newInstanceFollower; | ||||
|     @SerializedName("newUserRegistration") | ||||
|     private int newUserRegistration; | ||||
|     @SerializedName("newVideoFromSubscription") | ||||
|     private int newVideoFromSubscription; | ||||
|     @SerializedName("videoAutoBlacklistAsModerator") | ||||
|     private int videoAutoBlacklistAsModerator; | ||||
|  | ||||
|  | ||||
|     public int getAbuseAsModerator() { | ||||
|         return abuseAsModerator; | ||||
|     } | ||||
|  | ||||
|     public void setAbuseAsModerator(int abuseAsModerator) { | ||||
|         this.abuseAsModerator = abuseAsModerator; | ||||
|     } | ||||
|  | ||||
|     public int getAbuseNewMessage() { | ||||
|         return abuseNewMessage; | ||||
|     } | ||||
|  | ||||
|     public void setAbuseNewMessage(int abuseNewMessage) { | ||||
|         this.abuseNewMessage = abuseNewMessage; | ||||
|     } | ||||
|  | ||||
|     public int getAbuseStateChange() { | ||||
|         return abuseStateChange; | ||||
|     } | ||||
|  | ||||
|     public void setAbuseStateChange(int abuseStateChange) { | ||||
|         this.abuseStateChange = abuseStateChange; | ||||
|     } | ||||
|  | ||||
|     public int getAutoInstanceFollowing() { | ||||
|         return autoInstanceFollowing; | ||||
|     } | ||||
|  | ||||
|     public void setAutoInstanceFollowing(int autoInstanceFollowing) { | ||||
|         this.autoInstanceFollowing = autoInstanceFollowing; | ||||
|     } | ||||
|  | ||||
|     public int getBlacklistOnMyVideo() { | ||||
|         return blacklistOnMyVideo; | ||||
|     } | ||||
|  | ||||
|     public void setBlacklistOnMyVideo(int blacklistOnMyVideo) { | ||||
|         this.blacklistOnMyVideo = blacklistOnMyVideo; | ||||
|     } | ||||
|  | ||||
|     public int getCommentMention() { | ||||
|         return commentMention; | ||||
|     } | ||||
|  | ||||
|     public void setCommentMention(int commentMention) { | ||||
|         this.commentMention = commentMention; | ||||
|     } | ||||
|  | ||||
|     public int getMyVideoImportFinished() { | ||||
|         return myVideoImportFinished; | ||||
|     } | ||||
|  | ||||
|     public void setMyVideoImportFinished(int myVideoImportFinished) { | ||||
|         this.myVideoImportFinished = myVideoImportFinished; | ||||
|     } | ||||
|  | ||||
|     public int getMyVideoPublished() { | ||||
|         return myVideoPublished; | ||||
|     } | ||||
|  | ||||
|     public void setMyVideoPublished(int myVideoPublished) { | ||||
|         this.myVideoPublished = myVideoPublished; | ||||
|     } | ||||
|  | ||||
|     public int getNewCommentOnMyVideo() { | ||||
|         return newCommentOnMyVideo; | ||||
|     } | ||||
|  | ||||
|     public void setNewCommentOnMyVideo(int newCommentOnMyVideo) { | ||||
|         this.newCommentOnMyVideo = newCommentOnMyVideo; | ||||
|     } | ||||
|  | ||||
|     public int getNewFollow() { | ||||
|         return newFollow; | ||||
|     } | ||||
|  | ||||
|     public void setNewFollow(int newFollow) { | ||||
|         this.newFollow = newFollow; | ||||
|     } | ||||
|  | ||||
|     public int getNewInstanceFollower() { | ||||
|         return newInstanceFollower; | ||||
|     } | ||||
|  | ||||
|     public void setNewInstanceFollower(int newInstanceFollower) { | ||||
|         this.newInstanceFollower = newInstanceFollower; | ||||
|     } | ||||
|  | ||||
|     public int getNewUserRegistration() { | ||||
|         return newUserRegistration; | ||||
|     } | ||||
|  | ||||
|     public void setNewUserRegistration(int newUserRegistration) { | ||||
|         this.newUserRegistration = newUserRegistration; | ||||
|     } | ||||
|  | ||||
|     public int getNewVideoFromSubscription() { | ||||
|         return newVideoFromSubscription; | ||||
|     } | ||||
|  | ||||
|     public void setNewVideoFromSubscription(int newVideoFromSubscription) { | ||||
|         this.newVideoFromSubscription = newVideoFromSubscription; | ||||
|     } | ||||
|  | ||||
|     public int getVideoAutoBlacklistAsModerator() { | ||||
|         return videoAutoBlacklistAsModerator; | ||||
|     } | ||||
|  | ||||
|     public void setVideoAutoBlacklistAsModerator(int videoAutoBlacklistAsModerator) { | ||||
|         this.videoAutoBlacklistAsModerator = videoAutoBlacklistAsModerator; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,257 @@ | ||||
| package app.fedilab.fedilabtube.client.entities; | ||||
| /* 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 com.google.gson.annotations.SerializedName; | ||||
|  | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
|  | ||||
| import app.fedilab.fedilabtube.client.data.AccountData.Account; | ||||
| import app.fedilab.fedilabtube.client.data.ChannelData; | ||||
|  | ||||
| public class UserMe { | ||||
|  | ||||
|     @SerializedName("account") | ||||
|     private Account account; | ||||
|     @SerializedName("autoPlayNextVideo") | ||||
|     private boolean autoPlayNextVideo; | ||||
|     @SerializedName("autoPlayNextVideoPlaylist") | ||||
|     private boolean autoPlayNextVideoPlaylist; | ||||
|     @SerializedName("blocked") | ||||
|     private boolean blocked; | ||||
|     @SerializedName("blockedReason") | ||||
|     private String blockedReason; | ||||
|     @SerializedName("createdAt") | ||||
|     private Date createdAt; | ||||
|     @SerializedName("email") | ||||
|     private String email; | ||||
|     @SerializedName("emailVerified") | ||||
|     private String emailVerified; | ||||
|     @SerializedName("id") | ||||
|     private String id; | ||||
|     @SerializedName("lastLoginDate") | ||||
|     private Date lastLoginDate; | ||||
|     @SerializedName("noInstanceConfigWarningModal") | ||||
|     private boolean noInstanceConfigWarningModal; | ||||
|     @SerializedName("noWelcomeModal") | ||||
|     private boolean noWelcomeModal; | ||||
|     @SerializedName("notificationSettings") | ||||
|     private NotificationSettings notificationSettings; | ||||
|     @SerializedName("nsfwPolicy") | ||||
|     private String nsfwPolicy; | ||||
|     @SerializedName("role") | ||||
|     private int role; | ||||
|     @SerializedName("roleLabel") | ||||
|     private String roleLabel; | ||||
|     @SerializedName("username") | ||||
|     private String username; | ||||
|     @SerializedName("videoChannels") | ||||
|     private List<ChannelData.Channel> videoChannels; | ||||
|     @SerializedName("videoLanguages") | ||||
|     private List<String> videoLanguages; | ||||
|     @SerializedName("videoQuota") | ||||
|     private String videoQuota; | ||||
|     @SerializedName("videoQuotaDaily") | ||||
|     private String videoQuotaDaily; | ||||
|     @SerializedName("videosHistoryEnabled") | ||||
|     private boolean videosHistoryEnabled; | ||||
|     @SerializedName("webTorrentEnabled") | ||||
|     private boolean webTorrentEnabled; | ||||
|  | ||||
|     public Account getAccount() { | ||||
|         return account; | ||||
|     } | ||||
|  | ||||
|     public void setAccount(Account account) { | ||||
|         this.account = account; | ||||
|     } | ||||
|  | ||||
|     public boolean isAutoPlayNextVideo() { | ||||
|         return autoPlayNextVideo; | ||||
|     } | ||||
|  | ||||
|     public void setAutoPlayNextVideo(boolean autoPlayNextVideo) { | ||||
|         this.autoPlayNextVideo = autoPlayNextVideo; | ||||
|     } | ||||
|  | ||||
|     public boolean isAutoPlayNextVideoPlaylist() { | ||||
|         return autoPlayNextVideoPlaylist; | ||||
|     } | ||||
|  | ||||
|     public void setAutoPlayNextVideoPlaylist(boolean autoPlayNextVideoPlaylist) { | ||||
|         this.autoPlayNextVideoPlaylist = autoPlayNextVideoPlaylist; | ||||
|     } | ||||
|  | ||||
|     public boolean isBlocked() { | ||||
|         return blocked; | ||||
|     } | ||||
|  | ||||
|     public void setBlocked(boolean blocked) { | ||||
|         this.blocked = blocked; | ||||
|     } | ||||
|  | ||||
|     public String getBlockedReason() { | ||||
|         return blockedReason; | ||||
|     } | ||||
|  | ||||
|     public void setBlockedReason(String blockedReason) { | ||||
|         this.blockedReason = blockedReason; | ||||
|     } | ||||
|  | ||||
|     public Date getCreatedAt() { | ||||
|         return createdAt; | ||||
|     } | ||||
|  | ||||
|     public void setCreatedAt(Date createdAt) { | ||||
|         this.createdAt = createdAt; | ||||
|     } | ||||
|  | ||||
|     public String getEmail() { | ||||
|         return email; | ||||
|     } | ||||
|  | ||||
|     public void setEmail(String email) { | ||||
|         this.email = email; | ||||
|     } | ||||
|  | ||||
|     public String getEmailVerified() { | ||||
|         return emailVerified; | ||||
|     } | ||||
|  | ||||
|     public void setEmailVerified(String emailVerified) { | ||||
|         this.emailVerified = emailVerified; | ||||
|     } | ||||
|  | ||||
|     public String getId() { | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     public void setId(String id) { | ||||
|         this.id = id; | ||||
|     } | ||||
|  | ||||
|     public Date getLastLoginDate() { | ||||
|         return lastLoginDate; | ||||
|     } | ||||
|  | ||||
|     public void setLastLoginDate(Date lastLoginDate) { | ||||
|         this.lastLoginDate = lastLoginDate; | ||||
|     } | ||||
|  | ||||
|     public boolean isNoInstanceConfigWarningModal() { | ||||
|         return noInstanceConfigWarningModal; | ||||
|     } | ||||
|  | ||||
|     public void setNoInstanceConfigWarningModal(boolean noInstanceConfigWarningModal) { | ||||
|         this.noInstanceConfigWarningModal = noInstanceConfigWarningModal; | ||||
|     } | ||||
|  | ||||
|     public boolean isNoWelcomeModal() { | ||||
|         return noWelcomeModal; | ||||
|     } | ||||
|  | ||||
|     public void setNoWelcomeModal(boolean noWelcomeModal) { | ||||
|         this.noWelcomeModal = noWelcomeModal; | ||||
|     } | ||||
|  | ||||
|     public NotificationSettings getNotificationSettings() { | ||||
|         return notificationSettings; | ||||
|     } | ||||
|  | ||||
|     public void setNotificationSettings(NotificationSettings notificationSettings) { | ||||
|         this.notificationSettings = notificationSettings; | ||||
|     } | ||||
|  | ||||
|     public String getNsfwPolicy() { | ||||
|         return nsfwPolicy; | ||||
|     } | ||||
|  | ||||
|     public void setNsfwPolicy(String nsfwPolicy) { | ||||
|         this.nsfwPolicy = nsfwPolicy; | ||||
|     } | ||||
|  | ||||
|     public int getRole() { | ||||
|         return role; | ||||
|     } | ||||
|  | ||||
|     public void setRole(int role) { | ||||
|         this.role = role; | ||||
|     } | ||||
|  | ||||
|     public String getRoleLabel() { | ||||
|         return roleLabel; | ||||
|     } | ||||
|  | ||||
|     public void setRoleLabel(String roleLabel) { | ||||
|         this.roleLabel = roleLabel; | ||||
|     } | ||||
|  | ||||
|     public String getUsername() { | ||||
|         return username; | ||||
|     } | ||||
|  | ||||
|     public void setUsername(String username) { | ||||
|         this.username = username; | ||||
|     } | ||||
|  | ||||
|     public List<ChannelData.Channel> getVideoChannels() { | ||||
|         return videoChannels; | ||||
|     } | ||||
|  | ||||
|     public void setVideoChannels(List<ChannelData.Channel> videoChannels) { | ||||
|         this.videoChannels = videoChannels; | ||||
|     } | ||||
|  | ||||
|     public List<String> getVideoLanguages() { | ||||
|         return videoLanguages; | ||||
|     } | ||||
|  | ||||
|     public void setVideoLanguages(List<String> videoLanguages) { | ||||
|         this.videoLanguages = videoLanguages; | ||||
|     } | ||||
|  | ||||
|     public String getVideoQuota() { | ||||
|         return videoQuota; | ||||
|     } | ||||
|  | ||||
|     public void setVideoQuota(String videoQuota) { | ||||
|         this.videoQuota = videoQuota; | ||||
|     } | ||||
|  | ||||
|     public String getVideoQuotaDaily() { | ||||
|         return videoQuotaDaily; | ||||
|     } | ||||
|  | ||||
|     public void setVideoQuotaDaily(String videoQuotaDaily) { | ||||
|         this.videoQuotaDaily = videoQuotaDaily; | ||||
|     } | ||||
|  | ||||
|     public boolean isVideosHistoryEnabled() { | ||||
|         return videosHistoryEnabled; | ||||
|     } | ||||
|  | ||||
|     public void setVideosHistoryEnabled(boolean videosHistoryEnabled) { | ||||
|         this.videosHistoryEnabled = videosHistoryEnabled; | ||||
|     } | ||||
|  | ||||
|     public boolean isWebTorrentEnabled() { | ||||
|         return webTorrentEnabled; | ||||
|     } | ||||
|  | ||||
|     public void setWebTorrentEnabled(boolean webTorrentEnabled) { | ||||
|         this.webTorrentEnabled = webTorrentEnabled; | ||||
|     } | ||||
| } | ||||
| @@ -91,8 +91,6 @@ public class ChannelListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|                         builder.setMessage(context.getString(R.string.action_channel_confirm_delete)); | ||||
|                         builder.setIcon(android.R.drawable.ic_dialog_alert) | ||||
|                                 .setPositiveButton(R.string.yes, (dialog, which) -> { | ||||
|                                     channels.remove(channel); | ||||
|                                     notifyDataSetChanged(); | ||||
|                                     new Thread(() -> { | ||||
|                                         new RetrofitPeertubeAPI(context).post(RetrofitPeertubeAPI.ActionType.DELETE_CHANNEL, channel.getName(), null); | ||||
|                                         Handler mainHandler = new Handler(Looper.getMainLooper()); | ||||
|   | ||||
| @@ -15,9 +15,11 @@ package app.fedilab.fedilabtube.drawer; | ||||
|  * see <http://www.gnu.org/licenses>. */ | ||||
|  | ||||
| import android.annotation.SuppressLint; | ||||
| import android.app.Activity; | ||||
| import android.content.Context; | ||||
| import android.content.SharedPreferences; | ||||
| import android.os.Build; | ||||
| import android.os.Handler; | ||||
| import android.os.Looper; | ||||
| import android.text.Html; | ||||
| import android.text.Spannable; | ||||
| import android.text.SpannableString; | ||||
| @@ -28,13 +30,14 @@ import android.view.LayoutInflater; | ||||
| import android.view.MotionEvent; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.EditText; | ||||
| import android.widget.ImageView; | ||||
| import android.widget.LinearLayout; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
|  | ||||
| import androidx.annotation.NonNull; | ||||
| import androidx.appcompat.app.AlertDialog; | ||||
| import androidx.appcompat.widget.PopupMenu; | ||||
| import androidx.core.content.ContextCompat; | ||||
| import androidx.lifecycle.LifecycleOwner; | ||||
| import androidx.lifecycle.ViewModelProvider; | ||||
| @@ -45,28 +48,24 @@ import java.util.List; | ||||
| import java.util.regex.Matcher; | ||||
| import java.util.regex.Pattern; | ||||
|  | ||||
| import app.fedilab.fedilabtube.PeertubeActivity; | ||||
| import app.fedilab.fedilabtube.R; | ||||
| import app.fedilab.fedilabtube.client.APIResponse; | ||||
| import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; | ||||
| import app.fedilab.fedilabtube.client.data.CommentData.Comment; | ||||
| import app.fedilab.fedilabtube.client.entities.Report; | ||||
| import app.fedilab.fedilabtube.helper.Helper; | ||||
| import app.fedilab.fedilabtube.viewmodel.PostActionsVM; | ||||
| import es.dmoral.toasty.Toasty; | ||||
|  | ||||
| import static android.content.Context.MODE_PRIVATE; | ||||
| import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.PEERTUBEDELETECOMMENT; | ||||
|  | ||||
|  | ||||
| public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | ||||
|  | ||||
|  | ||||
|     public AllCommentRemoved allCommentRemoved; | ||||
|     private Context context; | ||||
|     private List<Comment> comments; | ||||
|  | ||||
|     private CommentListAdapter commentListAdapter; | ||||
|  | ||||
|  | ||||
|     public CommentListAdapter(List<Comment> comments) { | ||||
|         this.comments = comments; | ||||
|         commentListAdapter = this; | ||||
| @@ -89,7 +88,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|  | ||||
|         context = parent.getContext(); | ||||
|         LayoutInflater layoutInflater = LayoutInflater.from(this.context); | ||||
|         return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status_compact, parent, false)); | ||||
|         return new ViewHolder(layoutInflater.inflate(R.layout.drawer_comment, parent, false)); | ||||
|     } | ||||
|  | ||||
|     @SuppressLint({"SetJavaScriptEnabled", "ClickableViewAccessibility"}) | ||||
| @@ -97,9 +96,6 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|     public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) { | ||||
|  | ||||
|         context = viewHolder.itemView.getContext(); | ||||
|         final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); | ||||
|         final String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); | ||||
|  | ||||
|  | ||||
|         final ViewHolder holder = (ViewHolder) viewHolder; | ||||
|  | ||||
| @@ -108,26 +104,50 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|  | ||||
|         if (comment == null) | ||||
|             return; | ||||
|         if (comment.getAccount() != null && comment.getAccount().getId().equals(userId)) | ||||
|             holder.status_peertube_delete.setVisibility(View.VISIBLE); | ||||
|         else | ||||
|             holder.status_peertube_delete.setVisibility(View.GONE); | ||||
|         holder.status_peertube_delete.setOnClickListener(v -> { | ||||
|             AlertDialog.Builder builderInner; | ||||
|             builderInner = new AlertDialog.Builder(context); | ||||
|             builderInner.setTitle(R.string.delete_comment); | ||||
|             builderInner.setMessage(R.string.delete_comment_confirm); | ||||
|             builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); | ||||
|             builderInner.setPositiveButton(R.string.yes, (dialog, which) -> { | ||||
|                 PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class); | ||||
|                 viewModel.post(PEERTUBEDELETECOMMENT, PeertubeActivity.video_id, comment.getId()).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(PEERTUBEDELETECOMMENT, apiResponse)); | ||||
|  | ||||
|  | ||||
|         holder.more_actions.setOnClickListener(view -> { | ||||
|             PopupMenu popup = new PopupMenu(context, holder.more_actions); | ||||
|             popup.getMenuInflater() | ||||
|                     .inflate(R.menu.comment_menu, popup.getMenu()); | ||||
|             if (!Helper.isOwner(context, comment.getAccount())) { | ||||
|                 popup.getMenu().findItem(R.id.action_delete).setVisible(false); | ||||
|             } | ||||
|             popup.setOnMenuItemClickListener(item -> { | ||||
|                 switch (item.getItemId()) { | ||||
|                     case R.id.action_delete: | ||||
|                         android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(context); | ||||
|                         builder.setTitle(R.string.delete_comment); | ||||
|                         builder.setMessage(R.string.delete_comment_confirm); | ||||
|                         builder.setIcon(android.R.drawable.ic_dialog_alert) | ||||
|                                 .setPositiveButton(R.string.delete, (dialog, which) -> { | ||||
|                                     new Thread(() -> { | ||||
|                                         new RetrofitPeertubeAPI(context).post(RetrofitPeertubeAPI.ActionType.PEERTUBEDELETECOMMENT, comment.getVideoId(), comment.getId()); | ||||
|                                         Handler mainHandler = new Handler(Looper.getMainLooper()); | ||||
|                                         Runnable myRunnable = () -> { | ||||
|                                             comments.remove(comment); | ||||
|                                             notifyDataSetChanged(); | ||||
|                                             if (comments.size() == 0) { | ||||
|                                                 allCommentRemoved.onAllCommentRemoved(); | ||||
|                                             } | ||||
|                                         }; | ||||
|                                         mainHandler.post(myRunnable); | ||||
|                                     }).start(); | ||||
|  | ||||
|                                     dialog.dismiss(); | ||||
|                                 }) | ||||
|                                 .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()) | ||||
|                                 .show(); | ||||
|                         break; | ||||
|                     case R.id.action_report: | ||||
|                         reportComment(comment); | ||||
|                         break; | ||||
|                 } | ||||
|                 return true; | ||||
|             }); | ||||
|             builderInner.show(); | ||||
|             popup.show(); | ||||
|         }); | ||||
|  | ||||
|  | ||||
|         holder.status_content.setOnTouchListener((view, motionEvent) -> { | ||||
|         holder.comment_content.setOnTouchListener((view, motionEvent) -> { | ||||
|             if (motionEvent.getAction() == MotionEvent.ACTION_UP && !view.hasFocus()) { | ||||
|                 try { | ||||
|                     view.requestFocus(); | ||||
| @@ -139,17 +159,16 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|  | ||||
|         Spanned commentSpan; | ||||
|         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) | ||||
|             commentSpan = Html.fromHtml(comment.getDescription(), Html.FROM_HTML_MODE_LEGACY); | ||||
|             commentSpan = Html.fromHtml(comment.getText(), Html.FROM_HTML_MODE_LEGACY); | ||||
|         else | ||||
|             commentSpan = Html.fromHtml(comment.getDescription()); | ||||
|         holder.status_content.setText(commentSpan, TextView.BufferType.SPANNABLE); | ||||
|             commentSpan = Html.fromHtml(comment.getText()); | ||||
|         holder.comment_content.setText(commentSpan, TextView.BufferType.SPANNABLE); | ||||
|  | ||||
|         holder.status_content.setMovementMethod(LinkMovementMethod.getInstance()); | ||||
|         holder.comment_content.setMovementMethod(LinkMovementMethod.getInstance()); | ||||
|  | ||||
|         holder.comment_account_displayname.setText(comment.getAccount().getDisplayName()); | ||||
|  | ||||
|         holder.status_account_displayname.setVisibility(View.GONE); | ||||
|         if (comment.getAccount() != null) { | ||||
|             holder.status_account_displayname_owner.setText(comment.getAccount().getUsername().replace("@", ""), TextView.BufferType.SPANNABLE); | ||||
|             Spannable wordtoSpan; | ||||
|             Pattern hashAcct; | ||||
|             wordtoSpan = new SpannableString("@" + comment.getAccount().getAcct()); | ||||
| @@ -161,16 +180,14 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|                 if (wordtoSpan.length() >= matchEnd && matchStart < matchEnd) { | ||||
|                     wordtoSpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, android.R.color.darker_gray)), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); | ||||
|                 } | ||||
|  | ||||
|             } | ||||
|             holder.status_account_username.setText(wordtoSpan); | ||||
|             holder.comment_account_username.setText(wordtoSpan); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         holder.status_toot_date.setText(Helper.dateDiff(context, comment.getCreatedAt())); | ||||
|         holder.comment_date.setText(Helper.dateDiff(context, comment.getCreatedAt())); | ||||
|  | ||||
|  | ||||
|         Helper.loadGiF(context, comment.getAccount().getAvatar().getPath(), holder.status_account_profile); | ||||
|         Helper.loadGiF(context, comment.getAccount().getAvatar() != null ? comment.getAccount().getAvatar().getPath() : null, holder.comment_account_profile); | ||||
|     } | ||||
|  | ||||
|     public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, APIResponse apiResponse) { | ||||
| @@ -179,7 +196,6 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|             Toasty.error(context, apiResponse.getError().getError(), Toast.LENGTH_LONG).show(); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         if (statusAction == RetrofitPeertubeAPI.ActionType.PEERTUBEDELETECOMMENT) { | ||||
|             int position = 0; | ||||
|             for (Comment comment : comments) { | ||||
| @@ -190,33 +206,61 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo | ||||
|                 } | ||||
|                 position++; | ||||
|             } | ||||
|         } else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_COMMENT) { | ||||
|             Toasty.success(context, context.getString(R.string.successful_report_comment), Toasty.LENGTH_LONG).show(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     private void reportComment(Comment comment) { | ||||
|         androidx.appcompat.app.AlertDialog.Builder dialogBuilder = new androidx.appcompat.app.AlertDialog.Builder(context); | ||||
|         LayoutInflater inflater = ((Activity) context).getLayoutInflater(); | ||||
|         View dialogView = inflater.inflate(R.layout.popup_report, new LinearLayout(context), false); | ||||
|         dialogBuilder.setView(dialogView); | ||||
|         EditText report_content = dialogView.findViewById(R.id.report_content); | ||||
|         dialogBuilder.setNeutralButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); | ||||
|         dialogBuilder.setPositiveButton(R.string.report, (dialog, id) -> { | ||||
|             if (report_content.getText().toString().trim().length() == 0) { | ||||
|                 Toasty.info(context, context.getString(R.string.report_comment_size), Toasty.LENGTH_LONG).show(); | ||||
|             } else { | ||||
|                 PostActionsVM viewModel = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class); | ||||
|                 Report report = new Report(); | ||||
|                 Report.CommentReport commentReport = new Report.CommentReport(); | ||||
|                 commentReport.setId(comment.getId()); | ||||
|                 report.setComment(commentReport); | ||||
|                 report.setReason(report_content.getText().toString()); | ||||
|                 viewModel.report(report).observe((LifecycleOwner) context, apiResponse -> manageVIewPostActions(RetrofitPeertubeAPI.ActionType.REPORT_COMMENT, apiResponse)); | ||||
|                 dialog.dismiss(); | ||||
|             } | ||||
|         }); | ||||
|         androidx.appcompat.app.AlertDialog alertDialog2 = dialogBuilder.create(); | ||||
|         alertDialog2.show(); | ||||
|     } | ||||
|  | ||||
|     public interface AllCommentRemoved { | ||||
|         void onAllCommentRemoved(); | ||||
|     } | ||||
|  | ||||
|     static class ViewHolder extends RecyclerView.ViewHolder { | ||||
|  | ||||
|         TextView status_content; | ||||
|         TextView status_account_username; | ||||
|         TextView status_account_displayname, status_account_displayname_owner; | ||||
|         ImageView status_account_profile; | ||||
|         TextView status_toot_date; | ||||
|         TextView comment_content; | ||||
|         TextView comment_account_username; | ||||
|         TextView comment_account_displayname; | ||||
|         ImageView comment_account_profile; | ||||
|         TextView comment_date; | ||||
|         LinearLayout main_container; | ||||
|         LinearLayout status_content_container; | ||||
|         TextView status_peertube_delete; | ||||
|         TextView more_actions; | ||||
|  | ||||
|         @SuppressLint("SetJavaScriptEnabled") | ||||
|         ViewHolder(View itemView) { | ||||
|             super(itemView); | ||||
|             status_content = itemView.findViewById(R.id.status_content); | ||||
|             status_account_username = itemView.findViewById(R.id.status_account_username); | ||||
|             status_account_displayname = itemView.findViewById(R.id.status_account_displayname); | ||||
|             status_account_displayname_owner = itemView.findViewById(R.id.status_account_displayname_owner); | ||||
|             status_account_profile = itemView.findViewById(R.id.status_account_profile); | ||||
|             status_toot_date = itemView.findViewById(R.id.status_toot_date); | ||||
|             comment_content = itemView.findViewById(R.id.comment_content); | ||||
|             comment_account_username = itemView.findViewById(R.id.comment_account_username); | ||||
|             comment_account_profile = itemView.findViewById(R.id.comment_account_profile); | ||||
|             comment_account_displayname = itemView.findViewById(R.id.comment_account_displayname); | ||||
|             comment_date = itemView.findViewById(R.id.comment_date); | ||||
|             main_container = itemView.findViewById(R.id.main_container); | ||||
|             status_content_container = itemView.findViewById(R.id.status_content_container); | ||||
|             status_peertube_delete = itemView.findViewById(R.id.status_peertube_delete); | ||||
|             more_actions = itemView.findViewById(R.id.more_actions); | ||||
|  | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import android.view.LayoutInflater; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.RelativeLayout; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toast; | ||||
|  | ||||
| import androidx.annotation.NonNull; | ||||
| @@ -75,6 +76,8 @@ public class DisplayNotificationsFragment extends Fragment { | ||||
|         mainLoader = rootView.findViewById(R.id.loader); | ||||
|         nextElementLoader = rootView.findViewById(R.id.loading_next); | ||||
|         textviewNoAction = rootView.findViewById(R.id.no_action); | ||||
|         TextView no_action_text = rootView.findViewById(R.id.no_action_text); | ||||
|         no_action_text.setText(context.getString(R.string.no_notifications)); | ||||
|         mainLoader.setVisibility(View.VISIBLE); | ||||
|         nextElementLoader.setVisibility(View.GONE); | ||||
|         peertubeNotificationsListAdapter = new PeertubeNotificationsListAdapter(this.notifications); | ||||
|   | ||||
| @@ -106,6 +106,7 @@ public class Helper { | ||||
|     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"; | ||||
| @@ -670,4 +671,15 @@ public class Helper { | ||||
|     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); | ||||
|         String userName = sharedpreferences.getString(Helper.PREF_KEY_NAME, ""); | ||||
|         String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, ""); | ||||
|         if (instance != null && userName != null) { | ||||
|             return account.getUsername().compareTo(userName) == 0 && account.getHost().compareTo(instance) == 0; | ||||
|         } else { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -106,6 +106,7 @@ public class AccountDAO { | ||||
|             account.setCreatedAt(new Date()); | ||||
|         if (account.getDescription() == null) | ||||
|             account.setDescription(""); | ||||
|         values.put(Sqlite.COL_USER_ID, account.getId()); | ||||
|         values.put(Sqlite.COL_USERNAME, account.getUsername()); | ||||
|         values.put(Sqlite.COL_ACCT, account.getUsername() + "@" + account.getHost()); | ||||
|         values.put(Sqlite.COL_DISPLAYED_NAME, account.getDisplayName()); | ||||
| @@ -113,20 +114,18 @@ public class AccountDAO { | ||||
|         values.put(Sqlite.COL_FOLLOWING_COUNT, account.getFollowingCount()); | ||||
|         values.put(Sqlite.COL_NOTE, account.getDescription()); | ||||
|         values.put(Sqlite.COL_URL, account.getUrl()); | ||||
|         values.put(Sqlite.COL_AVATAR, account.getAvatar().getPath()); | ||||
|         values.put(Sqlite.COL_AVATAR, account.getAvatar() != null ? account.getAvatar().getPath() : "null"); | ||||
|         values.put(Sqlite.COL_CREATED_AT, Helper.dateToString(account.getCreatedAt())); | ||||
|         if (account.getClient_id() != null && account.getClient_secret() != null) { | ||||
|             values.put(Sqlite.COL_CLIENT_ID, account.getClient_id()); | ||||
|             values.put(Sqlite.COL_CLIENT_SECRET, account.getClient_secret()); | ||||
|         } | ||||
|         if (account.getRefresh_token() != null) { | ||||
|             values.put(Sqlite.COL_REFRESH_TOKEN, account.getRefresh_token()); | ||||
|         } | ||||
|         if (account.getToken() != null) | ||||
|             values.put(Sqlite.COL_OAUTHTOKEN, account.getToken()); | ||||
|  | ||||
|         try { | ||||
|             return db.update(Sqlite.TABLE_USER_ACCOUNT, | ||||
|                 values, Sqlite.COL_USER_ID + " =  ? AND " + Sqlite.COL_INSTANCE + " =?", | ||||
|                 new String[]{account.getId(), account.getHost()}); | ||||
|                     values, Sqlite.COL_USERNAME + " =  ? AND " + Sqlite.COL_INSTANCE + " =?", | ||||
|                     new String[]{account.getUsername(), account.getHost()}); | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|             return -1; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
| @@ -248,23 +247,6 @@ public class AccountDAO { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns an Account by token | ||||
|      * | ||||
|      * @param userId   String | ||||
|      * @param instance String | ||||
|      * @return Account | ||||
|      */ | ||||
|     public Account getUniqAccount(String userId, String instance) { | ||||
|  | ||||
|         try { | ||||
|             Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_USER_ID + " = \"" + userId + "\" AND " + Sqlite.COL_INSTANCE + " = \"" + instance + "\"", null, null, null, null, "1"); | ||||
|             return cursorToUser(c); | ||||
|         } catch (Exception e) { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * Test if the current user is already stored in data base | ||||
|   | ||||
| @@ -73,13 +73,10 @@ public class PlaylistsVM extends AndroidViewModel { | ||||
|         new Thread(() -> { | ||||
|             try { | ||||
|                 SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); | ||||
|                 String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); | ||||
|                 String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); | ||||
|                 String instance = Helper.getLiveInstance(_mContext); | ||||
|                 SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); | ||||
|                 Account account = new AccountDAO(_mContext, db).getUniqAccount(userId, instance); | ||||
|                 if (account == null) { | ||||
|                     account = new AccountDAO(_mContext, db).getUniqAccount(userId, Helper.getPeertubeUrl(instance)); | ||||
|                 } | ||||
|                 Account account = new AccountDAO(_mContext, db).getAccountByToken(token); | ||||
|                 int statusCode = -1; | ||||
|                 APIResponse apiResponse; | ||||
|                 if (account == null) { | ||||
|   | ||||
| @@ -15,17 +15,17 @@ | ||||
|     see <http://www.gnu.org/licenses>. | ||||
| --> | ||||
| <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:layout_margin="@dimen/fab_margin"> | ||||
|  | ||||
|     <androidx.coordinatorlayout.widget.CoordinatorLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         tools:context=".InstancePickerActivity" | ||||
|         > | ||||
|         tools:context=".InstancePickerActivity"> | ||||
|  | ||||
|         <androidx.constraintlayout.widget.ConstraintLayout | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
| @@ -125,14 +125,14 @@ | ||||
|             </RelativeLayout> | ||||
|  | ||||
|             <LinearLayout | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/filters_container" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_marginTop="10dp" | ||||
|                 android:layout_height="0dp" | ||||
|                 android:orientation="vertical"> | ||||
|                 android:layout_marginTop="10dp" | ||||
|                 android:orientation="vertical" | ||||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/filters_container"> | ||||
|  | ||||
|                 <androidx.recyclerview.widget.RecyclerView | ||||
|                     android:id="@+id/lv_instances" | ||||
|   | ||||
| @@ -63,10 +63,10 @@ | ||||
|  | ||||
|         <LinearLayout | ||||
|             android:id="@+id/title_login_instance" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_width="match_parent" | ||||
|             android:orientation="horizontal" | ||||
|             android:layout_marginTop="20dp"> | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="20dp" | ||||
|             android:orientation="horizontal"> | ||||
|  | ||||
|             <TextView | ||||
|                 android:layout_width="150dp" | ||||
|   | ||||
| @@ -156,6 +156,7 @@ | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginTop="5dp" | ||||
|         app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | ||||
|  | ||||
|     <com.google.android.material.floatingactionbutton.FloatingActionButton | ||||
|         android:id="@+id/action_button" | ||||
|         android:layout_width="wrap_content" | ||||
|   | ||||
| @@ -50,8 +50,8 @@ | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="10dp" | ||||
|             android:singleLine="true" | ||||
|             android:ellipsize="end" | ||||
|             android:singleLine="true" | ||||
|             android:textSize="16sp" /> | ||||
|  | ||||
|     </LinearLayout> | ||||
| @@ -63,7 +63,6 @@ | ||||
|         android:layout_height="40dp" | ||||
|         android:layout_gravity="center" | ||||
|         android:contentDescription="@string/display_more" | ||||
|         android:src="@drawable/ic_baseline_more_vert_24" | ||||
|          /> | ||||
|         android:src="@drawable/ic_baseline_more_vert_24" /> | ||||
|  | ||||
| </LinearLayout> | ||||
							
								
								
									
										98
									
								
								app/src/main/res/layout/drawer_comment.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								app/src/main/res/layout/drawer_comment.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?><!-- | ||||
|     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>. | ||||
| --> | ||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:id="@+id/main_container" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
|     android:divider="?android:dividerHorizontal" | ||||
|     android:orientation="vertical" | ||||
|     android:showDividers="end"> | ||||
|  | ||||
|     <androidx.constraintlayout.widget.ConstraintLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content"> | ||||
|  | ||||
|         <ImageView | ||||
|             android:id="@+id/comment_account_profile" | ||||
|             android:layout_width="40dp" | ||||
|             android:layout_height="40dp" | ||||
|             android:layout_marginTop="5dp" | ||||
|             android:contentDescription="@string/profile_picture" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/comment_account_displayname" | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginStart="5dp" | ||||
|             android:singleLine="true" | ||||
|             android:textStyle="bold" | ||||
|             app:layout_constraintEnd_toStartOf="@+id/comment_date" | ||||
|             app:layout_constraintStart_toEndOf="@+id/comment_account_profile" | ||||
|             app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/comment_date" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="end" | ||||
|             android:layout_marginStart="2dp" | ||||
|             android:layout_weight="0" | ||||
|             android:gravity="end" | ||||
|             android:maxLines="1" | ||||
|             android:textSize="12sp" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/more_actions" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="center_horizontal" | ||||
|             android:gravity="end" | ||||
|             android:text="" | ||||
|             app:drawableTopCompat="@drawable/ic_baseline_more_vert_24" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintTop_toBottomOf="@+id/comment_date" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/comment_account_username" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="10dp" | ||||
|             android:ellipsize="end" | ||||
|             android:singleLine="true" | ||||
|             android:textSize="12sp" | ||||
|             app:layout_constraintBottom_toBottomOf="@+id/comment_account_profile" | ||||
|             app:layout_constraintStart_toEndOf="@+id/comment_account_profile" | ||||
|             app:layout_constraintTop_toBottomOf="@+id/comment_account_displayname" /> | ||||
|  | ||||
|         <TextView | ||||
|             android:id="@+id/comment_content" | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginTop="10dp" | ||||
|             android:textIsSelectable="true" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toBottomOf="@+id/comment_account_profile" /> | ||||
|  | ||||
|     </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|  | ||||
| </LinearLayout> | ||||
							
								
								
									
										14
									
								
								app/src/main/res/menu/comment_menu.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/src/main/res/menu/comment_menu.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||
|     <item | ||||
|         android:id="@+id/action_delete" | ||||
|         android:icon="@drawable/ic_baseline_delete_24" | ||||
|         android:title="@string/delete" | ||||
|         app:showAsAction="ifRoom" /> | ||||
|     <item | ||||
|         android:id="@+id/action_report" | ||||
|         android:icon="@drawable/ic_baseline_report_24" | ||||
|         android:title="@string/report" | ||||
|         app:showAsAction="ifRoom" /> | ||||
| </menu> | ||||
		Reference in New Issue
	
	Block a user