Skip to content

Commit 1bab6e5

Browse files
authored
Merge pull request #90 from xLexip/develop
v0.12.1-beta
2 parents faa3256 + 741cf19 commit 1bab6e5

File tree

8 files changed

+44
-28
lines changed

8 files changed

+44
-28
lines changed
28.8 KB
Loading

README.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
# Adaptive Theme: Auto Dark Mode by Ambient Light
44

5-
Adaptive Theme automatically switches between **Light** and **Dark mode** using your phone’s
6-
**ambient light sensor (lux)** — not a fixed schedule.
5+
Adaptive Theme automatically switches between Light and **Dark mode**
6+
using the **ambient light sensor** — not a fixed schedule.
77

88
It adapts to real lighting conditions to improve **readability**, **eye comfort**, and **battery
99
life**.
1010

11-
---
12-
13-
## 🚀 Quick Start (2 minutes)
14-
1511
<a href="https://play.google.com/store/apps/details?id=dev.lexip.hecate">
1612
<img src=".github/resources/get-it-on-google-play.svg" alt="Get Adaptive Theme on Google Play" width="200"/>
1713
</a>
14+
‎ ‎ ‎
15+
<a href="https://github.com/xLexip/Adaptive-Theme/releases">
16+
<img src=".github/resources/github-releases.png" alt="GitHub" width="200"/>
17+
</a>
18+
19+
## 🚀 Quick Start (2 minutes)
1820

