Skip to content

Commit

Permalink
feat(YouTube/Seekbar components): add Disable seekbar chapters setting
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 13, 2024
1 parent 20389d5 commit 504998f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import app.revanced.patches.youtube.player.seekbar.fingerprints.SeekbarTappingFi
import app.revanced.patches.youtube.player.seekbar.fingerprints.ShortsSeekbarColorFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.ThumbnailPreviewConfigFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.TimeCounterFingerprint
import app.revanced.patches.youtube.player.seekbar.fingerprints.TimelineMarkerArrayFingerprint
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.youtube.utils.fingerprints.PlayerButtonsResourcesFingerprint
import app.revanced.patches.youtube.utils.fingerprints.PlayerButtonsVisibilityFingerprint
Expand Down Expand Up @@ -67,8 +68,9 @@ object SeekbarComponentsPatch : BaseBytecodePatch(
SeekbarFingerprint,
SeekbarTappingFingerprint,
ShortsSeekbarColorFingerprint,
TimelineMarkerArrayFingerprint,
ThumbnailPreviewConfigFingerprint,
TotalTimeFingerprint
TotalTimeFingerprint,
)
) {
override fun execute(context: BytecodeContext) {
Expand Down Expand Up @@ -211,6 +213,21 @@ object SeekbarComponentsPatch : BaseBytecodePatch(

// region patch for hide chapter

TimelineMarkerArrayFingerprint.resultOrThrow().let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0, """
invoke-static {}, $PLAYER_CLASS_DESCRIPTOR->disableSeekbarChapters()Z
move-result v0
if-eqz v0, :show
const/4 v0, 0x0
new-array v0, v0, [Lcom/google/android/libraries/youtube/player/features/overlay/timebar/TimelineMarker;
return-object v0
""", ExternalLabel("show", getInstruction(0))
)
}
}

PlayerButtonsVisibilityFingerprint.resolve(
context,
PlayerButtonsResourcesFingerprint.resultOrThrow().mutableClass
Expand All @@ -223,7 +240,7 @@ object SeekbarComponentsPatch : BaseBytecodePatch(

addInstructionsWithLabels(
viewIndex, """
invoke-static {v$viewRegister}, $PLAYER_CLASS_DESCRIPTOR->hideSeekbarChapters(Landroid/view/View;)Z
invoke-static {v$viewRegister}, $PLAYER_CLASS_DESCRIPTOR->hideSeekbarChapterLabel(Landroid/view/View;)Z
move-result v$freeRegister
if-eqz v$freeRegister, :ignore
return-void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package app.revanced.patches.youtube.player.seekbar.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.MethodFingerprint
import com.android.tools.smali.dexlib2.AccessFlags

internal object TimelineMarkerArrayFingerprint : MethodFingerprint(
returnType = "[Lcom/google/android/libraries/youtube/player/features/overlay/timebar/TimelineMarker;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
)
9 changes: 6 additions & 3 deletions src/main/resources/youtube/settings/host/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1076,9 +1076,12 @@ Tap and hold to undo."</string>
<string name="revanced_hide_seekbar_thumbnail_title">Hide seekbar in video thumbnails</string>
<string name="revanced_hide_seekbar_thumbnail_summary_on">Thumbnail seekbar is hidden.</string>
<string name="revanced_hide_seekbar_thumbnail_summary_off">Thumbnail seekbar is shown.</string>
<string name="revanced_hide_seekbar_chapters_title">Hide seekbar chapters</string>
<string name="revanced_hide_seekbar_chapters_summary_on">Chapters are hidden in the seekbar.</string>
<string name="revanced_hide_seekbar_chapters_summary_off">Chapters are shown in the seekbar.</string>
<string name="revanced_disable_seekbar_chapters_title">Disable seekbar chapters</string>
<string name="revanced_disable_seekbar_chapters_summary_on">Chapters are disabled in the seekbar.</string>
<string name="revanced_disable_seekbar_chapters_summary_off">Chapters are enabled in the seekbar.</string>
<string name="revanced_hide_seekbar_chapter_label_title">Hide seekbar chapter labels</string>
<string name="revanced_hide_seekbar_chapter_label_summary_on">Chapter labels next to the timestamp are hidden.</string>
<string name="revanced_hide_seekbar_chapter_label_summary_off">Chapter labels next to the timestamp are hidden.</string>
<string name="revanced_hide_time_stamp_title">Hide timestamp</string>
<string name="revanced_hide_time_stamp_summary_on">Timestamp is hidden.</string>
<string name="revanced_hide_time_stamp_summary_off">Timestamp is shown.</string>
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/youtube/settings/xml/revanced_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@
<SwitchPreference android:title="@string/revanced_enable_seekbar_tapping_title" android:key="revanced_enable_seekbar_tapping" android:summaryOn="@string/revanced_enable_seekbar_tapping_summary_on" android:summaryOff="@string/revanced_enable_seekbar_tapping_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seekbar_title" android:key="revanced_hide_seekbar" android:summaryOn="@string/revanced_hide_seekbar_summary_on" android:summaryOff="@string/revanced_hide_seekbar_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seekbar_thumbnail_title" android:key="revanced_hide_seekbar_thumbnail" android:summaryOn="@string/revanced_hide_seekbar_thumbnail_summary_on" android:summaryOff="@string/revanced_hide_seekbar_thumbnail_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seekbar_chapters_title" android:key="revanced_hide_seekbar_chapters" android:summaryOn="@string/revanced_hide_seekbar_chapters_summary_on" android:summaryOff="@string/revanced_hide_seekbar_chapters_summary_off" />
<SwitchPreference android:title="@string/revanced_disable_seekbar_chapters_title" android:key="revanced_disable_seekbar_chapters" android:summaryOn="@string/revanced_disable_seekbar_chapters_summary_on" android:summaryOff="@string/revanced_disable_seekbar_chapters_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_seekbar_chapter_label_title" android:key="revanced_hide_seekbar_chapter_label" android:summaryOn="@string/revanced_hide_seekbar_chapter_label_summary_on" android:summaryOff="@string/revanced_hide_seekbar_chapter_label_summary_off" />
<SwitchPreference android:title="@string/revanced_hide_time_stamp_title" android:key="revanced_hide_time_stamp" android:summaryOn="@string/revanced_hide_time_stamp_summary_on" android:summaryOff="@string/revanced_hide_time_stamp_summary_off" />SETTINGS: SEEKBAR_COMPONENTS -->
<!-- SETTINGS: RESTORE_OLD_SEEKBAR_THUMBNAILS
<SwitchPreference android:title="@string/revanced_restore_old_seekbar_thumbnails_title" android:key="revanced_restore_old_seekbar_thumbnails" android:summaryOn="@string/revanced_restore_old_seekbar_thumbnails_summary_on" android:summaryOff="@string/revanced_restore_old_seekbar_thumbnails_summary_off" />SETTINGS: RESTORE_OLD_SEEKBAR_THUMBNAILS -->
Expand Down

0 comments on commit 504998f

Please sign in to comment.