From 145b3c063a2c02ab21d58854c7bb0c292df7cbfa Mon Sep 17 00:00:00 2001 From: j4k0xb <55899582+j4k0xb@users.noreply.github.com> Date: Tue, 19 Apr 2022 17:53:38 +0200 Subject: [PATCH] feat: `hide-shorts-button` patch --- .../main/java/fi/razerman/youtube/XAdRemover.java | 13 +++++++++++++ app/src/main/java/fi/razerman/youtube/XGlobals.java | 1 + .../youtube/preferences/BooleanPreferences.java | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/app/src/main/java/fi/razerman/youtube/XAdRemover.java b/app/src/main/java/fi/razerman/youtube/XAdRemover.java index 215064f5..0fff219c 100644 --- a/app/src/main/java/fi/razerman/youtube/XAdRemover.java +++ b/app/src/main/java/fi/razerman/youtube/XAdRemover.java @@ -178,6 +178,19 @@ public class XAdRemover { } } + public static void hideShortsButton(View view) { + if (XGlobals.lastPivotTab != null && XGlobals.lastPivotTab.name() == "TAB_SHORTS") { + if (BooleanPreferences.isShortsButtonHidden()) { + if (XGlobals.debug) { + Log.d("XAdRemover", "Shorts button: shown"); + } + view.setVisibility(View.GONE); + } else if (XGlobals.debug) { + Log.d("XAdRemover", "Shorts button: hidden"); + } + } + } + public static void inspectComponentHost(Object item) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); if (stackTraceElements.length <= 3) { diff --git a/app/src/main/java/fi/razerman/youtube/XGlobals.java b/app/src/main/java/fi/razerman/youtube/XGlobals.java index d4c33fb4..bf280bfb 100644 --- a/app/src/main/java/fi/razerman/youtube/XGlobals.java +++ b/app/src/main/java/fi/razerman/youtube/XGlobals.java @@ -152,6 +152,7 @@ public class XGlobals { public static Integer maxBuffer = 120000; public static Integer playbackMS = 2500; public static Integer reBuffer = 5000; + public static Enum lastPivotTab; public static void ReadSettings() { Context context; diff --git a/app/src/main/java/fi/razerman/youtube/preferences/BooleanPreferences.java b/app/src/main/java/fi/razerman/youtube/preferences/BooleanPreferences.java index 285ca330..9db4a538 100644 --- a/app/src/main/java/fi/razerman/youtube/preferences/BooleanPreferences.java +++ b/app/src/main/java/fi/razerman/youtube/preferences/BooleanPreferences.java @@ -19,4 +19,8 @@ public class BooleanPreferences { public static boolean isCreateButtonHidden() { return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_create_button_hidden", true); } + + public static boolean isShortsButtonHidden() { + return SharedPrefs.getBoolean(Objects.requireNonNull(YouTubeTikTokRoot_Application.getAppContext()), "xfile_shorts_button_hidden", true); + } }