mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-24 04:35:49 +01:00
refactor(youtube/enable-wide-searchbar): apply Kotlin class structure conventions
This commit is contained in:
parent
6ae0f0b466
commit
d23d19b2a6
@ -33,6 +33,30 @@ class WideSearchbarPatch : BytecodePatch(
|
||||
SetWordmarkHeaderFingerprint, DrawActionBarFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_wide_searchbar",
|
||||
StringResource("revanced_wide_searchbar_enabled_title", "Enable wide search bar"),
|
||||
false,
|
||||
StringResource("revanced_wide_searchbar_summary_on", "Wide search bar is enabled"),
|
||||
StringResource("revanced_wide_searchbar_summary_off", "Wide search bar is disabled")
|
||||
)
|
||||
)
|
||||
|
||||
val result = DrawActionBarFingerprint.result ?: return DrawActionBarFingerprint.toErrorResult()
|
||||
|
||||
// patch methods
|
||||
mapOf(
|
||||
SetWordmarkHeaderFingerprint to 1,
|
||||
DrawActionBarFingerprint to result.scanResult.patternScanResult!!.endIndex
|
||||
).forEach { (fingerprint, callIndex) ->
|
||||
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
/**
|
||||
* Walk a fingerprints method at a given index mutably.
|
||||
@ -61,28 +85,4 @@ class WideSearchbarPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_wide_searchbar",
|
||||
StringResource("revanced_wide_searchbar_enabled_title", "Enable wide search bar"),
|
||||
false,
|
||||
StringResource("revanced_wide_searchbar_summary_on", "Wide search bar is enabled"),
|
||||
StringResource("revanced_wide_searchbar_summary_off", "Wide search bar is disabled")
|
||||
)
|
||||
)
|
||||
|
||||
val result = DrawActionBarFingerprint.result ?: return DrawActionBarFingerprint.toErrorResult()
|
||||
|
||||
// patch methods
|
||||
mapOf(
|
||||
SetWordmarkHeaderFingerprint to 1,
|
||||
DrawActionBarFingerprint to result.scanResult.patternScanResult!!.endIndex
|
||||
).forEach { (fingerprint, callIndex) ->
|
||||
context.walkMutable(callIndex, fingerprint).injectSearchBarHook()
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user