feat(YouTube - Fullscreen components): Add Enter fullscreen mode setting

This commit is contained in:
inotia00
2025-01-03 21:54:27 +09:00
parent 428047b725
commit 1f95e07e7a
6 changed files with 103 additions and 0 deletions

View File

@ -18,6 +18,10 @@ lateinit var onConfigurationChangedMethod: MutableMethod
private set
lateinit var onCreateMethod: MutableMethod
private set
lateinit var onStartMethod: MutableMethod
private set
lateinit var onStopMethod: MutableMethod
private set
private lateinit var constructorMethod: MutableMethod
private lateinit var onBackPressedMethod: MutableMethod
@ -45,6 +49,9 @@ fun baseMainActivityResolvePatch(
// set onConfigurationChanged method
onConfigurationChangedMethod = getMainActivityMethod("onConfigurationChanged")
onStartMethod = getMainActivityMethod("onStart")
onStopMethod = getMainActivityMethod("onStop")
}
}

View File

@ -11,6 +11,8 @@ import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.litho.addLithoFilter
import app.revanced.patches.shared.litho.lithoFilterPatch
import app.revanced.patches.shared.mainactivity.onConfigurationChangedMethod
import app.revanced.patches.shared.mainactivity.onStartMethod
import app.revanced.patches.shared.mainactivity.onStopMethod
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.extension.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.extension.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
@ -31,6 +33,7 @@ import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.patches.youtube.utils.youtubeControlsOverlayFingerprint
import app.revanced.patches.youtube.video.information.hookBackgroundPlayVideoInformation
import app.revanced.patches.youtube.video.information.videoEndMethod
import app.revanced.patches.youtube.video.information.videoInformationPatch
import app.revanced.util.Utils.printWarn
@ -54,6 +57,9 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
private const val FILTER_CLASS_DESCRIPTOR =
"$COMPONENTS_PATH/QuickActionFilter;"
private const val EXTENSION_ENTER_FULLSCREEN_CLASS_DESCRIPTOR =
"$PLAYER_PATH/EnterFullscreenPatch;"
private const val EXTENSION_EXIT_FULLSCREEN_CLASS_DESCRIPTOR =
"$PLAYER_PATH/ExitFullscreenPatch;"
@ -118,6 +124,22 @@ val fullscreenComponentsPatch = bytecodePatch(
// endregion
// region patch for enter fullscreen
mapOf(
onStartMethod to "onAppForegrounded",
onStopMethod to "onAppBackgrounded"
).forEach { (method, name) ->
method.addInstruction(
0,
"invoke-static {}, $EXTENSION_ENTER_FULLSCREEN_CLASS_DESCRIPTOR->$name()V"
)
}
hookBackgroundPlayVideoInformation("$EXTENSION_ENTER_FULLSCREEN_CLASS_DESCRIPTOR->enterFullscreen(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JZ)V")
// endregion
// region patch for exit fullscreen
videoEndMethod.apply {