feat(YouTube/Description components): add Always expand panel and Disable description interaction settings

This commit is contained in:
inotia00 2024-03-25 05:42:04 +09:00
parent 4bf3feefdc
commit c6faf2120f
10 changed files with 123 additions and 55 deletions

View File

@ -9,13 +9,12 @@ import app.revanced.patcher.patch.PatchException
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.youtube.flyoutpanel.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.fingerprints.QualityMenuViewInflateFingerprint
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.patches.youtube.utils.fingerprints.VideoQualitySetterFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.FLYOUT_PANEL
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
@ -69,7 +68,6 @@ import com.android.tools.smali.dexlib2.iface.reference.FieldReference
@Suppress("unused")
object OldQualityLayoutPatch : BytecodePatch(
setOf(
RecyclerViewTreeObserverFingerprint,
QualityMenuViewInflateFingerprint,
VideoQualitySetterFingerprint
)
@ -117,17 +115,7 @@ object OldQualityLayoutPatch : BytecodePatch(
/**
* New method
*/
RecyclerViewTreeObserverFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val recyclerViewRegister = 2
addInstruction(
insertIndex,
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
)
}
} ?: throw RecyclerViewTreeObserverFingerprint.exception
BottomSheetRecyclerViewPatch.injectCall("$FLYOUT_PANEL->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
LithoFilterPatch.addFilter("$COMPONENTS_PATH/VideoQualityMenuFilter;")

View File

@ -11,11 +11,10 @@ import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.CustomPlaybackSpeedIntegrationsFingerprint
import app.revanced.patches.youtube.flyoutpanel.oldspeedlayout.fingerprints.PlaybackRateBottomSheetClassFingerprint
import app.revanced.patches.youtube.flyoutpanel.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.VIDEO_PATH
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.immutable.ImmutableField
@ -30,8 +29,7 @@ import com.android.tools.smali.dexlib2.immutable.ImmutableField
object OldSpeedLayoutPatch : BytecodePatch(
setOf(
CustomPlaybackSpeedIntegrationsFingerprint,
PlaybackRateBottomSheetClassFingerprint,
RecyclerViewTreeObserverFingerprint
PlaybackRateBottomSheetClassFingerprint
)
) {
override fun execute(context: BytecodeContext) {
@ -91,17 +89,7 @@ object OldSpeedLayoutPatch : BytecodePatch(
/**
* New method
*/
RecyclerViewTreeObserverFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val recyclerViewRegister = 2
addInstruction(
insertIndex,
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V"
)
}
} ?: throw RecyclerViewTreeObserverFingerprint.exception
BottomSheetRecyclerViewPatch.injectCall("$INTEGRATIONS_CLASS_DESCRIPTOR->onFlyoutMenuCreate(Landroid/support/v7/widget/RecyclerView;)V")
LithoFilterPatch.addFilter("$COMPONENTS_PATH/PlaybackSpeedMenuFilter;")

View File

@ -1,17 +1,26 @@
package app.revanced.patches.youtube.general.descriptions
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.youtube.general.descriptions.fingerprints.TextViewComponentFingerprint
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL
import app.revanced.patches.youtube.utils.litho.LithoFilterPatch
import app.revanced.patches.youtube.utils.recyclerview.BottomSheetRecyclerViewPatch
import app.revanced.patches.youtube.utils.settings.SettingsPatch
import app.revanced.util.exception
import app.revanced.util.getTargetIndexWithMethodReferenceName
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
@Patch(
name = "Hide description components",
description = "Adds an option to hide description components.",
name = "Description components",
description = "Adds an option to hide or disable description components.",
dependencies = [
BottomSheetRecyclerViewPatch::class,
LithoFilterPatch::class,
SettingsPatch::class
],
@ -46,8 +55,37 @@ import app.revanced.patches.youtube.utils.settings.SettingsPatch
]
)
@Suppress("unused")
object DescriptionComponentsPatch : BytecodePatch(emptySet()) {
object DescriptionComponentsPatch : BytecodePatch(
setOf(TextViewComponentFingerprint)
) {
override fun execute(context: BytecodeContext) {
if (SettingsPatch.upward1902) {
TextViewComponentFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = getTargetIndexWithMethodReferenceName("setTextIsSelectable")
val insertInstruction = getInstruction<FiveRegisterInstruction>(insertIndex)
replaceInstruction(
insertIndex,
"invoke-static {v${insertInstruction.registerC}, v${insertInstruction.registerD}}, " +
"$GENERAL->disableDescriptionInteraction(Landroid/widget/TextView;Z)V"
)
}
} ?: throw TextViewComponentFingerprint.exception
BottomSheetRecyclerViewPatch.injectCall("$GENERAL->onDescriptionPanelCreate(Landroid/support/v7/widget/RecyclerView;)V")
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: DESCRIPTION_PANEL_INTERACTION"
)
)
}
LithoFilterPatch.addFilter("$COMPONENTS_PATH/DescriptionsFilter;")
/**
@ -56,11 +94,11 @@ object DescriptionComponentsPatch : BytecodePatch(emptySet()) {
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_DESCRIPTION_COMPONENTS"
"SETTINGS: DESCRIPTION_COMPONENTS"
)
)
SettingsPatch.updatePatchStatus("Hide description components")
SettingsPatch.updatePatchStatus("Description components")
}
}

View File

@ -0,0 +1,14 @@
package app.revanced.patches.youtube.general.descriptions.fingerprints
import app.revanced.util.fingerprint.MethodReferenceNameFingerprint
import com.android.tools.smali.dexlib2.Opcode
/**
* This fingerprint is compatible with YouTube v18.35.xx~
* Nonetheless, the patch works in YouTube v19.02.xx~
*/
object TextViewComponentFingerprint : MethodReferenceNameFingerprint(
returnType = "V",
opcodes = listOf(Opcode.CMPL_FLOAT),
reference = { "setBreakStrategy" }
)

