mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-22 19:09:12 +02:00
feat(YouTube/Description components): add Disable rolling number animations
settings
This commit is contained in:
parent
75449aa709
commit
b09e3b6d86
@ -2,12 +2,16 @@ package app.revanced.patches.youtube.player.descriptions
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.patches.youtube.player.descriptions.fingerprints.EngagementPanelSubHeaderFingerprint
|
||||
import app.revanced.patches.youtube.player.descriptions.fingerprints.TextViewComponentFingerprint
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RollingNumberTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.PLAYER_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
@ -36,6 +40,7 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(
|
||||
EngagementPanelSubHeaderFingerprint,
|
||||
RollingNumberTextViewFingerprint,
|
||||
TextViewComponentFingerprint
|
||||
)
|
||||
) {
|
||||
@ -44,7 +49,49 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
// patch for disable video description interaction and expand video description.
|
||||
// region patch for disable rolling number animation
|
||||
|
||||
// RollingNumber is applied to YouTube v18.49.37+.
|
||||
// In order to maintain compatibility with YouTube v18.48.39 or previous versions,
|
||||
// This patch is applied only to the version after YouTube v18.49.37.
|
||||
if (SettingsPatch.upward1849) {
|
||||
RollingNumberTextViewAnimationUpdateFingerprint.resolve(
|
||||
context,
|
||||
RollingNumberTextViewFingerprint.resultOrThrow().classDef
|
||||
)
|
||||
RollingNumberTextViewAnimationUpdateFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
val imageSpanIndex = it.scanResult.patternScanResult!!.startIndex
|
||||
val setTextIndex = getTargetIndexWithMethodReferenceName("setText")
|
||||
|
||||
addInstruction(setTextIndex, "nop")
|
||||
addInstructionsWithLabels(
|
||||
imageSpanIndex, """
|
||||
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->disableRollingNumberAnimations()Z
|
||||
move-result v$freeRegister
|
||||
if-nez v$freeRegister, :disable_animations
|
||||
""", ExternalLabel("disable_animations", getInstruction(setTextIndex))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE_SCREEN: PLAYER",
|
||||
"SETTINGS: DESCRIPTION_COMPONENTS",
|
||||
"SETTINGS: DISABLE_ROLLING_NUMBER_ANIMATIONS"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for disable video description interaction and expand video description
|
||||
|
||||
// since these patches are still A/B tested, they are classified as 'Experimental flags'.
|
||||
if (SettingsPatch.upward1902) {
|
||||
TextViewComponentFingerprint.resultOrThrow().let {
|
||||
@ -85,6 +132,8 @@ object DescriptionComponentsPatch : BaseBytecodePatch(
|
||||
)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object RollingNumberTextViewAnimationUpdateFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/graphics/Bitmap;"),
|
||||
opcodes = listOf(
|
||||
Opcode.NEW_INSTANCE, // bitmap ImageSpan
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
)
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
package app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints
|
||||
package app.revanced.patches.youtube.utils.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
@ -9,13 +9,13 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint
|
||||
import app.revanced.patches.youtube.utils.fingerprints.RollingNumberTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberMeasureAnimatedTextFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberMeasureStaticLabelFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberMeasureTextParentFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberSetterFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberTextViewAnimationUpdateFingerprint
|
||||
import app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints.RollingNumberTextViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.getTargetIndex
|
||||
import app.revanced.util.getTargetIndexWithMethodReferenceName
|
||||
@ -33,8 +33,7 @@ object ReturnYouTubeDislikeRollingNumberPatch : BytecodePatch(
|
||||
RollingNumberSetterFingerprint,
|
||||
RollingNumberMeasureTextParentFingerprint,
|
||||
RollingNumberTextViewFingerprint,
|
||||
RollingNumberMeasureAnimatedTextFingerprint,
|
||||
RollingNumberTextViewAnimationUpdateFingerprint
|
||||
RollingNumberMeasureAnimatedTextFingerprint
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_RYD_CLASS_DESCRIPTOR =
|
||||
@ -138,15 +137,16 @@ object ReturnYouTubeDislikeRollingNumberPatch : BytecodePatch(
|
||||
|
||||
// The rolling number Span is missing styling since it's initially set as a String.
|
||||
// Modify the UI text view and use the styled like/dislike Span.
|
||||
RollingNumberTextViewFingerprint.resultOrThrow().let {
|
||||
RollingNumberTextViewFingerprint.resultOrThrow().let { parentResult ->
|
||||
// Initial TextView is set in this method.
|
||||
val initiallyCreatedTextViewMethod = it.mutableMethod
|
||||
val initiallyCreatedTextViewMethod = parentResult.mutableMethod
|
||||
|
||||
// Video less than 24 hours after uploaded, like counts will be updated in real time.
|
||||
// Whenever like counts are updated, TextView is set in this method.
|
||||
val realTimeUpdateTextViewMethod = it.mutableClass.methods.find { method ->
|
||||
method.parameterTypes.first() == "Landroid/graphics/Bitmap;"
|
||||
} ?: throw PatchException("Failed to find realTimeUpdateTextViewMethod")
|
||||
val realTimeUpdateTextViewMethod =
|
||||
RollingNumberTextViewAnimationUpdateFingerprint.also {
|
||||
it.resolve(context, parentResult.classDef)
|
||||
}.resultOrThrow().mutableMethod
|
||||
|
||||
arrayOf(
|
||||
initiallyCreatedTextViewMethod,
|
||||
|
@ -1,30 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.returnyoutubedislike.rollingnumber.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object RollingNumberTextViewAnimationUpdateFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/graphics/Bitmap;"),
|
||||
opcodes = listOf(
|
||||
Opcode.NEW_INSTANCE, // bitmap ImageSpan
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.CONST_16,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INT_TO_FLOAT,
|
||||
Opcode.INVOKE_VIRTUAL, // set textview padding using bitmap width
|
||||
),
|
||||
customFingerprint = { _, classDef ->
|
||||
classDef.superclass == "Landroid/support/v7/widget/AppCompatTextView;"
|
||||
}
|
||||
)
|
@ -847,6 +847,9 @@ Please download %2$s from the website."</string>
|
||||
<string name="revanced_preference_screen_video_description_title">Video description</string>
|
||||
<string name="revanced_preference_screen_video_description_summary">Hide or show video description components.</string>
|
||||
|
||||
<string name="revanced_disable_rolling_number_animations_title">Disable rolling number animations</string>
|
||||
<string name="revanced_disable_rolling_number_animations_summary_on">Rolling numbers are not animated.</string>
|
||||
<string name="revanced_disable_rolling_number_animations_summary_off">Rolling numbers are animated.</string>
|
||||
<string name="revanced_hide_chapters_section_title">Hide chapters sections</string>
|
||||
<string name="revanced_hide_chapters_section_summary_on">Chapters sections are hidden.</string>
|
||||
<string name="revanced_hide_chapters_section_summary_off">Chapters sections are shown.</string>
|
||||
|
@ -360,7 +360,10 @@
|
||||
</PreferenceScreen>SETTINGS: SEEKBAR_COMPONENTS -->
|
||||
|
||||
<!-- SETTINGS: DESCRIPTION_COMPONENTS
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_video_description_title" android:key="revanced_preference_screen_video_description" android:summary="@string/revanced_preference_screen_video_description_summary">
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_video_description_title" android:key="revanced_preference_screen_video_description" android:summary="@string/revanced_preference_screen_video_description_summary">SETTINGS: DESCRIPTION_COMPONENTS -->
|
||||
<!-- SETTINGS: DISABLE_ROLLING_NUMBER_ANIMATIONS
|
||||
<SwitchPreference android:title="@string/revanced_disable_rolling_number_animations_title" android:key="revanced_disable_rolling_number_animations" android:defaultValue="false" android:summaryOn="@string/revanced_disable_rolling_number_animations_summary_on" android:summaryOff="@string/revanced_disable_rolling_number_animations_summary_off" />SETTINGS: DISABLE_ROLLING_NUMBER_ANIMATIONS -->
|
||||
<!-- SETTINGS: DESCRIPTION_COMPONENTS
|
||||
<SwitchPreference android:title="@string/revanced_hide_chapters_section_title" android:key="revanced_hide_chapters_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_chapters_section_summary_on" android:summaryOff="@string/revanced_hide_chapters_section_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_info_cards_section_title" android:key="revanced_hide_info_cards_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_info_cards_section_summary_on" android:summaryOff="@string/revanced_hide_info_cards_section_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_hide_podcast_section_title" android:key="revanced_hide_podcast_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_podcast_section_summary_on" android:summaryOff="@string/revanced_hide_podcast_section_summary_off" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user