From 7fa079e4a74e74557dbcfabf340d3ae246672cf8 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:04:15 -0400 Subject: [PATCH] fix: Allow double tapping area where forward/back normally is. --- .../patches/HidePlayerButtonsPatch.java | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/HidePlayerButtonsPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/HidePlayerButtonsPatch.java index 3f38769836..bc876cc327 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/HidePlayerButtonsPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/HidePlayerButtonsPatch.java @@ -11,11 +11,11 @@ public final class HidePlayerButtonsPatch { private static final boolean HIDE_PLAYER_BUTTONS_ENABLED = Settings.HIDE_PLAYER_BUTTONS.get(); - private static final int PREVIOUS_BUTTON_RESOURCE_ID = - Utils.getResourceIdentifier("player_control_previous_button", "id"); + private static final int PLAYER_CONTROL_PREVIOUS_BUTTON_TOUCH_AREA_ID = + Utils.getResourceIdentifier("player_control_previous_button_touch_area", "id"); - private static final int NEXT_BUTTON_RESOURCE_ID = - Utils.getResourceIdentifier("player_control_next_button", "id"); + private static final int PLAYER_CONTROL_NEXT_BUTTON_TOUCH_AREA_ID = + Utils.getResourceIdentifier("player_control_next_button_touch_area", "id"); /** * Injection point. @@ -25,28 +25,23 @@ public static void hidePreviousNextButtons(View parentView) { return; } - hideButton(parentView, PREVIOUS_BUTTON_RESOURCE_ID); - hideButton(parentView, NEXT_BUTTON_RESOURCE_ID); + // Must use a deferred call to main thread to hide the button. + // Otherwise the layout crashes if set to hidden now. + Utils.runOnMainThread(() -> { + hideView(parentView, PLAYER_CONTROL_PREVIOUS_BUTTON_TOUCH_AREA_ID); + hideView(parentView, PLAYER_CONTROL_NEXT_BUTTON_TOUCH_AREA_ID); + }); } - private static void hideButton(View parentView, int resourceId) { - try { - View nextPreviousButton = parentView.findViewById(resourceId); - - if (nextPreviousButton == null) { - Logger.printException(() -> "Could not find player previous/next button"); - return; - } - - // Must use a deferred call to main thread to hide the button. - // Otherwise if set to hidden here then the layout crashes, - // and if set to 0dp the button still functions even though it's not visible. - Utils.runOnMainThread(() -> { - Logger.printDebug(() -> "Hiding previous/next button"); - Utils.hideViewByRemovingFromParentUnderCondition(true, nextPreviousButton); - }); - } catch (Exception ex) { - Logger.printException(() -> "hideButton failure", ex); + private static void hideView(View parentView, int resourceId) { + View nextPreviousButton = parentView.findViewById(resourceId); + + if (nextPreviousButton == null) { + Logger.printException(() -> "Could not find player previous/next button"); + return; } + + Logger.printDebug(() -> "Hiding previous/next button"); + Utils.hideViewByRemovingFromParentUnderCondition(true, nextPreviousButton); } }