Crazy-Marvin/Flashy

Support for Controlling the Brightness of the Flashlight

CrazyMarvin opened this issue ยท 12 comments

Some Samsung and Pixel phones are able to adjust the flashlight brightness using getTorchStrengthLevel and turnOnTorchWithStrengthLevel. I came along this by @esper-io and this blog post.
Would this be a good idea for Flashy?

It would be a handy feature, seems good. I'd like to work on it

It would be a handy feature, seems good. I'd like to work on it

Awesome! ๐Ÿ˜Ž

There's a tiny problem...
I can develop it, but I cannot test it because I don't have a compatible physical Android 13 device.

I don't have a device running Android 13 too. Maybe we can ship it and let the users test. ๐Ÿ˜…

I don't have a device running Android 13 too. Maybe we can ship it and let the users test. ๐Ÿ˜…

b r u h.
Anyway, if we're forced to go that route, maybe you can stick a huge disclaimer for this feature in the release notes for next version?
Something like

DISCLAIMER: Controlling flashlight brightness is an EXPERIMENTAL feature that is only available in a few devices. If something goes wrong when using this feature, please open an issue. We need detailed explanations, as well as your willingness to test multiple times to properly fix the issue.

I can test if you give me an apk or some build instructions more detailed than

I can test if you give me an apk or some build instructions more detailed than

Alright, here's a apk. You can adjust flashlight brightness with the seekbar if your device supports it otherwise the seekbar stays disabled as before
Please test every action you can think of, ie. screen rotation, switching modes, etc. and report any weird behavior along with reproduction steps.
app-debug.zip

Also @CrazyMarvin please update your guidelines lol.

  1. The default brightness (after app (re)start) is 1 (i.e. darkest). I think max brightness would be a better default.
    • This also affects the tile. If flashy is open, the value from the seekbar is used. However if Flashy is closed, the default (i.e. darkest) value is used by the tile. So maybe change the default to 100% and remember the last value.
  2. Screen light goes "off" when you dimm it to zero, flashlight not. On the one hand this is a bit inconsistent, on the other hand it makes it easier to use the darkest value. And the screen light has wired on/off behaviour if you adjust it. I think it's fine the way it is.

Everything else seem to work fine.


Other things I noted while playing around and thinking about app functionality:

  • darktheme + material you needs some polishing. can be expanded in a new issue.
  • is this actually used somewhere? Flashy works fine for me w/o it.
    <uses-permission
    android:name="android.permission.WRITE_SETTINGS"
    tools:ignore="ProtectedPermissions" />

The default brightness (after app (re)start) is 1 (i.e. darkest). I think max brightness would be a better default.
This also affects the tile. If flashy is open, the value from the seekbar is used. However if Flashy is closed, the default (i.e. darkest) value is used by the tile. So maybe change the default to 100% and remember the last value.

Please test this apk. It should have these behaviors:

  • If the seekbar is not touched, it should be at max value. The flashlight should be at max brightness as well, in both the app, the qs tile and the widgets.
  • If it is adjusted, a setting for the current flash brightness is saved when you release your finger. You can test it by closing and opening the app again (the seekbar should be set at the saved value), as well as measuring the brightness in the app, the tile and the widgets to see if it is correctly set according to the setting.
    app-debug.zip

darktheme + material you needs some polishing. can be expanded in a new issue.

Please do.

is this actually used somewhere? Flashy works fine for me w/o it.

There is a widget called "Maximize screen brightness". It works by setting the system's brightness to max (as opposed to the app's brightness in the screen light mode, you can verify this by checking the system brightness bar in quick settings). To do so, the app needs this permission (you'll be prompted for it when adding this widget).

As you can already see, the permission is not used anywhere other than that.

Seems to work fine now.

I can test if you give me an apk or some build instructions more detailed than

I added a little bit more details. ๐Ÿ˜…
Please let me know if you miss something.