From 5162dccecc5e2cb9bd51a9da65de89292b982efc Mon Sep 17 00:00:00 2001
From: inotia00 <108592928+inotia00@users.noreply.github.com>
Date: Mon, 31 Mar 2025 21:16:29 +0900
Subject: [PATCH] feat(YouTube - Settings): Add `App name`, `App version` and
`Patched date` to patch information
---
.../youtube/patches/utils/PatchStatus.java | 22 ++++++++++--------
.../ReVancedSettingsPreference.java | 23 +++++++++++++++++++
.../branding/name/CustomBrandingNamePatch.kt | 3 ---
.../youtube/utils/settings/ResourceUtils.kt | 3 ---
.../youtube/utils/settings/SettingsPatch.kt | 12 ++++++++++
.../youtube/settings/host/values/strings.xml | 8 ++++---
.../youtube/settings/xml/revanced_prefs.xml | 7 +++---
7 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/utils/PatchStatus.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/utils/PatchStatus.java
index d5317e396..cf8efd5db 100644
--- a/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/utils/PatchStatus.java
+++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/patches/utils/PatchStatus.java
@@ -9,6 +9,11 @@ public class PatchStatus {
return false;
}
+ // Modified by a patch. Do not touch.
+ public static boolean OldSeekbarThumbnailsDefaultBoolean() {
+ return false;
+ }
+
public static boolean OldSplashAnimation() {
// Replace this with true if the Restore old splash animation (Custom branding icon) succeeds
return false;
@@ -40,23 +45,22 @@ public class PatchStatus {
return false;
}
- public static String SpoofAppVersionDefaultString() {
- return "18.17.43";
- }
-
public static boolean ToolBarComponents() {
// Replace this with true if the Toolbar components patch succeeds
return false;
}
+ public static long PatchedTime() {
+ return 0L;
+ }
+
+ public static String SpoofAppVersionDefaultString() {
+ return "18.17.43";
+ }
+
// Modified by a patch. Do not touch.
public static String RVXMusicPackageName() {
return "com.google.android.apps.youtube.music";
}
- // Modified by a patch. Do not touch.
- public static boolean OldSeekbarThumbnailsDefaultBoolean() {
- return false;
- }
-
}
diff --git a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java
index e4cc256bf..3cb96c7ae 100644
--- a/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java
+++ b/extensions/shared/src/main/java/app/revanced/extension/youtube/settings/preference/ReVancedSettingsPreference.java
@@ -6,6 +6,8 @@ import static app.revanced.extension.shared.utils.Utils.isSDKAbove;
import android.preference.Preference;
import android.preference.SwitchPreference;
+import java.util.Date;
+
import app.revanced.extension.shared.settings.Setting;
import app.revanced.extension.youtube.patches.general.ChangeFormFactorPatch;
import app.revanced.extension.youtube.patches.utils.PatchStatus;
@@ -44,6 +46,7 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
AmbientModePreferenceLinks();
FullScreenPanelPreferenceLinks();
NavigationPreferenceLinks();
+ PatchInformationPreferenceLinks();
RYDPreferenceLinks();
SeekBarPreferenceLinks();
ShortsPreferenceLinks();
@@ -143,6 +146,26 @@ public class ReVancedSettingsPreference extends ReVancedPreferenceFragment {
);
}
+ /**
+ * Set patch information preference summary
+ */
+ private static void PatchInformationPreferenceLinks() {
+ Preference appNamePreference = mPreferenceManager.findPreference("revanced_app_name");
+ if (appNamePreference != null) {
+ appNamePreference.setSummary(ExtendedUtils.getAppLabel());
+ }
+ Preference appVersionPreference = mPreferenceManager.findPreference("revanced_app_version");
+ if (appVersionPreference != null) {
+ appVersionPreference.setSummary(ExtendedUtils.getAppVersionName());
+ }
+ Preference patchedDatePreference = mPreferenceManager.findPreference("revanced_patched_date");
+ if (patchedDatePreference != null) {
+ long patchedTime = PatchStatus.PatchedTime();
+ Date date = new Date(patchedTime);
+ patchedDatePreference.setSummary(date.toLocaleString());
+ }
+ }
+
/**
* Enable/Disable Preference related to RYD settings
*/
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt
index a1fe0d202..1dca220ca 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/branding/name/CustomBrandingNamePatch.kt
@@ -4,7 +4,6 @@ import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_BRANDING_NAME_FOR_YOUTUBE
-import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusLabel
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.removeStringsElements
import app.revanced.util.valueOrThrow
@@ -53,7 +52,5 @@ val customBrandingNamePatch = resourcePatch(
.appendChild(stringElement)
}
- updatePatchStatusLabel(appName)
-
}
}
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt
index 43cd0c4f1..094ca72fd 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/ResourceUtils.kt
@@ -88,9 +88,6 @@ internal object ResourceUtils {
updatePatchStatusSettings("Icon", "@string/revanced_icon_$iconName")
}
- fun updatePatchStatusLabel(appName: String) =
- updatePatchStatusSettings("Label", appName)
-
fun updatePatchStatusTheme(themeName: String) =
updatePatchStatusSettings("Theme", themeName)
diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt
index d3fe3da10..471e4cd71 100644
--- a/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt
+++ b/patches/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt
@@ -1,15 +1,18 @@
package app.revanced.patches.youtube.utils.settings
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
+import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.BytecodePatchContext
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patcher.patch.resourcePatch
import app.revanced.patcher.patch.stringOption
+import app.revanced.patcher.util.proxy.mutableTypes.encodedValue.MutableLongEncodedValue
import app.revanced.patches.shared.extension.Constants.EXTENSION_UTILS_CLASS_DESCRIPTOR
import app.revanced.patches.shared.extension.Constants.EXTENSION_UTILS_PATH
import app.revanced.patches.shared.mainactivity.injectConstructorMethodCall
import app.revanced.patches.shared.mainactivity.injectOnCreateMethodCall
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
+import app.revanced.patches.youtube.utils.extension.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
import app.revanced.patches.youtube.utils.extension.Constants.UTILS_PATH
import app.revanced.patches.youtube.utils.extension.sharedExtensionPatch
import app.revanced.patches.youtube.utils.fix.attributes.themeAttributesPatch
@@ -25,11 +28,13 @@ import app.revanced.util.addInstructionsAtControlFlowLabel
import app.revanced.util.copyResources
import app.revanced.util.copyXmlNode
import app.revanced.util.findInstructionIndicesReversedOrThrow
+import app.revanced.util.findMethodOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.removeStringsElements
import app.revanced.util.valueOrThrow
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
+import com.android.tools.smali.dexlib2.immutable.value.ImmutableLongEncodedValue
import org.w3c.dom.Element
import java.nio.file.Files
import java.util.jar.Manifest
@@ -81,6 +86,13 @@ private val settingsBytecodePatch = bytecodePatch(
EXTENSION_UTILS_CLASS_DESCRIPTOR,
"setActivity"
)
+
+ findMethodOrThrow(PATCH_STATUS_CLASS_DESCRIPTOR) {
+ name == "PatchedTime"
+ }.replaceInstruction(
+ 0,
+ "const-wide v0, ${MutableLongEncodedValue(ImmutableLongEncodedValue(System.currentTimeMillis()))}L"
+ )
}
}
diff --git a/patches/src/main/resources/youtube/settings/host/values/strings.xml b/patches/src/main/resources/youtube/settings/host/values/strings.xml
index 2e355c1e1..daa701e47 100644
--- a/patches/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/patches/src/main/resources/youtube/settings/host/values/strings.xml
@@ -2303,8 +2303,11 @@ Click to see more information."
Patch information
Information about applied patches.
-
- Tool used
+
+ App info
+ App name
+ App version
+ Patched date
Others
@@ -2316,7 +2319,6 @@ Click to see more information."
Revancify Blue
Revancify Red
YouTube
- Stock
Excluded
Included
Stock
diff --git a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 3b906b092..18ab51e47 100644
--- a/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/patches/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -912,10 +912,12 @@
-
+
+
+
+
-
@@ -999,7 +1001,6 @@
-