mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-06 06:37:04 +01:00
feat(youtube/hide-seekbar): more fine grained hiding of seekbar (#2252)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
94f31f8491
commit
0f07bf467a
@ -17,6 +17,7 @@ import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.hide.seekbar.annotations.HideSeekbarCompatibility
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.patch.SeekbarColorBytecodePatch
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarPreferencesPatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
|
||||
@ -24,7 +25,10 @@ import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
@DependsOn([
|
||||
IntegrationsPatch::class,
|
||||
SettingsPatch::class,
|
||||
SeekbarColorBytecodePatch::class // Used to hide the seekbar in the feed and watch history
|
||||
// Does not alter the behavior of the seek bar by default.
|
||||
SeekbarColorBytecodePatch::class,
|
||||
// Used to add preferences to the seekbar settings menu.
|
||||
SeekbarPreferencesPatch::class
|
||||
])
|
||||
@Name("hide-seekbar")
|
||||
@Description("Hides the seekbar.")
|
||||
@ -34,12 +38,18 @@ class HideSeekbarPatch : BytecodePatch(
|
||||
listOf(SeekbarFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SeekbarPreferencesPatch.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_seekbar",
|
||||
StringResource("revanced_hide_seekbar_title", "Hide seekbar"),
|
||||
StringResource("revanced_hide_seekbar_summary_on", "Seekbar is hidden"),
|
||||
StringResource("revanced_hide_seekbar_summary_off", "Seekbar is shown")
|
||||
StringResource("revanced_hide_seekbar_title", "Hide seekbar in video player"),
|
||||
StringResource("revanced_hide_seekbar_summary_on", "Video player seekbar is hidden"),
|
||||
StringResource("revanced_hide_seekbar_summary_off", "Video player seekbar is shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_hide_seekbar_thumbnail",
|
||||
StringResource("revanced_hide_seekbar_thumbnail_title", "Hide seekbar in video thumbnails"),
|
||||
StringResource("revanced_hide_seekbar_thumbnail_summary_on", "Thumbnail seekbar is hidden"),
|
||||
StringResource("revanced_hide_seekbar_thumbnail_summary_off", "Thumbnail seekbar is shown")
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -15,9 +15,9 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.layout.seekbar.annotations.SeekbarColorCompatibility
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.CreateDarkThemeSeekbarFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.bytecode.fingerprints.SetSeekbarClickedColorFingerprint
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResourcePatch
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.LithoColorHookPatch.Companion.lithoColorOverrideHook
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarColorResourcePatch
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.util.patch.indexOfFirstConstantInstruction
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -37,7 +37,7 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
addInstructions(
|
||||
registerIndex + 1,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorValue(I)I
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
@ -47,7 +47,7 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
addInstructions(
|
||||
registerIndex + 1,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorValue(I)I
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
@ -66,7 +66,7 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getSeekbarColorOverride(I)I
|
||||
invoke-static { v$colorRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->getVideoPlayerSeekbarClickedColor(I)I
|
||||
move-result v$colorRegister
|
||||
"""
|
||||
)
|
||||
@ -74,7 +74,7 @@ class SeekbarColorBytecodePatch : BytecodePatch(
|
||||
}
|
||||
} ?: return SetSeekbarClickedColorFingerprint.toErrorResult()
|
||||
|
||||
lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getSeekbarColorOverride")
|
||||
lithoColorOverrideHook(INTEGRATIONS_CLASS_DESCRIPTOR, "getLithoColor")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.resource
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.BasePreference
|
||||
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import java.io.Closeable
|
||||
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
class SeekbarPreferencesPatch : ResourcePatch, Closeable {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
// Nothing to do here. All work is done in close method.
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
PreferenceScreen(
|
||||
"revanced_seekbar_preference_screen",
|
||||
StringResource("revanced_seekbar_preference_screen_title", "Seekbar settings"),
|
||||
seekbarPreferences
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val seekbarPreferences = mutableListOf<BasePreference>()
|
||||
|
||||
internal fun addPreferences(vararg preferencesToAdd: BasePreference) {
|
||||
seekbarPreferences.addAll(preferencesToAdd)
|
||||
}
|
||||
}
|
||||
}
|
@ -9,25 +9,23 @@ import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.InputType
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.TextPreference
|
||||
import app.revanced.patches.youtube.layout.seekbar.resource.SeekbarPreferencesPatch
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.darkThemeBackgroundColor
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.lightThemeBackgroundColor
|
||||
import app.revanced.patches.youtube.layout.theme.bytecode.patch.ThemeBytecodePatch.Companion.splashScreenBackgroundColor
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import org.w3c.dom.Element
|
||||
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class])
|
||||
@DependsOn([SettingsPatch::class, ResourceMappingPatch::class, SeekbarPreferencesPatch::class])
|
||||
class ThemeResourcePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SeekbarPreferencesPatch.addPreferences(
|
||||
TextPreference(
|
||||
"revanced_seekbar_color",
|
||||
StringResource("revanced_seekbar_color_title", "Seekbar color"),
|
||||
StringResource(
|
||||
"revanced_seekbar_color_summary",
|
||||
"The color of the seekbar"
|
||||
),
|
||||
StringResource("revanced_seekbar_color_summary", "The color of the seekbar"),
|
||||
InputType.TEXT_CAP_CHARACTERS
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
// Edit theme colors via resources.
|
||||
|
Loading…
Reference in New Issue
Block a user