diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/MiniplayerPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/MiniplayerPatch.java index 33bdf26b29..068aa4d2ef 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/MiniplayerPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/MiniplayerPatch.java @@ -24,9 +24,20 @@ public final class MiniplayerPatch { * Mini player type. Null fields indicates to use the original un-patched value. */ public enum MiniplayerType { + /** + * Disabled. When swiped down the miniplayer is immediately closed. + * Only available with 19.43+ + */ + DISABLED(false, null), /** Unmodified type, and same as un-patched. */ ORIGINAL(null, null), + /** + * Exactly the same as MINIMAL, and only here for migration of user settings. + * Eventually this should be deleted. + */ + @Deprecated PHONE(false, null), + MINIMAL(false, null), TABLET(true, null), MODERN_1(null, 1), MODERN_2(null, 2), @@ -164,6 +175,18 @@ public boolean isAvailable() { OPACITY_LEVEL = (opacity * 255) / 100; } + /** + * Injection point. + * + * Enables a handler that immediately closes the miniplayer when the video is minimized, + * effectively disabling the miniplayer. + */ + public static boolean getMiniplayerOnCloseHandler(boolean original) { + return CURRENT_TYPE == ORIGINAL + ? original + : CURRENT_TYPE == DISABLED; + } + /** * Injection point. */ 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 48b4d99032..9b7232368e 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 @@ -375,15 +375,20 @@ public class Settings extends BaseSettings { migrateOldSettingToNew(DEPRECATED_SB_UUID_OLD_MIGRATION_SETTING, SB_PRIVATE_USER_ID); + migrateOldSettingToNew(DEPRECATED_HIDE_PLAYER_BUTTONS, HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS); + + migrateOldSettingToNew(DEPRECATED_HIDE_PLAYER_FLYOUT_VIDEO_QUALITY_FOOTER, HIDE_PLAYER_FLYOUT_VIDEO_QUALITY_FOOTER); + // Old spoof versions that no longer work reliably. if (SpoofAppVersionPatch.isSpoofingToLessThan(SPOOF_APP_VERSION_TARGET.defaultValue)) { Logger.printInfo(() -> "Resetting spoof app version target"); SPOOF_APP_VERSION_TARGET.resetToDefault(); } - migrateOldSettingToNew(DEPRECATED_HIDE_PLAYER_BUTTONS, HIDE_PLAYER_PREVIOUS_NEXT_BUTTONS); - - migrateOldSettingToNew(DEPRECATED_HIDE_PLAYER_FLYOUT_VIDEO_QUALITY_FOOTER, HIDE_PLAYER_FLYOUT_VIDEO_QUALITY_FOOTER); + // Migrate renamed enum type. + if (MINIPLAYER_TYPE.get() == PHONE) { + MINIPLAYER_TYPE.save(MINIMAL); + } // endregion } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/Fingerprints.kt index 125f043a3b..5a2f47239f 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/Fingerprints.kt @@ -43,6 +43,7 @@ internal const val MINIPLAYER_DRAG_DROP_FEATURE_KEY = 45628752L internal const val MINIPLAYER_HORIZONTAL_DRAG_FEATURE_KEY = 45658112L internal const val MINIPLAYER_ROUNDED_CORNERS_FEATURE_KEY = 45652224L internal const val MINIPLAYER_INITIAL_SIZE_FEATURE_KEY = 45640023L +internal const val MINIPLAYER_DISABLED_FEATURE_KEY = 45657015L internal val miniplayerModernConstructorFingerprint = fingerprint { accessFlags(AccessFlags.PUBLIC, AccessFlags.CONSTRUCTOR) @@ -50,6 +51,12 @@ internal val miniplayerModernConstructorFingerprint = fingerprint { literal { 45623000L } } +internal val miniplayerOnCloseHandlerFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + literal { MINIPLAYER_DISABLED_FEATURE_KEY } +} + /** * Matches using the class found in [miniplayerModernViewParentFingerprint]. */ diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt index 61d5fcc06b..cd56100963 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/miniplayer/MiniplayerPatch.kt @@ -147,8 +147,7 @@ val miniplayerPatch = bytecodePatch( compatibleWith( "com.google.android.youtube"( - "18.38.44", - "18.49.37", + // 18.49.37 // Could be supported, but no reason when 19.16 exists and has modern types. // 19.14.43 // Incomplete code for modern miniplayers. // 19.15.36 // Different code for handling subtitle texts and not worth supporting. "19.16.39", // First with modern miniplayers. @@ -179,58 +178,60 @@ val miniplayerPatch = bytecodePatch( val preferences = mutableSetOf() - if (!is_19_16_or_greater) { - preferences += ListPreference( - "revanced_miniplayer_type", - summaryKey = null, - entriesKey = "revanced_miniplayer_type_legacy_entries", - entryValuesKey = "revanced_miniplayer_type_legacy_entry_values", - ) - } else { - preferences += ListPreference( - "revanced_miniplayer_type", - summaryKey = null, - ) - - if (is_19_25_or_greater) { - if (!is_19_29_or_greater) { - preferences += SwitchPreference("revanced_miniplayer_double_tap_action") - } - preferences += SwitchPreference("revanced_miniplayer_drag_and_drop") - } + preferences += if (is_19_43_or_greater) { - preferences += SwitchPreference("revanced_miniplayer_horizontal_drag") + ListPreference( + "revanced_miniplayer_type", + summaryKey = null, + ) + } else { + ListPreference( + "revanced_miniplayer_type", + summaryKey = null, + entriesKey = "revanced_miniplayer_type_legacy_entries", + entryValuesKey = "revanced_miniplayer_type_legacy_entry_values", + ) } - if (is_19_36_or_greater) { - preferences += SwitchPreference("revanced_miniplayer_rounded_corners") + if (is_19_25_or_greater) { + if (!is_19_29_or_greater) { + preferences += SwitchPreference("revanced_miniplayer_double_tap_action") } + preferences += SwitchPreference("revanced_miniplayer_drag_and_drop") + } - preferences += SwitchPreference("revanced_miniplayer_hide_subtext") + if (is_19_43_or_greater) { + preferences += SwitchPreference("revanced_miniplayer_horizontal_drag") + } - preferences += if (is_19_26_or_greater) { - SwitchPreference("revanced_miniplayer_hide_expand_close") - } else { - SwitchPreference( - key = "revanced_miniplayer_hide_expand_close", - titleKey = "revanced_miniplayer_hide_expand_close_legacy_title", - summaryOnKey = "revanced_miniplayer_hide_expand_close_legacy_summary_on", - summaryOffKey = "revanced_miniplayer_hide_expand_close_legacy_summary_off", - ) - } + if (is_19_36_or_greater) { + preferences += SwitchPreference("revanced_miniplayer_rounded_corners") + } - if (!is_19_26_or_greater) { - preferences += SwitchPreference("revanced_miniplayer_hide_rewind_forward") - } + preferences += SwitchPreference("revanced_miniplayer_hide_subtext") - if (is_19_26_or_greater) { - preferences += TextPreference("revanced_miniplayer_width_dip", inputType = InputType.NUMBER) - } + preferences += if (is_19_26_or_greater) { + SwitchPreference("revanced_miniplayer_hide_expand_close") + } else { + SwitchPreference( + key = "revanced_miniplayer_hide_expand_close", + titleKey = "revanced_miniplayer_hide_expand_close_legacy_title", + summaryOnKey = "revanced_miniplayer_hide_expand_close_legacy_summary_on", + summaryOffKey = "revanced_miniplayer_hide_expand_close_legacy_summary_off", + ) + } + + if (!is_19_26_or_greater) { + preferences += SwitchPreference("revanced_miniplayer_hide_rewind_forward") + } - preferences += TextPreference("revanced_miniplayer_opacity", inputType = InputType.NUMBER) + if (is_19_26_or_greater) { + preferences += TextPreference("revanced_miniplayer_width_dip", inputType = InputType.NUMBER) } + preferences += TextPreference("revanced_miniplayer_opacity", inputType = InputType.NUMBER) + PreferenceScreen.PLAYER.addPreferences( PreferenceScreenPreference( key = "revanced_miniplayer_screen", @@ -350,11 +351,6 @@ val miniplayerPatch = bytecodePatch( it.method.insertLegacyTabletMiniplayerOverride(it.patternMatch!!.endIndex) } - if (!is_19_16_or_greater) { - // Return here, as patch below is only for the current versions of the app. - return@execute - } - // endregion // region Enable modern miniplayer. @@ -380,13 +376,6 @@ val miniplayerPatch = bytecodePatch( ) } - if (is_19_43_or_greater) { - miniplayerModernConstructorFingerprint.insertLiteralValueBooleanOverride( - MINIPLAYER_HORIZONTAL_DRAG_FEATURE_KEY, - "setHorizontalDrag", - ) - } - if (is_19_25_or_greater) { miniplayerModernConstructorFingerprint.insertLiteralValueBooleanOverride( MINIPLAYER_MODERN_FEATURE_LEGACY_KEY, @@ -443,6 +432,18 @@ val miniplayerPatch = bytecodePatch( ) } + if (is_19_43_or_greater) { + miniplayerOnCloseHandlerFingerprint.insertLiteralValueBooleanOverride( + MINIPLAYER_DISABLED_FEATURE_KEY, + "getMiniplayerOnCloseHandler" + ) + + miniplayerModernConstructorFingerprint.insertLiteralValueBooleanOverride( + MINIPLAYER_HORIZONTAL_DRAG_FEATURE_KEY, + "setHorizontalDrag", + ) + } + // endregion // region Fix 19.16 using mixed up drawables for tablet modern. diff --git a/patches/src/main/resources/addresources/values/arrays.xml b/patches/src/main/resources/addresources/values/arrays.xml index 6df8ea926a..7dbc76b2cc 100644 --- a/patches/src/main/resources/addresources/values/arrays.xml +++ b/patches/src/main/resources/addresources/values/arrays.xml @@ -34,6 +34,7 @@ + @string/revanced_miniplayer_type_entry_0 @string/revanced_miniplayer_type_entry_1 @string/revanced_miniplayer_type_entry_2 @string/revanced_miniplayer_type_entry_3 @@ -43,8 +44,9 @@ + DISABLED ORIGINAL - PHONE + MINIMAL TABLET MODERN_1 MODERN_2 @@ -54,11 +56,18 @@ @string/revanced_miniplayer_type_entry_1 @string/revanced_miniplayer_type_entry_2 @string/revanced_miniplayer_type_entry_3 + @string/revanced_miniplayer_type_entry_4 + @string/revanced_miniplayer_type_entry_5 + @string/revanced_miniplayer_type_entry_6 + ORIGINAL - PHONE + MINIMAL TABLET + MODERN_1 + MODERN_2 + MODERN_3 diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index 34c145280e..86fb2405cc 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -1021,8 +1021,9 @@ This is because Crowdin requires temporarily flattening this file and removing t Miniplayer Change the style of the in app minimized player Miniplayer type + Disabled Original - Phone + Minimal Tablet Modern 1 Modern 2