Skip to content

Commit 01a04c3

Browse files
author
LisoUseInAIKyrios
authored
fix(YouTube): Use correct fade out animation when tapping to dismiss the video overlay (#5670)
1 parent 3130225 commit 01a04c3

18 files changed

+291
-45
lines changed

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/PlayerControlsPatch.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,4 @@ public void onGlobalLayout() {
5757
private static void fullscreenButtonVisibilityChanged(boolean isVisible) {
5858
// Code added during patching.
5959
}
60-
61-
/**
62-
* Injection point.
63-
*/
64-
public static String getPlayerTopControlsLayoutResourceName(String original) {
65-
return "default";
66-
}
6760
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package app.revanced.extension.youtube.patches;
2+
3+
import androidx.annotation.Nullable;
4+
5+
import app.revanced.extension.youtube.shared.PlayerControlsVisibility;
6+
7+
@SuppressWarnings("unused")
8+
public class PlayerControlsVisibilityHookPatch {
9+
10+
/**
11+
* Injection point.
12+
*/
13+
public static void setPlayerControlsVisibility(@Nullable Enum<?> youTubePlayerControlsVisibility) {
14+
if (youTubePlayerControlsVisibility == null) return;
15+
16+
PlayerControlsVisibility.setFromString(youTubePlayerControlsVisibility.name());
17+
}
18+
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/spoof/SpoofAppVersionPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class SpoofAppVersionPatch {
99
private static final String SPOOF_APP_VERSION_TARGET = Settings.SPOOF_APP_VERSION_TARGET.get();
1010

1111
/**
12-
* Injection point
12+
* injection point.
1313
*/
1414
public static String getYouTubeVersionOverride(String version) {
1515
if (SPOOF_APP_VERSION_ENABLED) return SPOOF_APP_VERSION_TARGET;

extensions/youtube/src/main/java/app/revanced/extension/youtube/patches/theme/SeekbarColorPatch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static String get9BitStyleIdentifier(int color24Bit) {
126126
}
127127

128128
/**
129-
* Injection point
129+
* injection point.
130130
*/
131131
public static boolean useLotteLaunchSplashScreen(boolean original) {
132132
// This method is only used for development purposes to force the old style launch screen.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package app.revanced.extension.youtube.shared
2+
3+
import app.revanced.extension.shared.Logger
4+
import app.revanced.extension.youtube.Event
5+
6+
/**
7+
* PlayerControls visibility state.
8+
*/
9+
enum class PlayerControlsVisibility {
10+
PLAYER_CONTROLS_VISIBILITY_UNKNOWN,
11+
PLAYER_CONTROLS_VISIBILITY_WILL_HIDE,
12+
PLAYER_CONTROLS_VISIBILITY_HIDDEN,
13+
PLAYER_CONTROLS_VISIBILITY_WILL_SHOW,
14+
PLAYER_CONTROLS_VISIBILITY_SHOWN;
15+
16+
companion object {
17+
18+
private val nameToPlayerControlsVisibility = PlayerControlsVisibility.entries.associateBy { it.name }
19+
20+
@JvmStatic
21+
fun setFromString(enumName: String) {
22+
val newType = nameToPlayerControlsVisibility[enumName]
23+
if (newType == null) {
24+
Logger.printException { "Unknown PlayerControlsVisibility encountered: $enumName" }
25+
} else {
26+
current = newType
27+
}
28+
}
29+
30+
@JvmStatic
31+
var current
32+
get() = currentPlayerControlsVisibility
33+
private set(type) {
34+
if (currentPlayerControlsVisibility != type) {
35+
Logger.printDebug { "Changed to: $type" }
36+
37+
currentPlayerControlsVisibility = type
38+
onChange(type)
39+
}
40+
}
41+
42+
@Volatile // Read/write from different threads.
43+
private var currentPlayerControlsVisibility = PLAYER_CONTROLS_VISIBILITY_UNKNOWN
44+
45+
@JvmStatic
46+
val onChange = Event<PlayerControlsVisibility>()
47+
}
48+
}

extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/SegmentPlaybackController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import android.graphics.drawable.ShapeDrawable;
1414
import android.graphics.drawable.shapes.RoundRectShape;
1515
import android.text.TextUtils;
16-
import android.util.DisplayMetrics;
1716
import android.util.Range;
1817
import android.view.Gravity;
1918
import android.view.ViewGroup;
@@ -877,7 +876,7 @@ public static void onSkipSegmentClicked(SponsorSegment segment) {
877876
}
878877

879878
/**
880-
* Injection point
879+
* injection point.
881880
*/
882881
@SuppressWarnings("unused")
883882
public static void setSponsorBarRect(Object self) {
@@ -909,7 +908,7 @@ private static void setSponsorBarAbsoluteRight(Rect rect) {
909908
}
910909

911910
/**
912-
* Injection point
911+
* injection point.
913912
*/
914913
@SuppressWarnings("unused")
915914
public static void setSponsorBarThickness(int thickness) {

extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/ui/CreateSegmentButton.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void hideControls() {
1818
}
1919

2020
/**
21-
* injection point
21+
* injection point.
2222
*/
2323
public static void initialize(View controlsView) {
2424
try {
@@ -37,14 +37,21 @@ public static void initialize(View controlsView) {
3737
}
3838

3939
/**
40-
* Injection point
40+
* injection point.
41+
*/
42+
public static void setVisibilityNegatedImmediate() {
43+
if (instance != null) instance.setVisibilityNegatedImmediate();
44+
}
45+
46+
/**
47+
* injection point.
4148
*/
4249
public static void setVisibilityImmediate(boolean visible) {
4350
if (instance != null) instance.setVisibilityImmediate(visible);
4451
}
4552

4653
/**
47-
* Injection point
54+
* injection point.
4855
*/
4956
public static void setVisibility(boolean visible, boolean animated) {
5057
if (instance != null) instance.setVisibility(visible, animated);

extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/ui/VotingButton.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static void hideControls() {
2020
}
2121

2222
/**
23-
* injection point
23+
* injection point.
2424
*/
2525
public static void initialize(View controlsView) {
2626
try {
@@ -39,14 +39,21 @@ public static void initialize(View controlsView) {
3939
}
4040

4141
/**
42-
* Injection point
42+
* injection point.
43+
*/
44+
public static void setVisibilityNegatedImmediate() {
45+
if (instance != null) instance.setVisibilityNegatedImmediate();
46+
}
47+
48+
/**
49+
* injection point.
4350
*/
4451
public static void setVisibilityImmediate(boolean visible) {
4552
if (instance != null) instance.setVisibilityImmediate(visible);
4653
}
4754

4855
/**
49-
* Injection point
56+
* injection point.
5057
*/
5158
public static void setVisibility(boolean visible, boolean animated) {
5259
if (instance != null) instance.setVisibility(visible, animated);

extensions/youtube/src/main/java/app/revanced/extension/youtube/videoplayer/CopyVideoUrlButton.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,22 @@ public static void initializeButton(View controlsView) {
3535
}
3636
}
3737

38+
/**`
39+
* injection point.
40+
*/
41+
public static void setVisibilityNegatedImmediate() {
42+
if (instance != null) instance.setVisibilityNegatedImmediate();
43+
}
44+
3845
/**
39-
* injection point
46+
* injection point.
4047
*/
4148
public static void setVisibilityImmediate(boolean visible) {
4249
if (instance != null) instance.setVisibilityImmediate(visible);
4350
}
4451

4552
/**
46-
* injection point
53+
* injection point.
4754
*/
4855
public static void setVisibility(boolean visible, boolean animated) {
4956
if (instance != null) instance.setVisibility(visible, animated);

extensions/youtube/src/main/java/app/revanced/extension/youtube/videoplayer/CopyVideoUrlTimestampButton.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,21 @@ public static void initializeButton(View controlsView) {
3636
}
3737

3838
/**
39-
* injection point
39+
* injection point.
40+
*/
41+
public static void setVisibilityNegatedImmediate() {
42+
if (instance != null) instance.setVisibilityNegatedImmediate();
43+
}
44+
45+
/**
46+
* injection point.
4047
*/
4148
public static void setVisibilityImmediate(boolean visible) {
4249
if (instance != null) instance.setVisibilityImmediate(visible);
4350
}
4451

4552
/**
46-
* injection point
53+
* injection point.
4754
*/
4855
public static void setVisibility(boolean visible, boolean animated) {
4956
if (instance != null) instance.setVisibility(visible, animated);

0 commit comments

Comments
 (0)