From 3398da382342f8d77aab2ffbc0cd67c003a4a00d Mon Sep 17 00:00:00 2001 From: Mikkeli Date: Thu, 15 Oct 2026 22:24:36 +0900 Subject: [PATCH] Auto dark/bright takes a light sensor where the device allows one lib/theme/light.dart: dark at 15 lux or less, bright from 60, held 5 s; Settings shows the reading. The Redmi Pad SE refuses apps its only light sensor (Xiaomi's, from the front camera), so there Auto keeps following Android's dark theme. DASH-NEXT.md records the other lux sources. Co-Authored-By: Claude Opus 5.5 --- .../kotlin/dev/yukart/display/MainActivity.kt | 36 +++++++++++ docs/impl/plans/DASH-NEXT.md | 12 +++- lib/README.md | 3 +- lib/main.dart | 4 +- lib/pages/settings.dart | 14 ++++- lib/theme/light.dart | 63 +++++++++++++++++++ lib/theme/palette.dart | 59 ++++++++++++++--- test/palette_test.dart | 37 +++++++++++ 8 files changed, 215 insertions(+), 13 deletions(-) create mode 100644 lib/theme/light.dart diff --git a/android/app/src/main/kotlin/dev/yukart/display/MainActivity.kt b/android/app/src/main/kotlin/dev/yukart/display/MainActivity.kt index 83229b4..35805d0 100644 --- a/android/app/src/main/kotlin/dev/yukart/display/MainActivity.kt +++ b/android/app/src/main/kotlin/dev/yukart/display/MainActivity.kt @@ -2,6 +2,10 @@ package dev.yukart.display import android.content.Context import android.content.Intent +import android.hardware.Sensor +import android.hardware.SensorEvent +import android.hardware.SensorEventListener +import android.hardware.SensorManager import android.net.ConnectivityManager import android.net.Network import android.net.NetworkCapabilities @@ -10,6 +14,7 @@ import android.os.Bundle import android.view.WindowManager import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.MethodChannel /** @@ -22,6 +27,9 @@ import io.flutter.plugin.common.MethodChannel * When asked, the whole process is bound to the Ethernet (NCM) network while it * exists, and unbound when it goes. * + * Also the light sensor, for auto dark/bright (lib/theme/light.dart): lux on `yukart/light` + * while Dart listens, where the device lets apps read one (the Redmi Pad SE does not). + * * Also a development hook: `am start -n dev.yukart.display/.MainActivity --es linktest [dl:|bi:]