mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube - Description components): Remove Title in video description panel
setting (No more necessary)
This commit is contained in:
@ -1,32 +1,18 @@
|
||||
package app.revanced.extension.youtube.patches.feed;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.BottomSheetState;
|
||||
import app.revanced.extension.youtube.shared.EngagementPanel;
|
||||
import app.revanced.extension.youtube.shared.RootView;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class RelatedVideoPatch {
|
||||
private static final boolean HIDE_RELATED_VIDEOS = Settings.HIDE_RELATED_VIDEOS.get();
|
||||
|
||||
private static final int OFFSET = Settings.RELATED_VIDEOS_OFFSET.get();
|
||||
|
||||
// video title,channel bar, video action bar, comment
|
||||
private static final int MAX_ITEM_COUNT = 4 + OFFSET;
|
||||
|
||||
private static final AtomicBoolean engagementPanelOpen = new AtomicBoolean(false);
|
||||
|
||||
public static void showEngagementPanel(@Nullable Object object) {
|
||||
engagementPanelOpen.set(object != null);
|
||||
}
|
||||
|
||||
public static void hideEngagementPanel() {
|
||||
engagementPanelOpen.compareAndSet(true, false);
|
||||
}
|
||||
|
||||
public static int overrideItemCounts(int itemCounts) {
|
||||
if (!HIDE_RELATED_VIDEOS) {
|
||||
return itemCounts;
|
||||
@ -40,7 +26,7 @@ public final class RelatedVideoPatch {
|
||||
if (BottomSheetState.getCurrent().isOpen()) {
|
||||
return itemCounts;
|
||||
}
|
||||
if (engagementPanelOpen.get()) {
|
||||
if (EngagementPanel.isOpen()) {
|
||||
return itemCounts;
|
||||
}
|
||||
return MAX_ITEM_COUNT;
|
||||
|
@ -19,6 +19,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import app.revanced.extension.shared.settings.BaseSettings;
|
||||
import app.revanced.extension.shared.settings.BooleanSetting;
|
||||
@ -30,6 +31,7 @@ import app.revanced.extension.shared.utils.Utils;
|
||||
import app.revanced.extension.youtube.patches.utils.InitializationPatch;
|
||||
import app.revanced.extension.youtube.patches.utils.PatchStatus;
|
||||
import app.revanced.extension.youtube.settings.Settings;
|
||||
import app.revanced.extension.youtube.shared.EngagementPanel;
|
||||
import app.revanced.extension.youtube.shared.PlayerType;
|
||||
import app.revanced.extension.youtube.shared.RootView;
|
||||
import app.revanced.extension.youtube.shared.ShortsPlayerState;
|
||||
@ -118,37 +120,6 @@ public class PlayerPatch {
|
||||
*/
|
||||
private static final int contentId = ResourceUtils.getIdIdentifier("content");
|
||||
private static final boolean EXPAND_VIDEO_DESCRIPTION = Settings.EXPAND_VIDEO_DESCRIPTION.get();
|
||||
private static final StringSetting EXPAND_VIDEO_DESCRIPTION_STRINGS = Settings.EXPAND_VIDEO_DESCRIPTION_STRINGS;
|
||||
private static final String EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE = "revanced_expand_video_description_strings_default_value";
|
||||
|
||||
static {
|
||||
final String descriptionString = EXPAND_VIDEO_DESCRIPTION_STRINGS.get();
|
||||
if (descriptionString.equals(EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE) &&
|
||||
Utils.getContext() != null) {
|
||||
String defaultValue = ResourceUtils.getString(EXPAND_VIDEO_DESCRIPTION_STRINGS_DEFAULT_VALUE);
|
||||
if (!descriptionString.equals(defaultValue)) {
|
||||
EXPAND_VIDEO_DESCRIPTION_STRINGS.save(defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isDescriptionPanel = false;
|
||||
|
||||
public static void setContentDescription(String contentDescription) {
|
||||
if (!EXPAND_VIDEO_DESCRIPTION) {
|
||||
return;
|
||||
}
|
||||
if (contentDescription == null || contentDescription.isEmpty()) {
|
||||
isDescriptionPanel = false;
|
||||
return;
|
||||
}
|
||||
final String descriptionString = EXPAND_VIDEO_DESCRIPTION_STRINGS.get();
|
||||
if (descriptionString.isEmpty()) {
|
||||
isDescriptionPanel = false;
|
||||
return;
|
||||
}
|
||||
isDescriptionPanel = descriptionString.equals(contentDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* The last time the clickDescriptionView method was called.
|
||||
@ -172,9 +143,8 @@ public class PlayerPatch {
|
||||
if (contentView.getId() != contentId) {
|
||||
return;
|
||||
}
|
||||
// This method is invoked whenever the Engagement panel is opened. (Description, Chapters, Comments, etc.)
|
||||
// Check the title of the Engagement panel to prevent unnecessary clicking.
|
||||
if (!isDescriptionPanel) {
|
||||
// Check description panel opened.
|
||||
if (!EngagementPanel.isDescription()) {
|
||||
return;
|
||||
}
|
||||
// The first view group contains information such as the video's title, like count, and number of views.
|
||||
@ -456,20 +426,22 @@ public class PlayerPatch {
|
||||
imageView.setImageAlpha(PLAYER_OVERLAY_OPACITY_LEVEL);
|
||||
}
|
||||
|
||||
private static boolean isAutoPopupPanel;
|
||||
@NonNull
|
||||
private static final AtomicBoolean newVideoStarted = new AtomicBoolean(false);
|
||||
|
||||
public static boolean disableAutoPlayerPopupPanels(boolean isLiveChatOrPlaylistPanel) {
|
||||
if (!Settings.DISABLE_AUTO_PLAYER_POPUP_PANELS.get()) {
|
||||
return false;
|
||||
public static boolean disableAutoPlayerPopupPanels(boolean isLiveChatOrPlaylistPanel, String panelId) {
|
||||
if (Settings.DISABLE_AUTO_PLAYER_POPUP_PANELS.get()) {
|
||||
return isLiveChatOrPlaylistPanel || (panelId.equals("PAproduct_list") && newVideoStarted.get());
|
||||
}
|
||||
if (isLiveChatOrPlaylistPanel) {
|
||||
return true;
|
||||
}
|
||||
return isAutoPopupPanel && ShortsPlayerState.getCurrent().isClosed();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setInitVideoPanel(boolean initVideoPanel) {
|
||||
isAutoPopupPanel = initVideoPanel;
|
||||
public static void disableAutoPlayerPopupPanels(@NonNull String newlyLoadedChannelId, @NonNull String newlyLoadedChannelName,
|
||||
@NonNull String newlyLoadedVideoId, @NonNull String newlyLoadedVideoTitle,
|
||||
final long newlyLoadedVideoLength, boolean newlyLoadedLiveStreamValue) {
|
||||
if (Settings.DISABLE_AUTO_PLAYER_POPUP_PANELS.get() && newVideoStarted.compareAndSet(false, true)) {
|
||||
Utils.runOnMainThreadDelayed(() -> newVideoStarted.compareAndSet(true, false), 1500L);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -493,7 +465,7 @@ public class PlayerPatch {
|
||||
return;
|
||||
}
|
||||
VideoUtils.pauseMedia();
|
||||
VideoUtils.openVideo(videoId);
|
||||
VideoUtils.openVideo(newlyLoadedVideoId);
|
||||
}
|
||||
|
||||
public static boolean disableSpeedOverlay() {
|
||||
|
@ -345,7 +345,7 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting HIDE_PLAYER_FLYOUT_MENU_YT_MUSIC = new BooleanSetting("revanced_hide_player_flyout_menu_listen_with_youtube_music", TRUE);
|
||||
|
||||
// PreferenceScreen: Player - Fullscreen
|
||||
public static final BooleanSetting DISABLE_ENGAGEMENT_PANEL = new BooleanSetting("revanced_disable_engagement_panel", FALSE, true);
|
||||
public static final BooleanSetting DISABLE_ENGAGEMENT_PANEL = new BooleanSetting("revanced_disable_engagement_panel", FALSE);
|
||||
public static final BooleanSetting ENTER_FULLSCREEN = new BooleanSetting("revanced_enter_fullscreen", FALSE);
|
||||
public static final EnumSetting<FullscreenMode> EXIT_FULLSCREEN = new EnumSetting<>("revanced_exit_fullscreen", FullscreenMode.DISABLED);
|
||||
public static final BooleanSetting SHOW_VIDEO_TITLE_SECTION = new BooleanSetting("revanced_show_video_title_section", TRUE, true, parent(DISABLE_ENGAGEMENT_PANEL));
|
||||
@ -428,7 +428,6 @@ public class Settings extends BaseSettings {
|
||||
public static final BooleanSetting HIDE_TRANSCRIPT_SECTION = new BooleanSetting("revanced_hide_transcript_section", FALSE);
|
||||
public static final BooleanSetting DISABLE_VIDEO_DESCRIPTION_INTERACTION = new BooleanSetting("revanced_disable_video_description_interaction", FALSE, true);
|
||||
public static final BooleanSetting EXPAND_VIDEO_DESCRIPTION = new BooleanSetting("revanced_expand_video_description", FALSE, true);
|
||||
public static final StringSetting EXPAND_VIDEO_DESCRIPTION_STRINGS = new StringSetting("revanced_expand_video_description_strings", str("revanced_expand_video_description_strings_default_value"), true, parent(EXPAND_VIDEO_DESCRIPTION));
|
||||
|
||||
|
||||
// PreferenceScreen: Shorts
|
||||
|
@ -0,0 +1,46 @@
|
||||
package app.revanced.extension.youtube.shared;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import app.revanced.extension.shared.utils.Logger;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EngagementPanel {
|
||||
private static final AtomicReference<String> engagementPanelId = new AtomicReference<>("");
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void setId(@Nullable String panelId) {
|
||||
if (panelId != null) {
|
||||
Logger.printDebug(() -> "engagementPanel open\npanelId: " + panelId);
|
||||
engagementPanelId.set(panelId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void hide() {
|
||||
String panelId = getId();
|
||||
if (!panelId.isEmpty()) {
|
||||
Logger.printDebug(() -> "engagementPanel closed\npanelId: " + panelId);
|
||||
engagementPanelId.set("");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOpen() {
|
||||
return !getId().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isDescription() {
|
||||
return getId().equals("video-description-ep-identifier");
|
||||
}
|
||||
|
||||
public static String getId() {
|
||||
return engagementPanelId.get();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user