mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-19 15:57:20 +02:00
feat(YouTube/Shorts components): add Enable timestamps
, Timestamp long press action
, Meta panel bottom margin
settings
This commit is contained in:
parent
6d3a61fdcd
commit
81ba1d3dbf
@ -60,6 +60,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
|||||||
ShortsAnimationPatch::class,
|
ShortsAnimationPatch::class,
|
||||||
ShortsNavigationBarPatch::class,
|
ShortsNavigationBarPatch::class,
|
||||||
ShortsRepeatPatch::class,
|
ShortsRepeatPatch::class,
|
||||||
|
ShortsTimeStampPatch::class,
|
||||||
ShortsToolBarPatch::class,
|
ShortsToolBarPatch::class,
|
||||||
VideoInformationPatch::class
|
VideoInformationPatch::class
|
||||||
),
|
),
|
||||||
@ -84,6 +85,15 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
|||||||
|
|
||||||
override fun execute(context: BytecodeContext) {
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
var settingArray = arrayOf(
|
||||||
|
"PREFERENCE_SCREEN: SHORTS",
|
||||||
|
"SETTINGS: SHORTS_COMPONENTS"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (SettingsPatch.upward1925) {
|
||||||
|
settingArray += "SETTINGS: SHORTS_TIME_STAMP"
|
||||||
|
}
|
||||||
|
|
||||||
// region patch for hide comments button (non-litho)
|
// region patch for hide comments button (non-litho)
|
||||||
|
|
||||||
ShortsButtonFingerprint.hideButton(RightComment, "hideShortsCommentsButton", false)
|
ShortsButtonFingerprint.hideButton(RightComment, "hideShortsCommentsButton", false)
|
||||||
@ -300,12 +310,7 @@ object ShortsComponentPatch : BaseBytecodePatch(
|
|||||||
/**
|
/**
|
||||||
* Add settings
|
* Add settings
|
||||||
*/
|
*/
|
||||||
SettingsPatch.addPreference(
|
SettingsPatch.addPreference(settingArray)
|
||||||
arrayOf(
|
|
||||||
"PREFERENCE_SCREEN: SHORTS",
|
|
||||||
"SETTINGS: SHORTS_COMPONENTS"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
SettingsPatch.updatePatchStatus(this)
|
SettingsPatch.updatePatchStatus(this)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.components
|
||||||
|
|
||||||
|
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.patches.youtube.shorts.components.fingerprints.ShortsTimeStampConstructorFingerprint
|
||||||
|
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsTimeStampMetaPanelFingerprint
|
||||||
|
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsTimeStampPrimaryFingerprint
|
||||||
|
import app.revanced.patches.youtube.shorts.components.fingerprints.ShortsTimeStampSecondaryFingerprint
|
||||||
|
import app.revanced.patches.youtube.utils.integrations.Constants.SHORTS_CLASS_DESCRIPTOR
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.MetaPanel
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelVodTimeStampsContainer
|
||||||
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
|
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
|
||||||
|
import app.revanced.util.getWideLiteralInstructionIndex
|
||||||
|
import app.revanced.util.literalInstructionBooleanHook
|
||||||
|
import app.revanced.util.literalInstructionViewHook
|
||||||
|
import app.revanced.util.resultOrThrow
|
||||||
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
object ShortsTimeStampPatch : BytecodePatch(
|
||||||
|
setOf(
|
||||||
|
ShortsTimeStampConstructorFingerprint,
|
||||||
|
ShortsTimeStampMetaPanelFingerprint,
|
||||||
|
ShortsTimeStampPrimaryFingerprint,
|
||||||
|
ShortsTimeStampSecondaryFingerprint,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext) {
|
||||||
|
|
||||||
|
if (!SettingsPatch.upward1925) return
|
||||||
|
|
||||||
|
// region patch for enable time stamp
|
||||||
|
|
||||||
|
mapOf(
|
||||||
|
ShortsTimeStampPrimaryFingerprint to 45627350,
|
||||||
|
ShortsTimeStampPrimaryFingerprint to 45638282,
|
||||||
|
ShortsTimeStampSecondaryFingerprint to 45638187
|
||||||
|
).forEach { (fingerprint, literal) ->
|
||||||
|
fingerprint.literalInstructionBooleanHook(
|
||||||
|
literal,
|
||||||
|
"$SHORTS_CLASS_DESCRIPTOR->enableShortsTimeStamp(Z)Z"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
ShortsTimeStampPrimaryFingerprint.resultOrThrow().mutableMethod.apply {
|
||||||
|
val literalIndex = getWideLiteralInstructionIndex(10002)
|
||||||
|
val literalRegister = getInstruction<OneRegisterInstruction>(literalIndex).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
literalIndex + 1, """
|
||||||
|
invoke-static {v$literalRegister}, $SHORTS_CLASS_DESCRIPTOR->enableShortsTimeStamp(I)I
|
||||||
|
move-result v$literalRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
// region patch for timestamp long press action and meta panel bottom margin
|
||||||
|
|
||||||
|
ShortsTimeStampMetaPanelFingerprint.resolve(
|
||||||
|
context,
|
||||||
|
ShortsTimeStampConstructorFingerprint.resultOrThrow().classDef
|
||||||
|
)
|
||||||
|
|
||||||
|
listOf(
|
||||||
|
Triple(
|
||||||
|
ShortsTimeStampConstructorFingerprint,
|
||||||
|
ReelVodTimeStampsContainer,
|
||||||
|
"setShortsTimeStampChangeRepeatState"
|
||||||
|
),
|
||||||
|
Triple(
|
||||||
|
ShortsTimeStampMetaPanelFingerprint,
|
||||||
|
MetaPanel,
|
||||||
|
"setShortsMetaPanelBottomMargin"
|
||||||
|
)
|
||||||
|
).forEach { (fingerprint, literalValue, methodName) ->
|
||||||
|
val smaliInstruction = """
|
||||||
|
invoke-static {v$REGISTER_TEMPLATE_REPLACEMENT}, $SHORTS_CLASS_DESCRIPTOR->$methodName(Landroid/view/View;)V
|
||||||
|
"""
|
||||||
|
|
||||||
|
fingerprint.literalInstructionViewHook(literalValue, smaliInstruction)
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.ReelVodTimeStampsContainer
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ShortsTimeStampConstructorFingerprint : LiteralValueFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
|
||||||
|
literalSupplier = { ReelVodTimeStampsContainer }
|
||||||
|
)
|
@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.MetaPanel
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ShortsTimeStampMetaPanelFingerprint : LiteralValueFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
literalSupplier = { MetaPanel }
|
||||||
|
)
|
@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
|
import app.revanced.util.containsWideLiteralInstructionIndex
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ShortsTimeStampPrimaryFingerprint : MethodFingerprint(
|
||||||
|
returnType = "I",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("I"),
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.containsWideLiteralInstructionIndex(45627350)
|
||||||
|
&& methodDef.containsWideLiteralInstructionIndex(45638282)
|
||||||
|
&& methodDef.containsWideLiteralInstructionIndex(10002)
|
||||||
|
},
|
||||||
|
)
|
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.youtube.shorts.components.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||||
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
|
|
||||||
|
internal object ShortsTimeStampSecondaryFingerprint : LiteralValueFingerprint(
|
||||||
|
returnType = "Z",
|
||||||
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
literalSupplier = { 45638187 }
|
||||||
|
)
|
@ -65,6 +65,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var InsetOverlayViewLayout = -1L
|
var InsetOverlayViewLayout = -1L
|
||||||
var InterstitialsContainer = -1L
|
var InterstitialsContainer = -1L
|
||||||
var MenuItemView = -1L
|
var MenuItemView = -1L
|
||||||
|
var MetaPanel = -1L
|
||||||
var ModernMiniPlayerClose = -1L
|
var ModernMiniPlayerClose = -1L
|
||||||
var ModernMiniPlayerExpand = -1L
|
var ModernMiniPlayerExpand = -1L
|
||||||
var ModernMiniPlayerForwardButton = -1L
|
var ModernMiniPlayerForwardButton = -1L
|
||||||
@ -87,6 +88,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
var ReelRightDislikeIcon = -1L
|
var ReelRightDislikeIcon = -1L
|
||||||
var ReelRightLikeIcon = -1L
|
var ReelRightLikeIcon = -1L
|
||||||
var ReelTimeBarPlayedColor = -1L
|
var ReelTimeBarPlayedColor = -1L
|
||||||
|
var ReelVodTimeStampsContainer = -1L
|
||||||
var RelatedChipCloudMargin = -1L
|
var RelatedChipCloudMargin = -1L
|
||||||
var RightComment = -1L
|
var RightComment = -1L
|
||||||
var ScrimOverlay = -1L
|
var ScrimOverlay = -1L
|
||||||
@ -165,6 +167,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
InsetOverlayViewLayout = getId(ID, "inset_overlay_view_layout")
|
InsetOverlayViewLayout = getId(ID, "inset_overlay_view_layout")
|
||||||
InterstitialsContainer = getId(ID, "interstitials_container")
|
InterstitialsContainer = getId(ID, "interstitials_container")
|
||||||
MenuItemView = getId(ID, "menu_item_view")
|
MenuItemView = getId(ID, "menu_item_view")
|
||||||
|
MetaPanel = getId(ID, "metapanel")
|
||||||
ModernMiniPlayerClose = getId(ID, "modern_miniplayer_close")
|
ModernMiniPlayerClose = getId(ID, "modern_miniplayer_close")
|
||||||
ModernMiniPlayerExpand = getId(ID, "modern_miniplayer_expand")
|
ModernMiniPlayerExpand = getId(ID, "modern_miniplayer_expand")
|
||||||
ModernMiniPlayerForwardButton = getId(ID, "modern_miniplayer_forward_button")
|
ModernMiniPlayerForwardButton = getId(ID, "modern_miniplayer_forward_button")
|
||||||
@ -187,6 +190,7 @@ object SharedResourceIdPatch : ResourcePatch() {
|
|||||||
ReelRightDislikeIcon = getId(DRAWABLE, "reel_right_dislike_icon")
|
ReelRightDislikeIcon = getId(DRAWABLE, "reel_right_dislike_icon")
|
||||||
ReelRightLikeIcon = getId(DRAWABLE, "reel_right_like_icon")
|
ReelRightLikeIcon = getId(DRAWABLE, "reel_right_like_icon")
|
||||||
ReelTimeBarPlayedColor = getId(COLOR, "reel_time_bar_played_color")
|
ReelTimeBarPlayedColor = getId(COLOR, "reel_time_bar_played_color")
|
||||||
|
ReelVodTimeStampsContainer = getId(ID, "reel_vod_timestamps_container")
|
||||||
RelatedChipCloudMargin = getId(LAYOUT, "related_chip_cloud_reduced_margins")
|
RelatedChipCloudMargin = getId(LAYOUT, "related_chip_cloud_reduced_margins")
|
||||||
RightComment = getId(DRAWABLE, "ic_right_comment_32c")
|
RightComment = getId(DRAWABLE, "ic_right_comment_32c")
|
||||||
ScrimOverlay = getId(ID, "scrim_overlay")
|
ScrimOverlay = getId(ID, "scrim_overlay")
|
||||||
|
@ -1116,8 +1116,15 @@ Side effect: Official headers in search results will be hidden."</string>
|
|||||||
<string name="revanced_enable_shorts_time_stamp_title">Enable timestamps</string>
|
<string name="revanced_enable_shorts_time_stamp_title">Enable timestamps</string>
|
||||||
<string name="revanced_enable_shorts_time_stamp_summary_on">"Timestamp is enabled.
|
<string name="revanced_enable_shorts_time_stamp_summary_on">"Timestamp is enabled.
|
||||||
|
|
||||||
Known issue: As this is a feature in the development stage by Google, the layout may be broken."</string>
|
Limitations:
|
||||||
|
• This setting not only enables timestamps, but also allows users to hide the UI by clicking on the player background.
|
||||||
|
• As this is a feature in the development stage by Google, the layout may be broken."</string>
|
||||||
<string name="revanced_enable_shorts_time_stamp_summary_off">Timestamp is disabled.</string>
|
<string name="revanced_enable_shorts_time_stamp_summary_off">Timestamp is disabled.</string>
|
||||||
|
<string name="revanced_shorts_time_stamp_change_repeat_state_title">Timestamp long press action</string>
|
||||||
|
<string name="revanced_shorts_time_stamp_change_repeat_state_summary">Press and hold the timestamp to change the Shorts repeat status.</string>
|
||||||
|
<string name="revanced_shorts_meta_panel_bottom_margin_title">Meta panel bottom margin</string>
|
||||||
|
<string name="revanced_shorts_meta_panel_bottom_margin_summary">Configure the spacing from the seekbar to the meta panel, between 0-64.</string>
|
||||||
|
<string name="revanced_shorts_meta_panel_bottom_margin_invalid_toast">Meta panel bottom margin must be between 0-64. Reset to default values.</string>
|
||||||
<string name="revanced_hide_shorts_toolbar_title">Hide toolbar</string>
|
<string name="revanced_hide_shorts_toolbar_title">Hide toolbar</string>
|
||||||
<string name="revanced_hide_shorts_toolbar_summary_on">Toolbar is hidden.</string>
|
<string name="revanced_hide_shorts_toolbar_summary_on">Toolbar is hidden.</string>
|
||||||
<string name="revanced_hide_shorts_toolbar_summary_off">Toolbar is shown.</string>
|
<string name="revanced_hide_shorts_toolbar_summary_off">Toolbar is shown.</string>
|
||||||
|
@ -487,7 +487,14 @@
|
|||||||
<SwitchPreference android:title="@string/revanced_hide_shorts_play_pause_button_background_title" android:key="revanced_hide_shorts_play_pause_button_background" android:summaryOn="@string/revanced_hide_shorts_play_pause_button_background_summary_on" android:summaryOff="@string/revanced_hide_shorts_play_pause_button_background_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_shorts_play_pause_button_background_title" android:key="revanced_hide_shorts_play_pause_button_background" android:summaryOn="@string/revanced_hide_shorts_play_pause_button_background_summary_on" android:summaryOff="@string/revanced_hide_shorts_play_pause_button_background_summary_off" />
|
||||||
<ListPreference android:entries="@array/revanced_shorts_double_tap_to_like_animation_entries" android:title="@string/revanced_shorts_double_tap_to_like_animation_title" android:key="revanced_shorts_double_tap_to_like_animation" android:entryValues="@array/revanced_shorts_double_tap_to_like_animation_entry_values" />
|
<ListPreference android:entries="@array/revanced_shorts_double_tap_to_like_animation_entries" android:title="@string/revanced_shorts_double_tap_to_like_animation_title" android:key="revanced_shorts_double_tap_to_like_animation" android:entryValues="@array/revanced_shorts_double_tap_to_like_animation_entry_values" />
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>
|
<PreferenceCategory android:title="@string/revanced_preference_category_experimental_flag" android:layout="@layout/revanced_settings_preferences_category"/>SETTINGS: SHORTS_COMPONENTS -->
|
||||||
|
|
||||||
|
<!-- SETTINGS: SHORTS_TIME_STAMP
|
||||||
|
<SwitchPreference android:title="@string/revanced_enable_shorts_time_stamp_title" android:key="revanced_enable_shorts_time_stamp" android:summaryOn="@string/revanced_enable_shorts_time_stamp_summary_on" android:summaryOff="@string/revanced_enable_shorts_time_stamp_summary_off" />
|
||||||
|
<SwitchPreference android:title="@string/revanced_shorts_time_stamp_change_repeat_state_title" android:key="revanced_shorts_time_stamp_change_repeat_state" android:summary="@string/revanced_shorts_time_stamp_change_repeat_state_summary" />
|
||||||
|
<app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference android:hint="32" android:title="@string/revanced_shorts_meta_panel_bottom_margin_title" android:key="revanced_shorts_meta_panel_bottom_margin" android:summary="@string/revanced_shorts_meta_panel_bottom_margin_summary" android:inputType="number" />SETTINGS: SHORTS_TIME_STAMP -->
|
||||||
|
|
||||||
|
<!-- SETTINGS: SHORTS_COMPONENTS
|
||||||
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_title" android:key="revanced_hide_shorts_toolbar" android:summaryOn="@string/revanced_hide_shorts_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_shorts_toolbar_title" android:key="revanced_hide_shorts_toolbar" android:summaryOn="@string/revanced_hide_shorts_toolbar_summary_on" android:summaryOff="@string/revanced_hide_shorts_toolbar_summary_off" />
|
||||||
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />
|
<SwitchPreference android:title="@string/revanced_hide_shorts_navigation_bar_title" android:key="revanced_hide_shorts_navigation_bar" android:summaryOn="@string/revanced_hide_shorts_navigation_bar_summary_on" android:summaryOff="@string/revanced_hide_shorts_navigation_bar_summary_off" />
|
||||||
<SwitchPreference android:title="@string/revanced_replace_channel_handle_title" android:key="revanced_replace_channel_handle" android:summaryOn="@string/revanced_replace_channel_handle_summary_on" android:summaryOff="@string/revanced_replace_channel_handle_summary_off" />
|
<SwitchPreference android:title="@string/revanced_replace_channel_handle_title" android:key="revanced_replace_channel_handle" android:summaryOn="@string/revanced_replace_channel_handle_summary_on" android:summaryOff="@string/revanced_replace_channel_handle_summary_off" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user