diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java index b5652471b..4f71ef011 100644 --- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java +++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/general/GeneralPatch.java @@ -40,6 +40,8 @@ import java.util.EnumMap; import java.util.Map; import java.util.Objects; +import app.revanced.extension.shared.settings.BaseSettings; +import app.revanced.extension.shared.utils.Logger; import app.revanced.extension.shared.utils.ResourceUtils; import app.revanced.extension.shared.utils.Utils; import app.revanced.extension.youtube.settings.Settings; @@ -234,6 +236,17 @@ public class GeneralPatch { } } + public static int getLibraryDrawableId(int original) { + if (ExtendedUtils.IS_19_26_OR_GREATER && + !ExtendedUtils.isSpoofingToLessThan("19.27.00")) { + int libraryCairoId = ResourceUtils.getDrawableIdentifier("yt_outline_library_cairo_black_24"); + if (libraryCairoId != 0) { + return libraryCairoId; + } + } + return original; + } + public static boolean switchCreateWithNotificationButton(boolean original) { return Settings.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.get() || original; } diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt index 33821a219..23fbde7f5 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/Fingerprints.kt @@ -1,6 +1,7 @@ package app.revanced.patches.youtube.general.navigation import app.revanced.patches.youtube.utils.resourceid.ytFillBell +import app.revanced.patches.youtube.utils.resourceid.ytOutlineLibrary import app.revanced.util.fingerprint.legacyFingerprint import app.revanced.util.or import com.android.tools.smali.dexlib2.AccessFlags @@ -74,6 +75,11 @@ internal val setEnumMapFingerprint = legacyFingerprint( literals = listOf(ytFillBell), ) +internal val setEnumMapSecondaryFingerprint = legacyFingerprint( + name = "setEnumMapSecondaryFingerprint", + literals = listOf(ytOutlineLibrary), +) + internal const val TRANSLUCENT_NAVIGATION_BAR_FEATURE_FLAG = 45630927L internal val translucentNavigationBarFingerprint = legacyFingerprint( diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt index ee584d225..e96975ac3 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/general/navigation/NavigationBarComponentsPatch.kt @@ -15,6 +15,7 @@ import app.revanced.patches.youtube.utils.playservice.is_19_25_or_greater import app.revanced.patches.youtube.utils.playservice.is_19_28_or_greater import app.revanced.patches.youtube.utils.playservice.versionCheckPatch import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch +import app.revanced.patches.youtube.utils.resourceid.ytOutlineLibrary import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference import app.revanced.patches.youtube.utils.settings.settingsPatch import app.revanced.util.ResourceGroup @@ -25,6 +26,7 @@ import app.revanced.util.fingerprint.methodOrThrow import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstInstructionReversedOrThrow +import app.revanced.util.indexOfFirstLiteralInstructionOrThrow import app.revanced.util.indexOfFirstStringInstructionOrThrow import com.android.tools.smali.dexlib2.Opcode import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction @@ -56,6 +58,14 @@ private val navigationBarComponentsResourcePatch = resourcePatch( ) ) } + + copyResources( + "youtube/navigationbuttons", + ResourceGroup( + "drawable-xxxhdpi", + "yt_outline_library_cairo_black_24.png" + ) + ) } } } @@ -204,6 +214,18 @@ val navigationBarComponentsPatch = bytecodePatch( """ ) } + + setEnumMapSecondaryFingerprint.methodOrThrow().apply { + val index = indexOfFirstLiteralInstructionOrThrow(ytOutlineLibrary) + val register = getInstruction(index).registerA + + addInstructions( + index + 1, """ + invoke-static {v$register}, $GENERAL_CLASS_DESCRIPTOR->getLibraryDrawableId(I)I + move-result v$register + """ + ) + } } // endregion diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt index 6bf586431..b8598df1e 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/resourceid/SharedResourceIdPatch.kt @@ -237,6 +237,8 @@ var youTubeLogo = -1L private set var ytFillBell = -1L private set +var ytOutlineLibrary = -1L + private set var ytOutlineMoonZ = -1L private set var ytOutlinePictureInPictureWhite = -1L @@ -706,6 +708,10 @@ internal val sharedResourceIdPatch = resourcePatch( DRAWABLE, "yt_fill_bell_black_24" ] + ytOutlineLibrary = resourceMappings[ + DRAWABLE, + "yt_outline_library_black_24" + ] ytOutlineMoonZ = resourceMappings[ DRAWABLE, "yt_outline_moon_z_vd_theme_24" diff --git a/patches/src/main/resources/youtube/navigationbuttons/drawable-xxxhdpi/yt_outline_library_cairo_black_24.png b/patches/src/main/resources/youtube/navigationbuttons/drawable-xxxhdpi/yt_outline_library_cairo_black_24.png new file mode 100644 index 000000000..a91f3f8fd Binary files /dev/null and b/patches/src/main/resources/youtube/navigationbuttons/drawable-xxxhdpi/yt_outline_library_cairo_black_24.png differ