Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(YouTube - Hide layout components): Add option to hide horizontal shelves #2951

Merged
merged 21 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e517f5b
feat: hide `suggestions shelf`
johnconner122 Mar 29, 2024
7105e08
fix: use correct class path
johnconner122 Mar 29, 2024
006e6dd
fix: commit suggestion
johnconner122 Mar 29, 2024
e0906c9
fix build
johnconner122 Mar 29, 2024
5dfe5b0
Merge remote-tracking branch 'origin/hide-suggetions-shelf' into hide…
johnconner122 Mar 29, 2024
b2ffafa
fix build
johnconner122 Mar 29, 2024
3b67d59
fix: remove `PlayerTypeHookPatch` dependency
johnconner122 Mar 29, 2024
ee19b7f
fix: improve patch description
johnconner122 Mar 31, 2024
26cb1a6
fix typo
johnconner122 Mar 31, 2024
d2c1af0
use unicode character instead of code
johnconner122 Mar 31, 2024
d963db1
fix: Filter only the home feed, and not search or if the player is ac…
LisoUseInAIKyrios Apr 3, 2024
3d79ceb
Update src/main/resources/addresources/values/strings.xml
LisoUseInAIKyrios Apr 5, 2024
0d186db
Update src/main/kotlin/app/revanced/patches/youtube/layout/hide/sugge…
LisoUseInAIKyrios Apr 5, 2024
b86cec6
Update src/main/kotlin/app/revanced/patches/youtube/layout/hide/sugge…
johnconner122 Apr 5, 2024
47e78a0
fix: Shorten the first line of the summary so there's less chance of …
LisoUseInAIKyrios Apr 5, 2024
6f23339
Update src/main/resources/addresources/values/strings.xml
LisoUseInAIKyrios Apr 6, 2024
3e8dde4
Merge remote-tracking branch 'upstream/dev' into hide-suggetions-shelf
LisoUseInAIKyrios Apr 6, 2024
e9f537a
refactor: Use 'shelves' language
LisoUseInAIKyrios Apr 6, 2024
10a860d
fix: Deprecate instead of deleting
LisoUseInAIKyrios Apr 6, 2024
a18c924
rename
oSumAtrIX Apr 6, 2024
b954981
merge to layouts components patch
oSumAtrIX Apr 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/revanced-patches.api
Original file line number Diff line number Diff line change
Expand Up @@ -1346,12 +1346,6 @@ public final class app/revanced/patches/youtube/layout/hide/albumcards/AlbumCard
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/breakingnews/BreakingNewsPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/hide/comments/CommentsPatch : app/revanced/patcher/patch/ResourcePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/comments/CommentsPatch;
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
Expand Down Expand Up @@ -1448,6 +1442,12 @@ public final class app/revanced/patches/youtube/layout/hide/suggestedvideoendscr
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/hide/suggestionsshelf/HideSuggestionsShelfPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/suggestionsshelf/HideSuggestionsShelfPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
public synthetic fun execute (Lapp/revanced/patcher/data/Context;)V
}

