Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: Allow double tapping area where forward/back normally is.
Browse files Browse the repository at this point in the history
  • Loading branch information
LisoUseInAIKyrios committed Oct 16, 2024
1 parent ea11907 commit 7fa079e
Showing 1 changed file with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
}

0 comments on commit 7fa079e

Please sign in to comment.