diff --git a/extensions/youtube/build.gradle.kts b/extensions/youtube/build.gradle.kts index 30509bf1b..f84a54a0d 100644 --- a/extensions/youtube/build.gradle.kts +++ b/extensions/youtube/build.gradle.kts @@ -5,8 +5,6 @@ dependencies { } android { - compileSdk = 33 // TODO: Update Swipe controls code to allow updating this to the latest sdk. - defaultConfig { minSdk = 26 } diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java index ec5b813f3..72f946a7d 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/settings/Settings.java @@ -306,21 +306,21 @@ public class Settings extends BaseSettings { // Swipe controls public static final BooleanSetting SWIPE_CHANGE_VIDEO = new BooleanSetting("revanced_swipe_change_video", FALSE, true); - public static final BooleanSetting SWIPE_BRIGHTNESS = new BooleanSetting("revanced_swipe_brightness", FALSE); - public static final BooleanSetting SWIPE_VOLUME = new BooleanSetting("revanced_swipe_volume", FALSE); + public static final BooleanSetting SWIPE_BRIGHTNESS = new BooleanSetting("revanced_swipe_brightness", FALSE, true); + public static final BooleanSetting SWIPE_VOLUME = new BooleanSetting("revanced_swipe_volume", FALSE, true); public static final BooleanSetting SWIPE_PRESS_TO_ENGAGE = new BooleanSetting("revanced_swipe_press_to_engage", FALSE, true, parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME)); public static final BooleanSetting SWIPE_HAPTIC_FEEDBACK = new BooleanSetting("revanced_swipe_haptic_feedback", TRUE, true, parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME)); public static final IntegerSetting SWIPE_MAGNITUDE_THRESHOLD = new IntegerSetting("revanced_swipe_threshold", 30, true, parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME)); - public static final IntegerSetting SWIPE_OVERLAY_OPACITY = new IntegerSetting("revanced_swipe_overlay_background_opacity", 50, true, + public static final BooleanSetting SWIPE_SHOW_CIRCULAR_OVERLAY = new BooleanSetting("revanced_swipe_show_circular_overlay", FALSE, true, + parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME)); + public static final BooleanSetting SWIPE_OVERLAY_MINIMAL_STYLE = new BooleanSetting("revanced_swipe_overlay_minimal_style", FALSE, 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)); private static final IntegerSetting DEPRECATED_SWIPE_OVERLAY_BACKGROUND_ALPHA = new IntegerSetting("revanced_swipe_overlay_background_alpha", 127); - - // Debugging - public static final IntegerSetting SWIPE_OVERLAY_TEXT_SIZE = new IntegerSetting("revanced_swipe_text_overlay_size", 22, 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)); diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/SwipeControlsConfigurationProvider.kt b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/SwipeControlsConfigurationProvider.kt index 303ffe9b0..08e7e0480 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/SwipeControlsConfigurationProvider.kt +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/SwipeControlsConfigurationProvider.kt @@ -20,19 +20,17 @@ class SwipeControlsConfigurationProvider( * should swipe controls be enabled? (global setting) */ val enableSwipeControls: Boolean - get() = isFullscreenVideo && (enableVolumeControls || enableBrightnessControl) + get() = (enableVolumeControls || enableBrightnessControl) && isFullscreenVideo /** * should swipe controls for volume be enabled? */ - val enableVolumeControls: Boolean - get() = Settings.SWIPE_VOLUME.get() + val enableVolumeControls = Settings.SWIPE_VOLUME.get() /** * should swipe controls for volume be enabled? */ - val enableBrightnessControl: Boolean - get() = Settings.SWIPE_BRIGHTNESS.get() + val enableBrightnessControl = Settings.SWIPE_BRIGHTNESS.get() /** * is the video player currently in fullscreen mode? @@ -46,7 +44,7 @@ class SwipeControlsConfigurationProvider( * should volume key controls be overwritten? (global setting) */ val overwriteVolumeKeyControls: Boolean - get() = isFullscreenVideo && enableVolumeControls + get() = enableVolumeControls && isFullscreenVideo //endregion //region gesture adjustments @@ -65,7 +63,6 @@ class SwipeControlsConfigurationProvider( //endregion //region overlay adjustments - /** * should the overlay enable haptic feedback? */ @@ -79,15 +76,10 @@ class SwipeControlsConfigurationProvider( get() = Settings.SWIPE_OVERLAY_TIMEOUT.get() /** - * text size for the overlay, in sp + * Gets the opacity value (0-100%) is converted to an alpha value (0-255) for transparency. + * If the opacity value is out of range, it resets to the default and displays a warning message. */ - val overlayTextSize: Int - get() = Settings.SWIPE_OVERLAY_TEXT_SIZE.get() - - /** - * get the background color for text on the overlay, as a color int - */ - val overlayTextBackgroundColor: Int + val overlayBackgroundOpacity: Int get() { var opacity = Settings.SWIPE_OVERLAY_OPACITY.get() @@ -102,11 +94,34 @@ class SwipeControlsConfigurationProvider( } /** - * get the foreground color for text on the overlay, as a color int + * The color of the progress overlay. */ - val overlayForegroundColor: Int + val overlayProgressColor: Int + get() = 0xBFFFFFFF.toInt() + + /** + * The color used for the background of the progress overlay fill. + */ + val overlayFillBackgroundPaint: Int + get() = 0x80D3D3D3.toInt() + + /** + * The color used for the text and icons in the overlay. + */ + val overlayTextColor: Int get() = Color.WHITE + /** + * A flag that determines if the overlay should only show the icon. + */ + val overlayShowOverlayMinimalStyle: Boolean + get() = Settings.SWIPE_OVERLAY_MINIMAL_STYLE.get() + + /** + * A flag that determines if the progress bar should be circular. + */ + val isCircularProgressBar: Boolean + get() = Settings.SWIPE_SHOW_CIRCULAR_OVERLAY.get() //endregion //region behaviour diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/controller/gesture/core/BaseGestureController.kt b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/controller/gesture/core/BaseGestureController.kt index fca1da9f8..286a6fe43 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/controller/gesture/core/BaseGestureController.kt +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/controller/gesture/core/BaseGestureController.kt @@ -82,11 +82,15 @@ abstract class BaseGestureController( } override fun onScroll( - from: MotionEvent, + from: MotionEvent?, to: MotionEvent, distanceX: Float, distanceY: Float, ): Boolean { + if (from == null) { + return false + } + // submit to swipe detector submitForSwipe(from, to, distanceX, distanceY) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/views/SwipeControlsOverlayLayout.kt b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/views/SwipeControlsOverlayLayout.kt index b3422d7bd..eda008cf6 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/views/SwipeControlsOverlayLayout.kt +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/swipecontrols/views/SwipeControlsOverlayLayout.kt @@ -1,138 +1,145 @@ package app.revanced.extension.youtube.swipecontrols.views import android.content.Context +import android.graphics.Canvas +import android.graphics.Paint +import android.graphics.RectF import android.graphics.drawable.Drawable -import android.graphics.drawable.GradientDrawable import android.os.Handler import android.os.Looper -import android.util.TypedValue +import android.util.AttributeSet import android.view.HapticFeedbackConstants import android.view.View -import android.view.ViewGroup import android.widget.RelativeLayout -import android.widget.TextView -import app.revanced.extension.shared.StringRef.str import app.revanced.extension.shared.Utils import app.revanced.extension.youtube.swipecontrols.SwipeControlsConfigurationProvider import app.revanced.extension.youtube.swipecontrols.misc.SwipeControlsOverlay -import app.revanced.extension.youtube.swipecontrols.misc.applyDimension +import kotlin.math.min import kotlin.math.round /** - * main overlay layout for volume and brightness swipe controls - * - * @param context context to create in + * Main overlay layout for displaying volume and brightness level with both circular and rectangular progress bars. */ class SwipeControlsOverlayLayout( context: Context, private val config: SwipeControlsConfigurationProvider, ) : RelativeLayout(context), SwipeControlsOverlay { - /** - * DO NOT use this, for tools only - */ + constructor(context: Context) : this(context, SwipeControlsConfigurationProvider(context)) - private val feedbackTextView: TextView - private val autoBrightnessIcon: Drawable - private val manualBrightnessIcon: Drawable - private val mutedVolumeIcon: Drawable - private val normalVolumeIcon: Drawable + // Drawable icons for brightness and volume + private val autoBrightnessIcon: Drawable = getDrawable("revanced_ic_sc_brightness_auto") + private val lowBrightnessIcon: Drawable = getDrawable("revanced_ic_sc_brightness_low") + private val mediumBrightnessIcon: Drawable = getDrawable("revanced_ic_sc_brightness_medium") + private val highBrightnessIcon: Drawable = getDrawable("revanced_ic_sc_brightness_high") + private val fullBrightnessIcon: Drawable = getDrawable("revanced_ic_sc_brightness_full") + private val mutedVolumeIcon: Drawable = getDrawable("revanced_ic_sc_volume_mute") + private val lowVolumeIcon: Drawable = getDrawable("revanced_ic_sc_volume_low") + private val normalVolumeIcon: Drawable = getDrawable("revanced_ic_sc_volume_normal") + private val fullVolumeIcon: Drawable = getDrawable("revanced_ic_sc_volume_high") - private fun getDrawable(name: String, width: Int, height: Int): Drawable { - return resources.getDrawable( + // Function to retrieve drawable resources by name + private fun getDrawable(name: String): Drawable { + val drawable = resources.getDrawable( Utils.getResourceIdentifier(context, name, "drawable"), context.theme, - ).apply { - setTint(config.overlayForegroundColor) - setBounds( - 0, - 0, - width, - height, - ) - } + ) + drawable.setTint(config.overlayTextColor) + return drawable } + // Initialize progress bars + private val circularProgressView: CircularProgressView + private val horizontalProgressView: HorizontalProgressView + init { - // init views - val feedbackTextViewPadding = 2.applyDimension(context, TypedValue.COMPLEX_UNIT_DIP) - val compoundIconPadding = 4.applyDimension(context, TypedValue.COMPLEX_UNIT_DIP) - feedbackTextView = TextView(context).apply { - layoutParams = LayoutParams( - LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT, - ).apply { + // Initialize circular progress bar + circularProgressView = CircularProgressView( + context, + config.overlayBackgroundOpacity, + config.overlayShowOverlayMinimalStyle, + config.overlayProgressColor, + config.overlayFillBackgroundPaint, + config.overlayTextColor + ).apply { + layoutParams = LayoutParams(300, 300).apply { addRule(CENTER_IN_PARENT, TRUE) - setPadding( - feedbackTextViewPadding, - feedbackTextViewPadding, - feedbackTextViewPadding, - feedbackTextViewPadding, - ) } - background = GradientDrawable().apply { - cornerRadius = 8f - setColor(config.overlayTextBackgroundColor) - } - setTextColor(config.overlayForegroundColor) - setTextSize(TypedValue.COMPLEX_UNIT_SP, config.overlayTextSize.toFloat()) - compoundDrawablePadding = compoundIconPadding - visibility = GONE + visibility = GONE // Initially hidden } - addView(feedbackTextView) + addView(circularProgressView) - // get icons scaled, assuming square icons - val iconHeight = round(feedbackTextView.lineHeight * .8).toInt() - autoBrightnessIcon = getDrawable("revanced_ic_sc_brightness_auto", iconHeight, iconHeight) - manualBrightnessIcon = getDrawable("revanced_ic_sc_brightness_manual", iconHeight, iconHeight) - mutedVolumeIcon = getDrawable("revanced_ic_sc_volume_mute", iconHeight, iconHeight) - normalVolumeIcon = getDrawable("revanced_ic_sc_volume_normal", iconHeight, iconHeight) + // Initialize rectangular progress bar + val screenWidth = resources.displayMetrics.widthPixels + val layoutWidth = (screenWidth * 2 / 3).toInt() // 2/3 of screen width + horizontalProgressView = HorizontalProgressView( + context, + config.overlayBackgroundOpacity, + config.overlayShowOverlayMinimalStyle, + config.overlayProgressColor, + config.overlayFillBackgroundPaint, + config.overlayTextColor + ).apply { + layoutParams = LayoutParams(layoutWidth, 100).apply { + addRule(CENTER_HORIZONTAL) + topMargin = 40 // Top margin + } + visibility = GONE // Initially hidden + } + addView(horizontalProgressView) } + // Handler and callback for hiding progress bars private val feedbackHideHandler = Handler(Looper.getMainLooper()) private val feedbackHideCallback = Runnable { - feedbackTextView.visibility = GONE + circularProgressView.visibility = GONE + horizontalProgressView.visibility = GONE } /** - * show the feedback view for a given time - * - * @param message the message to show - * @param icon the icon to use + * Displays the progress bar with the appropriate value, icon, and type (brightness or volume). */ - private fun showFeedbackView(message: String, icon: Drawable) { + private fun showFeedbackView(value: String, progress: Int, max: Int, icon: Drawable, isBrightness: Boolean) { feedbackHideHandler.removeCallbacks(feedbackHideCallback) feedbackHideHandler.postDelayed(feedbackHideCallback, config.overlayShowTimeoutMillis) - feedbackTextView.apply { - text = message - setCompoundDrawablesRelative( - icon, - null, - null, - null, - ) + + val viewToShow = if (config.isCircularProgressBar) circularProgressView else horizontalProgressView + viewToShow.apply { + setProgress(progress, max, value, isBrightness) + this.icon = icon visibility = VISIBLE } } + // Handle volume change override fun onVolumeChanged(newVolume: Int, maximumVolume: Int) { - showFeedbackView( - "$newVolume", - if (newVolume > 0) normalVolumeIcon else mutedVolumeIcon, - ) + val volumePercentage = (newVolume.toFloat() / maximumVolume) * 100 + val icon = when { + newVolume == 0 -> mutedVolumeIcon + volumePercentage < 33 -> lowVolumeIcon + volumePercentage < 66 -> normalVolumeIcon + else -> fullVolumeIcon + } + showFeedbackView("$newVolume", newVolume, maximumVolume, icon, isBrightness = false) } + // Handle brightness change override fun onBrightnessChanged(brightness: Double) { if (config.shouldLowestValueEnableAutoBrightness && brightness <= 0) { - showFeedbackView( - str("revanced_swipe_lowest_value_enable_auto_brightness_overlay_text"), - autoBrightnessIcon, - ) - } else if (brightness >= 0) { - showFeedbackView("${round(brightness).toInt()}%", manualBrightnessIcon) + showFeedbackView("Auto", 0, 100, autoBrightnessIcon, isBrightness = true) + } else { + val brightnessValue = round(brightness).toInt() + val icon = when { + brightnessValue < 25 -> lowBrightnessIcon + brightnessValue < 50 -> mediumBrightnessIcon + brightnessValue < 75 -> highBrightnessIcon + else -> fullBrightnessIcon + } + showFeedbackView("$brightnessValue%", brightnessValue, 100, icon, isBrightness = true) } } + // Begin swipe session override fun onEnterSwipeSession() { if (config.shouldEnableHapticFeedback) { @Suppress("DEPRECATION") @@ -143,3 +150,233 @@ class SwipeControlsOverlayLayout( } } } + +/** + * Abstract base class for progress views to reduce code duplication. + */ +/** + * Abstract base class for progress views to reduce code duplication. + */ +abstract class AbstractProgressView( + context: Context, + protected val overlayBackgroundOpacity: Int, + protected val overlayShowOverlayMinimalStyle: Boolean, + protected val overlayProgressColor: Int, + protected val overlayFillBackgroundPaint: Int, + protected val overlayTextColor: Int, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { + + // Combined paint creation function for both fill and stroke styles + private fun createPaint(color: Int, style: Paint.Style = Paint.Style.FILL, strokeCap: Paint.Cap = Paint.Cap.BUTT, strokeWidth: Float = 0f) = Paint(Paint.ANTI_ALIAS_FLAG).apply { + this.style = style + this.color = color + this.strokeCap = strokeCap + this.strokeWidth = strokeWidth + } + + // Initialize paints + public val backgroundPaint = createPaint(overlayBackgroundOpacity, style = Paint.Style.FILL) + public val progressPaint = createPaint(overlayProgressColor, style = Paint.Style.STROKE, strokeCap = Paint.Cap.ROUND, strokeWidth = 20f) + public val fillBackgroundPaint = createPaint(overlayFillBackgroundPaint, style = Paint.Style.FILL) + public val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + color = overlayTextColor + textAlign = Paint.Align.CENTER + textSize = 30f // Can adjust based on need + } + + + protected var progress = 0 + protected var maxProgress = 100 + protected var displayText: String = "0" + protected var isBrightness = true + public var icon: Drawable? = null + + init { + // Stroke widths are now set in createPaint for progressPaint and fillBackgroundPaint + } + + fun setProgress(value: Int, max: Int, text: String, isBrightnessMode: Boolean) { + progress = value + maxProgress = max + displayText = text + isBrightness = isBrightnessMode + invalidate() + } + + override fun onDraw(canvas: Canvas) { + // Base class implementation can be empty + } +} + +/** + * Custom view for rendering a circular progress indicator with text and icon. + */ +class CircularProgressView( + context: Context, + overlayBackgroundOpacity: Int, + overlayShowOverlayMinimalStyle: Boolean, + overlayProgressColor: Int, + overlayFillBackgroundPaint: Int, + overlayTextColor: Int, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AbstractProgressView( + context, + overlayBackgroundOpacity, + overlayShowOverlayMinimalStyle, + overlayProgressColor, + overlayFillBackgroundPaint, + overlayTextColor, + attrs, + defStyleAttr +) { + private val rectF = RectF() + + init { + textPaint.textSize = 40f // Override default text size for horizontal view + progressPaint.strokeWidth = 20f + fillBackgroundPaint.strokeWidth = 20f + progressPaint.strokeCap = Paint.Cap.ROUND + fillBackgroundPaint.strokeCap = Paint.Cap.BUTT + progressPaint.style = Paint.Style.STROKE + fillBackgroundPaint.style = Paint.Style.STROKE + } + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + + val size = min(width, height).toFloat() + rectF.set(20f, 20f, size - 20f, size - 20f) + + canvas.drawOval(rectF, fillBackgroundPaint) // Draw the outer ring. + canvas.drawCircle(width / 2f, height / 2f, size / 3, backgroundPaint) // Draw the inner circle. + + // Select the paint for drawing based on whether it's brightness or volume. + val sweepAngle = (progress.toFloat() / maxProgress) * 360 + canvas.drawArc(rectF, -90f, sweepAngle, false, progressPaint) // Draw the progress arc. + + // Draw the icon in the center. + icon?.let { + val iconSize = if (overlayShowOverlayMinimalStyle) 100 else 80 + val iconX = (width - iconSize) / 2 + val iconY = (height / 2) - if (overlayShowOverlayMinimalStyle) 50 else 80 + it.setBounds(iconX, iconY, iconX + iconSize, iconY + iconSize) + it.draw(canvas) + } + + // If not in icon-only mode, draw the text inside the ring. + if (!overlayShowOverlayMinimalStyle) { + canvas.drawText(displayText, width / 2f, height / 2f + 60f, textPaint) + } + } +} + +/** + * Custom view for rendering a rectangular progress bar with icons and text. + */ +class HorizontalProgressView( + context: Context, + overlayBackgroundOpacity: Int, + overlayShowOverlayMinimalStyle: Boolean, + overlayProgressColor: Int, + overlayFillBackgroundPaint: Int, + overlayTextColor: Int, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AbstractProgressView( + context, + overlayBackgroundOpacity, + overlayShowOverlayMinimalStyle, + overlayProgressColor, + overlayFillBackgroundPaint, + overlayTextColor, + attrs, + defStyleAttr +) { + + private val iconSize = 60f + private val padding = 40f + + init { + textPaint.textSize = 30f // Override default text size for horizontal view + progressPaint.strokeWidth = 0f + progressPaint.strokeCap = Paint.Cap.BUTT + progressPaint.style = Paint.Style.FILL + fillBackgroundPaint.style = Paint.Style.FILL + } + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + + val width = width.toFloat() + val height = height.toFloat() + + // Radius for rounded corners + val cornerRadius = min(width, height) / 2 + + // Calculate the total width for the elements + val minimalElementWidth = 5 * padding + iconSize + + // Calculate the starting point (X) to center the elements + val minimalStartX = (width - minimalElementWidth) / 2 + + // Draw the background + if (!overlayShowOverlayMinimalStyle) { + canvas.drawRoundRect(0f, 0f, width, height, cornerRadius, cornerRadius, backgroundPaint) + } else { + canvas.drawRoundRect(minimalStartX, 0f, minimalStartX + minimalElementWidth, height, cornerRadius, cornerRadius, backgroundPaint) + } + + if (!overlayShowOverlayMinimalStyle) { + // Draw the fill background + val startX = 2 * padding + iconSize + val endX = width - 4 * padding + val fillWidth = endX - startX + + canvas.drawRoundRect( + startX, + height / 2 - 5f, + endX, + height / 2 + 5f, + 10f, 10f, + fillBackgroundPaint + ) + + // Draw the progress + val progressWidth = (progress.toFloat() / maxProgress) * fillWidth + canvas.drawRoundRect( + startX, + height / 2 - 5f, + startX + progressWidth, + height / 2 + 5f, + 10f, 10f, + progressPaint + ) + } + + // Draw the icon + icon?.let { + val iconX = if (!overlayShowOverlayMinimalStyle) { + padding + } else { + padding + minimalStartX + } + val iconY = height / 2 - iconSize / 2 + it.setBounds(iconX.toInt(), iconY.toInt(), (iconX + iconSize).toInt(), (iconY + iconSize).toInt()) + it.draw(canvas) + } + + // Draw the text on the right + val textX = if (!overlayShowOverlayMinimalStyle) { + width - 2 * padding + } else { + minimalStartX + minimalElementWidth - 2 * padding + } + val textY = height / 2 + textPaint.textSize / 3 + + // Draw the text + canvas.drawText(displayText, textX, textY, textPaint) + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt index 1090e7b92..f127357d4 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/interaction/swipecontrols/SwipeControlsPatch.kt @@ -42,9 +42,10 @@ private val swipeControlsResourcePatch = resourcePatch { SwitchPreference("revanced_swipe_haptic_feedback"), SwitchPreference("revanced_swipe_save_and_restore_brightness"), SwitchPreference("revanced_swipe_lowest_value_enable_auto_brightness"), - TextPreference("revanced_swipe_overlay_timeout", inputType = InputType.NUMBER), - TextPreference("revanced_swipe_text_overlay_size", inputType = InputType.NUMBER), + SwitchPreference("revanced_swipe_show_circular_overlay"), + SwitchPreference("revanced_swipe_overlay_minimal_style"), TextPreference("revanced_swipe_overlay_background_opacity", inputType = InputType.NUMBER), + TextPreference("revanced_swipe_overlay_timeout", inputType = InputType.NUMBER), TextPreference("revanced_swipe_threshold", inputType = InputType.NUMBER), ) @@ -53,7 +54,12 @@ private val swipeControlsResourcePatch = resourcePatch { ResourceGroup( "drawable", "revanced_ic_sc_brightness_auto.xml", - "revanced_ic_sc_brightness_manual.xml", + "revanced_ic_sc_brightness_full.xml", + "revanced_ic_sc_brightness_high.xml", + "revanced_ic_sc_brightness_low.xml", + "revanced_ic_sc_brightness_medium.xml", + "revanced_ic_sc_volume_high.xml", + "revanced_ic_sc_volume_low.xml", "revanced_ic_sc_volume_mute.xml", "revanced_ic_sc_volume_normal.xml", ), diff --git a/patches/src/main/resources/addresources/values/strings.xml b/patches/src/main/resources/addresources/values/strings.xml index 3aa4fdda8..d4c3f4749 100644 --- a/patches/src/main/resources/addresources/values/strings.xml +++ b/patches/src/main/resources/addresources/values/strings.xml @@ -489,11 +489,15 @@ This feature is only available for older devices" Enable brightness gesture - Brightness swipe is enabled - Brightness swipe is disabled + "Fullscreen brightness swipe is enabled + +Adjust brightness by swiping vertically on the left side of the screen" + Fullscreen brightness swipe is disabled Enable volume gesture - Volume swipe is enabled - Volume swipe is disabled + "Fullscreen volume swipe is enabled + +Adjust volume by swiping vertically on the right side of the screen" + Fullscreen volume swipe is disabled Enable press-to-swipe gesture Press-to-swipe is enabled Press-to-swipe is disabled @@ -506,16 +510,19 @@ This feature is only available for older devices" Enable auto-brightness gesture Swiping down to the lowest value of the brightness gesture enable auto-brightness Swiping down to the lowest value does not enable auto-brightness - Auto Swipe overlay timeout The amount of milliseconds the overlay is visible - Swipe overlay text size - The text size for swipe overlay Swipe overlay background opacity Opacity value between 0-100 Swipe opacity must be between 0-100 Swipe magnitude threshold The amount of threshold for swipe to occur + Show circular overlay + Circular overlay is shown + Horizontal overlay is shown + Enable minimal style + Minimal overlay style is enabled + Minimal overlay style is disabled Enable swipe to change videos Swiping in fullscreen mode will change to the next/previous video Swiping in fullscreen mode will not change to the next/previous video diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_auto.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_auto.xml index f479e7175..252a97982 100644 --- a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_auto.xml +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_auto.xml @@ -1,7 +1,5 @@ + android:viewportHeight="24" + android:tint="?attr/colorControlNormal"> + android:pathData="M8,16H9.275L10.175,13.55H13.875L14.775,16H16.05L12.575,7H11.45ZM10.55,12.5 L11.95,8.6H12.05L13.475,12.5ZM12,22.6 L8.85,19.5H4.5V15.15L1.4,12L4.5,8.85V4.5H8.85L12,1.4L15.15,4.5H19.5V8.85L22.6,12L19.5,15.15V19.5H15.15ZM12,12ZM12,20.5 L14.5,18H18V14.5L20.5,12L18,9.5V6H14.5L12,3.5L9.5,6H6V9.5L3.5,12L6,14.5V18H9.5Z"/> diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_full.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_full.xml new file mode 100644 index 000000000..c0d45293c --- /dev/null +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_full.xml @@ -0,0 +1,29 @@ + + + + + diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_high.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_high.xml new file mode 100644 index 000000000..fe45b31be --- /dev/null +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_high.xml @@ -0,0 +1,29 @@ + + + + + diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_manual.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_low.xml similarity index 50% rename from patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_manual.xml rename to patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_low.xml index a5dc31c48..66010e253 100644 --- a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_manual.xml +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_low.xml @@ -1,7 +1,6 @@ + android:viewportHeight="24" + android:tint="?attr/colorControlNormal"> + android:pathData="M12,1.40039 L8.84961,4.5 L4.5,4.5 L4.5,8.84961 L1.40039,12 L4.5,15.1504 L4.5,19.5 L8.84961,19.5 L12,22.5996 L15.1504,19.5 L19.5,19.5 L19.5,15.1504 L22.5996,12 L19.5,8.84961 L19.5,4.5 L15.1504,4.5 L12,1.40039 Z M12,3.5 L14.5,6 L18,6 L18,9.5 L20.5,12 L18,14.5 L18,18 L14.5,18 L12,20.5 L9.5,18 L6,18 L6,14.5 L3.5,12 L6,9.5 L6,6 L9.5,6 L12,3.5 Z M12,6 L12,12 L18,12 C18,10.3333,17.4167,8.91667,16.25,7.75 C15.0833,6.58333,13.6667,6,12,6 Z"/> diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_medium.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_medium.xml new file mode 100644 index 000000000..fc191d25e --- /dev/null +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_brightness_medium.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_high.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_high.xml new file mode 100644 index 000000000..5dfb76a0e --- /dev/null +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_high.xml @@ -0,0 +1,29 @@ + + + + + diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_low.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_low.xml new file mode 100644 index 000000000..e52b1fe4a --- /dev/null +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_low.xml @@ -0,0 +1,29 @@ + + + + + diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_mute.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_mute.xml index b63afa603..59b9e72e4 100644 --- a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_mute.xml +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_mute.xml @@ -1,7 +1,5 @@ + android:viewportHeight="24" + android:tint="?attr/colorControlNormal"> + android:pathData="M19.475,22.15 L16.45,19.125Q15.95,19.45 15.375,19.7Q14.8,19.95 14.175,20.1V18.55Q14.5,18.45 14.8,18.325Q15.1,18.2 15.375,18.05L11.8,14.45V18.8L7.5,14.5H3.8V9.5H6.825L2,4.65L3.05,3.6L20.525,21.075ZM18.975,16.725 L17.9,15.65Q18.425,14.85 18.7,13.912Q18.975,12.975 18.975,11.975Q18.975,9.7 17.65,7.887Q16.325,6.075 14.175,5.4V3.85Q16.975,4.6 18.725,6.85Q20.475,9.1 20.475,11.975Q20.475,13.3 20.088,14.5Q19.7,15.7 18.975,16.725ZM9.3,11.975ZM15.925,13.675 L14.175,11.925V8.3Q15.175,8.85 15.738,9.85Q16.3,10.85 16.3,12Q16.3,12.45 16.2,12.862Q16.1,13.275 15.925,13.675ZM11.8,9.525 L9.625,7.375 11.8,5.2ZM10.3,15.15V12.95L8.325,11H5.3V13H8.15Z"/> diff --git a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_normal.xml b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_normal.xml index 7ef42ada6..602cd2a64 100644 --- a/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_normal.xml +++ b/patches/src/main/resources/swipecontrols/drawable/revanced_ic_sc_volume_normal.xml @@ -1,7 +1,6 @@ + android:viewportHeight="24" + android:tint="?attr/colorControlNormal"> + android:pathData="M3.8,14.5 L3.8,9.5 L7.5,9.5 L11.8,5.2 L11.8,18.8 L7.5,14.5 Z M14.175,15.65 L14.175,8.3 Q15.15,8.825,15.725,9.825 Q16.3,10.825,16.3,12 Q16.3,13.175,15.725,14.15 Q15.15,15.125,14.175,15.65 Z M10.3,8.85 L8.15,11 L5.3,11 L5.3,13 L8.15,13 L10.3,15.15 Z M7.8,12 Z"/>