[APP][OPEN SOURCE][ROOT][5.0+] Night Light (KCAL)

Search This thread

corphish

Recognized Developer / Inactive Recognized Contrib
Apr 16, 2014
1,014
2,453
Durgapur
Version 3.0 preview

The next major version of Night Light is in works, and the preview of the same is available in beta channels of XDA Labs and Google Play (will go live shortly). Feel free to try it out and let me know how it works. While the UI is not final, it is definitely usable. Here are the features added so far.
  • Option to disable Night Light in lock screen - Inspired from OxygenOS (or maybe other OEMs also who implements this) where the Night Light is temporarily turned off in the lock screen so that finger print unlock can work better, the same is now available as an option in the app. Night Light will be turned off when in lock screen, while it will be turned back on when you unlock.
  • More accurate intensity information in dashboard.
  • Switched to Android framework preferences - Mostly to make it easier for me to maintain the settings section.

As you will notice while using the "Disable Night Light in Lock screen" feature, a foreground service will run in order to detect screen off/unlock events, and then the first thing that will probably come to your mind would be "Y no u add fade in when you are running a service?". Yes, the very reason why I held back from implementing the much requested fade in feature was because of the service that would run continuously, compromising memory efficiency and battery life. But since we are running a service, it now makes sense to implement the fade in feature. And I tried... But it looks like we would need another service for fade in, which would mean 2 notifications and unnecessary clutter, and the continuous running of the fade in polling would mean unexplainable ANRs even though the UI would run smoothly, so I had to ditch the idea.

Luckily, I was able to figure out another way of implementing this feature without using any foreground or background service using some neat automation techniques which were already being implemented by the app. Yep, fade in feature is finally here, with a greatly efficient implementation. Not only that, but this also resulted in a significantly improved and efficient automation implementation. Earlier, there would be a minimum of 2 alarms set if automation was enabled (one for start time and other for end time), it would be 3 if dark hours was used. Now, at any given time, no matter how less fade polling is used, there will only be 1 alarm set. As far as fade in goes, it avoids all the reasons which held me back from implementing it in the first place.
  • No background service? Check!
  • No unnecessary KCAL manipulation while screen is off? Check!
  • No continuous polling which hogs CPU and battery? Check!
  • Respects battery saving features of Android and does not hold a wakelock? Check!

So yeah, it took a while, but its here, in the best way possible (probably). I would also like to thank all the people who offered their interest and support in helping me bringing this feature. Enjoy! Please do tell me how its working for you. Thanks!
 

corphish

Recognized Developer / Inactive Recognized Contrib
Apr 16, 2014
1,014
2,453
Durgapur
Night Light 3.0 is here!

  • Automation routines - Brand new way of automating Night Light is here.
    • Setup routines where you can define the Night Light settings that you would want to apply in a specific time period of the day.
    • You can have as many routines as you want. They will be automatically applied in the time period specified.
    • There is only one thumb rule: Time periods of routines cannot overlap, which means you cannot have more than 1 routine for a specific time period.
    • Routines are easy to set up with a step wise interface.
  • Night Light intensity fading in/out.
    • You can have Night Light intensity to fade in/out from intensity to other as part of an automation routine.
    • Set fade poll rate which defines the interval at which faded settings are applied.
  • Removed the maximum and minimum intensities since we now have automation routines.
  • Added an option to automatically disable Night Light in lock screen and automatically turn it back on when the device is unlocked.
  • Redesigned settings section.
  • Updated the interface for creating and listing profiles.
  • Fixed launcher shortcut toggle.
  • Added tutorials in various sections.
  • Other bug fixes.

It is available in Play Store (RIP XDA Labs). Do let me know if you have any ideas to enhance any functionality. Thank you and happy new year!
 

ghnomb

