Skip to content

Commit

Permalink
Merge branch 'dev' into revanced-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 21, 2024
2 parents 934c33a + 53130c9 commit d8ae741
Show file tree
Hide file tree
Showing 108 changed files with 2,522 additions and 779 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ See the [documentation](https://github.com/inotia00/revanced-documentation#readm
| `Remove background playback restrictions` | Removes restrictions on background playback, including for music and kids videos. | 18.29.38 ~ 19.16.39 |
| `Remove viewer discretion dialog` | Adds an option to remove the dialog that appears when opening a video that has been age-restricted by accepting it automatically. This does not bypass the age restriction. | 18.29.38 ~ 19.16.39 |
| `Return YouTube Dislike` | Adds an option to show the dislike count of videos using the Return YouTube Dislike API. | 18.29.38 ~ 19.16.39 |
| `Return YouTube Username` | Adds an option to replace YouTube handles with usernames in comments using YouTube Data API v3. | 18.29.38 ~ 19.16.39 |
| `Sanitize sharing links` | Adds an option to remove tracking query parameters from URLs when sharing links. | 18.29.38 ~ 19.16.39 |
| `Seekbar components` | Adds options to hide or change components related to the seekbar. | 18.29.38 ~ 19.16.39 |
| `Settings for YouTube` | Applies mandatory patches to implement ReVanced Extended settings into the application. | 18.29.38 ~ 19.16.39 |
Expand Down Expand Up @@ -108,6 +109,7 @@ See the [documentation](https://github.com/inotia00/revanced-documentation#readm
| `Remove viewer discretion dialog` | Adds an option to remove the dialog that appears when opening a video that has been age-restricted by accepting it automatically. This does not bypass the age restriction. | 6.20.51 ~ 7.16.53 |
| `Restore old style library shelf` | Adds an option to return the Library tab to the old style. | 6.20.51 ~ 7.16.53 |
| `Return YouTube Dislike` | Adds an option to show the dislike count of songs using the Return YouTube Dislike API. | 6.20.51 ~ 7.16.53 |
| `Return YouTube Username` | Adds an option to replace YouTube handles with usernames in comments using YouTube Data API v3. | 6.20.51 ~ 7.16.53 |
| `Sanitize sharing links` | Adds an option to remove tracking query parameters from URLs when sharing links. | 6.20.51 ~ 7.16.53 |
| `Settings for YouTube Music` | Applies mandatory patches to implement ReVanced Extended settings into the application. | 6.20.51 ~ 7.16.53 |
| `SponsorBlock` | Adds options to enable and configure SponsorBlock, which can skip undesired video segments, such as non-music sections. | 6.20.51 ~ 7.16.53 |
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 4.14.2
version = 4.15.1
2 changes: 1 addition & 1 deletion patches.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.flyoutmenu.components.fingerprints.DialogSolidFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.EndButtonsContainerFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.MenuItemFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.ScreenWidthFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.ScreenWidthParentFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.SleepTimerFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.TouchOutsideFingerprint
import app.revanced.patches.music.flyoutmenu.components.fingerprints.TrimSilenceConfigFingerprint
Expand All @@ -25,6 +26,7 @@ import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
import app.revanced.patches.music.video.information.VideoInformationPatch
import app.revanced.patches.shared.litho.LithoFilterPatch
import app.revanced.util.alsoResolve
import app.revanced.util.findMethodOrThrow
import app.revanced.util.getReference
import app.revanced.util.getWalkerMethod
Expand Down Expand Up @@ -55,9 +57,9 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
),
compatiblePackages = COMPATIBLE_PACKAGE,
fingerprints = setOf(
DialogSolidFingerprint,
EndButtonsContainerFingerprint,
MenuItemFingerprint,
ScreenWidthParentFingerprint,
SleepTimerFingerprint,
TouchOutsideFingerprint,
TrimSilenceConfigFingerprint,
Expand All @@ -72,15 +74,20 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(

// region patch for enable compact dialog

DialogSolidFingerprint.resultOrThrow().let {
val walkerMethod =
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
walkerMethod.addInstructions(
2, """
invoke-static {p0}, $FLYOUT_CLASS_DESCRIPTOR->enableCompactDialog(I)I
move-result p0
"""
)
ScreenWidthFingerprint.alsoResolve(
context, ScreenWidthParentFingerprint
).let {
it.mutableMethod.apply {
val index = it.scanResult.patternScanResult!!.startIndex
val register = getInstruction<TwoRegisterInstruction>(index).registerA

addInstructions(
index, """
invoke-static {v$register}, $FLYOUT_CLASS_DESCRIPTOR->enableCompactDialog(I)I
move-result v$register
"""
)
}
}

// endregion
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package app.revanced.patches.music.flyoutmenu.components.fingerprints

import app.revanced.util.fingerprint.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.Opcode

internal object ScreenWidthFingerprint : LiteralValueFingerprint(
returnType = "Z",
parameters = listOf("L"),
opcodes = listOf(Opcode.IF_LT),
literalSupplier = { 600 },
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.revanced.patches.music.flyoutmenu.components.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstructionReversed
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.reference.MethodReference

internal object ScreenWidthParentFingerprint : MethodFingerprint(
returnType = "Landroid/graphics/Bitmap;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
parameters = listOf("Landroid/app/Activity;", "I"),
customFingerprint = { methodDef, _ ->
methodDef.indexOfFirstInstructionReversed {
opcode == Opcode.INVOKE_VIRTUAL &&
getReference<MethodReference>()?.name == "destroyDrawingCache"
} >= 0
}
)

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patches.music.general.oldstylelibraryshelf.OldStyleLibraryShelfPatch
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.integrations.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsBytecodePatch
import app.revanced.patches.music.utils.settings.SettingsPatch
Expand All @@ -26,21 +26,30 @@ object SpoofAppVersionPatch : BaseResourcePatch(
) {
override fun execute(context: ResourceContext) {

var defaultValue = "false"

if (SettingsPatch.upward0718) {
context.appendAppVersion("7.16.53")

SettingsBytecodePatch.contexts.findMethodOrThrow(GENERAL_CLASS_DESCRIPTOR) {
name == "getSpoofAppVersionDefault"
SettingsBytecodePatch.contexts.findMethodOrThrow(PATCH_STATUS_CLASS_DESCRIPTOR) {
name == "SpoofAppVersionDefaultString"
}.replaceInstruction(
0,
"const-string v0, \"7.16.53\""
)
SettingsBytecodePatch.contexts.findMethodOrThrow(PATCH_STATUS_CLASS_DESCRIPTOR) {
name == "SpoofAppVersionDefaultBoolean"
}.replaceInstruction(
0,
"const/4 v0, 0x1"
)
defaultValue = "true"
}

SettingsPatch.addSwitchPreference(
CategoryType.GENERAL,
"revanced_spoof_app_version",
"false"
defaultValue
)
SettingsPatch.addPreferenceWithIntent(
CategoryType.GENERAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPat
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.settings.ResourceUtils.setIconType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyResources
Expand All @@ -15,13 +16,18 @@ import app.revanced.util.underBarOrThrow
import org.w3c.dom.Element
import java.io.File
import java.nio.file.Files
import java.nio.file.StandardCopyOption

@Suppress("DEPRECATION", "unused")
object CustomBrandingIconPatch : BaseResourcePatch(
name = "Custom branding icon for YouTube Music",
description = "Changes the YouTube Music app icon to the icon specified in options.json.",
compatiblePackages = COMPATIBLE_PACKAGE
) {
private const val ADAPTIVE_ICON_BACKGROUND_FILE_NAME =
"adaptiveproduct_youtube_music_background_color_108"
private const val ADAPTIVE_ICON_FOREGROUND_FILE_NAME =
"adaptiveproduct_youtube_music_foreground_color_108"
private const val DEFAULT_ICON = "revancify_blue"

private val availableIcon = mapOf(
Expand Down Expand Up @@ -60,8 +66,8 @@ object CustomBrandingIconPatch : BaseResourcePatch(
private val mipmapDirectories = sizeArray.map { "mipmap-$it" }

private val launcherIconResourceFileNames = arrayOf(
"adaptiveproduct_youtube_music_background_color_108",
"adaptiveproduct_youtube_music_foreground_color_108",
ADAPTIVE_ICON_BACKGROUND_FILE_NAME,
ADAPTIVE_ICON_FOREGROUND_FILE_NAME,
"ic_launcher_release"
).map { "$it.png" }.toTypedArray()

Expand Down Expand Up @@ -224,5 +230,53 @@ object CustomBrandingIconPatch : BaseResourcePatch(

setIconType(appIcon)
}

// region fix app icon

if (!SettingsPatch.upward0723) {
return
}
if (appIcon == "youtube_music") {
return
}

fun getAdaptiveIconResourceFile(tag: String): String {
context.xmlEditor["res/mipmap-anydpi/ic_launcher_release.xml"].use { editor ->
val adaptiveIcon = editor
.file
.getElementsByTagName("adaptive-icon")
.item(0) as Element

val childNodes = adaptiveIcon.childNodes
for (i in 0 until childNodes.length) {
val node = childNodes.item(i)
if (node is Element && node.tagName == tag && node.hasAttribute("android:drawable")) {
return node.getAttribute("android:drawable").split("/")[1]
}
}
throw PatchException("Element not found: $tag")
}
}

mapOf(
ADAPTIVE_ICON_BACKGROUND_FILE_NAME to getAdaptiveIconResourceFile("background"),
ADAPTIVE_ICON_FOREGROUND_FILE_NAME to getAdaptiveIconResourceFile("foreground")
).forEach { (oldIconResourceFile, newIconResourceFile) ->
mipmapDirectories.forEach {
val mipmapDirectory = context["res"].resolve(it)
Files.move(
mipmapDirectory
.resolve("$oldIconResourceFile.png")
.toPath(),
mipmapDirectory
.resolve("$newIconResourceFile.png")
.toPath(),
StandardCopyOption.REPLACE_EXISTING
)
}
}

// endregion

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
"revanced_preference_screen_settings",
"revanced_preference_screen_video",
"revanced_preference_screen_ryd",
"revanced_preference_screen_return_youtube_username",
"revanced_preference_screen_sb",
"revanced_preference_screen_misc",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ object PlayerComponentsPatch : BaseBytecodePatch(
.filter { (_, instruction) ->
val reference = (instruction as? ReferenceInstruction)?.reference
instruction.opcode == Opcode.INVOKE_VIRTUAL &&
reference is MethodReference &&
reference is MethodReference &&
reference.toString() == AUDIO_VIDEO_SWITCH_TOGGLE_VISIBILITY
}
.map { (index, _) -> index }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ object Constants {
const val GENERAL_CLASS_DESCRIPTOR = "$GENERAL_PATH/GeneralPatch;"
const val NAVIGATION_CLASS_DESCRIPTOR = "$NAVIGATION_PATH/NavigationPatch;"
const val PLAYER_CLASS_DESCRIPTOR = "$PLAYER_PATH/PlayerPatch;"

const val PATCH_STATUS_CLASS_DESCRIPTOR = "$UTILS_PATH/PatchStatus;"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object SharedResourceIdPatch : ResourcePatch() {
var ColorGrey = -1L
var DarkBackground = -1L
var DesignBottomSheetDialog = -1L
var DialogSolid = -1L
var EndButtonsContainer = -1L
var FloatingLayout = -1L
var HistoryMenuItem = -1L
Expand Down Expand Up @@ -68,7 +67,6 @@ object SharedResourceIdPatch : ResourcePatch() {
ColorGrey = getId(COLOR, "ytm_color_grey_12")
DarkBackground = getId(ID, "dark_background")
DesignBottomSheetDialog = getId(LAYOUT, "design_bottom_sheet_dialog")
DialogSolid = getId(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
EndButtonsContainer = getId(ID, "end_buttons_container")
FloatingLayout = getId(ID, "floating_layout")
HistoryMenuItem = getId(ID, "history_menu_item")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ object ReturnYouTubeDislikePatch : BaseResourcePatch(
"false",
"revanced_ryd_enabled"
)
SettingsPatch.addSwitchPreference(
CategoryType.RETURN_YOUTUBE_DISLIKE,
"revanced_ryd_estimated_like",
"false",
"revanced_ryd_enabled"
)
SettingsPatch.addSwitchPreference(
CategoryType.RETURN_YOUTUBE_DISLIKE,
"revanced_ryd_toast_on_connection_error",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package app.revanced.patches.music.utils.returnyoutubeusername

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.patches.shared.returnyoutubeusername.BaseReturnYouTubeUsernamePatch
import app.revanced.util.patch.BaseBytecodePatch

@Suppress("unused")
object ReturnYouTubeUsernamePatch : BaseBytecodePatch(
name = "Return YouTube Username",
description = "Adds an option to replace YouTube handles with usernames in comments using YouTube Data API v3.",
dependencies = setOf(
BaseReturnYouTubeUsernamePatch::class,
SettingsPatch::class,
),
compatiblePackages = COMPATIBLE_PACKAGE,
use = false
) {
override fun execute(context: BytecodeContext) {

SettingsPatch.addSwitchPreference(
CategoryType.RETURN_YOUTUBE_USERNAME,
"revanced_return_youtube_username_enabled",
"false"
)
SettingsPatch.addPreferenceWithIntent(
CategoryType.RETURN_YOUTUBE_USERNAME,
"revanced_return_youtube_username_display_format",
"revanced_return_youtube_username_enabled"
)
SettingsPatch.addPreferenceWithIntent(
CategoryType.RETURN_YOUTUBE_USERNAME,
"revanced_return_youtube_username_youtube_data_api_v3_developer_key",
"revanced_return_youtube_username_enabled"
)
if (SettingsPatch.upward0627) {
SettingsPatch.addPreferenceWithIntent(
CategoryType.RETURN_YOUTUBE_USERNAME,
"revanced_return_youtube_username_youtube_data_api_v3_about"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum class CategoryType(val value: String, var added: Boolean) {
SETTINGS("settings", false),
VIDEO("video", false),
RETURN_YOUTUBE_DISLIKE("ryd", false),
RETURN_YOUTUBE_USERNAME("return_youtube_username", false),
SPONSOR_BLOCK("sb", false),
MISC("misc", false)
}
Loading

0 comments on commit d8ae741

Please sign in to comment.