mihon/app/src/main/java/eu/kanade/tachiyomi/App.kt

77 lines
2.4 KiB
Kotlin
Raw Normal View History

package eu.kanade.tachiyomi
import android.app.Application
2016-10-15 11:12:16 +02:00
import android.content.Context
import android.content.res.Configuration
import androidx.multidex.MultiDex
import com.evernote.android.job.JobManager
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.data.updater.UpdaterJob
2020-02-03 04:22:54 +01:00
import eu.kanade.tachiyomi.util.system.LocaleHelper
import org.acra.ACRA
import org.acra.annotation.ReportsCrashes
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.registry.default.DefaultRegistrar
@ReportsCrashes(
formUri = "http://tachiyomi.kanade.eu/crash_report",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
buildConfigClass = BuildConfig::class,
2020-01-08 01:20:08 +01:00
excludeMatchingSharedPreferencesKeys = [".*username.*", ".*password.*", ".*token.*"]
)
open class App : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(this))
setupAcra()
setupJobManager()
setupNotificationChannels()
LocaleHelper.updateConfiguration(this, resources.configuration)
}
2016-10-15 11:12:16 +02:00
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
2019-04-13 15:10:44 +02:00
MultiDex.install(this)
2016-10-15 11:12:16 +02:00
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
LocaleHelper.updateConfiguration(this, newConfig, true)
}
protected open fun setupAcra() {
ACRA.init(this)
}
protected open fun setupJobManager() {
2019-03-14 21:44:20 +01:00
try {
JobManager.create(this).addJobCreator { tag ->
when (tag) {
LibraryUpdateJob.TAG -> LibraryUpdateJob()
UpdaterJob.TAG -> UpdaterJob()
BackupCreatorJob.TAG -> BackupCreatorJob()
else -> null
}
}
2019-03-14 21:44:20 +01:00
} catch (e: Exception) {
Timber.w("Can't initialize job manager")
}
}
protected open fun setupNotificationChannels() {
Notifications.createChannels(this)
}
}