From a596959d710dfea5bfb49df346b8070cec10e02c Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Fri, 3 Jan 2025 21:48:58 +0900 Subject: [PATCH] feat(YouTube - Fullscreen components): Remove `Force fullscreen` setting --- .../youtube/patches/player/PlayerPatch.java | 34 ------------ .../extension/youtube/settings/Settings.java | 1 - .../ReVancedSettingsPreference.java | 22 -------- .../youtube/player/fullscreen/Fingerprints.kt | 20 ------- .../fullscreen/FullscreenComponentsPatch.kt | 55 ------------------- .../youtube/settings/host/values/strings.xml | 5 -- .../youtube/settings/xml/revanced_prefs.xml | 3 +- 7 files changed, 1 insertion(+), 139 deletions(-) diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/player/PlayerPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/player/PlayerPatch.java index e7fd135d1..669d57fae 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/player/PlayerPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/player/PlayerPatch.java @@ -5,8 +5,6 @@ import static app.revanced.extension.shared.utils.Utils.hideViewByRemovingFromPa import static app.revanced.extension.shared.utils.Utils.hideViewUnderCondition; import static app.revanced.extension.youtube.utils.ExtendedUtils.validateValue; -import android.app.Activity; -import android.content.pm.ActivityInfo; import android.support.v7.widget.RecyclerView; import android.util.TypedValue; import android.view.View; @@ -20,7 +18,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; -import java.lang.ref.WeakReference; import java.util.Objects; import app.revanced.extension.shared.settings.BaseSettings; @@ -328,37 +325,6 @@ public class PlayerPatch { Utils.runOnMainThreadDelayed(() -> isScreenOn = false, Settings.KEEP_LANDSCAPE_MODE_TIMEOUT.get()); } - private static WeakReference watchDescriptorActivityRef = new WeakReference<>(null); - private static volatile boolean isLandScapeVideo = true; - - public static void setWatchDescriptorActivity(Activity activity) { - watchDescriptorActivityRef = new WeakReference<>(activity); - } - - public static boolean forceFullscreen(boolean original) { - if (!Settings.FORCE_FULLSCREEN.get()) - return original; - - Utils.runOnMainThreadDelayed(PlayerPatch::setOrientation, 1000); - return true; - } - - private static void setOrientation() { - final Activity watchDescriptorActivity = watchDescriptorActivityRef.get(); - final int requestedOrientation = isLandScapeVideo - ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE - : watchDescriptorActivity.getRequestedOrientation(); - - watchDescriptorActivity.setRequestedOrientation(requestedOrientation); - } - - public static void setVideoPortrait(int width, int height) { - if (!Settings.FORCE_FULLSCREEN.get()) - return; - - isLandScapeVideo = width > height; - } - // endregion // region [Hide comments component] patch diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java index 5093be2df..593395496 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -353,7 +353,6 @@ public class Settings extends BaseSettings { public static final BooleanSetting DISABLE_LANDSCAPE_MODE = new BooleanSetting("revanced_disable_landscape_mode", FALSE, true); public static final BooleanSetting ENABLE_COMPACT_CONTROLS_OVERLAY = new BooleanSetting("revanced_enable_compact_controls_overlay", FALSE, true); - public static final BooleanSetting FORCE_FULLSCREEN = new BooleanSetting("revanced_force_fullscreen", FALSE, true); public static final BooleanSetting KEEP_LANDSCAPE_MODE = new BooleanSetting("revanced_keep_landscape_mode", FALSE, true); public static final LongSetting KEEP_LANDSCAPE_MODE_TIMEOUT = new LongSetting("revanced_keep_landscape_mode_timeout", 3000L, true); diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java index e902d2ab8..dc13a6bb6 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java @@ -49,7 +49,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment { ChangeHeaderPreferenceLinks(); ExternalDownloaderPreferenceLinks(); FullScreenPanelPreferenceLinks(); - LayoutOverrideLinks(); MiniPlayerPreferenceLinks(); NavigationPreferenceLinks(); RYDPreferenceLinks(); @@ -93,16 +92,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment { ); } - /** - * Enable/Disable Layout Override Preference - */ - private static void LayoutOverrideLinks() { - enableDisablePreferences( - ExtendedUtils.isTablet(), - Settings.FORCE_FULLSCREEN - ); - } - /** * Enable/Disable Preferences not working in tablet layout */ @@ -139,17 +128,6 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment { Settings.HIDE_QUICK_ACTIONS_SAVE_TO_PLAYLIST_BUTTON, Settings.HIDE_QUICK_ACTIONS_SHARE_BUTTON ); - - enableDisablePreferences( - Settings.DISABLE_LANDSCAPE_MODE.get(), - Settings.FORCE_FULLSCREEN - ); - - enableDisablePreferences( - Settings.FORCE_FULLSCREEN.get(), - Settings.DISABLE_LANDSCAPE_MODE - ); - } /** diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/Fingerprints.kt index d89496da6..f65a4b917 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/Fingerprints.kt @@ -23,19 +23,6 @@ internal val broadcastReceiverFingerprint = legacyFingerprint( } ) -internal val clientSettingEndpointFingerprint = legacyFingerprint( - name = "clientSettingEndpointFingerprint", - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L", "Ljava/util/Map;"), - strings = listOf( - "OVERRIDE_EXIT_FULLSCREEN_TO_MAXIMIZED", - "force_fullscreen", - "start_watch_minimized", - "watch" - ) -) - internal val engagementPanelFingerprint = legacyFingerprint( name = "engagementPanelFingerprint", returnType = "L", @@ -72,10 +59,3 @@ internal val relatedEndScreenResultsFingerprint = legacyFingerprint( literals = listOf(appRelatedEndScreenResults), ) -internal val videoPortraitParentFingerprint = legacyFingerprint( - name = "videoPortraitParentFingerprint", - returnType = "V", - accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL, - parameters = listOf("L", "Ljava/util/Map;"), - strings = listOf("Acquiring NetLatencyActionLogger failed. taskId=") -) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt index f00ad80bd..e57b0d6c7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/player/fullscreen/FullscreenComponentsPatch.kt @@ -42,7 +42,6 @@ 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 import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction -import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction import com.android.tools.smali.dexlib2.iface.instruction.WideLiteralInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -198,60 +197,6 @@ val fullscreenComponentsPatch = bytecodePatch( // endregion - // region patch for force fullscreen - - clientSettingEndpointFingerprint.methodOrThrow().apply { - val getActivityIndex = indexOfFirstStringInstructionOrThrow("watch") + 2 - val getActivityReference = - getInstruction(getActivityIndex).reference - val classRegister = - getInstruction(getActivityIndex).registerB - - val watchDescriptorMethodIndex = - indexOfFirstStringInstructionOrThrow("start_watch_minimized") - 1 - val watchDescriptorRegister = - getInstruction(watchDescriptorMethodIndex).registerD - - addInstructions( - watchDescriptorMethodIndex, """ - invoke-static {v$watchDescriptorRegister}, $PLAYER_CLASS_DESCRIPTOR->forceFullscreen(Z)Z - move-result v$watchDescriptorRegister - """ - ) - - // hooks Activity. - val insertIndex = indexOfFirstStringInstructionOrThrow("force_fullscreen") - val freeRegister = getInstruction(insertIndex).registerA - - addInstructions( - insertIndex, """ - iget-object v$freeRegister, v$classRegister, $getActivityReference - check-cast v$freeRegister, Landroid/app/Activity; - invoke-static {v$freeRegister}, $PLAYER_CLASS_DESCRIPTOR->setWatchDescriptorActivity(Landroid/app/Activity;)V - """ - ) - } - - videoPortraitParentFingerprint.methodOrThrow().apply { - val stringIndex = - indexOfFirstStringInstructionOrThrow("Acquiring NetLatencyActionLogger failed. taskId=") - val invokeIndex = - indexOfFirstInstructionOrThrow(stringIndex, Opcode.INVOKE_INTERFACE) - val targetIndex = indexOfFirstInstructionOrThrow(invokeIndex, Opcode.CHECK_CAST) - val targetClass = - getInstruction(targetIndex).reference.toString() - - // add an instruction to check the vertical video - findMethodOrThrow(targetClass) { - parameters == listOf("I", "I", "Z") - }.addInstruction( - 1, - "invoke-static {p1, p2}, $PLAYER_CLASS_DESCRIPTOR->setVideoPortrait(II)V" - ) - } - - // endregion - // region patch for disable landscape mode onConfigurationChangedMethod.apply { diff --git a/patches/src/main/resources/youtube/settings/host/values/strings.xml b/patches/src/main/resources/youtube/settings/host/values/strings.xml index 746137b9d..6a4648ebe 100644 --- a/patches/src/main/resources/youtube/settings/host/values/strings.xml +++ b/patches/src/main/resources/youtube/settings/host/values/strings.xml @@ -980,11 +980,6 @@ Limitation: Video title disappears when clicked." Enable compact controls overlay Controls overlay does not fill the fullscreen. Controls overlay fills the fullscreen. - Force fullscreen - "Videos will be switched to fullscreen in the following situations: - -• When a video is started. -• When a timestamp in the comments is clicked on." Keep landscape mode Keeps landscape mode when turning the screen off and on in fullscreen. Keep landscape mode timeout diff --git a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 8c4f1daf1..43903afc8 100644 --- a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -416,8 +416,7 @@ - - SETTINGS: FULLSCREEN_COMPONENTS --> + SETTINGS: FULLSCREEN_COMPONENTS -->