1921
1. **Install** Adaptive Theme.
2022
2. **Grant the permission** with our [web-tool](https://lexip.dev/setup), Shizuku, or other methods
2123
below.
2224
3. **Pick your lux threshold** and you’re done. ✅
2325

24-
---
25-
2626
## 📋 Table of Contents
2727

2828
- [✨ Features & Highlights](#-features--highlights)
@@ -33,8 +33,6 @@ life**.
3333
- [❤️ Support the Project](#%EF%B8%8F-support-the-project)
3434
- [🏗️ Architecture & Tech Stack](#%EF%B8%8F-architecture--tech-stack)
3535

36-
---
37-
3836
## ✨ Features & Highlights
3937

4038
* 🌤️ **Smart Detection:** Uses your devices physical light sensor to switch the system
@@ -50,8 +48,6 @@ life**.
5048
for a smooth and solid experience.
5149
* 🔒 **Transparent:** Free, open-source, no-ads.
5250

53-
---
54-
5551
## 🛠️ One-Time Setup
5652

5753
Android restricts apps from changing system themes by default. To unlock this feature, the
@@ -75,8 +71,6 @@ methods to do so:
7571
command manually via your
7672
terminal.
7773

78-
---
79-
8074
## ⚙️ How it Works
8175

8276
**Wondering why the theme didn't change immediately?**
@@ -88,17 +82,13 @@ To avoid screen flicker and unnecessary background work, Adaptive Theme follows
8882
- **Seamless switch:** It switches the theme instantly, ensuring the UI is ready before you start
8983
interacting with it.
9084

91-
---
92-
9385
## ✅ Safety
9486

9587
The required permission only allows the app to change system settings such as the dark mode. This is
9688
absolutely safe and
9789
completely reversible by uninstalling the app. It does **not** grant root access or read any user
9890
data.
9991

100-
---
101-
10292
## ❓ FAQ
10393

10494
**Does this require root?**
@@ -124,8 +114,6 @@ data.
124114
If Adaptive Theme doesn’t work for you — or if you have any questions or ideas — please open an
125115
issue here or send feedback via the app.
126116

127-
---
128-
129117
## ❤️ Support the Project
130118

131119
Adaptive Theme is **completely free**, **ad-free**, **open source**, and developed in my free time.
@@ -143,8 +131,6 @@ also [buy me a coffee](https://buymeacoffee.com/lexip).
143131

144132
📣 **Spread the Word:** Share the app to help the project grow.
145133

146-
---
147-
148134
## 🏗️ Architecture & Tech Stack
149135

150136
[![Android](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white)](https://developer.android.com/)

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
applicationId = "dev.lexip.hecate"
1717
minSdk = 34
1818
targetSdk = 35
19-
versionCode = 81
20-
versionName = "0.12.0"
19+
versionCode = 86
20+
versionName = "0.12.1"
2121
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2222
}
2323

app/src/foss/kotlin/dev/lexip/hecate/logging/Logger.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import android.content.Context
1616

1717
object Logger {
1818

19+
fun logException(e: Throwable) {
20+
// No-op for FOSS build
21+
}
22+
1923
fun logServiceEnabled(context: Context, source: String) {
2024
// No-op for FOSS build
2125
}

app/src/main/kotlin/dev/lexip/hecate/broadcasts/AppLifecycleReceiver.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import android.content.Context
1717
import android.content.Intent
1818
import android.util.Log
1919
import androidx.core.content.ContextCompat
20+
import dev.lexip.hecate.logging.Logger
2021
import dev.lexip.hecate.services.BroadcastReceiverService
2122

2223
private const val TAG = "BootCompletedReceiver"
@@ -28,13 +29,21 @@ class AppLifecycleReceiver : BroadcastReceiver() {
2829
Intent.ACTION_BOOT_COMPLETED -> {
2930
Log.i(TAG, "Boot completed, starting broadcast receiver service...")
3031
val serviceIntent = Intent(context, BroadcastReceiverService::class.java)
31-
ContextCompat.startForegroundService(context, serviceIntent)
32+
try {
33+
ContextCompat.startForegroundService(context, serviceIntent)
34+
} catch (e: Exception) {
35+
Logger.logException(e)
36+
}
3237
}
3338

3439
Intent.ACTION_MY_PACKAGE_REPLACED -> {
3540
Log.i(TAG, "App package replaced, starting broadcast receiver service if needed...")
3641
val serviceIntent = Intent(context, BroadcastReceiverService::class.java)
37-
ContextCompat.startForegroundService(context, serviceIntent)
42+
try {
43+
ContextCompat.startForegroundService(context, serviceIntent)
44+
} catch (e: Exception) {
45+
Logger.logException(e)
46+
}
3847
}
3948

4049
else -> {

app/src/main/kotlin/dev/lexip/hecate/services/BroadcastReceiverService.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import dev.lexip.hecate.Application
2828
import dev.lexip.hecate.R
2929
import dev.lexip.hecate.broadcasts.ScreenOnReceiver
3030
import dev.lexip.hecate.data.UserPreferencesRepository
31+
import dev.lexip.hecate.logging.Logger
3132
import dev.lexip.hecate.util.DarkThemeHandler
3233
import dev.lexip.hecate.util.LightSensorManager
3334
import dev.lexip.hecate.util.ProximitySensorManager
@@ -91,11 +92,16 @@ class BroadcastReceiverService : Service() {
9192
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
9293
)
9394
} catch (e: Exception) {
95+
Logger.logException(e)
9496
/**
9597
* Catch required because some Android 14 ROMs (HyperOS/MIUI) are broken
9698
* and throw false-positive SecurityExceptions for valid FGS types.
9799
*/
98-
startForeground(1, initialNotification)
100+
try {
101+
startForeground(1, initialNotification)
102+
} catch (e2: Exception) {
103+
Logger.logException(e2)
104+
}
99105
}
100106

101107

app/src/main/kotlin/dev/lexip/hecate/ui/setup/SetupViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,11 @@ class SetupViewModel(
434434
// Start Service
435435
val intent =
436436
Intent(application.applicationContext, BroadcastReceiverService::class.java)
437-
ContextCompat.startForegroundService(application.applicationContext, intent)
437+
try {
438+
ContextCompat.startForegroundService(application.applicationContext, intent)
439+
} catch (e: Exception) {
440+
Logger.logException(e)
441+
}
438442

439443
Logger.logServiceEnabled(
440444
application.applicationContext,

app/src/play/kotlin/dev/lexip/hecate/logging/Logger.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package dev.lexip.hecate.logging
1515
import android.content.Context
1616
import com.google.firebase.analytics.FirebaseAnalytics
1717
import com.google.firebase.analytics.logEvent
18+
import com.google.firebase.crashlytics.FirebaseCrashlytics
1819

1920
object Logger {
2021

@@ -25,6 +26,12 @@ object Logger {
2526
if (LoggerGate.allowed()) block()
2627
}
2728

29+
fun logException(e: Throwable) {
30+
ifAllowed {
31+
FirebaseCrashlytics.getInstance().recordException(e)
32+
}
33+
}
34+
2835
fun logServiceEnabled(context: Context, source: String) {
2936
ifAllowed {
3037
analytics(context).logEvent("adaptive_service_enabled") {

0 commit comments

Comments
 (0)