Skip to content

Commit 5316211

Browse files
committed
Merge remote-tracking branch 'revanced/dev' into package-structure
# Conflicts: # patches/src/main/resources/addresources/values/strings.xml
2 parents 9cb8a67 + 1853c27 commit 5316211

File tree

87 files changed

+1588
-635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1588
-635
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [5.25.0-dev.12](https://github.com/ReVanced/revanced-patches/compare/v5.25.0-dev.11...v5.25.0-dev.12) (2025-05-28)
2+
3+
4+
### Features
5+
6+
* **YouTube - Swipe controls:** Add separate color settings for the brightness and volume bars ([#5043](https://github.com/ReVanced/revanced-patches/issues/5043)) ([80f50e8](https://github.com/ReVanced/revanced-patches/commit/80f50e8c50ca6a8366b7fd7b01459fb16fa1074a))
7+
18
# [5.25.0-dev.11](https://github.com/ReVanced/revanced-patches/compare/v5.25.0-dev.10...v5.25.0-dev.11) (2025-05-27)
29

310

extensions/shared/library/src/main/java/app/revanced/extension/shared/Logger.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ private enum LogLevel {
4141
ERROR
4242
}
4343

44-
private static final String REVANCED_LOG_TAG = "revanced";
44+
/**
45+
* Log tag prefix. Only used for system logging.
46+
*/
47+
private static final String REVANCED_LOG_TAG_PREFIX = "revanced: ";
4548

4649
private static final String LOGGER_CLASS_NAME = Logger.class.getName();
4750

@@ -90,17 +93,13 @@ private static void logInternal(LogLevel logLevel, LogMessage message, @Nullable
9093
String messageString = message.buildMessageString();
9194
String className = getOuterClassSimpleName(message);
9295

93-
StringBuilder logBuilder = new StringBuilder(className.length() + 2
94-
+ messageString.length());
95-
logBuilder.append(className).append(": ").append(messageString);
96-
97-
String toastMessage = showToast ? logBuilder.toString() : null;
96+
String logText = messageString;
9897

9998
// Append exception message if present.
10099
if (ex != null) {
101100
var exceptionMessage = ex.getMessage();
102101
if (exceptionMessage != null) {
103-
logBuilder.append("\nException: ").append(exceptionMessage);
102+
logText += "\nException: " + exceptionMessage;
104103
}
105104
}
106105

@@ -111,29 +110,31 @@ private static void logInternal(LogLevel logLevel, LogMessage message, @Nullable
111110
// Remove the stacktrace elements of this class.
112111
final int loggerIndex = stackTrace.lastIndexOf(LOGGER_CLASS_NAME);
113112
final int loggerBegins = stackTrace.indexOf('\n', loggerIndex);
114-
logBuilder.append(stackTrace, loggerBegins, stackTrace.length());
113+
logText += stackTrace.substring(loggerBegins);
115114
}
116115

117-
String logText = logBuilder.toString();
118-
LogBufferManager.appendToLogBuffer(logText);
116+
// Do not include "revanced:" prefix in clipboard logs.
117+
String managerToastString = className + ": " + logText;
118+
LogBufferManager.appendToLogBuffer(managerToastString);
119119

120+
String logTag = REVANCED_LOG_TAG_PREFIX + className;
120121
switch (logLevel) {
121122
case DEBUG:
122-
if (ex == null) Log.d(REVANCED_LOG_TAG, logText);
123-
else Log.d(REVANCED_LOG_TAG, logText, ex);
123+
if (ex == null) Log.d(logTag, logText);
124+
else Log.d(logTag, logText, ex);
124125
break;
125126
case INFO:
126-
if (ex == null) Log.i(REVANCED_LOG_TAG, logText);
127-
else Log.i(REVANCED_LOG_TAG, logText, ex);
127+
if (ex == null) Log.i(logTag, logText);
128+
else Log.i(logTag, logText, ex);
128129
break;
129130
case ERROR:
130-
if (ex == null) Log.e(REVANCED_LOG_TAG, logText);
131-
else Log.e(REVANCED_LOG_TAG, logText, ex);
131+
if (ex == null) Log.e(logTag, logText);
132+
else Log.e(logTag, logText, ex);
132133
break;
133134
}
134135

135-
if (toastMessage != null) {
136-
Utils.showToastLong(toastMessage);
136+
if (showToast) {
137+
Utils.showToastLong(managerToastString);
137138
}
138139
}
139140

extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,17 @@ public class Settings extends BaseSettings {
337337
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
338338
public static final IntegerSetting SWIPE_OVERLAY_OPACITY = new IntegerSetting("revanced_swipe_overlay_background_opacity", 60, true,
339339
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
340-
public static final StringSetting SWIPE_OVERLAY_PROGRESS_COLOR = new StringSetting("revanced_swipe_overlay_progress_color", "#FFFFFF", true,
341-
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
340+
public static final StringSetting SWIPE_OVERLAY_BRIGHTNESS_COLOR = new StringSetting("revanced_swipe_overlay_progress_brightness_color", "#FFFFFF", true,
341+
parent(SWIPE_BRIGHTNESS));
342+
public static final StringSetting SWIPE_OVERLAY_VOLUME_COLOR = new StringSetting("revanced_swipe_overlay_progress_volume_color", "#FFFFFF", true,
343+
parent(SWIPE_VOLUME));
342344
public static final LongSetting SWIPE_OVERLAY_TIMEOUT = new LongSetting("revanced_swipe_overlay_timeout", 500L, true,
343345
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
344-
public static final BooleanSetting SWIPE_SAVE_AND_RESTORE_BRIGHTNESS = new BooleanSetting("revanced_swipe_save_and_restore_brightness", TRUE, true, parent(SWIPE_BRIGHTNESS));
346+
public static final BooleanSetting SWIPE_SAVE_AND_RESTORE_BRIGHTNESS = new BooleanSetting("revanced_swipe_save_and_restore_brightness", TRUE, true,
347+
parent(SWIPE_BRIGHTNESS));
345348
public static final FloatSetting SWIPE_BRIGHTNESS_VALUE = new FloatSetting("revanced_swipe_brightness_value", -1f);
346-
public static final BooleanSetting SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS = new BooleanSetting("revanced_swipe_lowest_value_enable_auto_brightness", FALSE, true, parent(SWIPE_BRIGHTNESS));
349+
public static final BooleanSetting SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS = new BooleanSetting("revanced_swipe_lowest_value_enable_auto_brightness", FALSE, true,
350+
parent(SWIPE_BRIGHTNESS));
347351

348352
// ReturnYoutubeDislike
349353
public static final BooleanSetting RYD_ENABLED = new BooleanSetting("revanced_ryd_enabled", TRUE);

extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/SwipeControlsConfigurationProvider.kt

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package app.revanced.extension.youtube.swipecontrols
22

3-
import android.annotation.SuppressLint
43
import android.graphics.Color
54
import app.revanced.extension.shared.Logger
65
import app.revanced.extension.shared.StringRef.str
76
import app.revanced.extension.shared.Utils
7+
import app.revanced.extension.shared.settings.StringSetting
88
import app.revanced.extension.youtube.settings.Settings
99
import app.revanced.extension.youtube.shared.PlayerType
1010

@@ -51,105 +51,112 @@ class SwipeControlsConfigurationProvider {
5151
/**
5252
* Indicates whether press-to-swipe mode is enabled, requiring a press before swiping to activate controls.
5353
*/
54-
val shouldEnablePressToSwipe: Boolean
55-
get() = Settings.SWIPE_PRESS_TO_ENGAGE.get()
54+
val shouldEnablePressToSwipe = Settings.SWIPE_PRESS_TO_ENGAGE.get()
5655

5756
/**
5857
* The threshold for detecting swipe gestures, in pixels.
5958
* Loaded once to ensure consistent behavior during rapid scroll events.
6059
*/
61-
val swipeMagnitudeThreshold: Int
62-
get() = Settings.SWIPE_MAGNITUDE_THRESHOLD.get()
60+
val swipeMagnitudeThreshold = Settings.SWIPE_MAGNITUDE_THRESHOLD.get()
6361

6462
/**
6563
* The sensitivity of volume swipe gestures, determining how much volume changes per swipe.
6664
* Resets to default if set to 0, as it would disable swiping.
6765
*/
68-
val volumeSwipeSensitivity: Int
69-
get() {
70-
val sensitivity = Settings.SWIPE_VOLUME_SENSITIVITY.get()
66+
val volumeSwipeSensitivity: Int by lazy {
67+
val sensitivity = Settings.SWIPE_VOLUME_SENSITIVITY.get()
7168

72-
if (sensitivity < 1) {
73-
return Settings.SWIPE_VOLUME_SENSITIVITY.resetToDefault()
74-
}
75-
76-
return sensitivity
69+
if (sensitivity < 1) {
70+
return@lazy Settings.SWIPE_VOLUME_SENSITIVITY.resetToDefault()
7771
}
72+
73+
sensitivity
74+
}
7875
//endregion
7976

8077
//region overlay adjustments
8178
/**
8279
* Indicates whether haptic feedback should be enabled for swipe control interactions.
8380
*/
84-
val shouldEnableHapticFeedback: Boolean
85-
get() = Settings.SWIPE_HAPTIC_FEEDBACK.get()
81+
val shouldEnableHapticFeedback = Settings.SWIPE_HAPTIC_FEEDBACK.get()
8682

8783
/**
8884
* The duration in milliseconds that the overlay should remain visible after a change.
8985
*/
90-
val overlayShowTimeoutMillis: Long
91-
get() = Settings.SWIPE_OVERLAY_TIMEOUT.get()
86+
val overlayShowTimeoutMillis = Settings.SWIPE_OVERLAY_TIMEOUT.get()
9287

9388
/**
9489
* The background opacity of the overlay, converted from a percentage (0-100) to an alpha value (0-255).
9590
* Resets to default and shows a toast if the value is out of range.
9691
*/
97-
val overlayBackgroundOpacity: Int
98-
get() {
99-
var opacity = Settings.SWIPE_OVERLAY_OPACITY.get()
100-
101-
if (opacity < 0 || opacity > 100) {
102-
Utils.showToastLong(str("revanced_swipe_overlay_background_opacity_invalid_toast"))
103-
opacity = Settings.SWIPE_OVERLAY_OPACITY.resetToDefault()
104-
}
92+
val overlayBackgroundOpacity: Int by lazy {
93+
var opacity = Settings.SWIPE_OVERLAY_OPACITY.get()
10594

106-
opacity = opacity * 255 / 100
107-
return Color.argb(opacity, 0, 0, 0)
95+
if (opacity < 0 || opacity > 100) {
96+
Utils.showToastLong(str("revanced_swipe_overlay_background_opacity_invalid_toast"))
97+
opacity = Settings.SWIPE_OVERLAY_OPACITY.resetToDefault()
10898
}
10999

100+
opacity = opacity * 255 / 100
101+
Color.argb(opacity, 0, 0, 0)
102+
}
103+
110104
/**
111-
* The color of the progress bar in the overlay.
105+
* The color of the progress bar in the overlay for brightness.
112106
* Resets to default and shows a toast if the color string is invalid or empty.
113107
*/
114-
val overlayProgressColor: Int
115-
get() {
116-
try {
117-
@SuppressLint("UseKtx")
118-
val color = Color.parseColor(Settings.SWIPE_OVERLAY_PROGRESS_COLOR.get())
119-
return (0xBF000000.toInt() or (color and 0xFFFFFF))
120-
} catch (ex: IllegalArgumentException) {
121-
Logger.printDebug({ "Could not parse color" }, ex)
122-
Utils.showToastLong(str("revanced_swipe_overlay_progress_color_invalid_toast"))
123-
Settings.SWIPE_OVERLAY_PROGRESS_COLOR.resetToDefault()
124-
return overlayProgressColor // Recursively return.
125-
}
108+
val overlayBrightnessProgressColor: Int by lazy {
109+
// Use lazy to avoid repeat parsing. Changing color requires app restart.
110+
getSettingColor(Settings.SWIPE_OVERLAY_BRIGHTNESS_COLOR)
111+
}
112+
113+
/**
114+
* The color of the progress bar in the overlay for volume.
115+
* Resets to default and shows a toast if the color string is invalid or empty.
116+
*/
117+
val overlayVolumeProgressColor: Int by lazy {
118+
getSettingColor(Settings.SWIPE_OVERLAY_VOLUME_COLOR)
119+
}
120+
121+
private fun getSettingColor(setting: StringSetting): Int {
122+
try {
123+
//noinspection UseKtx
124+
val color = Color.parseColor(setting.get())
125+
return (0xBF000000.toInt() or (color and 0x00FFFFFF))
126+
} catch (ex: IllegalArgumentException) {
127+
// This code should never be reached.
128+
// Color picker rejects and will not save bad colors to a setting.
129+
// If a user imports bad data, the color picker preference resets the
130+
// bad color before this method can be called.
131+
Logger.printDebug({ "Could not parse color: $setting" }, ex)
132+
Utils.showToastLong(str("revanced_settings_color_invalid"))
133+
setting.resetToDefault()
134+
return getSettingColor(setting) // Recursively return.
126135
}
136+
}
127137

128138
/**
129139
* The background color used for the filled portion of the progress bar in the overlay.
130140
*/
131-
val overlayFillBackgroundPaint: Int
132-
get() = 0x80D3D3D3.toInt()
141+
val overlayFillBackgroundPaint = 0x80D3D3D3.toInt()
133142

134143
/**
135144
* The color used for text and icons in the overlay.
136145
*/
137-
val overlayTextColor: Int
138-
get() = Color.WHITE
146+
val overlayTextColor = Color.WHITE
139147

140148
/**
141149
* The text size in the overlay, in density-independent pixels (dp).
142150
* Must be between 1 and 30 dp; resets to default and shows a toast if invalid.
143151
*/
144-
val overlayTextSize: Int
145-
get() {
146-
val size = Settings.SWIPE_OVERLAY_TEXT_SIZE.get()
147-
if (size < 1 || size > 30) {
148-
Utils.showToastLong(str("revanced_swipe_text_overlay_size_invalid_toast"))
149-
return Settings.SWIPE_OVERLAY_TEXT_SIZE.resetToDefault()
150-
}
151-
return size
152+
val overlayTextSize: Int by lazy {
153+
val size = Settings.SWIPE_OVERLAY_TEXT_SIZE.get()
154+
if (size < 1 || size > 30) {
155+
Utils.showToastLong(str("revanced_swipe_text_overlay_size_invalid_toast"))
156+
return@lazy Settings.SWIPE_OVERLAY_TEXT_SIZE.resetToDefault()
152157
}
158+
size
159+
}
153160

154161
/**
155162
* Defines the style of the swipe controls overlay, determining its layout and appearance.
@@ -199,28 +206,25 @@ class SwipeControlsConfigurationProvider {
199206
/**
200207
* A minimal vertical progress bar.
201208
*/
202-
VERTICAL_MINIMAL(isMinimal = true, isVertical = true)
209+
VERTICAL_MINIMAL(isMinimal = true, isVertical = true)
203210
}
204211

205212
/**
206213
* The current style of the overlay, determining its layout and appearance.
207214
*/
208-
val overlayStyle: SwipeOverlayStyle
209-
get() = Settings.SWIPE_OVERLAY_STYLE.get()
215+
val overlayStyle = Settings.SWIPE_OVERLAY_STYLE.get()
210216
//endregion
211217

212218
//region behaviour
213219
/**
214220
* Indicates whether the brightness level should be saved and restored when entering or exiting fullscreen mode.
215221
*/
216-
val shouldSaveAndRestoreBrightness: Boolean
217-
get() = Settings.SWIPE_SAVE_AND_RESTORE_BRIGHTNESS.get()
222+
val shouldSaveAndRestoreBrightness = Settings.SWIPE_SAVE_AND_RESTORE_BRIGHTNESS.get()
218223

219224
/**
220225
* Indicates whether auto-brightness should be enabled when the brightness gesture reaches its lowest value.
221226
*/
222-
val shouldLowestValueEnableAutoBrightness: Boolean
223-
get() = Settings.SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS.get()
227+
val shouldLowestValueEnableAutoBrightness = Settings.SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS.get()
224228

225229
/**
226230
* The saved brightness value for the swipe gesture, used to restore brightness in fullscreen mode.
@@ -229,4 +233,4 @@ class SwipeControlsConfigurationProvider {
229233
get() = Settings.SWIPE_BRIGHTNESS_VALUE.get()
230234
set(value) = Settings.SWIPE_BRIGHTNESS_VALUE.save(value)
231235
//endregion
232-
}
236+
}

0 commit comments

Comments
 (0)