2019-08-19 16:50:33 +02:00
|
|
|
package com.github.apognu.otter
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
import androidx.appcompat.app.AppCompatDelegate
|
2019-10-22 20:03:52 +02:00
|
|
|
import com.github.apognu.otter.utils.Command
|
|
|
|
import com.github.apognu.otter.utils.Event
|
|
|
|
import com.github.apognu.otter.utils.Request
|
2019-08-19 16:50:33 +02:00
|
|
|
import com.preference.PowerPreference
|
2019-10-22 20:03:52 +02:00
|
|
|
import kotlinx.coroutines.channels.BroadcastChannel
|
|
|
|
import kotlinx.coroutines.channels.Channel
|
|
|
|
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
|
2019-08-19 16:50:33 +02:00
|
|
|
|
|
|
|
class Otter : Application() {
|
2019-10-22 20:03:52 +02:00
|
|
|
companion object {
|
|
|
|
private var instance: Otter = Otter()
|
|
|
|
|
|
|
|
fun get(): Otter = instance
|
|
|
|
}
|
|
|
|
|
2019-10-31 00:46:35 +01:00
|
|
|
val eventBus: BroadcastChannel<Event> = BroadcastChannel(10)
|
2019-10-22 20:03:52 +02:00
|
|
|
val commandBus: Channel<Command> = Channel(10)
|
|
|
|
val requestBus: BroadcastChannel<Request> = BroadcastChannel(10)
|
|
|
|
val progressBus: BroadcastChannel<Triple<Int, Int, Int>> = ConflatedBroadcastChannel()
|
|
|
|
|
2019-08-19 16:50:33 +02:00
|
|
|
override fun onCreate() {
|
|
|
|
super.onCreate()
|
|
|
|
|
2019-10-22 20:03:52 +02:00
|
|
|
instance = this
|
|
|
|
|
2019-08-19 16:50:33 +02:00
|
|
|
when (PowerPreference.getDefaultFile().getString("night_mode")) {
|
|
|
|
"on" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
|
|
|
"off" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
|
|
|
else -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|