LightBlog

mercredi 4 juillet 2018

How to enable Android P’s Dark Theme when Night Light is on

Android P Dark Theme

With the Google Pixel 2, Google added a partial system dark theme that gets applied when you have a dark-colored wallpaper. That feature came to the original Google Pixel and other devices with the Android 8.1 Oreo update and with the latest Android P Beta 3/Developer Preview 4, you no longer need to have a dark-colored wallpaper to use the dark theme. If you’ve ever wanted to make the dark mode a bit smarter, we figured out how to automate it so you can apply any condition before it’s enabled. The best part is it doesn’t require root!

For reference, the dark theme only themes parts of the SystemUI and Google Pixel Launcher such as the quick settings panel, volume panel, folder background, and app drawer background. The only way to get a full system-wide dark theme is to either remain on Android Oreo and use a Substratum theme or to root your Android P device to use Substratum. We realize that rooting your device isn’t something that some of you may want to do, so we’re always looking for customization options that don’t require root. Thanks to the latest Android P beta, it’s now possible to automate when the dark theme is applied so, for example, we can enable the dark mode only when Night Light is on.

Trigger Android P’s Dark Theme with Night Light

A brief explanation on what we’re doing. The latest Android P beta allows you to manually toggle the dark theme in Display settings. As such, a new Settings.Secure value was made by Google to hold the current value of this setting (Settings.Secure.theme_mode where 0 is automatic based on wallpaper, 1 is the light theme, and 2 is the dark theme.) Changing this value manually via ADB or with an application with the right permission allows us to change the theme. Using the latest Tasker beta version which allows us to monitor for changes in settings, we can monitor the Night Light state and then toggle the theme change at will.

Requirements

  • You must be on Android P Beta 3/Developer Preview 4 for this to work without root. The release is available for the following devices at the time of publication:
  • You will need to have the automation app “Tasker” installed and you need to be on the latest beta, v5.2.bf6.
  • You will need to grant Tasker a special permission via ADB. Set up ADB as outlined here and enter the following command in a Command Prompt/PowerShell/Terminal after installing the latest Tasker beta.
    • Windows Command Prompt:
      adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
      
    • Windows PowerShell:
      .\adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
      
    • macOS/Linux Terminal:
      ./adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
      

Tasker ($2.99, Google Play) →

Instructions

Here are step-by-step instructions on how to set it up. At the end, I will also include a link to import it.

Tasker

  1. Open Tasker and create a new Profile. Name it “Automatic Dark Theme At Night.”
  2. Choose the State Context.
  3. Pick the System category.
  4. Select the Custom Setting option.
  5. For the Type, pick “Secure”. For the Name, enter “night_display_activated”. For the Value, enter “1”.Tasker
  6. Enter the Task creation (no need to name the Task.)
  7. Add an Action.
  8. Pick the Settings category.
  9. Choose Custom Setting.
  10. For the Type, pick “Secure”. For the Name, enter “theme_mode”. For the Value, enter “2”. This will enable the dark theme when Night Light is on.
  11. Exit the Task creation and go back to Tasker’s main screen.
  12. Long-press on the Task you created and select “Add Exit Task.”
  13. Repeat steps 7-10 however for the Value in step 10, enter “1”. This will disable the dark theme when Night Light is off.
  14. You’re done. Now Tasker will automatically toggle the dark mode whenever Night Light is toggled. You can either toggle Night Light manually, set it on a custom schedule, or set it to enable based on the sun cycle.

Click here to import the Profile above. Note: this is using Tasker’s new URL import/export feature which is only available on the latest Tasker beta. The Profile won’t work if you’re not on the latest Tasker beta anyways.



from xda-developers https://ift.tt/2u4rYzH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire