<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lexip</title>
    <description>The latest articles on DEV Community by Lexip (@xlexip).</description>
    <link>https://dev.to/xlexip</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1212423%2F5a4fa651-37fa-4675-ba7b-4f18adb2fca5.png</url>
      <title>DEV Community: Lexip</title>
      <link>https://dev.to/xlexip</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xlexip"/>
    <language>en</language>
    <item>
      <title>Adaptive Theme: open-source ambient-light auto dark mode for Android</title>
      <dc:creator>Lexip</dc:creator>
      <pubDate>Sat, 03 Jan 2026 11:56:10 +0000</pubDate>
      <link>https://dev.to/xlexip/i-built-an-open-source-android-app-that-switches-dark-mode-based-on-ambient-light-adaptive-theme-2fd3</link>
      <guid>https://dev.to/xlexip/i-built-an-open-source-android-app-that-switches-dark-mode-based-on-ambient-light-adaptive-theme-2fd3</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, August 2026:&lt;/strong&gt; Adaptive Theme now includes Wallpaper Theme Sync and an optional blurred lock-screen wallpaper.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Android’s built-in automatic dark mode is usually based on a schedule or sunset. That is often a poor proxy for the actual lighting around you: a bright room at night may call for light mode, while a dark room during the day may not.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;Adaptive Theme&lt;/strong&gt;, a free and open-source Android app that switches the system-wide light and dark theme based on the device’s physical ambient light sensor.&lt;/p&gt;

&lt;p&gt;This is an Android app, not a Flutter theming library. Its package name is &lt;code&gt;dev.lexip.hecate&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design goal
&lt;/h2&gt;

&lt;p&gt;The app should react to real-world light conditions without continuously monitoring the sensor or switching the theme while someone is actively using their phone.&lt;/p&gt;

&lt;p&gt;The solution is an event-driven screen-on flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The screen turns on.&lt;/li&gt;
&lt;li&gt;Adaptive Theme briefly samples the ambient light sensor.&lt;/li&gt;
&lt;li&gt;It checks whether the sensor is likely obstructed, for example by a hand or pocket.&lt;/li&gt;
&lt;li&gt;The measured value is compared with a configurable lux threshold.&lt;/li&gt;
&lt;li&gt;If required, the Android system theme is changed before the user starts interacting.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The sensor is not continuously polled. After the short screen-on measurement, it stops.&lt;/p&gt;

&lt;p&gt;This also means the app deliberately does not change the system theme in the middle of a session. Some apps handle a live theme change poorly, so screen-on is a predictable and less disruptive moment for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automatic system-wide light and dark mode based on ambient light&lt;/li&gt;
&lt;li&gt;Custom lux threshold and presets&lt;/li&gt;
&lt;li&gt;Night Lock for keeping dark mode enabled during a chosen time window&lt;/li&gt;
&lt;li&gt;Wallpaper Theme Sync with separate wallpapers for light and dark mode&lt;/li&gt;
&lt;li&gt;Optional blur effect for the lock-screen wallpaper&lt;/li&gt;
&lt;li&gt;Quick Settings tile&lt;/li&gt;
&lt;li&gt;Material You interface&lt;/li&gt;
&lt;li&gt;Android 14+ smartphones&lt;/li&gt;
&lt;li&gt;Free, open source, and ad-free&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Android permission problem
&lt;/h2&gt;

&lt;p&gt;Changing the Android system theme requires &lt;code&gt;WRITE_SECURE_SETTINGS&lt;/code&gt;, which regular apps cannot grant to themselves through the usual Android permission dialog.&lt;/p&gt;

&lt;p&gt;Adaptive Theme has a guided setup for the one-time grant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;WebADB:&lt;/strong&gt; use another device through the browser-based setup tool&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shizuku:&lt;/strong&gt; grant the permission on-device&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root:&lt;/strong&gt; grant it through the app on a rooted device&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual ADB:&lt;/strong&gt; run the displayed command from a computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once granted, the permission persists across reboots. Shizuku, root, or an ADB connection is not required for normal operation afterwards.&lt;/p&gt;

&lt;p&gt;Android 14 is the minimum supported version because this screen-on sensor architecture depends on APIs that are not available on older Android releases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech stack
&lt;/h2&gt;

&lt;p&gt;The app is built with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Kotlin&lt;/li&gt;
&lt;li&gt;Jetpack Compose and Material 3&lt;/li&gt;
&lt;li&gt;MVVM&lt;/li&gt;
&lt;li&gt;Kotlin Coroutines and Flow&lt;/li&gt;
&lt;li&gt;DataStore&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google Play:&lt;/strong&gt; &lt;a href="https://play.google.com/store/apps/details?id=dev.lexip.hecate" rel="noopener noreferrer"&gt;https://play.google.com/store/apps/details?id=dev.lexip.hecate&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FOSS APK / releases:&lt;/strong&gt; &lt;a href="https://github.com/xLexip/Adaptive-Theme/releases" rel="noopener noreferrer"&gt;https://github.com/xLexip/Adaptive-Theme/releases&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source code:&lt;/strong&gt; &lt;a href="https://github.com/xLexip/Adaptive-Theme" rel="noopener noreferrer"&gt;https://github.com/xLexip/Adaptive-Theme&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature video:&lt;/strong&gt; &lt;a href="https://www.youtube.com/watch?v=8zCZFw_wx-Y" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=8zCZFw_wx-Y&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback, bug reports, feature ideas, and contributions are welcome.&lt;/p&gt;

</description>
      <category>android</category>
      <category>opensource</category>
      <category>kotlin</category>
      <category>jetpackcompose</category>
    </item>
  </channel>
</rss>
