Skip to content

feat(YouTube - Swipe controls): Add option for vertical progress bar #4811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,14 @@ public class Settings extends BaseSettings {
public static final IntegerSetting SWIPE_MAGNITUDE_THRESHOLD = new IntegerSetting("revanced_swipe_threshold", 30, true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final IntegerSetting SWIPE_VOLUME_SENSITIVITY = new IntegerSetting("revanced_swipe_volume_sensitivity", 1, true, parent(SWIPE_VOLUME));
public static final BooleanSetting SWIPE_SHOW_CIRCULAR_OVERLAY = new BooleanSetting("revanced_swipe_show_circular_overlay", FALSE, true,
public static final StringSetting SWIPE_OVERLAY_STYLE = new StringSetting("revanced_swipe_overlay_style", "HORIZONTAL", true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final BooleanSetting SWIPE_OVERLAY_MINIMAL_STYLE = new BooleanSetting("revanced_swipe_overlay_minimal_style", FALSE, true,
public static final IntegerSetting SWIPE_OVERLAY_TEXT_SIZE = new IntegerSetting("revanced_swipe_text_overlay_size", 14, true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final IntegerSetting SWIPE_OVERLAY_OPACITY = new IntegerSetting("revanced_swipe_overlay_background_opacity", 60, true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final StringSetting SWIPE_OVERLAY_PROGRESS_COLOR = new StringSetting("revanced_swipe_overlay_progress_color", "#FFFFFF", true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final LongSetting SWIPE_OVERLAY_TIMEOUT = new LongSetting("revanced_swipe_overlay_timeout", 500L, true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final BooleanSetting SWIPE_SAVE_AND_RESTORE_BRIGHTNESS = new BooleanSetting("revanced_swipe_save_and_restore_brightness", TRUE, true, parent(SWIPE_BRIGHTNESS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,29 @@ class SwipeControlsConfigurationProvider {

/**
* The color of the progress overlay.
* If the color value is out of range, it resets to the default and displays a warning message.
*/
val overlayProgressColor: Int
get() = 0xBFFFFFFF.toInt()
get() {
val colorString = Settings.SWIPE_OVERLAY_PROGRESS_COLOR.get()
val hexColorPattern = Regex("^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$")
val defaultColor = 0xBFFFFFFF.toInt()

return try {
if (colorString.isNotEmpty() && hexColorPattern.matches(colorString)) {
val color = Color.parseColor(colorString)
(0xBF000000.toInt() or (color and 0xFFFFFF))
} else {
Utils.showToastLong(str("revanced_swipe_overlay_progress_color_invalid_toast"))
Settings.SWIPE_OVERLAY_PROGRESS_COLOR.resetToDefault()
defaultColor
}
} catch (e: IllegalArgumentException) {
Utils.showToastLong(str("revanced_swipe_overlay_progress_color_invalid_toast"))
Settings.SWIPE_OVERLAY_PROGRESS_COLOR.resetToDefault()
defaultColor
}
}

/**
* The color used for the background of the progress overlay fill.
Expand All @@ -124,16 +144,55 @@ class SwipeControlsConfigurationProvider {
get() = Color.WHITE

/**
* A flag that determines if the overlay should only show the icon.
* The size of the text in the overlay.
* Ensures the size is between 1 and 30 dp, resetting to default if invalid.
*/
val overlayTextSize: Float
get() {
var size = Settings.SWIPE_OVERLAY_TEXT_SIZE.get().toFloat()

if (size < 1 || size > 30)
{
Utils.showToastLong(str("revanced_swipe_text_overlay_size_invalid_toast"))
Settings.SWIPE_OVERLAY_TEXT_SIZE.resetToDefault()
size = Settings.SWIPE_OVERLAY_TEXT_SIZE.get().toFloat()
}

return size
}

/**
* The style of the overlay, determining its layout and appearance.
*/
private val overlayStyle: String
get() = Settings.SWIPE_OVERLAY_STYLE.get()

/**
* A flag that determines whether the overlay uses a minimal style, showing only the icon and text.
*/
val overlayShowOverlayMinimalStyle: Boolean
get() = Settings.SWIPE_OVERLAY_MINIMAL_STYLE.get()
get() = overlayStyle == "HORIZONTAL_MINIMAL_TOP" ||
overlayStyle == "HORIZONTAL_MINIMAL_CENTER" ||
overlayStyle == "CIRCULAR_MINIMAL" ||
overlayStyle == "VERTICAL_MINIMAL"

/**
* A flag that determines if the overlay uses a minimal centered horizontal style.
*/
val overlayShowHorizontalOverlayMinimalCenterStyle: Boolean
get() = overlayStyle == "HORIZONTAL_MINIMAL_CENTER"

/**
* A flag that determines if the progress bar should be circular.
*/
val isCircularProgressBar: Boolean
get() = Settings.SWIPE_SHOW_CIRCULAR_OVERLAY.get()
get() = overlayStyle == "CIRCULAR" || overlayStyle == "CIRCULAR_MINIMAL"

/**
* A flag that determines if the progress bar should be vertical.
*/
val isVerticalProgressBar: Boolean
get() = overlayStyle == "VERTICAL" || overlayStyle == "VERTICAL_MINIMAL"
//endregion

//region behaviour
Expand Down
Loading
Loading