feat(YouTube - Settings): Add ability to search in settings (#4881)
Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
@ -6,7 +6,10 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.IntentPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.NonInteractivePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter
|
||||
import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch
|
||||
@ -15,15 +18,18 @@ import app.revanced.patches.youtube.misc.playservice.is_19_33_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_10_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.misc.settings.addSettingPreference
|
||||
import app.revanced.patches.youtube.misc.settings.newIntent
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.shared.conversionContextFingerprintToString
|
||||
import app.revanced.patches.youtube.shared.rollingNumberTextViewAnimationUpdateFingerprint
|
||||
import app.revanced.patches.youtube.video.videoid.hookPlayerResponseVideoId
|
||||
import app.revanced.patches.youtube.video.videoid.hookVideoId
|
||||
import app.revanced.patches.youtube.video.videoid.videoIdPatch
|
||||
import app.revanced.util.*
|
||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
||||
import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.returnLate
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -68,15 +74,24 @@ val returnYouTubeDislikePatch = bytecodePatch(
|
||||
execute {
|
||||
addResources("youtube", "layout.returnyoutubedislike.returnYouTubeDislikePatch")
|
||||
|
||||
addSettingPreference(
|
||||
IntentPreference(
|
||||
key = "revanced_settings_screen_09",
|
||||
titleKey = "revanced_ryd_settings_title",
|
||||
summaryKey = null,
|
||||
icon = "@drawable/revanced_settings_screen_09_ryd",
|
||||
layout = "@layout/preference_with_icon",
|
||||
intent = newIntent("revanced_ryd_settings_intent"),
|
||||
PreferenceScreen.RETURN_YOUTUBE_DISLIKE.addPreferences(
|
||||
SwitchPreference("revanced_ryd_enabled"),
|
||||
SwitchPreference("revanced_ryd_shorts"),
|
||||
SwitchPreference("revanced_ryd_dislike_percentage"),
|
||||
SwitchPreference("revanced_ryd_compact_layout"),
|
||||
SwitchPreference("revanced_ryd_estimated_like"),
|
||||
SwitchPreference("revanced_ryd_toast_on_connection_error"),
|
||||
NonInteractivePreference(
|
||||
key = "revanced_ryd_attribution",
|
||||
tag = "app.revanced.extension.youtube.returnyoutubedislike.ui.ReturnYouTubeDislikeAboutPreference",
|
||||
selectable = true,
|
||||
),
|
||||
PreferenceCategory(
|
||||
key = "revanced_ryd_statistics_category",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = emptySet(), // Preferences are added by custom class at runtime.
|
||||
tag = "app.revanced.extension.youtube.returnyoutubedislike.ui.ReturnYouTubeDislikeDebugStatsPreferenceCategory"
|
||||
)
|
||||
)
|
||||
|
||||
// region Inject newVideoLoaded event handler to update dislikes when a new video is loaded.
|
||||
|
@ -12,12 +12,13 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.all.misc.resources.addResources
|
||||
import app.revanced.patches.all.misc.resources.addResourcesPatch
|
||||
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.IntentPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.NonInteractivePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreenPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.playercontrols.*
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.settings.addSettingPreference
|
||||
import app.revanced.patches.youtube.misc.settings.newIntent
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.shared.*
|
||||
import app.revanced.patches.youtube.video.information.onCreateHook
|
||||
@ -43,15 +44,32 @@ private val sponsorBlockResourcePatch = resourcePatch {
|
||||
execute {
|
||||
addResources("youtube", "layout.sponsorblock.sponsorBlockResourcePatch")
|
||||
|
||||
addSettingPreference(
|
||||
IntentPreference(
|
||||
key = "revanced_settings_screen_10",
|
||||
titleKey = "revanced_sb_settings_title",
|
||||
summaryKey = null,
|
||||
icon = "@drawable/revanced_settings_screen_10_sb",
|
||||
layout = "@layout/preference_with_icon",
|
||||
intent = newIntent("revanced_sb_settings_intent"),
|
||||
PreferenceScreen.SPONSORBLOCK.addPreferences(
|
||||
// SB setting is old code with lots of custom preferences and updating behavior.
|
||||
// Added as a preference group and not a fragment so the preferences are searchable.
|
||||
PreferenceCategory(
|
||||
key = "revanced_settings_screen_10_sponsorblock",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = emptySet(), // Preferences are added by custom class at runtime.
|
||||
tag = "app.revanced.extension.youtube.sponsorblock.ui.SponsorBlockPreferenceGroup"
|
||||
),
|
||||
PreferenceCategory(
|
||||
key = "revanced_sb_stats",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = emptySet(), // Preferences are added by custom class at runtime.
|
||||
tag = "app.revanced.extension.youtube.sponsorblock.ui.SponsorBlockStatsPreferenceCategory"
|
||||
),
|
||||
PreferenceCategory(
|
||||
key = "revanced_sb_about",
|
||||
sorting = PreferenceScreenPreference.Sorting.UNSORTED,
|
||||
preferences = setOf(
|
||||
NonInteractivePreference(
|
||||
key = "revanced_sb_about_api",
|
||||
tag = "app.revanced.extension.youtube.sponsorblock.ui.SponsorBlockAboutPreference",
|
||||
selectable = true,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
arrayOf(
|
||||
|
@ -54,6 +54,7 @@ val changeStartPagePatch = bytecodePatch(
|
||||
ListPreference(
|
||||
key = "revanced_change_start_page",
|
||||
summaryKey = null,
|
||||
tag = "app.revanced.extension.shared.settings.preference.SortedListPreference"
|
||||
),
|
||||
SwitchPreference("revanced_change_start_page_always")
|
||||
)
|
||||
|
@ -74,6 +74,7 @@ private val settingsResourcePatch = resourcePatch {
|
||||
|
||||
arrayOf(
|
||||
ResourceGroup("drawable",
|
||||
"revanced_settings_cursor.xml",
|
||||
"revanced_settings_icon.xml",
|
||||
"revanced_settings_screen_00_about.xml",
|
||||
"revanced_settings_screen_01_ads.xml",
|
||||
@ -84,12 +85,16 @@ private val settingsResourcePatch = resourcePatch {
|
||||
"revanced_settings_screen_06_shorts.xml",
|
||||
"revanced_settings_screen_07_seekbar.xml",
|
||||
"revanced_settings_screen_08_swipe_controls.xml",
|
||||
"revanced_settings_screen_09_ryd.xml",
|
||||
"revanced_settings_screen_10_sb.xml",
|
||||
"revanced_settings_screen_09_return_youtube_dislike.xml",
|
||||
"revanced_settings_screen_10_sponsorblock.xml",
|
||||
"revanced_settings_screen_11_misc.xml",
|
||||
"revanced_settings_screen_12_video.xml",
|
||||
),
|
||||
ResourceGroup("layout", "revanced_settings_with_toolbar.xml"),
|
||||
ResourceGroup("layout",
|
||||
"revanced_preference_with_icon_no_search_result.xml",
|
||||
"revanced_search_suggestion_item.xml",
|
||||
"revanced_settings_with_toolbar.xml"),
|
||||
ResourceGroup("menu", "revanced_search_menu.xml")
|
||||
).forEach { resourceGroup ->
|
||||
copyResources("settings", resourceGroup)
|
||||
}
|
||||
@ -188,6 +193,7 @@ val settingsPatch = bytecodePatch(
|
||||
}
|
||||
|
||||
PreferenceScreen.GENERAL_LAYOUT.addPreferences(
|
||||
SwitchPreference("revanced_settings_search_history"),
|
||||
SwitchPreference("revanced_show_menu_icons")
|
||||
)
|
||||
|
||||
@ -201,7 +207,8 @@ val settingsPatch = bytecodePatch(
|
||||
),
|
||||
ListPreference(
|
||||
key = "revanced_language",
|
||||
summaryKey = null
|
||||
summaryKey = null,
|
||||
tag = "app.revanced.extension.shared.settings.preference.SortedListPreference"
|
||||
)
|
||||
)
|
||||
|
||||
@ -347,10 +354,20 @@ object PreferenceScreen : BasePreferenceScreen() {
|
||||
layout = "@layout/preference_with_icon",
|
||||
sorting = Sorting.UNSORTED,
|
||||
)
|
||||
|
||||
// RYD and SB are items 9 and 10.
|
||||
// Menus are added in their own patch because they use an Intent and not a Screen.
|
||||
|
||||
val RETURN_YOUTUBE_DISLIKE = Screen(
|
||||
key = "revanced_settings_screen_09_return_youtube_dislike",
|
||||
summaryKey = null,
|
||||
icon = "@drawable/revanced_settings_screen_09_return_youtube_dislike",
|
||||
layout = "@layout/preference_with_icon",
|
||||
sorting = Sorting.UNSORTED,
|
||||
)
|
||||
val SPONSORBLOCK = Screen(
|
||||
key = "revanced_settings_screen_10_sponsorblock",
|
||||
summaryKey = null,
|
||||
icon = "@drawable/revanced_settings_screen_10_sponsorblock",
|
||||
layout = "@layout/preference_with_icon",
|
||||
sorting = Sorting.UNSORTED,
|
||||
)
|
||||
val MISC = Screen(
|
||||
key = "revanced_settings_screen_11_misc",
|
||||
summaryKey = null,
|
||||
|
@ -62,7 +62,8 @@ val spoofVideoStreamsPatch = spoofVideoStreamsPatch({
|
||||
summaryKey = null,
|
||||
// Language strings are declared in Setting patch.
|
||||
entriesKey = "revanced_language_entries",
|
||||
entryValuesKey = "revanced_language_entry_values"
|
||||
entryValuesKey = "revanced_language_entry_values",
|
||||
tag = "app.revanced.extension.shared.settings.preference.SortedListPreference"
|
||||
),
|
||||
SwitchPreference("revanced_spoof_video_streams_ios_force_avc"),
|
||||
SwitchPreference("revanced_spoof_streaming_data_stats_for_nerds"),
|
||||
|
@ -38,6 +38,7 @@ internal val rememberPlaybackSpeedPatch = bytecodePatch {
|
||||
// Entries and values are set by the extension code based on the actual speeds available.
|
||||
entriesKey = null,
|
||||
entryValuesKey = null,
|
||||
tag = "app.revanced.extension.youtube.settings.preference.CustomVideoSpeedListPreference"
|
||||
),
|
||||
SwitchPreference("revanced_remember_playback_speed_last_selected")
|
||||
)
|
||||
|
@ -65,35 +65,6 @@ fun Method.findFreeRegister(startIndex: Int, vararg registersToExclude: Int): In
|
||||
val instruction = getInstruction(i)
|
||||
val instructionRegisters = instruction.registersUsed
|
||||
|
||||
if (instruction.isReturnInstruction) {
|
||||
usedRegisters.addAll(instructionRegisters)
|
||||
|
||||
// Use lowest register that hasn't been encountered.
|
||||
val freeRegister = (0 until implementation!!.registerCount).find {
|
||||
it !in usedRegisters
|
||||
}
|
||||
if (freeRegister != null) {
|
||||
return freeRegister
|
||||
}
|
||||
if (bestFreeRegisterFound != null) {
|
||||
return bestFreeRegisterFound
|
||||
}
|
||||
|
||||
// Somehow every method register was read from before any register was wrote to.
|
||||
// In practice this never occurs.
|
||||
throw IllegalArgumentException("Could not find a free register from startIndex: " +
|
||||
"$startIndex excluding: $registersToExclude")
|
||||
}
|
||||
|
||||
if (instruction.isBranchInstruction) {
|
||||
if (bestFreeRegisterFound != null) {
|
||||
return bestFreeRegisterFound
|
||||
}
|
||||
// This method is simple and does not follow branching.
|
||||
throw IllegalArgumentException("Encountered a branch statement before a free register could be found")
|
||||
}
|
||||
|
||||
|
||||
val writeRegister = instruction.writeRegister
|
||||
if (writeRegister != null) {
|
||||
if (writeRegister !in usedRegisters) {
|
||||
@ -114,6 +85,32 @@ fun Method.findFreeRegister(startIndex: Int, vararg registersToExclude: Int): In
|
||||
}
|
||||
|
||||
usedRegisters.addAll(instructionRegisters)
|
||||
|
||||
if (instruction.isBranchInstruction) {
|
||||
if (bestFreeRegisterFound != null) {
|
||||
return bestFreeRegisterFound
|
||||
}
|
||||
// This method is simple and does not follow branching.
|
||||
throw IllegalArgumentException("Encountered a branch statement before a free register could be found")
|
||||
}
|
||||
|
||||
if (instruction.isReturnInstruction) {
|
||||
// Use lowest register that hasn't been encountered.
|
||||
val freeRegister = (0 until implementation!!.registerCount).find {
|
||||
it !in usedRegisters
|
||||
}
|
||||
if (freeRegister != null) {
|
||||
return freeRegister
|
||||
}
|
||||
if (bestFreeRegisterFound != null) {
|
||||
return bestFreeRegisterFound
|
||||
}
|
||||
|
||||
// Somehow every method register was read from before any register was wrote to.
|
||||
// In practice this never occurs.
|
||||
throw IllegalArgumentException("Could not find a free register from startIndex: " +
|
||||
"$startIndex excluding: $registersToExclude")
|
||||
}
|
||||
}
|
||||
|
||||
// Some methods can have array payloads at the end of the method after a return statement.
|
||||
|
Reference in New Issue
Block a user