[Android] Add a setting to set the video grouping prefix length
Nicolas Pomepuy
git at videolan.org
Tue Sep 24 14:35:05 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Sep 24 13:57:38 2019 +0200| [16db3dfa6b286ded7d0b70fc208f00ee7127caeb] | committer: Geoffrey Métais
Add a setting to set the video grouping prefix length
> https://code.videolan.org/videolan/vlc-android/commit/16db3dfa6b286ded7d0b70fc208f00ee7127caeb
---
vlc-android/res/values/strings.xml | 3 +++
vlc-android/res/xml/preferences_ui.xml | 8 ++++++++
.../videolan/vlc/gui/preferences/PreferencesUi.kt | 24 ++++++++++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 76b7f00f3..90c1637ac 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -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>
diff --git a/vlc-android/res/xml/preferences_ui.xml b/vlc-android/res/xml/preferences_ui.xml
index adceffde8..30bf85766 100644
--- a/vlc-android/res/xml/preferences_ui.xml
+++ b/vlc-android/res/xml/preferences_ui.xml
@@ -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
diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
index d3afcd708..cad6fbe50 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
@@ -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()
+ }
}
}
More information about the Android
mailing list