mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-08 02:24:35 +02:00
feat(YouTube): add Custom player overlay opacity
patch
This commit is contained in:
parent
b24b1c3474
commit
2cb1923daa
@ -0,0 +1,84 @@
|
||||
package app.revanced.patches.youtube.player.playeroverlay
|
||||
|
||||
import app.revanced.extensions.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.utils.fingerprints.YouTubeControlsOverlayFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ScrimOverlay
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.bytecode.getWideLiteralIndex
|
||||
import app.revanced.util.integrations.Constants.PLAYER
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Patch(
|
||||
name = "Custom player overlay opacity",
|
||||
description = "Change the opacity of the player background, when player controls are visible.",
|
||||
dependencies = [
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
"com.google.android.youtube",
|
||||
[
|
||||
"18.24.37",
|
||||
"18.25.40",
|
||||
"18.27.36",
|
||||
"18.29.38",
|
||||
"18.30.37",
|
||||
"18.31.40",
|
||||
"18.32.39",
|
||||
"18.33.40",
|
||||
"18.34.38",
|
||||
"18.35.36",
|
||||
"18.36.39",
|
||||
"18.37.36",
|
||||
"18.38.44",
|
||||
"18.39.41"
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object CustomPlayerOverlayOpacityPatch : BytecodePatch(
|
||||
setOf(YouTubeControlsOverlayFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
YouTubeControlsOverlayFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getWideLiteralIndex(ScrimOverlay) + 3
|
||||
val targetParameter = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
if (!targetParameter.toString().endsWith("Landroid/widget/ImageView;"))
|
||||
throw PatchException("Method signature parameter did not match: $targetParameter")
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $PLAYER->changePlayerOpacity(Landroid/widget/ImageView;)V"
|
||||
)
|
||||
}
|
||||
} ?: throw YouTubeControlsOverlayFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: PLAYER_SETTINGS",
|
||||
"SETTINGS: CUSTOM_PLAYER_OVERLAY_OPACITY"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Custom player overlay opacity")
|
||||
|
||||
}
|
||||
}
|
@ -50,8 +50,13 @@
|
||||
<string name="revanced_custom_playback_speeds_summary">Add or change available playback speeds</string>
|
||||
<string name="revanced_custom_playback_speeds_title">Edit custom playback speeds</string>
|
||||
<string name="revanced_custom_playback_speeds_warning" formatted="false">Custom speeds can\'t be more than %sx. Reset to default values.</string>
|
||||
<string name="revanced_custom_player_overlay_opacity_summary">Opacity value between 0-100, where 0 is transparent</string>
|
||||
<string name="revanced_custom_player_overlay_opacity_title">Custom player overlay opacity</string>
|
||||
<string name="revanced_custom_player_overlay_opacity_warning">Player overlay opacity must be between 0-100. Reset to default values.</string>
|
||||
<string name="revanced_custom_seekbar_color_value_summary">Type the hex code of the seekbar color</string>
|
||||
<string name="revanced_custom_seekbar_color_value_title">Custom seekbar color value</string>
|
||||
<string name="revanced_custom_speed_overlay_summary">Speed value that changes while holding down</string>
|
||||
<string name="revanced_custom_speed_overlay_title">Custom speed overlay</string>
|
||||
<string name="revanced_default_app_settings_summary">To open RVX in an external browser, turn on \'Open supported links\' and enable supported web addresses</string>
|
||||
<string name="revanced_default_app_settings_title">Open default app settings</string>
|
||||
<string name="revanced_default_playback_speed_title">Default playback speed</string>
|
||||
@ -98,8 +103,6 @@
|
||||
<string name="revanced_enable_custom_seekbar_color_summary_off">Custom seekbar color is disabled</string>
|
||||
<string name="revanced_enable_custom_seekbar_color_summary_on">Custom seekbar color is enabled</string>
|
||||
<string name="revanced_enable_custom_seekbar_color_title">Enable custom seekbar color</string>
|
||||
<string name="revanced_edit_speed_overlay_value_summary">Edit speed that changes while holding down</string>
|
||||
<string name="revanced_edit_speed_overlay_value_title">Edit custom speed overlay</string>
|
||||
<string name="revanced_enable_debug_logging_summary_off">Debug logs are disabled</string>
|
||||
<string name="revanced_enable_debug_logging_summary_on">Debug logs are enabled</string>
|
||||
<string name="revanced_enable_debug_logging_title">Enable debug logging</string>
|
||||
|
@ -389,6 +389,7 @@
|
||||
<Preference android:title="Overlay buttons" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player" />
|
||||
<Preference android:title="Custom player overlay opacity" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Custom speed overlay" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Disable haptic feedback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Hide autoplay button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
@ -491,8 +492,11 @@
|
||||
<PreferenceScreen android:title="@string/revanced_player" android:key="player">
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_player" />PREFERENCE: PLAYER_SETTINGS -->
|
||||
|
||||
<!-- SETTINGS: CUSTOM_PLAYER_OVERLAY_OPACITY
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:hint="100" android:defaultValue="100" android:title="@string/revanced_custom_player_overlay_opacity_title" android:key="revanced_custom_player_overlay_opacity" android:summary="@string/revanced_custom_player_overlay_opacity_summary" android:inputType="number" />SETTINGS: CUSTOM_SPEED_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: CUSTOM_SPEED_OVERLAY
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:hint="2.0" android:defaultValue="2.0" android:title="@string/revanced_edit_speed_overlay_value_title" android:key="revanced_edit_speed_overlay_value" android:summary="@string/revanced_edit_speed_overlay_value_summary" android:inputType="text" />SETTINGS: CUSTOM_SPEED_OVERLAY -->
|
||||
<app.revanced.integrations.settingsmenu.ResettableEditTextPreference android:hint="2.0" android:defaultValue="2.0" android:title="@string/revanced_custom_speed_overlay_title" android:key="revanced_custom_speed_overlay" android:summary="@string/revanced_custom_speed_overlay_summary" android:inputType="text" />SETTINGS: CUSTOM_SPEED_OVERLAY -->
|
||||
|
||||
<!-- SETTINGS: HIDE_AUDIO_TRACK_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_audio_track_button_title" android:key="revanced_hide_audio_track_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_audio_track_button_summary_on" android:summaryOff="@string/revanced_hide_audio_track_button_summary_off" />SETTINGS: HIDE_AUDIO_TRACK_BUTTON -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user