View File

@ -1,17 +1,24 @@
package app.revanced.patches.youtube.flyoutpanel.recyclerview
package app.revanced.patches.youtube.utils.recyclerview
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.fingerprint.MethodFingerprintResult
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patches.youtube.flyoutpanel.recyclerview.fingerprints.BottomSheetRecyclerViewBuilderFingerprint
import app.revanced.patches.youtube.utils.recyclerview.fingerprints.BottomSheetRecyclerViewBuilderFingerprint
import app.revanced.patches.youtube.utils.recyclerview.fingerprints.RecyclerViewTreeObserverFingerprint
import app.revanced.util.exception
import app.revanced.util.getWideLiteralInstructionIndex
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
object BottomSheetRecyclerViewPatch : BytecodePatch(
setOf(BottomSheetRecyclerViewBuilderFingerprint)
setOf(
BottomSheetRecyclerViewBuilderFingerprint,
RecyclerViewTreeObserverFingerprint
)
) {
private lateinit var recyclerViewTreeObserverResult: MethodFingerprintResult
override fun execute(context: BytecodeContext) {
/**
@ -32,5 +39,23 @@ object BottomSheetRecyclerViewPatch : BytecodePatch(
}
} ?: throw BottomSheetRecyclerViewBuilderFingerprint.exception
recyclerViewTreeObserverResult = RecyclerViewTreeObserverFingerprint.result
?: throw RecyclerViewTreeObserverFingerprint.exception
}
fun injectCall(descriptor: String) {
recyclerViewTreeObserverResult.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.startIndex
val recyclerViewRegister = 2
addInstruction(
insertIndex,
"invoke-static/range { p$recyclerViewRegister .. p$recyclerViewRegister }, $descriptor"
)
}
}
}
}

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.flyoutpanel.recyclerview.fingerprints
package app.revanced.patches.youtube.utils.recyclerview.fingerprints
import app.revanced.util.fingerprint.LiteralValueFingerprint

View File

@ -1,4 +1,4 @@
package app.revanced.patches.youtube.utils.fingerprints
package app.revanced.patches.youtube.utils.recyclerview.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint

View File

@ -64,6 +64,17 @@ import java.util.jar.Manifest
object SettingsPatch : AbstractSettingsResourcePatch(
"youtube/settings"
), Closeable {
private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
internal lateinit var contexts: ResourceContext
internal var upward1831: Boolean = false
internal var upward1834: Boolean = false
internal var upward1839: Boolean = false
internal var upward1849: Boolean = false
internal var upward1902: Boolean = false
override fun execute(context: ResourceContext) {
super.execute(context)
contexts = context
@ -92,9 +103,10 @@ object SettingsPatch : AbstractSettingsResourcePatch(
val playServicesVersion = node.textContent.toInt()
upward1831 = 233200000 <= playServicesVersion
upward1834 = 233502000 <= playServicesVersion
upward1839 = 234002000 <= playServicesVersion
upward1849 = 235002000 <= playServicesVersion
upward1834 = 233500000 <= playServicesVersion
upward1839 = 234000000 <= playServicesVersion
upward1849 = 235000000 <= playServicesVersion
upward1902 = 240204000 < playServicesVersion
break
}
@ -155,15 +167,6 @@ object SettingsPatch : AbstractSettingsResourcePatch(
}
private val THREAD_COUNT = Runtime.getRuntime().availableProcessors()
private val threadPoolExecutor = Executors.newFixedThreadPool(THREAD_COUNT)
internal lateinit var contexts: ResourceContext
internal var upward1831: Boolean = false
internal var upward1834: Boolean = false
internal var upward1839: Boolean = false
internal var upward1849: Boolean = false
internal fun addPreference(settingArray: Array<String>) {
contexts.addPreference(settingArray)
}

View File

@ -50,6 +50,9 @@ Tap here to learn more about DeArrow."</string>
<string name="revanced_append_time_stamp_information_type_summary_off">Append playback speed.</string>
<string name="revanced_append_time_stamp_information_type_summary_on">Append video quality.</string>
<string name="revanced_append_time_stamp_information_type_title">Append information type</string>
<string name="revanced_always_expand_panel_summary_off">Description panel is expanded manually.</string>
<string name="revanced_always_expand_panel_summary_on">Description panel is always expanded.</string>
<string name="revanced_always_expand_panel_title">Always expand panel</string>
<string name="revanced_bottom_player">Bottom player</string>
<string name="revanced_button_container_title">Button container</string>
<string name="revanced_bypass_ambient_mode_restrictions_summary_off">Ambient mode is disabled in battery saver mode.</string>
@ -110,6 +113,11 @@ Note: This feature hasn't been tested."</string>
<string name="revanced_disable_auto_captions_summary_off">Forced auto captions are enabled.</string>
<string name="revanced_disable_auto_captions_summary_on">Forced auto captions are disabled.</string>
<string name="revanced_disable_auto_captions_title">Disable forced auto captions</string>
<string name="revanced_disable_description_interaction_summary">"Disables the following interactions when the description panel is expanded:
• Tap to scroll.
• Tap and hold to select text."</string>
<string name="revanced_disable_description_interaction_title">Disable description interaction</string>
<string name="revanced_disable_default_playback_speed_live_summary_off">Default playback speed is enabled in live stream.</string>
<string name="revanced_disable_default_playback_speed_live_summary_on">Default playback speed is disabled in live stream.</string>
<string name="revanced_disable_default_playback_speed_live_title">Disable playback speed in live stream</string>

View File

@ -300,8 +300,12 @@
<SwitchPreference android:title="@string/revanced_hide_for_you_shelf_title" android:key="revanced_hide_for_you_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_for_you_shelf_summary_on" android:summaryOff="@string/revanced_hide_for_you_shelf_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_store_tab_title" android:key="revanced_hide_store_tab" android:defaultValue="true" android:summaryOn="@string/revanced_hide_store_tab_summary_on" android:summaryOff="@string/revanced_hide_store_tab_summary_off" />SETTINGS: HIDE_CHANNEL_PROFILE_COMPONENTS -->
<!-- SETTINGS: HIDE_DESCRIPTION_COMPONENTS
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_description_title" />
<!-- SETTINGS: DESCRIPTION_COMPONENTS
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_description_title" />SETTINGS: DESCRIPTION_COMPONENTS -->
<!-- SETTINGS: DESCRIPTION_PANEL_INTERACTION
<SwitchPreference android:title="@string/revanced_always_expand_panel_title" android:key="revanced_always_expand_panel" android:defaultValue="false" android:summaryOn="@string/revanced_always_expand_panel_summary_on" android:summaryOff="@string/revanced_always_expand_panel_summary_off" />
<SwitchPreference android:title="@string/revanced_disable_description_interaction_title" android:key="revanced_disable_description_interaction" android:defaultValue="false" android:summary="@string/revanced_disable_description_interaction_summary" />SETTINGS: DESCRIPTION_PANEL_INTERACTION -->
<!-- SETTINGS: DESCRIPTION_COMPONENTS
<SwitchPreference android:title="@string/revanced_hide_chapters_title" android:key="revanced_hide_chapters" android:defaultValue="false" android:summaryOn="@string/revanced_hide_chapters_summary_on" android:summaryOff="@string/revanced_hide_chapters_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_game_section_title" android:key="revanced_hide_game_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_game_section_summary_on" android:summaryOff="@string/revanced_hide_game_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" />
@ -309,7 +313,7 @@
<SwitchPreference android:title="@string/revanced_hide_place_section_title" android:key="revanced_hide_place_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_place_section_summary_on" android:summaryOff="@string/revanced_hide_place_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" />
<SwitchPreference android:title="@string/revanced_hide_shopping_links_title" android:key="revanced_hide_shopping_links" android:defaultValue="true" android:summaryOn="@string/revanced_hide_shopping_links_summary_on" android:summaryOff="@string/revanced_hide_shopping_links_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_transcript_section_title" android:key="revanced_hide_transcript_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_transcript_section_summary_on" android:summaryOff="@string/revanced_hide_transcript_section_summary_off" />SETTINGS: HIDE_DESCRIPTION_COMPONENTS -->
<SwitchPreference android:title="@string/revanced_hide_transcript_section_title" android:key="revanced_hide_transcript_section" android:defaultValue="false" android:summaryOn="@string/revanced_hide_transcript_section_summary_on" android:summaryOff="@string/revanced_hide_transcript_section_summary_off" />SETTINGS: DESCRIPTION_COMPONENTS -->
<!-- PREFERENCE: GENERAL_SETTINGS
</PreferenceScreen>PREFERENCE: GENERAL_SETTINGS -->
@ -427,6 +431,7 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_general" />
<Preference android:title="Change start page" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Description components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Disable auto captions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Enable gradient loading screen" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Enable song search" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
@ -438,7 +443,6 @@
<Preference android:title="Hide category bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide channel avatar section" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide crowdfunding box" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide description components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide floating microphone" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide handle" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
<Preference android:title="Hide latest videos button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>