Skip to content

Commit

Permalink
fix(YouTube): Sort settings alphabetically despite punctuation (#3097)
Browse files Browse the repository at this point in the history
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
LisoUseInAIKyrios and oSumAtrIX committed Oct 8, 2023
1 parent 6e77812 commit 46e3c97
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ internal fun <T> Element.addDefault(default: T) {
}
)
}
}

internal fun CharSequence.removePunctuation(): String {
val punctuation = "\\p{P}+".toRegex()
return this.replace(punctuation, "")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.revanced.patches.shared.settings.preference.BasePreference
import app.revanced.patches.shared.settings.preference.impl.PreferenceCategory
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
import app.revanced.patches.shared.settings.preference.impl.StringResource
import app.revanced.patches.shared.settings.preference.removePunctuation
import java.io.Closeable

abstract class AbstractPreferenceScreen(
Expand Down Expand Up @@ -35,8 +36,8 @@ abstract class AbstractPreferenceScreen(
return PreferenceScreen(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value.lowercase() } +
categories.sortedBy { it.title.lowercase() }.map { it.transform() },
preferences.sortedBy { it.title.value.removePunctuation().lowercase() } +
categories.sortedBy { it.title.removePunctuation().lowercase() }.map { it.transform() },
summary?.let { summary ->
StringResource("${key}_summary", summary)
}
Expand All @@ -63,7 +64,7 @@ abstract class AbstractPreferenceScreen(
return PreferenceCategory(
key,
StringResource("${key}_title", title),
preferences.sortedBy { it.title.value.lowercase() }
preferences.sortedBy { it.title.value.removePunctuation().lowercase() }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ object HideLayoutComponentsPatch : BytecodePatch(
),
SwitchPreference(
"revanced_hide_join_membership_button",
StringResource("revanced_hide_join_membership_button_title", "Hide \"Join\" button"),
StringResource("revanced_hide_join_membership_button_title", "Hide \\\'Join\\\' button"),
StringResource("revanced_hide_join_membership_button_summary_on", "Button is hidden"),
StringResource("revanced_hide_join_membership_button_summary_off", "Button is shown")
),

SwitchPreference(
"revanced_hide_notify_me_button",
StringResource("revanced_hide_notify_me_button_title", "Hide \"Notify me\" button"),
StringResource("revanced_hide_notify_me_button_title", "Hide \\\'Notify me\\\' button"),
StringResource("revanced_hide_notify_me_button_summary_on", "Button is hidden"),
StringResource("revanced_hide_notify_me_button_summary_off", "Button is shown")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import app.revanced.patches.youtube.layout.hide.loadmorebutton.fingerprints.Hide
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction

@Patch(
name = "Hide \"Load more\" button",
name = "Hide \'Load more\' button",
description = "Hides the button under videos that loads similar videos.",
dependencies = [HideLoadMoreButtonResourcePatch::class],
compatiblePackages = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object HideLoadMoreButtonResourcePatch : ResourcePatch() {
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
SwitchPreference(
"revanced_hide_load_more_button",
StringResource("revanced_hide_load_more_button_title", "Hide \"Load More\" button"),
StringResource("revanced_hide_load_more_button_title", "Hide \\\'Load More\\\' button"),
StringResource("revanced_hide_load_more_button_summary_on", "Button is hidden"),
StringResource("revanced_hide_load_more_button_summary_off", "Button is shown")
)
Expand Down

0 comments on commit 46e3c97

Please sign in to comment.