Skip to content
Snippets Groups Projects
Commit e2e964e1 authored by Alexandre Perraud's avatar Alexandre Perraud
Browse files

Add Video Playlist Mode preference

parent 0c050d7f
No related branches found
No related tags found
No related merge requests found
......@@ -286,6 +286,8 @@
<string name="video_min_group_length_long">Long number of letters (9)</string>
<string name="force_list_portrait">No grid in portrait mode</string>
<string name="force_list_portrait_summary">Show videos in list instead of grid in portrait mode</string>
<string name="force_play_all_summary">Play all videos, starting with the one you clicked on</string>
<string name="force_play_all_title">Video playlist mode</string>
<string name="save_brightness_summary">Remember brightness level in video player</string>
<string name="save_brightness_title">Save brightness level for video</string>
<string name="enable_brightness_gesture_title">Brightness gesture</string>
......
......@@ -20,6 +20,11 @@
android:title="@string/force_list_portrait" />
<PreferenceCategory android:title="@string/controls_prefs_category">
<CheckBoxPreference
android:defaultValue="false"
android:key="force_play_all"
android:summary="@string/force_play_all_summary"
android:title="@string/force_play_all_title" />
<CheckBoxPreference
android:defaultValue="false"
android:key="save_brightness"
......
......@@ -236,20 +236,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
return true;
case R.id.video_list_play_all:
ArrayList<MediaWrapper> playList = new ArrayList<>();
ArrayList<MediaWrapper> videos = mVideoAdapter.getAll();
MediaWrapper mw;
int offset = 0;
for (int i = 0; i < videos.size(); ++i) {
mw = videos.get(i);
if (mw instanceof MediaGroup) {
for (MediaWrapper item : ((MediaGroup) mw).getAll())
playList.add(item);
if (i < position)
offset += ((MediaGroup)mw).size()-1;
} else
playList.add(mw);
}
MediaUtils.openList(getActivity(), playList, position+offset);
MediaUtils.openList(getActivity(), playList, mVideoAdapter.getListWithPosition(playList, position));
return true;
case R.id.video_list_info:
showInfoDialog(media);
......
......@@ -272,6 +272,22 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
return super.getItemViewType(position);
}
int getListWithPosition(ArrayList<MediaWrapper> list, int position) {
MediaWrapper mw;
int offset = 0;
for (int i = 0; i < getAll().size(); ++i) {
mw = getAll().get(i);
if (mw instanceof MediaGroup) {
for (MediaWrapper item : ((MediaGroup) mw).getAll())
list.add(item);
if (i < position)
offset += ((MediaGroup)mw).size()-1;
} else
list.add(mw);
}
return position+offset;
}
void setActionMode(boolean actionMode) {
mActionMode = actionMode;
if (!actionMode) {
......@@ -308,7 +324,13 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
((MainActivity)activity).showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, title);
} else {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
MediaUtils.openMedia(itemView.getContext(), media);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
if (settings.getBoolean("force_play_all", false)) {
ArrayList<MediaWrapper> playList = new ArrayList<>();
MediaUtils.openList(itemView.getContext(), playList, getListWithPosition(playList, getAdapterPosition()));
} else {
MediaUtils.openMedia(itemView.getContext(), media);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment