mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-30 06:34:28 +02:00
refactor(YouTube - Swipe controls): Use more consistent settings language of 'opacity' and 0-100 scale
This commit is contained in:
parent
226f40d75a
commit
ae432f8c36
@ -314,8 +314,9 @@ public class Settings extends BaseSettings {
|
||||
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_BACKGROUND_ALPHA = new IntegerSetting("revanced_swipe_overlay_background_alpha", 127, true,
|
||||
public static final IntegerSetting SWIPE_OVERLAY_OPACITY = new IntegerSetting("revanced_swipe_overlay_background_opacity", 50, 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,
|
||||
@ -436,6 +437,11 @@ public class Settings extends BaseSettings {
|
||||
DEPRECATED_SEEKBAR_CUSTOM_COLOR_PRIMARY.resetToDefault();
|
||||
}
|
||||
|
||||
if (!DEPRECATED_SWIPE_OVERLAY_BACKGROUND_ALPHA.isSetToDefault()) {
|
||||
SWIPE_OVERLAY_OPACITY.save(DEPRECATED_SWIPE_OVERLAY_BACKGROUND_ALPHA.get() / 255);
|
||||
DEPRECATED_SWIPE_OVERLAY_BACKGROUND_ALPHA.resetToDefault();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region SB import/export callbacks
|
||||
|
@ -2,6 +2,8 @@ package app.revanced.extension.youtube.swipecontrols
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import app.revanced.extension.shared.StringRef.str
|
||||
import app.revanced.extension.shared.Utils
|
||||
import app.revanced.extension.youtube.settings.Settings
|
||||
import app.revanced.extension.youtube.shared.PlayerType
|
||||
|
||||
@ -86,7 +88,18 @@ class SwipeControlsConfigurationProvider(
|
||||
* get the background color for text on the overlay, as a color int
|
||||
*/
|
||||
val overlayTextBackgroundColor: Int
|
||||
get() = Color.argb(Settings.SWIPE_OVERLAY_BACKGROUND_ALPHA.get(), 0, 0, 0)
|
||||
get() {
|
||||
var opacity = Settings.SWIPE_OVERLAY_OPACITY.get()
|
||||
|
||||
if (opacity < 0 || opacity > 100) {
|
||||
Utils.showToastLong(str("revanced_swipe_overlay_background_opacity_invalid_toast"))
|
||||
Settings.SWIPE_OVERLAY_OPACITY.resetToDefault()
|
||||
opacity = Settings.SWIPE_OVERLAY_OPACITY.get()
|
||||
}
|
||||
|
||||
opacity = opacity * 255 / 100
|
||||
return Color.argb(opacity, 0, 0, 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* get the foreground color for text on the overlay, as a color int
|
||||
|
@ -44,7 +44,7 @@ private val swipeControlsResourcePatch = resourcePatch {
|
||||
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),
|
||||
TextPreference("revanced_swipe_overlay_background_alpha", inputType = InputType.NUMBER),
|
||||
TextPreference("revanced_swipe_overlay_background_opacity", inputType = InputType.NUMBER),
|
||||
TextPreference("revanced_swipe_threshold", inputType = InputType.NUMBER),
|
||||
)
|
||||
|
||||
|
@ -511,8 +511,9 @@ This feature is only available for older devices"</string>
|
||||
<string name="revanced_swipe_overlay_timeout_summary">The amount of milliseconds the overlay is visible</string>
|
||||
<string name="revanced_swipe_text_overlay_size_title">Swipe overlay text size</string>
|
||||
<string name="revanced_swipe_text_overlay_size_summary">The text size for swipe overlay</string>
|
||||
<string name="revanced_swipe_overlay_background_alpha_title">Swipe background visibility</string>
|
||||
<string name="revanced_swipe_overlay_background_alpha_summary">The visibility of swipe overlay background</string>
|
||||
<string name="revanced_swipe_overlay_background_opacity_title">Swipe overlay background opacity</string>
|
||||
<string name="revanced_swipe_overlay_background_opacity_summary">Opacity value between 0-100</string>
|
||||
<string name="revanced_swipe_overlay_background_opacity_invalid_toast">Swipe opacity must be between 0-100</string>
|
||||
<string name="revanced_swipe_threshold_title">Swipe magnitude threshold</string>
|
||||
<string name="revanced_swipe_threshold_summary">The amount of threshold for swipe to occur</string>
|
||||
<string name="revanced_swipe_change_video_title">Enable swipe to change videos</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user