mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Fix issue #39 - Allow to display videos in smaller lists
This commit is contained in:
		| @@ -13,6 +13,10 @@ | ||||
|     <string name="set_autoplay_next_video_choice" translatable="false">set_autoplay_next_video_choice</string> | ||||
|     <string name="set_store_in_history" translatable="false">set_store_in_history</string> | ||||
|     <string name="set_play_screen_lock_choice" translatable="false">set_play_screen_lock_choice</string> | ||||
|     <string name="set_video_in_list_choice" translatable="false">set_video_in_list_choice</string> | ||||
|  | ||||
|     <string name="set_video_in_list">Vidéos dans une liste</string> | ||||
|     <string name="set_video_in_list_description">Change la mise en page pour afficher les vidéos dans une liste</string> | ||||
|  | ||||
|  | ||||
|     <string name="set_play_screen_lock">Verrouillage d\'écran</string> | ||||
|   | ||||
| @@ -12,6 +12,10 @@ | ||||
|     <string name="set_theme_choice" translatable="false">set_theme_choice</string> | ||||
|     <string name="set_fullscreen_choice" translatable="false">set_fullscreen_choice</string> | ||||
|     <string name="set_play_screen_lock_choice" translatable="false">set_play_screen_lock_choice</string> | ||||
|     <string name="set_video_in_list_choice" translatable="false">set_video_in_list_choice</string> | ||||
|  | ||||
|     <string name="set_video_in_list">Videos in list</string> | ||||
|     <string name="set_video_in_list_description">Change the layout for displaying videos in a list</string> | ||||
|  | ||||
|     <string name="set_play_screen_lock">Screen lock</string> | ||||
|     <string name="set_play_screen_lock_description">Keep playing videos when the screen is locked</string> | ||||
|   | ||||
| @@ -30,6 +30,7 @@ import android.widget.TextView; | ||||
| import androidx.annotation.NonNull; | ||||
| import androidx.appcompat.app.AlertDialog; | ||||
| import androidx.appcompat.widget.PopupMenu; | ||||
| import androidx.constraintlayout.widget.ConstraintLayout; | ||||
| import androidx.lifecycle.LifecycleOwner; | ||||
| import androidx.lifecycle.ViewModelProvider; | ||||
| import androidx.lifecycle.ViewModelStoreOwner; | ||||
| @@ -105,6 +106,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde | ||||
|  | ||||
|         assert userId != null; | ||||
|  | ||||
|         boolean videoInList = sharedpreferences.getBoolean(context.getString(R.string.set_video_in_list_choice), false); | ||||
|  | ||||
|         boolean ownVideos; | ||||
|         if (timelineType == TimelineVM.TimelineType.MY_VIDEOS) { | ||||
| @@ -126,7 +128,15 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde | ||||
|         holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt()))); | ||||
|         holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews()))); | ||||
|  | ||||
|         Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image); | ||||
|         if(videoInList) { | ||||
|             Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image_small); | ||||
|             holder.peertube_video_image_small.setVisibility(View.VISIBLE); | ||||
|             holder.preview_container.setVisibility(View.GONE); | ||||
|         }else{ | ||||
|             Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image); | ||||
|             holder.peertube_video_image_small.setVisibility(View.GONE); | ||||
|             holder.preview_container.setVisibility(View.VISIBLE); | ||||
|         } | ||||
|  | ||||
|         //For Overview Videos: boolean values for displaying title is managed in the fragment | ||||
|         if (video.isHasTitle()) { | ||||
| @@ -377,13 +387,15 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde | ||||
|  | ||||
|     static class ViewHolder extends RecyclerView.ViewHolder { | ||||
|         LinearLayout main_container, bottom_container; | ||||
|         ImageView peertube_profile, peertube_video_image; | ||||
|         ImageView peertube_profile, peertube_video_image, peertube_video_image_small; | ||||
|         TextView peertube_account_name, peertube_views, peertube_duration; | ||||
|         TextView peertube_title, peertube_date, header_title, more_actions; | ||||
|         ConstraintLayout preview_container; | ||||
|  | ||||
|         public ViewHolder(@NonNull View itemView) { | ||||
|             super(itemView); | ||||
|             peertube_account_name = itemView.findViewById(R.id.peertube_account_name); | ||||
|             peertube_video_image_small = itemView.findViewById(R.id.peertube_video_image_small); | ||||
|             peertube_title = itemView.findViewById(R.id.peertube_title); | ||||
|             peertube_video_image = itemView.findViewById(R.id.peertube_video_image); | ||||
|             peertube_profile = itemView.findViewById(R.id.peertube_profile); | ||||
| @@ -394,6 +406,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde | ||||
|             header_title = itemView.findViewById(R.id.header_title); | ||||
|             bottom_container = itemView.findViewById(R.id.bottom_container); | ||||
|             more_actions = itemView.findViewById(R.id.more_actions); | ||||
|             preview_container = itemView.findViewById(R.id.preview_container); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package app.fedilab.fedilabtube.fragment; | ||||
|  | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.SharedPreferences; | ||||
| import android.content.pm.PackageManager; | ||||
| import android.content.res.Resources; | ||||
| @@ -31,6 +32,9 @@ import java.util.LinkedHashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
|  | ||||
| import app.fedilab.fedilabtube.MainActivity; | ||||
| import app.fedilab.fedilabtube.PeertubeActivity; | ||||
| import app.fedilab.fedilabtube.R; | ||||
| import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; | ||||
| import app.fedilab.fedilabtube.client.entities.Error; | ||||
| @@ -199,6 +203,13 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared | ||||
|                 assert set_play_screen_lock_choice != null; | ||||
|                 editor.putBoolean(getString(R.string.set_play_screen_lock_choice), set_play_screen_lock_choice.isChecked()); | ||||
|             } | ||||
|             if (key.compareTo(getString(R.string.set_video_in_list_choice)) == 0) { | ||||
|                 SwitchPreference set_video_in_list_choice = findPreference(getString(R.string.set_video_in_list_choice)); | ||||
|                 assert set_video_in_list_choice != null; | ||||
|                 editor.putBoolean(getString(R.string.set_video_in_list_choice), set_video_in_list_choice.isChecked()); | ||||
|                 Intent intent = new Intent(getActivity(), MainActivity.class); | ||||
|                 startActivity(intent); | ||||
|             } | ||||
|             if (key.compareTo(getString(R.string.set_video_language_choice)) == 0) { | ||||
|                 MultiSelectListPreference set_video_language_choice = findPreference(getString(R.string.set_video_language_choice)); | ||||
|                 assert set_video_language_choice != null; | ||||
| @@ -349,6 +360,13 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Shared | ||||
|         assert set_play_screen_lock_choice != null; | ||||
|         set_play_screen_lock_choice.setChecked(playScreenLock); | ||||
|  | ||||
|  | ||||
|         //****** Display videos in a list ******* | ||||
|         boolean videosInList = sharedpref.getBoolean(getString(R.string.set_video_in_list_choice), false); | ||||
|         SwitchPreference set_video_in_list_choice = findPreference(getString(R.string.set_video_in_list_choice)); | ||||
|         assert set_video_in_list_choice != null; | ||||
|         set_video_in_list_choice.setChecked(videosInList); | ||||
|  | ||||
|         //****** Language filter  ********* | ||||
|         LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages()); | ||||
|         List<CharSequence> entriesLanguages = new ArrayList<>(); | ||||
|   | ||||
							
								
								
									
										10
									
								
								app/src/main/res/drawable/ic_baseline_view_list_24.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/src/main/res/drawable/ic_baseline_view_list_24.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:width="24dp" | ||||
|     android:height="24dp" | ||||
|     android:viewportWidth="24" | ||||
|     android:viewportHeight="24" | ||||
|     android:tint="?attr/colorControlNormal"> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M4,14h4v-4L4,10v4zM4,19h4v-4L4,15v4zM4,9h4L8,5L4,5v4zM9,14h12v-4L9,10v4zM9,19h12v-4L9,15v4zM9,5v4h12L21,5L9,5z"/> | ||||
| </vector> | ||||
| @@ -42,6 +42,7 @@ | ||||
|  | ||||
|     <androidx.constraintlayout.widget.ConstraintLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:id="@+id/preview_container" | ||||
|         android:layout_height="200dp"> | ||||
|  | ||||
|         <ImageView | ||||
| @@ -127,6 +128,17 @@ | ||||
|                     android:layout_marginStart="5dp" /> | ||||
|             </LinearLayout> | ||||
|         </LinearLayout> | ||||
|         <ImageView | ||||
|             android:id="@+id/peertube_video_image_small" | ||||
|             android:layout_width="80dp" | ||||
|             android:layout_height="80dp" | ||||
|             android:layout_marginStart="10dp" | ||||
|             android:layout_marginTop="10dp" | ||||
|             android:contentDescription="@string/image_preview" | ||||
|             android:gravity="center" | ||||
|             android:visibility="gone" | ||||
|             android:scaleType="centerCrop" | ||||
|             /> | ||||
|         <TextView | ||||
|             android:id="@+id/more_actions" | ||||
|             android:layout_width="wrap_content" | ||||
|   | ||||
| @@ -73,5 +73,10 @@ | ||||
|             android:key="@string/set_video_language_choice" | ||||
|             android:summary="@string/set_video_language_description" | ||||
|             android:title="@string/set_video_language" /> | ||||
|         <androidx.preference.SwitchPreference | ||||
|             android:icon="@drawable/ic_baseline_view_list_24" | ||||
|             android:key="@string/set_video_in_list_choice" | ||||
|             android:summary="@string/set_video_in_list_description" | ||||
|             android:title="@string/set_video_in_list" /> | ||||
|     </PreferenceCategory> | ||||
| </androidx.preference.PreferenceScreen> | ||||
		Reference in New Issue
	
	Block a user