From 3edd8eb43cff8e02a8f90769de7f5a566ea6748e Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:41:58 +0900 Subject: [PATCH] feat(YouTube Music/Spoof app version): add target version 7.16.53 --- .../spoofappversion/SpoofAppVersionPatch.kt | 5 +++++ .../spoofappversion/SpoofAppVersionPatch.kt | 21 +------------------ .../kotlin/app/revanced/util/ResourceUtils.kt | 5 ++++- .../music/settings/host/values/arrays.xml | 4 ++-- .../music/settings/host/values/strings.xml | 1 + 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt index f179b4c43..b3a40403d 100644 --- a/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/general/spoofappversion/SpoofAppVersionPatch.kt @@ -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", diff --git a/src/main/kotlin/app/revanced/patches/youtube/general/spoofappversion/SpoofAppVersionPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/general/spoofappversion/SpoofAppVersionPatch.kt index 54a4a0b0a..df15871e7 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/general/spoofappversion/SpoofAppVersionPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/general/spoofappversion/SpoofAppVersionPatch.kt @@ -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 - ) - } } \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/ResourceUtils.kt index 226a271e7..f82f8c1a5 100644 --- a/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -258,7 +258,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") } \ No newline at end of file diff --git a/src/main/resources/music/settings/host/values/arrays.xml b/src/main/resources/music/settings/host/values/arrays.xml index 6c3e25d26..525a55888 100644 --- a/src/main/resources/music/settings/host/values/arrays.xml +++ b/src/main/resources/music/settings/host/values/arrays.xml @@ -7,7 +7,7 @@ @string/revanced_change_start_page_entry_library @string/revanced_change_start_page_entry_subscription - + FEmusic_charts FEmusic_explore FEmusic_home @@ -41,7 +41,7 @@ @string/revanced_spoof_app_version_target_entry_6_11_52 @string/revanced_spoof_app_version_target_entry_4_27_53 - + 6.11.52 4.27.53 diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index 0e9c15303..38a74ab17 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -194,6 +194,7 @@ This does not bypass the age restriction. It just accepts it automatically."Select the spoof app version target. 4.27.53 - Disable Radio mode in Canadian regions 6.11.52 - Disable real-time lyrics + 7.16.53 - Restore old action bar