forked from ReVanced/revanced-integrations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
hdr-auto-brightness
patch (ReVanced#74)
- Loading branch information
Showing
6 changed files
with
61 additions
and
16 deletions.
There are no files selected for viewing
39 changes: 33 additions & 6 deletions
39
app/src/main/java/app/revanced/integrations/patches/HDRMaxBrightnessPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,41 @@ | ||
package app.revanced.integrations.patches; | ||
|
||
import android.view.WindowManager; | ||
|
||
import app.revanced.integrations.settings.SettingsEnum; | ||
import app.revanced.integrations.swipecontrols.views.SwipeControlsHostLayout; | ||
|
||
/** | ||
* Patch class for 'hdr-max-brightness' patch | ||
* | ||
* @usedBy app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch | ||
* @smali app/revanced/integrations/patches/HDRMaxBrightnessPatch | ||
*/ | ||
public class HDRMaxBrightnessPatch { | ||
|
||
//Used by app/revanced/patches/youtube/misc/hdrbrightness/patch/HDRBrightnessPatch | ||
/** | ||
* get brightness override for HDR brightness | ||
* | ||
* @param original brightness youtube would normally set | ||
* @return brightness to set on HRD video | ||
* @smali getHDRBrightness(F)F | ||
*/ | ||
public static float getHDRBrightness(float original) { | ||
if (!SettingsEnum.USE_HDR_BRIGHTNESS_BOOLEAN.getBoolean()) return original; | ||
//return SettingsEnum.ENABLE_SWIPE_BRIGHTNESS_BOOLEAN.getBoolean() ? BrightnessHelper.getBrightness() : -1.0f; | ||
return -1; | ||
} | ||
// do nothing if disabled | ||
if (!SettingsEnum.USE_HDR_AUTO_BRIGHTNESS_BOOLEAN.getBoolean()) { | ||
return original; | ||
} | ||
|
||
// override with brightness set by swipe-controls | ||
// only when swipe-controls is active and has overridden the brightness | ||
final SwipeControlsHostLayout swipeControlsHost = SwipeControlsPatch.CURRENT_HOST.get(); | ||
if (swipeControlsHost != null | ||
&& swipeControlsHost.getScreen() != null | ||
&& swipeControlsHost.getConfig().getEnableBrightnessControl() | ||
&& !swipeControlsHost.getScreen().isDefaultBrightness()) { | ||
return swipeControlsHost.getScreen().getRawScreenBrightness(); | ||
} | ||
|
||
// otherwise, set the brightness to auto | ||
return WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters