feat: Move strings to resources for localization (#2440)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: Aunali321 <aunvakil.aa@gmail.com> BREAKING CHANGE: Various APIs have been changed.
This commit is contained in:
committed by
GitHub
co-authored by
oSumAtrIX
semantic-release-bot
Aunali321
parent
15a83a6d28
commit
55fb1ebd9d
@@ -7,8 +7,8 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.twitch.ad.audio.fingerprints.AudioAdsPresenterPlayFingerprint
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
@@ -16,7 +16,7 @@ import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
@Patch(
|
||||
name = "Block audio ads",
|
||||
description = "Blocks audio ads in streams and VODs.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])],
|
||||
)
|
||||
@Suppress("unused")
|
||||
@@ -24,6 +24,10 @@ object AudioAdsPatch : BytecodePatch(
|
||||
setOf(AudioAdsPresenterPlayFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(SwitchPreference("revanced_block_audio_ads"))
|
||||
|
||||
// Block playAds call
|
||||
with(AudioAdsPresenterPlayFingerprint.result!!) {
|
||||
mutableMethod.addInstructionsWithLabels(
|
||||
@@ -37,23 +41,5 @@ object AudioAdsPatch : BytecodePatch(
|
||||
ExternalLabel("show_audio_ads", mutableMethod.getInstruction(0))
|
||||
)
|
||||
}
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_block_audio_ads",
|
||||
StringResource(
|
||||
"revanced_block_audio_ads",
|
||||
"Block audio ads"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_block_audio_ads_on",
|
||||
"Audio ads are blocked"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_block_audio_ads_off",
|
||||
"Audio ads are unblocked"
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
package app.revanced.patches.twitch.ad.embedded
|
||||
|
||||
import app.revanced.util.exception
|
||||
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.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.ListPreference
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
||||
import app.revanced.patches.twitch.ad.embedded.fingerprints.CreateUsherClientFingerprint
|
||||
import app.revanced.patches.twitch.ad.video.VideoAdsPatch
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Block embedded ads",
|
||||
description = "Blocks embedded stream ads using services like Luminous or PurpleAdBlocker.",
|
||||
dependencies = [VideoAdsPatch::class, IntegrationsPatch::class, SettingsPatch::class],
|
||||
dependencies = [
|
||||
VideoAdsPatch::class,
|
||||
IntegrationsPatch::class,
|
||||
SettingsPatch::class,
|
||||
AddResourcesPatch::class
|
||||
],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])]
|
||||
)
|
||||
@Suppress("unused")
|
||||
@@ -25,6 +29,12 @@ object EmbeddedAdsPatch : BytecodePatch(
|
||||
setOf(CreateUsherClientFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.SURESTREAM.addPreferences(
|
||||
ListPreference("revanced_block_embedded_ads")
|
||||
)
|
||||
|
||||
val result = CreateUsherClientFingerprint.result ?: throw CreateUsherClientFingerprint.exception
|
||||
|
||||
// Inject OkHttp3 application interceptor
|
||||
@@ -36,34 +46,5 @@ object EmbeddedAdsPatch : BytecodePatch(
|
||||
invoke-virtual {v0, v2}, Lokhttp3/OkHttpClient${"$"}Builder;->addInterceptor(Lokhttp3/Interceptor;)Lokhttp3/OkHttpClient${"$"}Builder;
|
||||
"""
|
||||
)
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.SURESTREAM.addPreferences(
|
||||
ListPreference(
|
||||
"revanced_block_embedded_ads",
|
||||
StringResource(
|
||||
"revanced_block_embedded_ads",
|
||||
"Block embedded video ads"
|
||||
),
|
||||
ArrayResource(
|
||||
"revanced_hls_proxies",
|
||||
listOf(
|
||||
StringResource("revanced_proxy_disabled", "Disabled"),
|
||||
StringResource("revanced_proxy_luminous", "Luminous proxy"),
|
||||
StringResource("revanced_proxy_purpleadblock", "PurpleAdBlock proxy"),
|
||||
)
|
||||
),
|
||||
ArrayResource(
|
||||
"revanced_hls_proxies_values",
|
||||
listOf(
|
||||
StringResource("key_revanced_proxy_disabled", "disabled"),
|
||||
StringResource("key_revanced_proxy_luminous", "luminous"),
|
||||
StringResource("key_revanced_proxy_purpleadblock", "purpleadblock")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.addString("revanced_embedded_ads_service_unavailable", "%s is unavailable. Ads may show. Try switching to another ad block service in settings.")
|
||||
SettingsPatch.addString("revanced_embedded_ads_service_failed", "%s server returned an error. Ads may show. Try switching to another ad block service in settings.")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
|
||||
abstract class AbstractAdPatch(
|
||||
abstract class BaseAdPatch(
|
||||
val conditionCall: String,
|
||||
val skipLabelName: String,
|
||||
internal val fingerprints: Set<MethodFingerprint> = emptySet(),
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.revanced.patches.twitch.ad.video
|
||||
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
@@ -8,22 +7,23 @@ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.twitch.ad.shared.util.AbstractAdPatch
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.twitch.ad.shared.util.BaseAdPatch
|
||||
import app.revanced.patches.twitch.ad.video.fingerprints.CheckAdEligibilityLambdaFingerprint
|
||||
import app.revanced.patches.twitch.ad.video.fingerprints.ContentConfigShowAdsFingerprint
|
||||
import app.revanced.patches.twitch.ad.video.fingerprints.GetReadyToShowAdFingerprint
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Block video ads",
|
||||
description = "Blocks video ads in streams and VODs.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])]
|
||||
)
|
||||
object VideoAdsPatch : AbstractAdPatch(
|
||||
object VideoAdsPatch : BaseAdPatch(
|
||||
"Lapp/revanced/integrations/twitch/patches/VideoAdsPatch;->shouldBlockVideoAds()Z",
|
||||
"show_video_ads",
|
||||
setOf(
|
||||
@@ -33,6 +33,10 @@ object VideoAdsPatch : AbstractAdPatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(SwitchPreference("revanced_block_video_ads"))
|
||||
|
||||
/* Amazon ads SDK */
|
||||
context.blockMethods(
|
||||
"Lcom/amazon/ads/video/player/AdsManagerImpl;",
|
||||
@@ -120,23 +124,5 @@ object VideoAdsPatch : AbstractAdPatch(
|
||||
"""
|
||||
)
|
||||
} ?: throw ContentConfigShowAdsFingerprint.exception
|
||||
|
||||
SettingsPatch.PreferenceScreen.ADS.CLIENT_SIDE.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_block_video_ads",
|
||||
StringResource(
|
||||
"revanced_block_video_ads",
|
||||
"Block video ads"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_block_video_ads_on",
|
||||
"Video ads are blocked"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_block_video_ads_off",
|
||||
"Video ads are unblocked"
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+18
-34
@@ -1,6 +1,5 @@
|
||||
package app.revanced.patches.twitch.chat.antidelete
|
||||
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
@@ -9,19 +8,23 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.ListPreference
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.ListPreference
|
||||
import app.revanced.patches.twitch.chat.antidelete.fingerprints.ChatUtilCreateDeletedSpanFingerprint
|
||||
import app.revanced.patches.twitch.chat.antidelete.fingerprints.DeletedMessageClickableSpanCtorFingerprint
|
||||
import app.revanced.patches.twitch.chat.antidelete.fingerprints.SetHasModAccessFingerprint
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Show deleted messages",
|
||||
description = "Shows deleted chat messages behind a clickable spoiler.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
||||
dependencies = [
|
||||
IntegrationsPatch::class,
|
||||
SettingsPatch::class,
|
||||
AddResourcesPatch::class,
|
||||
],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])]
|
||||
)
|
||||
@Suppress("unused")
|
||||
@@ -39,6 +42,15 @@ object ShowDeletedMessagesPatch : BytecodePatch(
|
||||
"""
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
|
||||
ListPreference(
|
||||
key = "revanced_show_deleted_messages",
|
||||
summaryKey = null,
|
||||
)
|
||||
)
|
||||
|
||||
// Spoiler mode: Force set hasModAccess member to true in constructor
|
||||
DeletedMessageClickableSpanCtorFingerprint.result?.mutableMethod?.apply {
|
||||
addInstructionsWithLabels(
|
||||
@@ -68,34 +80,6 @@ object ShowDeletedMessagesPatch : BytecodePatch(
|
||||
""",
|
||||
ExternalLabel("no_reformat", getInstruction(0))
|
||||
)
|
||||
} ?: throw ChatUtilCreateDeletedSpanFingerprint.exception
|
||||
|
||||
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
|
||||
ListPreference(
|
||||
"revanced_show_deleted_messages",
|
||||
StringResource(
|
||||
"revanced_show_deleted_messages_title",
|
||||
"Show deleted messages"
|
||||
),
|
||||
ArrayResource(
|
||||
"revanced_deleted_messages",
|
||||
listOf(
|
||||
StringResource("revanced_deleted_messages_hide", "Do not show deleted messages"),
|
||||
StringResource("revanced_deleted_messages_spoiler", "Hide deleted messages behind a spoiler"),
|
||||
StringResource("revanced_deleted_messages_cross_out", "Show deleted messages as crossed-out text")
|
||||
)
|
||||
),
|
||||
ArrayResource(
|
||||
"revanced_deleted_messages_values",
|
||||
listOf(
|
||||
StringResource("key_revanced_deleted_messages_hide", "hide"),
|
||||
StringResource("key_revanced_deleted_messages_spoiler", "spoiler"),
|
||||
StringResource("key_revanced_deleted_messages_cross_out", "cross-out")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.addString("revanced_deleted_msg", "message deleted")
|
||||
} ?: throw ChatUtilCreateDeletedSpanFingerprint.exception
|
||||
}
|
||||
}
|
||||
|
||||
+8
-20
@@ -1,6 +1,5 @@
|
||||
package app.revanced.patches.twitch.chat.autoclaim
|
||||
|
||||
import app.revanced.util.exception
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
@@ -8,38 +7,27 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.twitch.chat.autoclaim.fingerprints.CommunityPointsButtonViewDelegateFingerprint
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Auto claim channel points",
|
||||
description = "Automatically claim Channel Points.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
dependencies = [SettingsPatch::class, AddResourcesPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object AutoClaimChannelPointPatch : BytecodePatch(
|
||||
object AutoClaimChannelPointsPatch : BytecodePatch(
|
||||
setOf(CommunityPointsButtonViewDelegateFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.CHAT.GENERAL.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_auto_claim_channel_points",
|
||||
StringResource(
|
||||
"revanced_auto_claim_channel_points",
|
||||
"Automatically claim Channel Points"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_auto_claim_channel_points_on",
|
||||
"Channel Points are claimed automatically"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_auto_claim_channel_points_off",
|
||||
"Channel Points are not claimed automatically"
|
||||
)
|
||||
)
|
||||
SwitchPreference("revanced_auto_claim_channel_points")
|
||||
)
|
||||
|
||||
CommunityPointsButtonViewDelegateFingerprint.result?.mutableMethod?.apply {
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package app.revanced.patches.twitch.debug
|
||||
|
||||
import app.revanced.util.exception
|
||||
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.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.twitch.debug.fingerprints.IsDebugConfigEnabledFingerprint
|
||||
import app.revanced.patches.twitch.debug.fingerprints.IsOmVerificationEnabledFingerprint
|
||||
import app.revanced.patches.twitch.debug.fingerprints.ShouldShowDebugOptionsFingerprint
|
||||
import app.revanced.patches.twitch.misc.integrations.IntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.settings.SettingsPatch
|
||||
import app.revanced.util.exception
|
||||
|
||||
@Patch(
|
||||
name = "Debug mode",
|
||||
description = "Enables Twitch's internal debugging mode.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
|
||||
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
|
||||
compatiblePackages = [CompatiblePackage("tv.twitch.android.app")],
|
||||
use = false
|
||||
)
|
||||
@@ -30,6 +30,10 @@ object DebugModePatch : BytecodePatch(
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(SwitchPreference("revanced_twitch_debug_mode"))
|
||||
|
||||
listOf(
|
||||
IsDebugConfigEnabledFingerprint,
|
||||
IsOmVerificationEnabledFingerprint,
|
||||
@@ -46,23 +50,5 @@ object DebugModePatch : BytecodePatch(
|
||||
)
|
||||
} ?: throw it.exception
|
||||
}
|
||||
|
||||
SettingsPatch.PreferenceScreen.MISC.OTHER.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_twitch_debug_mode",
|
||||
StringResource(
|
||||
"revanced_twitch_debug_mode_title",
|
||||
"Enable Twitch debug mode"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_twitch_debug_mode_summary_on",
|
||||
"Twitch debug mode is enabled (not recommended)"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_twitch_debug_mode_summary_off",
|
||||
"Twitch debug mode is disabled"
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package app.revanced.patches.twitch.misc.integrations
|
||||
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch
|
||||
import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch
|
||||
import app.revanced.patches.twitch.misc.integrations.fingerprints.InitFingerprint
|
||||
|
||||
@Patch(requiresIntegrations = true)
|
||||
object IntegrationsPatch : AbstractIntegrationsPatch(
|
||||
object IntegrationsPatch : BaseIntegrationsPatch(
|
||||
setOf(InitFingerprint)
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package app.revanced.patches.twitch.misc.integrations.fingerprints
|
||||
|
||||
import app.revanced.patches.shared.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint
|
||||
import app.revanced.patches.shared.misc.integrations.BaseIntegrationsPatch.IntegrationsFingerprint
|
||||
|
||||
internal object InitFingerprint : IntegrationsFingerprint(
|
||||
customFingerprint = { methodDef, _ ->
|
||||
|
||||
@@ -11,10 +11,10 @@ import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
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.shared.settings.preference.impl.PreferenceCategory
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.shared.settings.util.AbstractPreferenceScreen
|
||||
import app.revanced.patches.all.misc.resources.AddResourcesPatch
|
||||
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
|
||||
@@ -29,7 +29,11 @@ import java.io.Closeable
|
||||
@Patch(
|
||||
name = "Settings",
|
||||
description = "Adds settings menu to Twitch.",
|
||||
dependencies = [IntegrationsPatch::class, SettingsResourcePatch::class],
|
||||
dependencies = [
|
||||
IntegrationsPatch::class,
|
||||
SettingsResourcePatch::class,
|
||||
AddResourcesPatch::class
|
||||
],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage("tv.twitch.android.app", ["15.4.1", "16.1.0", "16.9.1"])
|
||||
]
|
||||
@@ -48,13 +52,18 @@ object SettingsPatch : BytecodePatch(
|
||||
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;"
|
||||
private const val MENU_DISMISS_EVENT_CLASS_DESCRIPTOR = "Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;"
|
||||
private const val MENU_DISMISS_EVENT_CLASS_DESCRIPTOR =
|
||||
"Ltv/twitch/android/feature/settings/menu/SettingsMenuViewDelegate\$Event\$OnDismissClicked;"
|
||||
|
||||
private const val INTEGRATIONS_PACKAGE = "app/revanced/integrations/twitch"
|
||||
private const val ACTIVITY_HOOKS_CLASS_DESCRIPTOR = "L$INTEGRATIONS_PACKAGE/settings/AppCompatActivityHook;"
|
||||
private const val UTILS_CLASS_DESCRIPTOR = "L$INTEGRATIONS_PACKAGE/Utils;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
AddResourcesPatch(this::class)
|
||||
|
||||
PreferenceScreen.MISC.OTHER.addPreferences(SwitchPreference("revanced_debug"))
|
||||
|
||||
// Hook onCreate to handle fragment creation
|
||||
SettingsActivityOnCreateFingerprint.result?.apply {
|
||||
val insertIndex = mutableMethod.implementation!!.instructions.size - 2
|
||||
@@ -107,26 +116,9 @@ object SettingsPatch : BytecodePatch(
|
||||
""",
|
||||
ExternalLabel("no_rv_settings_onclick", mutableMethod.getInstruction(insertIndex))
|
||||
)
|
||||
} ?: throw MenuGroupsOnClickFingerprint.exception
|
||||
|
||||
addString("revanced_settings", "ReVanced Settings", false)
|
||||
|
||||
PreferenceScreen.MISC.OTHER.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_debug",
|
||||
StringResource("revanced_debug_title", "Debug logging"),
|
||||
StringResource("revanced_debug_summary_on", "Debug logs are enabled"),
|
||||
StringResource("revanced_debug_summary_off", "Debug logs are disabled")
|
||||
),
|
||||
)
|
||||
} ?: throw MenuGroupsOnClickFingerprint.exception
|
||||
}
|
||||
|
||||
fun addString(identifier: String, value: String, formatted: Boolean = true) =
|
||||
SettingsResourcePatch.addString(identifier, value, formatted)
|
||||
|
||||
fun addPreferenceScreen(preferenceScreen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) =
|
||||
SettingsResourcePatch.addPreferenceScreen(preferenceScreen)
|
||||
|
||||
private fun MethodFingerprintResult.injectMenuItem(
|
||||
name: String,
|
||||
value: Int,
|
||||
@@ -168,33 +160,32 @@ object SettingsPatch : BytecodePatch(
|
||||
/**
|
||||
* Preference screens patches should add their settings to.
|
||||
*/
|
||||
internal object PreferenceScreen : AbstractPreferenceScreen() {
|
||||
val ADS = CustomScreen("ads", "Ads", "Ad blocking settings")
|
||||
val CHAT = CustomScreen("chat", "Chat", "Chat settings")
|
||||
val MISC = CustomScreen("misc", "Misc", "Miscellaneous patches")
|
||||
internal object PreferenceScreen : BasePreferenceScreen() {
|
||||
val ADS = CustomScreen("revanced_ads_screen")
|
||||
val CHAT = CustomScreen("revanced_chat_screen")
|
||||
val MISC = CustomScreen("revanced_misc_screen")
|
||||
|
||||
internal class CustomScreen(key: String, title: String, summary: String) : Screen(key, title, summary) {
|
||||
internal class CustomScreen(key: String) : Screen(key) {
|
||||
/* Categories */
|
||||
val GENERAL = CustomCategory("general", "General settings")
|
||||
val OTHER = CustomCategory("other", "Other settings")
|
||||
val CLIENT_SIDE = CustomCategory("client_ads", "Client-side ads")
|
||||
val SURESTREAM = CustomCategory("surestream_ads", "Server-side surestream ads")
|
||||
val GENERAL = CustomCategory("revanced_general_category")
|
||||
val OTHER = CustomCategory("revanced_other_category")
|
||||
val CLIENT_SIDE = CustomCategory("revanced_client_ads_category")
|
||||
val SURESTREAM = CustomCategory("revanced_surestream_ads_category")
|
||||
|
||||
internal inner class CustomCategory(key: String, title: String) : Screen.Category(key, title) {
|
||||
internal inner class CustomCategory(key: String) : Screen.Category(key) {
|
||||
/* For Twitch, we need to load our CustomPreferenceCategory class instead of the default one. */
|
||||
override fun transform(): PreferenceCategory {
|
||||
return PreferenceCategory(
|
||||
key,
|
||||
StringResource("${key}_title", title),
|
||||
preferences.sortedBy { it.title.value },
|
||||
"app.revanced.integrations.twitch.settings.preference.CustomPreferenceCategory"
|
||||
preferences = preferences,
|
||||
tag = "app.revanced.integrations.twitch.settings.preference.CustomPreferenceCategory"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun commit(screen: app.revanced.patches.shared.settings.preference.impl.PreferenceScreen) {
|
||||
addPreferenceScreen(screen)
|
||||
override fun commit(screen: app.revanced.patches.shared.misc.settings.preference.PreferenceScreen) {
|
||||
SettingsResourcePatch += screen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,5 @@
|
||||
package app.revanced.patches.twitch.misc.settings
|
||||
|
||||
import app.revanced.patches.shared.settings.AbstractSettingsResourcePatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.ArrayResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
|
||||
import app.revanced.patches.shared.misc.settings.BaseSettingsResourcePatch
|
||||
|
||||
object SettingsResourcePatch : AbstractSettingsResourcePatch(
|
||||
"revanced_prefs",
|
||||
"twitch/settings"
|
||||
) {
|
||||
/* Companion delegates */
|
||||
|
||||
/**
|
||||
* Add a new string to the resources.
|
||||
*
|
||||
* @param identifier The key of the string.
|
||||
* @param value The value of the string.
|
||||
* @throws IllegalArgumentException if the string already exists.
|
||||
*/
|
||||
fun addString(identifier: String, value: String, formatted: Boolean) =
|
||||
AbstractSettingsResourcePatch.addString(identifier, value, formatted)
|
||||
|
||||
/**
|
||||
* Add an array to the resources.
|
||||
*
|
||||
* @param arrayResource The array resource to add.
|
||||
*/
|
||||
fun addArray(arrayResource: ArrayResource) = AbstractSettingsResourcePatch.addArray(arrayResource)
|
||||
|
||||
/**
|
||||
* Add a preference to the settings.
|
||||
*
|
||||
* @param preferenceScreen The name of the preference screen.
|
||||
*/
|
||||
fun addPreferenceScreen(preferenceScreen: PreferenceScreen) = AbstractSettingsResourcePatch.addPreference(preferenceScreen)
|
||||
}
|
||||
object SettingsResourcePatch : BaseSettingsResourcePatch()
|
||||
Reference in New Issue
Block a user