This repository has been archived by the owner on Oct 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube - Hide layout components): Filter home/search results by…
… keywords (#584) Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
1 parent
6e947e2
commit 0cbad98
Showing
12 changed files
with
563 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 24 additions & 23 deletions
47
app/src/main/java/app/revanced/integrations/youtube/patches/NavigationButtonsPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
package app.revanced.integrations.youtube.patches; | ||
|
||
import static app.revanced.integrations.youtube.shared.NavigationBar.NavigationButton; | ||
|
||
import android.view.View; | ||
|
||
import java.util.EnumMap; | ||
import java.util.Map; | ||
|
||
import app.revanced.integrations.youtube.settings.Settings; | ||
|
||
@SuppressWarnings("unused") | ||
public final class NavigationButtonsPatch { | ||
public static Enum lastNavigationButton; | ||
|
||
public static void hideCreateButton(final View view) { | ||
view.setVisibility(Settings.HIDE_CREATE_BUTTON.get() ? View.GONE : View.VISIBLE); | ||
} | ||
|
||
public static boolean switchCreateWithNotificationButton() { | ||
return Settings.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.get(); | ||
} | ||
private static final Map<NavigationButton, Boolean> shouldHideMap = new EnumMap<>(NavigationButton.class) { | ||
{ | ||
put(NavigationButton.HOME, Settings.HIDE_HOME_BUTTON.get()); | ||
put(NavigationButton.CREATE, Settings.HIDE_CREATE_BUTTON.get()); | ||
put(NavigationButton.SHORTS, Settings.HIDE_SHORTS_BUTTON.get()); | ||
} | ||
}; | ||
|
||
public static void hideButton(final View buttonView) { | ||
if (lastNavigationButton == null) return; | ||
private static final Boolean SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON | ||
= Settings.SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON.get(); | ||
|
||
for (NavigationButton button : NavigationButton.values()) | ||
if (button.name.equals(lastNavigationButton.name())) | ||
if (button.enabled) buttonView.setVisibility(View.GONE); | ||
/** | ||
* Injection point. | ||
*/ | ||
public static boolean switchCreateWithNotificationButton() { | ||
return SWITCH_CREATE_WITH_NOTIFICATIONS_BUTTON; | ||
} | ||
|
||
private enum NavigationButton { | ||
HOME("PIVOT_HOME", Settings.HIDE_HOME_BUTTON.get()), | ||
SHORTS("TAB_SHORTS", Settings.HIDE_SHORTS_BUTTON.get()), | ||
SUBSCRIPTIONS("PIVOT_SUBSCRIPTIONS", Settings.HIDE_SUBSCRIPTIONS_BUTTON.get()); | ||
private final boolean enabled; | ||
private final String name; | ||
|
||
NavigationButton(final String name, final boolean enabled) { | ||
this.name = name; | ||
this.enabled = enabled; | ||
/** | ||
* Injection point. | ||
*/ | ||
public static void navigationTabCreated(NavigationButton button, View tabView) { | ||
if (Boolean.TRUE.equals(shouldHideMap.get(button))) { | ||
tabView.setVisibility(View.GONE); | ||
} | ||
} | ||
} |
Oops, something went wrong.