mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
feat(YouTube Music): Add Settings
patch
This commit is contained in:
parent
cc1d9b7436
commit
c789d6ee14
@ -346,6 +346,10 @@ public final class app/revanced/patches/music/misc/androidauto/BypassCertificate
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/debugging/DebuggingPatch : app/revanced/patches/shared/misc/debugging/BaseDebuggingPatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/debugging/DebuggingPatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/gms/Constants {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/gms/Constants;
|
||||
}
|
||||
@ -362,6 +366,26 @@ public final class app/revanced/patches/music/misc/integrations/IntegrationsPatc
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/integrations/IntegrationsPatch;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/settings/SettingsPatch : app/revanced/patcher/patch/BytecodePatch, java/io/Closeable {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/settings/SettingsPatch;
|
||||
public fun close ()V
|
||||
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
public final fun newIntent (Ljava/lang/String;)Lapp/revanced/patches/shared/misc/settings/preference/IntentPreference$Intent;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/settings/SettingsPatch$PreferenceScreen : app/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/settings/SettingsPatch$PreferenceScreen;
|
||||
public fun commit (Lapp/revanced/patches/shared/misc/settings/preference/PreferenceScreen;)V
|
||||
public final fun getMISC ()Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/misc/settings/SettingsResourcePatch : app/revanced/patches/shared/misc/settings/BaseSettingsResourcePatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/misc/settings/SettingsResourcePatch;
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch : app/revanced/patcher/patch/BytecodePatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/music/premium/backgroundplay/BackgroundPlayPatch;
|
||||
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||
@ -580,6 +604,13 @@ public final class app/revanced/patches/serviceportalbund/detection/root/RootDet
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
}
|
||||
|
||||
public abstract class app/revanced/patches/shared/misc/debugging/BaseDebuggingPatch : app/revanced/patcher/patch/ResourcePatch {
|
||||
public fun <init> (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;Ljava/util/Set;Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/util/Set;Ljava/util/Set;)V
|
||||
public synthetic fun <init> (Lkotlin/reflect/KClass;Lkotlin/reflect/KClass;Ljava/util/Set;Lapp/revanced/patches/shared/misc/settings/preference/BasePreferenceScreen$Screen;Ljava/util/Set;Ljava/util/Set;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch : app/revanced/patcher/patch/BytecodePatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/shared/misc/fix/verticalscroll/VerticalScrollPatch;
|
||||
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
|
||||
@ -1473,7 +1504,7 @@ public final class app/revanced/patches/youtube/misc/autorepeat/AutoRepeatPatch
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
}
|
||||
|
||||
public final class app/revanced/patches/youtube/misc/debugging/DebuggingPatch : app/revanced/patcher/patch/ResourcePatch {
|
||||
public final class app/revanced/patches/youtube/misc/debugging/DebuggingPatch : app/revanced/patches/shared/misc/debugging/BaseDebuggingPatch {
|
||||
public static final field INSTANCE Lapp/revanced/patches/youtube/misc/debugging/DebuggingPatch;
|
||||
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
|
||||
public fun execute (Lapp/revanced/patcher/data/ResourceContext;)V
|
||||
|
@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.music.misc.debugging
|
||||
|
||||
import app.revanced.patches.music.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.music.misc.settings.SettingsPatch
|
||||
import app.revanced.patches.shared.misc.debugging.BaseDebuggingPatch
|
||||
|
||||
@Suppress("unused")
|
||||
object DebuggingPatch : BaseDebuggingPatch(
|
||||
integrationsPatch = IntegrationsPatch::class,
|
||||
settingsPatch = SettingsPatch::class,
|
||||
compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")),
|
||||
miscPreferenceScreen = SettingsPatch.PreferenceScreen.MISC,
|
||||
)
|
@ -0,0 +1,70 @@
|
||||
package app.revanced.patches.music.misc.settings
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.all.misc.packagename.ChangePackageNamePatch
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.music.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.music.misc.settings.fingerprints.FullStackTraceActivityFingerprint
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.IntentPreference
|
||||
import app.revanced.util.exception
|
||||
import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
import java.io.Closeable
|
||||
|
||||
@Patch(
|
||||
description = "Adds settings for ReVanced to YouTube Music.",
|
||||
dependencies = [
|
||||
IntegrationsPatch::class,
|
||||
SettingsResourcePatch::class,
|
||||
AddResourcesPatch::class
|
||||
]
|
||||
)
|
||||
object SettingsPatch : BytecodePatch(
|
||||
setOf(FullStackTraceActivityFingerprint)
|
||||
), Closeable {
|
||||
private const val INTEGRATIONS_PACKAGE = "app/revanced/integrations/music"
|
||||
private const val ACTIVITY_HOOK_CLASS_DESCRIPTOR = "L$INTEGRATIONS_PACKAGE/settings/FullStackTraceActivityHook;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
FullStackTraceActivityFingerprint.result?.let { result ->
|
||||
result.mutableMethod.addInstructions(
|
||||
1,
|
||||
"""
|
||||
invoke-static { p0 }, $ACTIVITY_HOOK_CLASS_DESCRIPTOR->initialize(Landroid/app/Activity;)V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
|
||||
// Remove other methods as they will break as the onCreate method is modified above.
|
||||
result.mutableClass.apply {
|
||||
methods.removeIf { it.name != "onCreate" && !MethodUtil.isConstructor(it) }
|
||||
}
|
||||
} ?: throw FullStackTraceActivityFingerprint.exception
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an intent to open ReVanced settings.
|
||||
*/
|
||||
fun newIntent(settingsName: String) = IntentPreference.Intent(
|
||||
data = settingsName,
|
||||
targetClass = "com.google.android.libraries.strictmode.penalties.notification.FullStackTraceActivity"
|
||||
) {
|
||||
// The package name change has to be reflected in the intent.
|
||||
ChangePackageNamePatch.setOrGetFallbackPackageName("com.google.android.apps.youtube.music")
|
||||
}
|
||||
|
||||
object PreferenceScreen : BasePreferenceScreen() {
|
||||
val MISC = Screen("revanced_misc_screen")
|
||||
|
||||
override fun commit(screen: app.revanced.patches.shared.misc.settings.preference.PreferenceScreen) {
|
||||
SettingsResourcePatch += screen
|
||||
}
|
||||
}
|
||||
|
||||
override fun close() = PreferenceScreen.close()
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package app.revanced.patches.music.misc.settings
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.mapping.ResourceMappingPatch
|
||||
import app.revanced.patches.shared.misc.settings.BaseSettingsResourcePatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.IntentPreference
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.copyResources
|
||||
|
||||
object SettingsResourcePatch : BaseSettingsResourcePatch(
|
||||
IntentPreference(
|
||||
"revanced_settings",
|
||||
intent = SettingsPatch.newIntent("revanced_settings_intent")
|
||||
) to "settings_headers",
|
||||
dependencies = setOf(
|
||||
ResourceMappingPatch::class,
|
||||
AddResourcesPatch::class,
|
||||
)
|
||||
) {
|
||||
override fun execute(context: ResourceContext) {
|
||||
super.execute(context)
|
||||
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
context.copyResources(
|
||||
"settings",
|
||||
ResourceGroup("layout", "revanced_settings_with_toolbar.xml")
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.music.misc.settings.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object FullStackTraceActivityFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
parameters = listOf("Landroid/os/Bundle;"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/FullStackTraceActivity;") && methodDef.name == "onCreate"
|
||||
}
|
||||
)
|
@ -0,0 +1,41 @@
|
||||
package app.revanced.patches.shared.misc.debugging
|
||||
|
||||
import app.revanced.patcher.PatchClass
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
|
||||
abstract class BaseDebuggingPatch(
|
||||
integrationsPatch: PatchClass,
|
||||
settingsPatch: PatchClass,
|
||||
compatiblePackages: Set<CompatiblePackage>,
|
||||
// TODO: Settings patch should probably be abstracted
|
||||
// so we do not have to pass it in as a dependency AND it's preference screen at the same time.
|
||||
private val miscPreferenceScreen: BasePreferenceScreen.Screen,
|
||||
private val additionalDebugPreferences: Set<BasePreference> = emptySet(),
|
||||
additionalDependencies: Set<PatchClass> = emptySet()
|
||||
) : ResourcePatch(
|
||||
name = "Enable debugging",
|
||||
description = "Adds options for debugging.",
|
||||
dependencies = setOf(integrationsPatch, settingsPatch) + AddResourcesPatch::class + additionalDependencies,
|
||||
compatiblePackages = compatiblePackages
|
||||
) {
|
||||
override fun execute(context: ResourceContext) {
|
||||
AddResourcesPatch(BaseDebuggingPatch::class)
|
||||
|
||||
miscPreferenceScreen.addPreferences(
|
||||
PreferenceScreen(
|
||||
"revanced_debug_preference_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_debug"),
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error")
|
||||
) + additionalDebugPreferences
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -12,9 +12,9 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceCategory
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsOnClickFingerprint
|
||||
import app.revanced.patches.twitch.misc.settings.fingerprints.MenuGroupsUpdatedFingerprint
|
||||
@ -48,7 +48,7 @@ object SettingsPatch : BytecodePatch(
|
||||
), Closeable {
|
||||
private const val REVANCED_SETTINGS_MENU_ITEM_NAME = "RevancedSettings"
|
||||
private const val REVANCED_SETTINGS_MENU_ITEM_ID = 0x7
|
||||
private const val REVANCED_SETTINGS_MENU_ITEM_TITLE_RES = "revanced_settings"
|
||||
private const val REVANCED_SETTINGS_MENU_ITEM_TITLE_RES = "revanced_settings_title"
|
||||
private const val REVANCED_SETTINGS_MENU_ITEM_ICON_RES = "ic_settings"
|
||||
|
||||
private const val MENU_ITEM_ENUM_CLASS_DESCRIPTOR = "Ltv/twitch/android/feature/settings/menu/SettingsMenuItem;"
|
||||
|
@ -1,36 +1,26 @@
|
||||
package app.revanced.patches.youtube.misc.debugging
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
|
||||
import app.revanced.patches.shared.misc.debugging.BaseDebuggingPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.SettingsPatch
|
||||
|
||||
@Patch(
|
||||
name = "Enable debugging",
|
||||
description = "Adds options for debugging.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("com.google.android.youtube")]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object DebuggingPatch : ResourcePatch() {
|
||||
object DebuggingPatch : BaseDebuggingPatch(
|
||||
integrationsPatch = IntegrationsPatch::class,
|
||||
settingsPatch = SettingsPatch::class,
|
||||
compatiblePackages = setOf(CompatiblePackage("com.google.android.youtube")),
|
||||
miscPreferenceScreen = SettingsPatch.PreferenceScreen.MISC,
|
||||
additionalDebugPreferences = setOf(
|
||||
SwitchPreference("revanced_debug_protobuffer")
|
||||
),
|
||||
additionalDependencies = setOf(AddResourcesPatch::class)
|
||||
) {
|
||||
override fun execute(context: ResourceContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.MISC.addPreferences(
|
||||
PreferenceScreen(
|
||||
"revanced_debug_preference_screen",
|
||||
preferences = setOf(
|
||||
SwitchPreference("revanced_debug"),
|
||||
SwitchPreference("revanced_debug_protobuffer"),
|
||||
SwitchPreference("revanced_debug_stacktrace"),
|
||||
SwitchPreference("revanced_debug_toast_on_error")
|
||||
)
|
||||
)
|
||||
)
|
||||
super.execute(context)
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,10 @@ object SettingsResourcePatch : BaseSettingsResourcePatch(
|
||||
it.type == "string" && it.name == "app_theme_appearance_dark"
|
||||
}!!.id
|
||||
|
||||
arrayOf(
|
||||
context.copyResources(
|
||||
"settings",
|
||||
ResourceGroup("layout", "revanced_settings_with_toolbar.xml")
|
||||
).forEach { resourceGroup ->
|
||||
context.copyResources("settings", resourceGroup)
|
||||
}
|
||||
)
|
||||
|
||||
// Modify the manifest and add a data intent filter to the LicenseActivity.
|
||||
// Some devices freak out if undeclared data is passed to an intent,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/ytBrandBackgroundSolid"
|
||||
app:navigationIcon="@drawable/yt_outline_arrow_left_black_24"
|
||||
app:title="@string/revanced_settings" />
|
||||
app:title="@string/revanced_settings_title" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
|
Loading…
x
Reference in New Issue
Block a user