diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt index f713e2d497bb..71ba923310c2 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/CustomButtonsSettingsFragment.kt @@ -21,7 +21,6 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AlertDialog import androidx.core.content.edit import androidx.preference.Preference -import androidx.preference.PreferenceCategory import com.ichi2.anki.R import com.ichi2.utils.* @@ -72,18 +71,7 @@ class CustomButtonsSettingsFragment : SettingsFragment() { @VisibleForTesting(otherwise = VisibleForTesting.NONE) fun allKeys(): HashSet { - val allKeys = HashSet() - for (i in 0 until preferenceScreen.preferenceCount) { - val pref = preferenceScreen.getPreference(i) - if (pref is PreferenceCategory) { - for (j in 0 until pref.preferenceCount) { - allKeys.add(pref.getPreference(j).key) - } - } else { - allKeys.add(pref.key) - } - } - return allKeys + return allPreferences().mapTo(hashSetOf()) { it.key } } companion object { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/SettingsFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/SettingsFragment.kt index 82e08ddc02d7..270acee5c437 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/preferences/SettingsFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/preferences/SettingsFragment.kt @@ -23,6 +23,7 @@ import androidx.annotation.VisibleForTesting import androidx.annotation.XmlRes import androidx.core.os.bundleOf import androidx.preference.Preference +import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager.OnPreferenceTreeClickListener @@ -78,6 +79,7 @@ abstract class SettingsFragment : override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { UsageAnalytics.sendAnalyticsScreenView(analyticsScreenNameConstant) addPreferencesFromResource(preferenceResource) + allPreferences().forEach { it.isSingleLineTitle = false } initSubscreen() } @@ -110,6 +112,21 @@ abstract class SettingsFragment : .unregisterOnSharedPreferenceChangeListener(this) } + protected fun allPreferences(): List { + val allPreferences = mutableListOf() + for (i in 0 until preferenceScreen.preferenceCount) { + val pref = preferenceScreen.getPreference(i) + if (pref is PreferenceCategory) { + for (j in 0 until pref.preferenceCount) { + allPreferences.add(pref.getPreference(j)) + } + } else { + allPreferences.add(pref) + } + } + return allPreferences + } + companion object { @JvmStatic // Using protected members which are not @JvmStatic in the superclass companion is unsupported yet protected fun getSubscreenIntent(context: Context, fragmentClass: KClass): Intent {