fix(YouTube - Hide Shorts Components): hide sound button

This commit is contained in:
oSumAtrIX 2023-07-15 03:41:52 +02:00
parent e78ef6df9c
commit a2b1630df8
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -1,33 +1,22 @@
package app.revanced.integrations.patches.components; package app.revanced.integrations.patches.components;
import android.view.View;
import app.revanced.integrations.settings.SettingsEnum;
import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar;
import static app.revanced.integrations.utils.ReVancedUtils.hideViewBy1dpUnderCondition; import static app.revanced.integrations.utils.ReVancedUtils.hideViewBy1dpUnderCondition;
import static app.revanced.integrations.utils.ReVancedUtils.hideViewUnderCondition; import static app.revanced.integrations.utils.ReVancedUtils.hideViewUnderCondition;
import android.annotation.SuppressLint;
import android.os.Build;
import android.view.View;
import com.google.android.libraries.youtube.rendering.ui.pivotbar.PivotBar;
import app.revanced.integrations.settings.SettingsEnum;
public final class ShortsFilter extends Filter { public final class ShortsFilter extends Filter {
// Set by patch.
public static PivotBar pivotBar; public static PivotBar pivotBar;
@SuppressLint("StaticFieldLeak") final StringFilterGroupList shortsFilterGroup = new StringFilterGroupList();
private final StringFilterGroup reelChannelBar = new StringFilterGroup( private final StringFilterGroup reelChannelBar = new StringFilterGroup(
null, null,
"reel_channel_bar" "reel_channel_bar"
); );
private final StringFilterGroup infoPanel = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_INFO_PANEL,
"shorts_info_panel_overview"
);
public ShortsFilter() { public ShortsFilter() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
final var thanksButton = new StringFilterGroup( final var thanksButton = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_THANKS_BUTTON, SettingsEnum.HIDE_SHORTS_THANKS_BUTTON,
"suggested_action" "suggested_action"
@ -48,6 +37,11 @@ public final class ShortsFilter extends Filter {
"reel_pivot_button" "reel_pivot_button"
); );
final var infoPanel = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_INFO_PANEL,
"shorts_info_panel_overview"
);
final var channelBar = new StringFilterGroup( final var channelBar = new StringFilterGroup(
SettingsEnum.HIDE_SHORTS_CHANNEL_BAR, SettingsEnum.HIDE_SHORTS_CHANNEL_BAR,
"reel_channel_bar" "reel_channel_bar"
@ -61,19 +55,20 @@ public final class ShortsFilter extends Filter {
"shorts_video_cell" "shorts_video_cell"
); );
this.pathFilterGroups.addAll(joinButton, subscribeButton, soundButton, channelBar); shortsFilterGroup.addAll(soundButton, infoPanel);
this.identifierFilterGroups.addAll(shorts, thanksButton); pathFilterGroups.addAll(joinButton, subscribeButton, channelBar);
identifierFilterGroups.addAll(shorts, thanksButton);
} }
@Override @Override
boolean isFiltered(final String path, final String identifier, boolean isFiltered(final String path, final String identifier,
final byte[] protobufBufferArray) { final byte[] protobufBufferArray) {
// Filter the path only when reelChannelBar is visible. // Filter the path only when reelChannelBar is visible.
if (reelChannelBar.check(path).isFiltered()) if (reelChannelBar.check(path).isFiltered())
if (this.pathFilterGroups.contains(path)) return true; if (this.pathFilterGroups.contains(path)) return true;
// Shorts info panel path appears outside of reelChannelBar path. if (shortsFilterGroup.contains(path)) return true;
if (infoPanel.isEnabled() && infoPanel.check(path).isFiltered()) return true;
return this.identifierFilterGroups.contains(identifier); return this.identifierFilterGroups.contains(identifier);
} }