[FREE] BrightnessTools - Tools that set brightness of your phone

Introduction

Hi there! Today I am going to publish my third extension - BrightnessTools
A simple extension to set your brightness! :iphone: :bulb:

Documentation



Blocks Description
WhenErrorOccurred
Raises when error occurred

Params Type Description
error String Return a description of error

WhenChanged
Triggered when detected any brightness or adaptive change. The param "changed" indicate what has change.

Params Type Description
changed Number (int) Return what has been changed.
0 = Brightness Change,
1 = Adaptive Change
brightness Number (int) Return current brightness
adaptive boolean Return current adaptive state

CanWritwSettings Returns: Boolean

Check if modify system setting permission is granted.
MaxBrightness Returns: Number (int)

Get Max brightness of user's phone. If max brightness not found, return 255.

Note: Android states that the maximum value should be 255.
However, different brands of phones have different settings, like some Xiaomi phones have a maximum of 4000.
blocks Register the listener for Changed
OpenWriteSettingsScreen Show screen for controlling which apps are allowed to write/modify system settings.
GetBrightness
SetBrightness

Set the brightness of user's phone. Minimum value is 0.

Params Type Description
Brightness Number (int) Set/Return the brightness depends on the given integer

GetBrightness
SetBrightness

Set brightness to adaptive or non-adaptive. Adaptive if true, otherwise non-adaptive.

Params Type Description
Adaptive Boolean Set/Return adaptive or non-adaptive

Download

v1.2

com.watermelonice.BrightnessTools.aix (16.3 KB)

v1.1

com.watermelonice.BrightnessTools.aix (14.0 KB)

v1.0

com.watermelonice.BrightnessTools.aix (10.7 KB)

Test AIA

TestBrightnessExt.aia (27.0 KB)

Change Log

v1.2
  • As the modify settings permission might be greyed out sometimes, now it would enable that back.
  • You don't need ActivityStarter to grant the permission anymore. Instead, you can use the OpenWriteSettingsScreen method.
v1.1
  • Big update! Added Listener for brightness and adaptive change
  • Optimized the code

Note

This extension will only be distributed in Kodular and AI2 communities. Reuploading my work is not allowed.

You need to grant WRITE_SETTINGS permission. For more please see this post. You can use either the method from Screen or use the OpenWriteSettingsScreen directly from my extension. Please note that only the Android version starting from 6.0 needs this permission. At the lower versions, it should be granted when the app is installed.

The intention of this extension is to change the brightness of the phone, not just the app. If you want to change the brightness of that app without permission, please refer to Requesting extension for app brightness without requiring permissions - #9 by Mohamed_Tamer - Extensions - Kodular Community

18 Likes

Can other users from other builders cant use your extension?

You misunderstood. I mean distributing my extension. That's mean only I can distribute this extension. Do not reupload it.

And yes, you can use it in other builder

1 Like

New big update! You can now register brightness change listener :wink:

3 Likes

Great extension :star: :+1:

1 Like

How can i get your extension ?

1 Like

It's in the first post.

1 Like

Oh yes i must be blind !

i tried your extension, but i can't succed to obtain permission


luminosite.aia (15,6 Ko)

I have no popup asking for permission, and i can't find it in app properties to turn it on manualy...

did you test this after building the app?
It wíll not work in the companion app...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Yes i tested it only after building

which device and Android version are you using for your tests?
Taifun
PS: the paid version of my settings extension is also able to set the brightness...

Device : Redmi 7A
Android version : QKQ1.191014.001

The user should manually grant the WRITE_SETTINGS permission from the settings.See also here:


As the OpenSystemWriteSettings doesn't exist in app Inventor, so you might use the activity starter solution:

That should only be needed fur devices with API version 23 ( Android 6 Marshmallow ) and heigher

1 Like

Here you will find an exemple with button to Allow Write Settings permisssion.
when this permission is granted you can change brigthness
ther is a button to keep screen on and an other to sleep it according to screen settings.
for this i used some extentions:
de.ullisroboterseite.ursai2applauncher.aix (29,4 Ko) to go to permissions setting screen
de.UllisRoboterSeite.UrsAI2WakeLock.aix (11,6 Ko) to keep screen on
both from https://ullisroboterseite.de/index.html
his site is full of interresting extentions...you can donate to him...

and i wrote a small extension to add "android.permission.WRITE_SETTINGS" in manifest in order to be able to turn it on.jml.SETTINGSpermission.aix (4,9 Ko)


here is aia: Change_luminosite.aia (56,5 Ko)

I hope it will help it works very well on my Redmi 7A.

3 Likes

Thank you for your extension jml.SETTINGSpermission.aix
It works very well in setting the permission.
I combined it with this activity starter code from BeeriaApps to allow user to activate modify write settings slider.

2 Likes

you're welcome..

but what is this code from BeeriaApps you are talking about ? i don't know it and i can't find it !

Its on kodular forum

Here's the link:

1 Like

Thank you for your demonstration with my extension!

2 Likes

I had trouble to make it works on AI so when i found solution, it was normal to share it !

1 Like

Hello everyone, I read the entire thread and tried all examples with no success. Is there anyone who successfully controlled the brightness of the screen?