forked from vhaudiquet/rhema-claw
The stored `colors` key names a palette — rhema (the default, Jadeite), aquamarine, black-and-white, or dracula — and the Appearance page of /settings cycles it live, like the theme and icon toggles beside it. Each palette carries a dark and a light appearance under the existing `theme` key; dracula's light side is derived, the official palette ships only dark. The appearance decision moves off token comparison: Theme now answers is_dark() from the ground/text luminance, so palettes beyond the original two get the right per-profile fallback tones.
42 lines
1.3 KiB
Kotlin
42 lines
1.3 KiB
Kotlin
package rs.rhema.phone
|
|
|
|
import android.app.Application
|
|
import android.content.Intent
|
|
import android.content.IntentFilter
|
|
import androidx.core.content.ContextCompat
|
|
import rs.rhema.phone.di.AppContainer
|
|
import rs.rhema.phone.work.PowerEventReceiver
|
|
|
|
class RhemaApp : Application() {
|
|
|
|
lateinit var container: AppContainer
|
|
private set
|
|
|
|
// Held in a field so the registered receiver cannot be collected while
|
|
// the process lives.
|
|
private var powerReceiver: PowerEventReceiver? = null
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
container = AppContainer(this)
|
|
container.notifier.ensureChannel()
|
|
container.schedulePeriodicWork()
|
|
|
|
// ACTION_BATTERY_CHANGED and the power actions are implicit broadcasts:
|
|
// manifest registration for them is refused, so this receiver lives for
|
|
// the process lifetime instead. It stays dumb: it only enqueues work.
|
|
val receiver = PowerEventReceiver()
|
|
powerReceiver = receiver
|
|
ContextCompat.registerReceiver(
|
|
this,
|
|
receiver,
|
|
IntentFilter().apply {
|
|
addAction(Intent.ACTION_POWER_CONNECTED)
|
|
addAction(Intent.ACTION_POWER_DISCONNECTED)
|
|
addAction(Intent.ACTION_BATTERY_CHANGED)
|
|
},
|
|
ContextCompat.RECEIVER_NOT_EXPORTED,
|
|
)
|
|
}
|
|
}
|