package invalid.lena.rsend

import android.app.Application
import android.app.NotificationChannel
import android.app.NotificationManager

// App creates the notification channel used by the foreground sync service.
class App : Application() {

    override fun onCreate() {
        super.onCreate()
        val ch = NotificationChannel(CHANNEL, "Sync", NotificationManager.IMPORTANCE_LOW)
        getSystemService(NotificationManager::class.java).createNotificationChannel(ch)
        // Apply on every process start, including one launched by an old
        // WorkManager request after an app upgrade. This retires stale unique
        // names without waiting for the dashboard to be opened.
        Scheduler.apply(this)
    }

    companion object {
        const val CHANNEL = "sync"
    }
}