public final class app/revanced/patches/youtube/layout/hide/time/HideTimestampPatch : app/revanced/patcher/patch/BytecodePatch {
public static final field INSTANCE Lapp/revanced/patches/youtube/layout/hide/time/HideTimestampPatch;
public fun execute (Lapp/revanced/patcher/data/BytecodeContext;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
package app.revanced.patches.youtube.layout.hide.breakingnews
package app.revanced.patches.youtube.layout.hide.suggestionsshelf

import app.revanced.util.exception
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
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.youtube.layout.hide.breakingnews.fingerprints.BreakingNewsFingerprint
import app.revanced.patches.youtube.layout.hide.suggestionsshelf.fingerprints.BreakingNewsFingerprint
import app.revanced.patches.youtube.misc.integrations.IntegrationsPatch
import app.revanced.patches.youtube.misc.litho.filter.LithoFilterPatch
import app.revanced.patches.youtube.misc.navigation.NavigationBarHookPatch
import app.revanced.patches.youtube.misc.playertype.PlayerTypeHookPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction

@Patch(
name = "Hide breaking news shelf",
description = "Adds an option to hide the breaking news shelf on the homepage tab.",
name = "Hide suggestions shelf",
description = "Hides suggestions shelf on the homepage tab.",
dependencies = [
johnconner122 marked this conversation as resolved.
Show resolved Hide resolved
IntegrationsPatch::class,
BreakingNewsResourcePatch::class
HideSuggestionsShelfResourcePatch::class,
NavigationBarHookPatch::class,
LithoFilterPatch::class,
PlayerTypeHookPatch::class,
],
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
compatiblePackages = [
CompatiblePackage(
Expand Down Expand Up @@ -44,9 +50,12 @@ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
]
)
@Suppress("unused")
object BreakingNewsPatch : BytecodePatch(
object HideSuggestionsShelfPatch : BytecodePatch(
setOf(BreakingNewsFingerprint)
) {
private const val FILTER_CLASS_DESCRIPTOR =
"Lapp/revanced/integrations/youtube/patches/components/SuggestionsShelfFilter;"

override fun execute(context: BytecodeContext) {
BreakingNewsFingerprint.result?.let {
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
Expand All @@ -59,15 +68,13 @@ object BreakingNewsPatch : BytecodePatch(
addInstruction(
insertIndex,
"""
invoke-static {v$breakingNewsViewRegister},
Lapp/revanced/integrations/youtube/patches/HideBreakingNewsPatch;
->
hideBreakingNews(Landroid/view/View;)V
invoke-static {v$breakingNewsViewRegister}, $FILTER_CLASS_DESCRIPTOR->hideBreakingNews(Landroid/view/View;)V
"""
)
}

} ?: throw BreakingNewsFingerprint.exception

LithoFilterPatch.addFilter(FILTER_CLASS_DESCRIPTOR)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package app.revanced.patches.youtube.layout.hide.breakingnews
package app.revanced.patches.youtube.layout.hide.suggestionsshelf

import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.ResourcePatch
Expand All @@ -15,14 +15,14 @@ import app.revanced.patches.youtube.misc.settings.SettingsPatch
AddResourcesPatch::class
],
)
internal object BreakingNewsResourcePatch : ResourcePatch() {
internal object HideSuggestionsShelfResourcePatch : ResourcePatch() {
internal var horizontalCardListId: Long = -1

override fun execute(context: ResourceContext) {
AddResourcesPatch(this::class)

SettingsPatch.PreferenceScreen.FEED.addPreferences(
SwitchPreference("revanced_hide_breaking_news")
SwitchPreference("revanced_hide_suggestions_shelf")
)

horizontalCardListId = ResourceMappingPatch.resourceMappings.single {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.revanced.patches.youtube.layout.hide.breakingnews.fingerprints
package app.revanced.patches.youtube.layout.hide.suggestionsshelf.fingerprints

import app.revanced.patcher.extensions.or
import app.revanced.patches.youtube.layout.hide.breakingnews.BreakingNewsResourcePatch
import app.revanced.patches.youtube.layout.hide.suggestionsshelf.HideSuggestionsShelfResourcePatch
import app.revanced.util.patch.LiteralValueFingerprint
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
Expand All @@ -16,5 +16,5 @@ internal object BreakingNewsFingerprint : LiteralValueFingerprint(
Opcode.CHECK_CAST,
Opcode.IPUT_OBJECT,
),
literalSupplier = { BreakingNewsResourcePatch.horizontalCardListId }
literalSupplier = { HideSuggestionsShelfResourcePatch.horizontalCardListId }
)
8 changes: 4 additions & 4 deletions src/main/resources/addresources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@
<string name="revanced_hide_album_cards_summary_on">Album cards are hidden</string>
<string name="revanced_hide_album_cards_summary_off">Album cards are shown</string>
</patch>
<patch id="layout.hide.breakingnews.BreakingNewsResourcePatch">
<string name="revanced_hide_breaking_news_title">Hide breaking news</string>
<string name="revanced_hide_breaking_news_summary_on">Breaking news are hidden</string>
<string name="revanced_hide_breaking_news_summary_off">Breaking news are shown</string>
<patch id="layout.hide.suggestionsshelf.HideSuggestionsShelfResourcePatch">
<string name="revanced_hide_suggestions_shelf_title">Hide Suggestions shelf</string>
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
<string name="revanced_hide_suggestions_shelf_summary_on">Suggestions shelves are hidden</string>
<string name="revanced_hide_suggestions_shelf_summary_off">Suggestions shelves are shown</string>
</patch>
<patch id="layout.hide.comments.CommentsPatch">
<string name="revanced_comments_screen_title">Comments</string>
Expand Down
Loading