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

Search This thread

Kocane

Senior Member
Apr 29, 2012
1,669
307
The app opens, works, but it does something weird with the colours. I can't provide a logcat right now because I'm currently using the stock kernel.
But I'll summarize it to this: the moment I turn on 'night mode' within your app, it does a weird things with the colours and by that I mean that it alternates between multiple tints, pink-ish, brown, orange, etc, one at a time, instead of applying a single filter. I hope I've been explicit enough.

I tried out the test APK on my OnePlus 6 with FlashKernel. Also made weird changes between all kinds of colors. In the end it seemed like it settled on the temperature i had chosen.

The APK definitely helped though whereas the playstore version would just claim I dont have KCAL support. Judging from the dev of the kernel I use, it's something with the KCAL paths having changed.

I hope you update this, maybe making a proper CF Lumen replacement.
 

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
I tried out the test APK on my OnePlus 6 with FlashKernel. Also made weird changes between all kinds of colors. In the end it seemed like it settled on the temperature i had chosen.

The APK definitely helped though whereas the playstore version would just claim I dont have KCAL support. Judging from the dev of the kernel I use, it's something with the KCAL paths having changed.

I hope you update this, maybe making a proper CF Lumen replacement.

The app opens, works, but it does something weird with the colours. I can't provide a logcat right now because I'm currently using the stock kernel.
But I'll summarize it to this: the moment I turn on 'night mode' within your app, it does a weird things with the colours and by that I mean that it alternates between multiple tints, pink-ish, brown, orange, etc, one at a time, instead of applying a single filter. I hope I've been explicit enough.

OK. Since the new driver has a file for each color, the variations in color appear because each color file is modified once at a time.
Delay is there because for each modification, a root terminal session is acquired, command is executed.
So what I did is execute all the commands in a single session, which means that the color shift should be negligible (it still applies modification one by one per file, there is no easy way to modify multiple files at once).
Although I don't have a compatible device, I did test this new method on mine, and best cases can result upto 6 times faster modification.
I have attached an updated .apk with the change, so could you please try it and let me know how it works?

Also btw all the previous changes (which includes support for the new KCAL driver), were lost because I was stupid enough to not push them to git, and my laptop died. So I had to redo everything again, which means there can be other issues as well (chances are less though).
Also I was busy with other important stuff lately so could not get time to look at this.
 

Attachments

  • app-generic-release.apk
    2.6 MB · Views: 34
  • Like
Reactions: Kocane

dragos281993

Recognized Contributor
Mar 29, 2014
2,884
4,019
Iasi
OK. Since the new driver has a file for each color, the variations in color appear because each color file is modified once at a time.
Delay is there because for each modification, a root terminal session is acquired, command is executed.
So what I did is execute all the commands in a single session, which means that the color shift should be negligible (it still applies modification one by one per file, there is no easy way to modify multiple files at once).
Although I don't have a compatible device, I did test this new method on mine, and best cases can result upto 6 times faster modification.
I have attached an updated .apk with the change, so could you please try it and let me know how it works?

Also btw all the previous changes (which includes support for the new KCAL driver), were lost because I was stupid enough to not push them to git, and my laptop died. So I had to redo everything again, which means there can be other issues as well (chances are less though).
Also I was busy with other important stuff lately so could not get time to look at this.
Yup, definitely better. The only thing that needs a bit more work is the colour temperature bar. It's a bit buggy in the sense that it goes to a very red tint before settling for the desired value. It's just a small thing in comparison to the previous bugs. This is more like a visual thing.
There's one thing I'd like to see added, though. Long pressing on the night light tile should open the actual app instead of the App info section from the device's Settings.
 
Last edited:

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
Apologies.
I made a derp which prevented settings from appearing. It has been fixed and available in XDA Labs as preview 2.
Sorry for realizing this late and thanks to Thomas Hoffmann for bringing this to my notice.
 

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
Version 2.0 has been out for a while. I hope the users are enjoying the new UI and features.
You can read about all the changes in this update here.
You can also help translate the project, whose instructions can be found here.

Feel free to report any bugs that you encounter. Also would appreciate some feedback.
 

matrixzone

Senior Member
Mar 19, 2012
3,535
3,583
Will this work Android 8.1 with the Google imposed limitation of notification bar?

Sent from my Moto G (5) Plus using Tapatalk
 

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
Small update

Made a small update which uses Kotlin coroutines instead of AsyncTasks, and now also has an option to hide help texts.

Feel free to try it. If you try, please do let me know whether everything is working fine or not.
 

Attachments

  • app-generic-release.apk
    3.1 MB · Views: 43
  • Like
Reactions: Kocane

tanish2k09

Senior Member
Jun 21, 2014
1,811
2,195
@corphish would you like to work with me to add a livedisplay-like actual RGB shifting to your app?