New member
Jul 10, 2019
1
1
Thank you so very much for this app, it's one of the first apps I recommend to anyone who roots their phone, and has also been a reason for some to root, most don't live or work in places where the ambient light is near 5000k and it's a major eye fatigue relief to be able to set it lower for anything except outdoors during the day. I know it could be adjusted just through kcal but this app, especially with the new automation system, is so very convenient, and for someone who's light sensitive like me this app would pretty much class as a medical must have. Thank you again for making it and maintaining it, even if you never add a single feature again this app will always be in the absolutely necessary category for me.
 
  • Like
Reactions: corphish

ziedje

Senior Member
Feb 28, 2014
116
25
Dhaka
Hello I love your app, been using it on my oneplus 8 pro since the beginning, but I've had some problems since the last update.
I've noticed that since the last update that my battery is draining (way) more quickly. (I'm not 100% sure this is due to the new update however.)
Also, I have a few bugs:
- when I open the app, it applies the filter even when it's the routine hasn't started yet (my routine is from 9pm to 7am, but when I open the app at 11am for example, the filter gets applied automatically)
- "disable in lockscreen" is turned on, but has never worked. When I get a fingerprint prompt (/when I'm on the lockscreen), the filter does not get turned off
 

corphish

Recognized Developer / Inactive Recognized Contrib
Apr 16, 2014
1,014
2,453
Durgapur
Hello I love your app, been using it on my oneplus 8 pro since the beginning, but I've had some problems since the last update.
I've noticed that since the last update that my battery is draining (way) more quickly. (I'm not 100% sure this is due to the new update however.)
Also, I have a few bugs:
- when I open the app, it applies the filter even when it's the routine hasn't started yet (my routine is from 9pm to 7am, but when I open the app at 11am for example, the filter gets applied automatically)
- "disable in lockscreen" is turned on, but has never worked. When I get a fingerprint prompt (/when I'm on the lockscreen), the filter does not get turned off

1. That's strange, shouldn't happen. Will have a look.
2. Disable in lockscreen could be buggy, as I only have few devices to test. Will check and test in more devices.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 18
    Night light is an open-source app which uses KCAL to adjust blue light intensity of the display colors, so that viewing the screen at dark becomes pleasant for the eyes, and help you fall asleep faster (this is what science have proven so...).

    Features
    • Easy to use user interface. Settings are easier to find.
    • Uses KCAL to adjust screen RGB colors, hence its efficient and changes are seen everywhere on screen.
    • Supports older KCAL implementations as well as newer KCAL implementation for v4.4 kernels.
    • Simple color controls for normal users through color temperature control.
    • Manual KCAL controls for advanced users.
    • Automation routines lets you define routines where you specify Night Light settings which you wish to apply, and they will be automatically applied for you in specified times.
    • Intensity fading in/out is supported as part of automation routines.
    • Supports sunset/sunrise timings.
    • Set on boot delay.
    • Original KCAL settings of user is backed up and applied when night light is turned off. And it can be configured as well.
    • Support for user profiles, which are collections of settings that user can apply with one click.
    • And to fulfill your all kinds of automation needs, app is supported as a Tasker plugin. You can use it with Profiles.
    • Option to automatically disable Night Light in lock screen, and turn it back on after the device is unlocked.
    • Quick Setting tile for easy toggling on/off night light anywhere.
    • Launcher icon shortcut for toggling Night Light on/off and toggling intensities.
    • Dark and Light theme.

    Advantages
    • No overlays.
    • Background service is only used for lock screen option. The entire automation (including the fading) is done using neat AlarmManager tricks (which not only is battery friendly, but memory friendly as well).

    Requirements
    • Kernel supporting KCAL.
    • Root access.

    Download


    Source - https://github.com/corphish/NightLight
    5
    Beta 2.5

    A beta version (2.5) was released in XDA Labs (Beta channel) as well as Play Store (Beta channel), with changes mostly based on user feedback and some stuff of my own, as well as fixes. This is in no way a finalised version, as lots of development is going on, but the existing features should work.

    Great app, great Cf.lumen alternative!
    One thing would be nice if we can set sunset/sunrise GPS coordinations manually

    Sent from my OnePlus 5T using XDA Labs

    Nice idea!
    Will be implementing this as well as an option to re-detect location. Thanks!.

    Anyone know how to get location access all the time for the app in Android 10? I can only see allow only when using the app on my Pixel 4 XL.

    Location is not used everytime. It is used only once when you enable sunset/sunrise timings. On doing so, the location co-ordinates are stored and loaded when sunset and sunrise timings are calculated. So location is technically used only inside the app.

    Here is how it works:
    • You enable sunset/sunrise timings.
    • App checks for location permission, and asks for it if not present.
    • When location permissions are acquired, it detects your current location using Location APIs, which is in form of co-ordinates (latitude and longitude), and stores them as shared preferences.
    • The sunset and sunrise timings are calculated based on the co-ordinates acquired from previous step.
    • An on alarm is set at sunset timing, and off alarm is set at sunrise timing.
    • Sunset time comes, on alarm fires, turning Night Light on.
    • Sunrise time comes, off alarm fires, turning Night Light off. Additionally, sunset and sunrise times are re-calculated for the new day. The co-ordinates used are the ones stored in shared preferences. This is basically step 4 re-done and so-forth.
    While this should work for most users, I understand the timings could be inaccurate for users who travel a lot. An option to re-detect location every time before calculating sunset/sunrise could be added if necessary.

    Also I remembering us talking about the same over email, but I get lots of emails , and eventually lost track of our conversation, so sorry for that. I hope this clarification is adequate.

    This is a terrific app. Thanks.

    Is it possible to set it up to use min intensity at all time (my display is on the cool side, so I like to reduce blue) and max intensity between x and y hours? I know that's not how it's i to be used, but that's my use case.

    Thanks in advance

    Edit : I set start time to 6am and end time to 5:59. That seems to work.

    It's not starting on boot though. I have to open the app manually. Delay set at 20 secs. Mi a3 android pie with bit caf kernel.

    You can disable "Dark hours", and set the color controls to use minimum intensity. Will need to check the set on boot though.
    4
    v2.0 preview is available in XDA Labs

    If you are interested in testing out the new v2 preview, you can get it from XDA Labs (beta channel)
    Link - https://labs.xda-developers.com/store/app/com.corphish.nightlight.generic
    4
    Night Light 3.0 is here!

    • Automation routines - Brand new way of automating Night Light is here.
      • Setup routines where you can define the Night Light settings that you would want to apply in a specific time period of the day.
      • You can have as many routines as you want. They will be automatically applied in the time period specified.
      • There is only one thumb rule: Time periods of routines cannot overlap, which means you cannot have more than 1 routine for a specific time period.
      • Routines are easy to set up with a step wise interface.
    • Night Light intensity fading in/out.
      • You can have Night Light intensity to fade in/out from intensity to other as part of an automation routine.
      • Set fade poll rate which defines the interval at which faded settings are applied.
    • Removed the maximum and minimum intensities since we now have automation routines.
    • Added an option to automatically disable Night Light in lock screen and automatically turn it back on when the device is unlocked.
    • Redesigned settings section.
    • Updated the interface for creating and listing profiles.
    • Fixed launcher shortcut toggle.
    • Added tutorials in various sections.
    • Other bug fixes.

    It is available in Play Store (RIP XDA Labs). Do let me know if you have any ideas to enhance any functionality. Thank you and happy new year!
    4
    @jineshpatel30 @rickysidhu_

    Here is an experimental version (in the attachment of this reply), with launcher shortcut toggle and set on boot fixed.
    The reason why it is experimental :
    - Now written in kotlin
    - Uses some of the new stuff announced in I/O 18, like ktx and the new material design style
    - Uses different font called 'Acme'. (Feel free to suggest fonts)
    - I decided to ditch cards because normal layouts look better in this new style.

    Source - https://github.com/corphish/NightLight/tree/p
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone