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

Set video group as an editable preference

(cherry picked from commit 957c50f7)
parent 17d924f4
No related branches found
No related tags found
No related merge requests found
......@@ -386,6 +386,12 @@
<string name="tv_ui_summary">Change UI to TV adapted theme</string>
<string name="lockscreen_cover_title">Media cover on Lockscreen</string>
<string name="lockscreen_cover_summary">When available, set the current media cover art as lockscreen wallpaper</string>
<string name="video_min_group_length_title">Group videos</string>
<string name="video_min_group_length_summary">Videos are grouped if their first letters are the same.</string>
<string name="video_min_group_length_disable">Disable</string>
<string name="video_min_group_length_first">First letter only</string>
<string name="video_min_group_length_short">Short number of letters (6)</string>
<string name="video_min_group_length_long">Long number of letters (9)</string>
<!--Accessibility-->
<string name="more_actions">More Actions</string>
......@@ -486,6 +492,20 @@
<item>3</item>
</string-array>
<string-array name="video_min_group_length_list" translatable="false">
<item>@string/video_min_group_length_disable</item>
<item>@string/video_min_group_length_first</item>
<item>@string/video_min_group_length_short</item>
<item>@string/video_min_group_length_long</item>
</string-array>
<string-array name="video_min_group_length_values" translatable="false">
<item>0</item>
<item>1</item>
<item>6</item>
<item>9</item>
</string-array>
<string-array name="subtitles_encoding_list" tools:ignore="TypographyDashes">
<item>Default (Windows-1252)</item>
<item>Universal (UTF-8)</item>
......
......@@ -9,6 +9,14 @@
android:key="enable_black_theme"
android:summary="@string/enable_black_theme_summary"
android:title="@string/enable_black_theme" />
<ListPreference
android:defaultValue="6"
android:entries="@array/video_min_group_length_list"
android:entryValues="@array/video_min_group_length_values"
android:key="video_min_group_length"
android:persistent="true"
android:summary="@string/video_min_group_length_summary"
android:title="@string/video_min_group_length_title" />
<PreferenceCategory android:title="@string/interface_gui" >
<CheckBoxPreference
android:key="tv_ui"
......
......@@ -58,6 +58,9 @@ public class PreferencesUi extends BasePreferenceFragment {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "video_min_group_length":
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
return true;
case "enable_headset_detection":
((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
return true;
......
......@@ -398,7 +398,8 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
final ArrayList<MediaWrapper> jobsList = new ArrayList<>();
if (mGroup != null || itemList.size() <= 10) {
for (MediaWrapper item : itemList) {
if (mGroup == null || item.getTitle().startsWith(mGroup))
String title = item.getTitle().substring(item.getTitle().toLowerCase().startsWith("the") ? 4 : 0);
if (mGroup == null || title.toLowerCase().startsWith(mGroup.toLowerCase()))
displayList.add(item);
jobsList.add(item);
}
......
......@@ -20,6 +20,10 @@
package org.videolan.vlc.media;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.BitmapUtil;
import java.util.ArrayList;
......@@ -29,8 +33,6 @@ public class MediaGroup extends MediaWrapper {
public final static String TAG = "VLC/MediaGroup";
public final static int MIN_GROUP_LENGTH = 6;
private ArrayList<MediaWrapper> mMedias;
public MediaGroup(MediaWrapper media) {
......@@ -92,6 +94,8 @@ public class MediaGroup extends MediaWrapper {
}
private static void insertInto(ArrayList<MediaGroup> groups, MediaWrapper media) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
int minGroupLengthValue = Integer.valueOf(preferences.getString("video_min_group_length", "6"));
for (MediaGroup mediaGroup : groups) {
String group = mediaGroup.getTitle();
String title = media.getTitle();
......@@ -105,10 +109,11 @@ public class MediaGroup extends MediaWrapper {
int commonLength = 0;
String groupTitle = group.substring(groupOffset);
int minLength = Math.min(groupTitle.length(), title.length());
while (commonLength < minLength && groupTitle.charAt(commonLength) == title.charAt(commonLength))
while (commonLength < minLength
&& groupTitle.toLowerCase().charAt(commonLength) == title.toLowerCase().charAt(commonLength))
++commonLength;
if (commonLength >= MIN_GROUP_LENGTH) {
if (commonLength >= minGroupLengthValue && minGroupLengthValue != 0) {
if (commonLength == group.length()) {
// same prefix name, just add
mediaGroup.add(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