aniyomiorg / aniyomi

An app for manga and anime
https://aniyomi.org
Apache License 2.0
4.91k stars 317 forks source link

Default brightness (0) doesn't matches device's current brightness. #1334

Closed gusainkun closed 3 months ago

gusainkun commented 8 months ago

Steps to reproduce

  1. Disable remeber and switch last used brightness under player settings.
  2. Play any video.
  3. The brightness of the player is now set to zero.

Expected behavior

The default brightness of the PLAYER should be equal to the device's current brightness.

Actual behavior

The default brightness of the player is automatically set to 0, which is 50% of the device's brightness and NOT the current brightness of device thus often blinding users while using the app in an low light enviornment.

Crash logs

No response

Aniyomi version

0.15.2.2

Android version

Android 12

Device

Moto G40 Fusion

Other details

Please fix this ASAP as it often flashes the users with sudden bright screen.

Acknowledgements

ShoyebOP commented 7 months ago

Why no one is noticing this issue as it is really annoying to get super bright screen while overlaying anything(ex: messenger chat baubles)

Snipyer commented 4 months ago

So i did some digging into this issue and found that it's caused by the device's max brightness value being different than the standard.

The code responsible for setting the players brightness is:

Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) / 255f

255: standard max brightness value.

The code will divide the value of brightness of the device by 255 to have a brightness range of 0 to 1. But my device uses 4095 as the max brightness value, when any value is received from the device in the range of 0-4095 it will always be a greater value than the correct brightness if we're dividing by 255.

Let's say i have my brightness as 5%.

ShoyebOP commented 4 months ago

So i did some digging into this issue and found that it's caused by the device's max brightness value being different than the standard.

The code responsible for setting the players brightness is:

Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) / 255f

255: standard max brightness value.

The code will divide the value of brightness of the device by 255 to have a brightness range of 0 to 1. But my device uses 4095 as the max brightness value, when any value is received from the device in the range of 0-4095 it will always be a greater value than the correct brightness if we're dividing by 255.

Let's say i have my brightness as 5%.

  • in case device uses 255: 5% is 12.75 so 12.75 / 255 = 0.05 which will have the player's brightness level as the same as the device
  • in case device uses 4095: 5% is 204.75 so 204.75 / 255 = 0.8 which will have the player's brightness level much higher than the device

So i did some digging into this issue and found that it's caused by the device's max brightness value being different than the standard.

The code responsible for setting the players brightness is:

Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS) / 255f

255: standard max brightness value.

The code will divide the value of brightness of the device by 255 to have a brightness range of 0 to 1. But my device uses 4095 as the max brightness value, when any value is received from the device in the range of 0-4095 it will always be a greater value than the correct brightness if we're dividing by 255.

Let's say i have my brightness as 5%.

  • in case device uses 255: 5% is 12.75 so 12.75 / 255 = 0.05 which will have the player's brightness level as the same as the device
  • in case device uses 4095: 5% is 204.75 so 204.75 / 255 = 0.8 which will have the player's brightness level much higher than the device

So now what? It's not something we can fix right?

jmir1 commented 3 months ago

https://github.com/aniyomiorg/aniyomi/commit/fb9f46331625b87deceb219a8132c25a99774472