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:
LisoUseInAIKyrios
2024-01-27 02:34:01 +01:00
committed by GitHub
co-authored by oSumAtrIX semantic-release-bot Aunali321
parent 15a83a6d28
commit 55fb1ebd9d
201 changed files with 3411 additions and 3784 deletions
@@ -3,50 +3,31 @@ package app.revanced.patches.youtube.interaction.copyvideourl
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.settings.preference.impl.PreferenceScreen
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.PreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.mergeStrings
@Patch(
dependencies = [
SettingsPatch::class,
BottomControlsResourcePatch::class
BottomControlsResourcePatch::class,
AddResourcesPatch::class
]
)
internal object CopyVideoUrlResourcePatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_copy_video_url_preference_screen",
StringResource("revanced_copy_video_url_preference_screen_title", "Copy video URL settings"),
listOf(
SwitchPreference(
"revanced_copy_video_url",
StringResource("revanced_copy_video_url_title", "Show copy video URL button"),
StringResource(
"revanced_copy_video_url_summary_on",
"Button is shown. Tap to copy video URL. Tap and hold to copy video URL with timestamp"
),
StringResource("revanced_copy_video_url_summary_off", "Button is not shown")
),
SwitchPreference(
"revanced_copy_video_url_timestamp",
StringResource("revanced_copy_video_url_timestamp_title", "Show copy timestamp URL button"),
StringResource(
"revanced_copy_video_url_timestamp_summary_on",
"Button is shown. Tap to copy video URL with timestamp. Tap and hold to copy video without timestamp"
),
StringResource("revanced_copy_video_url_timestamp_summary_off", "Button is not shown")
)
),
StringResource(
"revanced_copy_video_url_preference_screen_summary",
"Settings related to copy URL buttons in video player"
preferences = setOf(
SwitchPreference("revanced_copy_video_url"),
SwitchPreference("revanced_copy_video_url_timestamp")
)
)
)
@@ -59,7 +40,7 @@ internal object CopyVideoUrlResourcePatch : ResourcePatch() {
)
)
context.mergeStrings("copyvideourl/host/values/strings.xml")
AddResourcesPatch(this::class)
BottomControlsResourcePatch.addControls("copyvideourl")
}
@@ -6,8 +6,8 @@ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstructions
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.youtube.interaction.dialog.fingerprints.CreateDialogFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
@@ -18,7 +18,7 @@ import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
name = "Remove viewer discretion dialog",
description = "Adds an option to remove the dialog that appears when opening a video that has been age-restricted " +
"by accepting it automatically. This does not bypass the age restriction.",
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube", [
@@ -46,27 +46,9 @@ object RemoveViewerDiscretionDialogPatch : BytecodePatch(
"confirmDialog(Landroid/app/AlertDialog;)V"
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_remove_viewer_discretion_dialog",
StringResource(
"revanced_remove_viewer_discretion_dialog_title",
"Remove viewer discretion dialog"
),
StringResource(
"revanced_remove_viewer_discretion_dialog_summary_on",
"Dialog will be removed"
),
StringResource(
"revanced_remove_viewer_discretion_dialog_summary_off",
"Dialog will be shown"
),
StringResource(
"revanced_remove_viewer_discretion_dialog_user_dialog_message",
"This does not bypass the age restriction. It just accepts it automatically."
)
)
)
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_remove_viewer_discretion_dialog"))
CreateDialogFingerprint.result?.mutableMethod?.apply {
val showDialogIndex = implementation!!.instructions.lastIndex - 2
@@ -3,55 +3,37 @@ package app.revanced.patches.youtube.interaction.downloads
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.settings.preference.impl.*
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.InputType
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.shared.misc.settings.preference.TextPreference
import app.revanced.patches.youtube.misc.playercontrols.BottomControlsResourcePatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
import app.revanced.util.mergeStrings
@Patch(
dependencies = [
BottomControlsResourcePatch::class,
SettingsPatch::class
SettingsPatch::class,
AddResourcesPatch::class,
]
)
internal object ExternalDownloadsResourcePatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_external_downloader_preference_screen",
StringResource("revanced_external_downloader_preference_screen_title", "External download settings"),
listOf(
SwitchPreference(
"revanced_external_downloader",
StringResource("revanced_external_downloader_title", "Show external download button"),
StringResource("revanced_external_downloader_summary_on", "Download button shown in player"),
StringResource(
"revanced_external_downloader_summary_off",
"Download button not shown in player"
)
),
TextPreference(
"revanced_external_downloader_name",
StringResource("revanced_external_downloader_name_title", "Downloader package name"),
StringResource(
"revanced_external_downloader_name_summary",
"Package name of your installed external downloader app, such as NewPipe or Seal"
),
InputType.TEXT
)
preferences = setOf(
SwitchPreference("revanced_external_downloader"),
TextPreference("revanced_external_downloader_name", inputType = InputType.TEXT)
),
StringResource(
"revanced_external_downloader_preference_screen_summary",
"Settings for using an external downloader"
)
)
)
context.mergeStrings("downloads/host/values/strings.xml")
context.copyResources(
"downloads",
ResourceGroup("drawable", "revanced_yt_download_button.xml")
@@ -1,23 +1,23 @@
package app.revanced.patches.youtube.interaction.seekbar
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
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.youtube.interaction.seekbar.fingerprints.IsSwipingUpFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Patch(
name = "Disable precise seeking gesture",
description = "Adds an option to disable precise seeking when swiping up on the seekbar.",
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
@@ -46,13 +46,10 @@ object DisablePreciseSeekingGesturePatch : BytecodePatch(
"disableGesture(Landroid/view/VelocityTracker;Landroid/view/MotionEvent;)V"
override fun execute(context: BytecodeContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_disable_precise_seeking_gesture",
StringResource("revanced_disable_precise_seeking_gesture_title", "Disable precise seeking gesture"),
StringResource("revanced_disable_precise_seeking_gesture_summary_on", "Gesture is disabled"),
StringResource("revanced_disable_precise_seeking_gesture_summary_off", "Gesture is enabled"),
)
SwitchPreference("revanced_disable_precise_seeking_gesture")
)
IsSwipingUpFingerprint.result?.let {
@@ -1,6 +1,5 @@
package app.revanced.patches.youtube.interaction.seekbar
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,12 +7,13 @@ 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.youtube.interaction.seekbar.fingerprints.OnTouchEventHandlerFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SeekbarTappingFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
@@ -22,7 +22,7 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
name = "Seekbar tapping",
description = "Adds an option to enable tap-to-seek on the seekbar of the video player.",
dependencies = [
IntegrationsPatch::class, SettingsPatch::class],
IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
@@ -47,14 +47,9 @@ object EnableSeekbarTappingPatch : BytecodePatch(
)
) {
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_seekbar_tapping",
StringResource("revanced_seekbar_tapping_title", "Enable seekbar tapping"),
StringResource("revanced_seekbar_tapping_summary_on", "Seekbar tapping is enabled"),
StringResource("revanced_seekbar_tapping_summary_off", "Seekbar tapping is disabled")
)
)
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_seekbar_tapping"))
// Find the required methods to tap the seekbar.
val seekbarTappingMethods = OnTouchEventHandlerFingerprint.result?.let {
@@ -1,24 +1,24 @@
package app.revanced.patches.youtube.interaction.seekbar
import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
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.youtube.interaction.seekbar.fingerprints.DoubleSpeedSeekNoticeFingerprint
import app.revanced.patches.youtube.interaction.seekbar.fingerprints.SlideToSeekFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(
name = "Enable slide to seek",
description = "Adds an option to enable slide to seek instead of playing at 2x speed when pressing and holding in the video player. Including this patch may cause issues with tapping or double tapping the video player overlay.",
dependencies = [IntegrationsPatch::class, SettingsPatch::class],
dependencies = [IntegrationsPatch::class, SettingsPatch::class, AddResourcesPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.youtube",
@@ -46,23 +46,9 @@ object EnableSlideToSeekPatch : BytecodePatch(
private const val INTEGRATIONS_CLASS_DESCRIPTOR = "Lapp/revanced/integrations/youtube/patches/SlideToSeekPatch;"
override fun execute(context: BytecodeContext) {
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
SwitchPreference(
"revanced_slide_to_seek",
StringResource(
"revanced_slide_to_seek_title",
"Enable slide to seek"
),
StringResource(
"revanced_slide_to_seek_summary_on",
"Slide to seek is enabled"
),
StringResource(
"revanced_slide_to_seek_summary_off",
"Slide to seek is not enabled"
),
)
)
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(SwitchPreference("revanced_slide_to_seek"))
arrayOf(
// Restore the behaviour to slide to seek.
@@ -3,92 +3,36 @@ package app.revanced.patches.youtube.interaction.swipecontrols
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.shared.settings.preference.impl.*
import app.revanced.patches.all.misc.resources.AddResourcesPatch
import app.revanced.patches.shared.misc.settings.preference.InputType
import app.revanced.patches.shared.misc.settings.preference.PreferenceScreen
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
import app.revanced.patches.shared.misc.settings.preference.TextPreference
import app.revanced.patches.youtube.misc.settings.SettingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.copyResources
@Patch(
dependencies = [SettingsPatch::class]
dependencies = [SettingsPatch::class, AddResourcesPatch::class]
)
internal object SwipeControlsResourcePatch : ResourcePatch() {
override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)
SettingsPatch.PreferenceScreen.INTERACTIONS.addPreferences(
PreferenceScreen(
"revanced_swipe_controls_preference_screen",
StringResource("revanced_swipe_controls_preference_screen_title", "Swipe controls"),
listOf(
SwitchPreference(
"revanced_swipe_brightness",
StringResource("revanced_swipe_brightness_title", "Enable brightness gesture"),
StringResource("revanced_swipe_brightness_summary_on", "Brightness swipe is enabled"),
StringResource("revanced_swipe_brightness_summary_off", "Brightness swipe is disabled")
),
SwitchPreference(
"revanced_swipe_volume",
StringResource("revanced_swipe_volume_title", "Enable volume gesture"),
StringResource("revanced_swipe_volume_summary_on", "Volume swipe is enabled"),
StringResource("revanced_swipe_volume_summary_off", "Volume swipe is disabled")
),
SwitchPreference(
"revanced_swipe_press_to_engage",
StringResource("revanced_swipe_press_to_engage_title", "Enable press-to-swipe gesture"),
StringResource("revanced_swipe_press_to_engage_summary_on", "Press-to-swipe is enabled"),
StringResource("revanced_swipe_press_to_engage_summary_off", "Press-to-swipe is disabled")
),
SwitchPreference(
"revanced_swipe_haptic_feedback",
StringResource("revanced_swipe_haptic_feedback_title", "Enable haptic feedback"),
StringResource("revanced_swipe_haptic_feedback_summary_on", "Haptic feedback is enabled"),
StringResource("revanced_swipe_haptic_feedback_summary_off", "Haptic feedback is disabled")
),
SwitchPreference(
"revanced_swipe_save_and_restore_brightness",
StringResource("revanced_swipe_save_and_restore_brightness_title", "Save and restore brightness"),
StringResource(
"revanced_swipe_save_and_restore_brightness_summary_on",
"Save and restore brightness when exiting or entering fullscreen"
),
StringResource(
"revanced_swipe_save_and_restore_brightness_summary_off",
"Do not save and restore brightness when exiting or entering fullscreen"
)
),
TextPreference(
"revanced_swipe_overlay_timeout",
StringResource("revanced_swipe_overlay_timeout_title", "Swipe overlay timeout"),
StringResource(
"revanced_swipe_overlay_timeout_summary",
"The amount of milliseconds the overlay is visible"
),
InputType.NUMBER
),
TextPreference(
"revanced_swipe_text_overlay_size",
StringResource("revanced_swipe_text_overlay_size_title", "Swipe overlay text size"),
StringResource("revanced_swipe_text_overlay_size_summary", "The text size for swipe overlay"),
InputType.NUMBER
),
TextPreference(
"revanced_swipe_overlay_background_alpha",
StringResource("revanced_swipe_overlay_background_alpha_title", "Swipe background visibility"),
StringResource(
"revanced_swipe_overlay_background_alpha_summary",
"The visibility of swipe overlay background"
),
InputType.NUMBER
),
TextPreference(
"revanced_swipe_threshold",
StringResource("revanced_swipe_threshold_title", "Swipe magnitude threshold"),
StringResource(
"revanced_swipe_threshold_summary",
"The amount of threshold for swipe to occur"
),
InputType.NUMBER
)
key = "revanced_swipe_controls_preference_screen",
preferences = setOf(
SwitchPreference("revanced_swipe_brightness"),
SwitchPreference("revanced_swipe_volume"),
SwitchPreference("revanced_swipe_press_to_engage"),
SwitchPreference("revanced_swipe_haptic_feedback"),
SwitchPreference("revanced_swipe_save_and_restore_brightness"),
TextPreference("revanced_swipe_overlay_timeout", inputType = InputType.NUMBER),
TextPreference("revanced_swipe_text_overlay_size", inputType = InputType.NUMBER),
TextPreference("revanced_swipe_overlay_background_alpha", inputType = InputType.NUMBER),
TextPreference("revanced_swipe_threshold", inputType = InputType.NUMBER)
),
StringResource("revanced_swipe_controls_preference_screen_summary","Control volume and brightness")
)
)
@@ -96,10 +40,10 @@ internal object SwipeControlsResourcePatch : ResourcePatch() {
"swipecontrols",
ResourceGroup(
"drawable",
"ic_sc_brightness_auto.xml",
"ic_sc_brightness_manual.xml",
"ic_sc_volume_mute.xml",
"ic_sc_volume_normal.xml"
"revanced_ic_sc_brightness_auto.xml",
"revanced_ic_sc_brightness_manual.xml",
"revanced_ic_sc_volume_mute.xml",
"revanced_ic_sc_volume_normal.xml"
)
)
}