Skip to content

Commit

Permalink
feat(YouTube Music - Spoof app version): Add target version 7.16.53
Browse files Browse the repository at this point in the history
inotia00 authored and anddea committed Oct 4, 2024
1 parent 4ddc2d8 commit f8bf95c
Showing 4 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import app.revanced.patches.music.general.oldstylelibraryshelf.OldStyleLibrarySh
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.util.appendAppVersion
import app.revanced.util.patch.BaseResourcePatch

@Suppress("unused")
@@ -21,6 +22,10 @@ object SpoofAppVersionPatch : BaseResourcePatch(
) {
override fun execute(context: ResourceContext) {

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

SettingsPatch.addSwitchPreference(
CategoryType.GENERAL,
"revanced_spoof_app_version",
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ package app.revanced.patches.youtube.general.spoofappversion

import app.revanced.patcher.data.ResourceContext
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addEntryValues
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.appendAppVersion
import app.revanced.util.patch.BaseResourcePatch

@Suppress("unused")
@@ -17,12 +17,6 @@ object SpoofAppVersionPatch : BaseResourcePatch(
),
compatiblePackages = COMPATIBLE_PACKAGE
) {
private const val ATTRIBUTE_NAME_ENTRIES =
"revanced_spoof_app_version_target_entries"

private const val ATTRIBUTE_NAME_ENTRY_VALUE =
"revanced_spoof_app_version_target_entry_values"

override fun execute(context: ResourceContext) {

if (SettingsPatch.upward1834) {
@@ -48,17 +42,4 @@ object SpoofAppVersionPatch : BaseResourcePatch(

SettingsPatch.updatePatchStatus(this)
}

private fun ResourceContext.appendAppVersion(appVersion: String) {
addEntryValues(
ATTRIBUTE_NAME_ENTRIES,
"@string/revanced_spoof_app_version_target_entry_" + appVersion.replace(".", "_"),
prepend = false
)
addEntryValues(
ATTRIBUTE_NAME_ENTRY_VALUE,
appVersion,
prepend = false
)
}
}
5 changes: 4 additions & 1 deletion src/main/kotlin/app/revanced/util/ResourceUtils.kt
Original file line number Diff line number Diff line change
@@ -304,7 +304,10 @@ internal fun NodeList.findElementByAttributeValue(attributeName: String, value:
return null
}

internal fun NodeList.findElementByAttributeValueOrThrow(attributeName: String, value: String): Element {
internal fun NodeList.findElementByAttributeValueOrThrow(
attributeName: String,
value: String
): Element {
return findElementByAttributeValue(attributeName, value)
?: throw PatchException("Could not find: $attributeName $value")
}
4 changes: 2 additions & 2 deletions src/main/resources/music/settings/host/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<item>@string/revanced_change_start_page_entry_library</item>
<item>@string/revanced_change_start_page_entry_subscription</item>
</string-array>
<string-array name="revanced_change_start_page_entry_value">
<string-array name="revanced_change_start_page_entry_values">
<item>FEmusic_charts</item>
<item>FEmusic_explore</item>
<item>FEmusic_home</item>
@@ -41,7 +41,7 @@
<item>@string/revanced_spoof_app_version_target_entry_6_11_52</item>
<item>@string/revanced_spoof_app_version_target_entry_4_27_53</item>
</string-array>
<string-array name="revanced_spoof_app_version_target_entry_value">
<string-array name="revanced_spoof_app_version_target_entry_values">
<item>6.11.52</item>
<item>4.27.53</item>
</string-array>

0 comments on commit f8bf95c

Please sign in to comment.