I already have the groundwork laid out, as I made a kernel driver called K-lapse that does the same from within the kernel. The issue with it was it required another kernel dev to keep klapse updated. I got some suggestions to shift the scaling algorithm to userspace and use KCAL with root access. I was about to make my own app, but I found yours, open source as well. It would save me a great amount of time if I added it to your app instead of creating my own.

In case you'd like to learn more about k-lapse, here's the XDA thread:
https://www.google.com/amp/s/forum....pse-kernel-level-livedisplay-module-t3907025/

I saw there's also an enhancement tag on an issue in your repo, so I can see some users do indeed want it to happen.

It's completely fine if you can't due to lack of time or for some other reason, or if you simply don't want to add it, no issues there. I'd like to have a solid reply though, don't leave me hangin' :p
 

dragos281993

Recognized Contributor
Mar 29, 2014
2,884
4,019
Iasi
@corphish would you like to work with me to add a livedisplay-like actual RGB shifting to your app?

I already have the groundwork laid out, as I made a kernel driver called K-lapse that does the same from within the kernel. The issue with it was it required another kernel dev to keep klapse updated. I got some suggestions to shift the scaling algorithm to userspace and use KCAL with root access. I was about to make my own app, but I found yours, open source as well. It would save me a great amount of time if I added it to your app instead of creating my own.

In case you'd like to learn more about k-lapse, here's the XDA thread:
https://www.google.com/amp/s/forum....pse-kernel-level-livedisplay-module-t3907025/

I saw there's also an enhancement tag on an issue in your repo, so I can see some users do indeed want it to happen.

It's completely fine if you can't due to lack of time or for some other reason, or if you simply don't want to add it, no issues there. I'd like to have a solid reply though, don't leave me hangin' :p
Bro, I love the idea. I hope I'll see it implemented.
 
  • Like
Reactions: tanish2k09

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
@corphish would you like to work with me to add a livedisplay-like actual RGB shifting to your app?

I already have the groundwork laid out, as I made a kernel driver called K-lapse that does the same from within the kernel. The issue with it was it required another kernel dev to keep klapse updated. I got some suggestions to shift the scaling algorithm to userspace and use KCAL with root access. I was about to make my own app, but I found yours, open source as well. It would save me a great amount of time if I added it to your app instead of creating my own.

In case you'd like to learn more about k-lapse, here's the XDA thread:
https://www.google.com/amp/s/forum....pse-kernel-level-livedisplay-module-t3907025/

I saw there's also an enhancement tag on an issue in your repo, so I can see some users do indeed want it to happen.

It's completely fine if you can't due to lack of time or for some other reason, or if you simply don't want to add it, no issues there. I'd like to have a solid reply though, don't leave me hangin' :p

Sure. I guess its about time RGB scaling is added.
I checked the K-Lapse, impressive stuff. Adding support for K-Lapse sysfs as an automation alternative could be a nice idea.
Also, the brightness thing is neat, never noticed that myself, but very useful for Night Light purposes.
 
  • Like
Reactions: tanish2k09

tanish2k09

Senior Member
Jun 21, 2014
1,811
2,195
Sure. I guess its about time RGB scaling is added.
I checked the K-Lapse, impressive stuff. Adding support for K-Lapse sysfs as an automation alternative could be a nice idea.
Also, the brightness thing is neat, never noticed that myself, but very useful for Night Light purposes.
Perfect! Yeah the sysfs could be used as an alternative.

Lemme know how I could contact you, because XDA isn't known for being the fastest team communication platform :p

Edit: Sorry, @corphish I didn't get a reply back
 
Last edited:
  • Like
Reactions: dragos281993

Case_

Senior Member
Aug 12, 2009
565
29
Brno
www.edgeoftheworld.cz
Just discovered this app and it is a lifesaver on Android 10 as cf.lumen no longer seems to work (at least on my device) and I know of no other app that would allow to use KCal to be able to do an (almost) pure red display for night reading (and astronomy purposes) while being able to easily turn the red filter on or off.

So thank you!
 

barth2

Senior Member
Jan 30, 2014
580
226
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.
 
Last edited:

corphish

Recognized Dev / Inactive Recognized Contributor
Apr 16, 2014
1,014
2,453
Durgapur
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.
 

rickysidhu_

Senior Member
  • Apr 1, 2016
    1,865
    786
    Vancouver
    OnePlus 9
    ...
    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.
    ...
    Hey,

    This clarification is way more than just adequate, unexpectedly detailed and it's much appreciated!

    And yes you're right, I did email you about this just because I was confused about how sunset/sunrise timings would update as daylight savings changes over the course of the year (if I never manually went into the app).

    Thanks for this app, it truly is a game changer for night light customization:highfive:
     

    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