mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
refactor(YouTube): Sort no title preference group by first sub preference title
This commit is contained in:
parent
274df58056
commit
fd6bc6ec36
@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
public class NoTitlePreferenceCategory extends PreferenceCategory {
|
||||
|
||||
public NoTitlePreferenceCategory(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
@ -27,8 +28,27 @@ public class NoTitlePreferenceCategory extends PreferenceCategory {
|
||||
@Override
|
||||
@SuppressLint("MissingSuperCall")
|
||||
protected View onCreateView(ViewGroup parent) {
|
||||
// Return an empty, zero-height view to eliminate spacing
|
||||
// Return an zero-height view to eliminate empty title space.
|
||||
return new View(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
// Title can be used for sorting. Return the first sub preference title.
|
||||
if (getPreferenceCount() > 0) {
|
||||
return getPreference(0).getTitle();
|
||||
}
|
||||
|
||||
return super.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleRes() {
|
||||
if (getPreferenceCount() > 0) {
|
||||
return getPreference(0).getTitleRes();
|
||||
}
|
||||
|
||||
return super.getTitleRes();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,7 @@ val spoofAppVersionPatch = bytecodePatch(
|
||||
// Group the switch and list preference together, since General menu is sorted by name
|
||||
// and the preferences can be scattered apart with non English langauges.
|
||||
PreferenceCategory(
|
||||
key = null,
|
||||
// The title does not show, but is used for sorting the group.
|
||||
titleKey = "revanced_spoof_app_version_title",
|
||||
titleKey = null,
|
||||
sorting = Sorting.UNSORTED,
|
||||
tag = "app.revanced.extension.shared.settings.preference.NoTitlePreferenceCategory",
|
||||
preferences = setOf(
|
||||
|
@ -101,8 +101,7 @@ val themePatch = bytecodePatch(
|
||||
|
||||
PreferenceScreen.SEEKBAR.addPreferences(
|
||||
PreferenceCategory(
|
||||
// Title is hidden, but is used for sorting the group.
|
||||
titleKey = "revanced_seekbar_custom_color_title",
|
||||
titleKey = null,
|
||||
sorting = Sorting.UNSORTED,
|
||||
tag = "app.revanced.extension.shared.settings.preference.NoTitlePreferenceCategory",
|
||||
preferences = preferences
|
||||
|
Loading…
x
Reference in New Issue
Block a user