Commit 16db3dfa authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Add a setting to set the video grouping prefix length

parent 01b5b08f
......@@ -731,4 +731,7 @@
<string name="report_a_crash">Report a crash</string>
<string name="describe_crash">Please describe how this crash happened</string>
<string name="favorite">Favorite</string>
<string name="video_group_size_dialog_text">Number of characters used to group by name</string>
<string name="video_group_size_summary">Group by %s first letters</string>
<string name="video_group_size">Group videos by name</string>
</resources>
......@@ -57,6 +57,14 @@
android:summary="@string/show_video_thumbnails_summary"
android:title="@string/show_video_thumbnails"/>
<EditTextPreference
app:singleLineTitle="false"
android:defaultValue="true"
android:key="video_group_size"
app:defaultValue="6"
android:title="@string/video_group_size"
android:dialogTitle="@string/video_group_size_dialog_text" />
</PreferenceCategory>
<PreferenceCategory
......
......@@ -25,12 +25,16 @@ package org.videolan.vlc.gui.preferences
import android.content.SharedPreferences
import android.os.Bundle
import android.text.InputType
import android.text.TextUtils
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.TwoStatePreference
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.medialibrary.interfaces.AbstractMedialibrary
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.util.*
......@@ -50,6 +54,22 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
setupTheme()
}
override fun onCreatePreferences(bundle: Bundle?, s: String?) {
super.onCreatePreferences(bundle, s)
val groupVideoPreference = preferenceManager.findPreference<EditTextPreference>("video_group_size")
groupVideoPreference?.setOnBindEditTextListener { editText ->
editText.inputType = InputType.TYPE_CLASS_NUMBER
}
groupVideoPreference?.summaryProvider = Preference.SummaryProvider<EditTextPreference> { preference ->
val text = preference.text
if (TextUtils.isEmpty(text)) {
""
} else {
getString(R.string.video_group_size_summary, text)
}
}
}
private fun setupTheme() {
val prefs = preferenceScreen.sharedPreferences
if (!prefs.contains(KEY_APP_THEME)) {
......@@ -108,6 +128,10 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
Settings.listTitleEllipsize = sharedPreferences.getString(LIST_TITLE_ELLIPSIZE, "0").toInt()
(activity as PreferencesActivity).setRestart()
}
"video_group_size" -> {
AbstractMedialibrary.getInstance().setVideoGroupsPrefixLength(Settings.getInstance(requireActivity()).getString(key, "6").toInt())
(activity as PreferencesActivity).setRestart()
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment