Skip to content

Commit

Permalink
feat(youtube/swipe-controls): add option to save and restore brightness
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed May 31, 2023
1 parent 4c77e7f commit b5a71a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public enum SettingsEnum {
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_OVERLAY_TIMEOUT("revanced_swipe_overlay_timeout", LONG, 500L, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),
SWIPE_SAVE_AND_RESTORE_BRIGHTNESS("revanced_swipe_save_and_restore_brightness", BOOLEAN, TRUE, true,
parents(SWIPE_BRIGHTNESS, SWIPE_VOLUME)),

// Debugging
DEBUG("revanced_debug", BOOLEAN, FALSE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SwipeControlsConfigurationProvider(
*/
val overwriteVolumeKeyControls: Boolean
get() = isFullscreenVideo && enableVolumeControls
//endregioin
//endregion

//region gesture adjustments
/**
Expand Down Expand Up @@ -94,5 +94,15 @@ class SwipeControlsConfigurationProvider(
val overlayForegroundColor: Int
get() = Color.WHITE

//endregion

//region behaviour

/**
* should the brightness be saved and restored when exiting or entering fullscreen
*/
val shouldSaveAndRestoreBrightness: Boolean
get() = SettingsEnum.SWIPE_SAVE_AND_RESTORE_BRIGHTNESS.boolean

//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ class SwipeControlsHostActivity : Activity() {
* @param type the new player type
*/
private fun onPlayerTypeChanged(type: PlayerType) {
when (type) {
PlayerType.WATCH_WHILE_FULLSCREEN -> screen?.restore()
else -> {
screen?.save()
screen?.restoreDefaultBrightness()
if (config.shouldSaveAndRestoreBrightness)
when (type) {
PlayerType.WATCH_WHILE_FULLSCREEN -> screen?.restore()
else -> {
screen?.save()
screen?.restoreDefaultBrightness()
}
}
}
}

/**
Expand Down

0 comments on commit b5a71a8

Please sign in to comment.