<?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.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>I built an open-source Android app that switches dark mode based on ambient light – Adaptive Theme</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;p&gt;Howdy and happy new year!&lt;/p&gt;

&lt;p&gt;I wanted to share an open-source project of mine, that I’ve been working on in my free time:&lt;/p&gt;

&lt;h2&gt;
  
  
  Adaptive Theme
&lt;/h2&gt;

&lt;p&gt;It automatically switches between Light and Dark mode using the ambient light sensor - not a fixed schedule. Therefore it optimizes readability, eye comfort, and maybe even battery life.&lt;/p&gt;

&lt;p&gt;And it's &lt;strong&gt;free&lt;/strong&gt;, &lt;strong&gt;ad-free&lt;/strong&gt;, and &lt;strong&gt;open-source&lt;/strong&gt;, just like it should be. :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Play Store:&lt;/strong&gt; &lt;a href="https://play.google.com/store/apps/details?id=dev.lexip.hecate&amp;amp;referrer=utm_source%3Ddevto%26utm_medium%3Darticle" rel="noopener noreferrer"&gt;&lt;strong&gt;play.google.com/store/apps/details?id=dev.lexip.hecate&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/xLexip/Adaptive-Theme" rel="noopener noreferrer"&gt;&lt;strong&gt;github.com/xLexip/Adaptive-Theme&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Battery Efficiency
&lt;/h2&gt;

&lt;p&gt;To avoid the battery drain with constant sensor polling, the app is entirely passive.&lt;/p&gt;

&lt;p&gt;I built an event-driven architecture that only checks the light sensor for a split second immediately after the screen turns on. Zero background polling and activity, since it only reacts to system broadcasts.&lt;/p&gt;

&lt;p&gt;This event-driven architecture does only work on Android 14 and above. Below that, the sensors can't be properly read in the receiver.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup &amp;amp; Permissions
&lt;/h2&gt;

&lt;p&gt;That's the biggest challenge: The app requires &lt;code&gt;WRITE_SECURE_SETTINGS&lt;/code&gt; to change the system theme.&lt;/p&gt;

&lt;p&gt;Unfortunately this can't be granted that easy and deters many users. So I've tried to make it as easy as possible and implemented a wizard-based setup flow to help grant this via one of multiple methods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web Tool (Recommended)&lt;/strong&gt; – A browser-based setup tool to use with another device. No code or ADB installation required (WebADB). It's at &lt;a href="https://lexip.dev/setup" rel="noopener noreferrer"&gt;lexip.dev/setup&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shizuku&lt;/strong&gt; – If you have &lt;a href="https://play.google.com/store/apps/details?id=moe.shizuku.privileged.api" rel="noopener noreferrer"&gt;Shizuku&lt;/a&gt; installed and configured, you can grant the permission directly within the Adaptive Theme app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root&lt;/strong&gt; – If your device is rooted, you can grant the permission with one tap inside the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual ADB&lt;/strong&gt; – If you have ADB installed on your computer, you can run the ADB command manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tech Stack &amp;amp; Architecture
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UI&lt;/strong&gt;: Jetpack Compose with Material 3 / Material You. I've tried to rebuild the system settings look in my app (stock/Pixel), hope you like it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architecture&lt;/strong&gt;: MVVM with Single-Activity pattern.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Concurrency &amp;amp; Streams&lt;/strong&gt;: Kotlin Coroutines and Flows for reactive state management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Persistence&lt;/strong&gt;: Jetpack DataStore for type-safe settings storage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Build Flavors
&lt;/h2&gt;

&lt;p&gt;I maintain two distinct build flavors to keep the core app FOSS-compliant:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Play Store:&lt;/strong&gt; Does includes Firebase (proprietary, crash logs etc.).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FOSS (GitHub Releases, etc.):&lt;/strong&gt; Completely clean build with no proprietary blobs or trackers at all.&lt;/p&gt;




&lt;p&gt;I’m curious to hear your thoughts and opinions!&lt;/p&gt;

&lt;p&gt;Let me know if you encounter any bugs or have ideas for new features. I'll be around to answer questions!&lt;/p&gt;

</description>
      <category>android</category>
      <category>androidapp</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
