forked from upstream-mirrors/quik
109 lines
3.8 KiB
Kotlin
109 lines
3.8 KiB
Kotlin
package com.moez.QKSMS.common
|
|
|
|
/*
|
|
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
|
*
|
|
* This file is part of QKSMS.
|
|
*
|
|
* QKSMS is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* QKSMS is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
import android.app.Activity
|
|
import android.app.Application
|
|
import android.app.Service
|
|
import android.content.BroadcastReceiver
|
|
import android.support.text.emoji.EmojiCompat
|
|
import android.support.text.emoji.FontRequestEmojiCompatConfig
|
|
import android.support.v4.provider.FontRequest
|
|
import com.akaita.java.rxjava2debug.RxJava2Debug
|
|
import com.bugsnag.android.Bugsnag
|
|
import com.bugsnag.android.Configuration
|
|
import com.moez.QKSMS.BuildConfig
|
|
import com.moez.QKSMS.R
|
|
import com.moez.QKSMS.common.util.BugsnagTree
|
|
import com.moez.QKSMS.injection.AppComponentManager
|
|
import com.moez.QKSMS.injection.appComponent
|
|
import com.moez.QKSMS.manager.AnalyticsManager
|
|
import com.moez.QKSMS.migration.QkRealmMigration
|
|
import com.moez.QKSMS.util.NightModeManager
|
|
import dagger.android.AndroidInjector
|
|
import dagger.android.DispatchingAndroidInjector
|
|
import dagger.android.HasActivityInjector
|
|
import dagger.android.HasBroadcastReceiverInjector
|
|
import dagger.android.HasServiceInjector
|
|
import io.realm.Realm
|
|
import io.realm.RealmConfiguration
|
|
import timber.log.Timber
|
|
import javax.inject.Inject
|
|
|
|
class QKApplication : Application(), HasActivityInjector, HasBroadcastReceiverInjector, HasServiceInjector {
|
|
|
|
/**
|
|
* Inject this so that it is forced to initialize
|
|
*/
|
|
@Suppress("unused")
|
|
@Inject lateinit var analyticsManager: AnalyticsManager
|
|
|
|
@Inject lateinit var dispatchingActivityInjector: DispatchingAndroidInjector<Activity>
|
|
@Inject lateinit var dispatchingBroadcastReceiverInjector: DispatchingAndroidInjector<BroadcastReceiver>
|
|
@Inject lateinit var dispatchingServiceInjector: DispatchingAndroidInjector<Service>
|
|
@Inject lateinit var nightModeManager: NightModeManager
|
|
|
|
private val packages = arrayOf("com.moez.QKSMS")
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
|
|
Bugsnag.init(this, Configuration(BuildConfig.BUGSNAG_API_KEY).apply {
|
|
appVersion = BuildConfig.VERSION_NAME
|
|
projectPackages = packages
|
|
})
|
|
|
|
RxJava2Debug.enableRxJava2AssemblyTracking(packages)
|
|
|
|
Realm.init(this)
|
|
Realm.setDefaultConfiguration(RealmConfiguration.Builder()
|
|
.compactOnLaunch()
|
|
.migration(QkRealmMigration())
|
|
.schemaVersion(QkRealmMigration.SCHEMA_VERSION)
|
|
.build())
|
|
|
|
AppComponentManager.init(this)
|
|
appComponent.inject(this)
|
|
|
|
nightModeManager.updateCurrentTheme()
|
|
|
|
val fontRequest = FontRequest(
|
|
"com.google.android.gms.fonts",
|
|
"com.google.android.gms",
|
|
"Noto Color Emoji Compat",
|
|
R.array.com_google_android_gms_fonts_certs)
|
|
|
|
EmojiCompat.init(FontRequestEmojiCompatConfig(this, fontRequest))
|
|
|
|
Timber.plant(Timber.DebugTree(), BugsnagTree())
|
|
}
|
|
|
|
override fun activityInjector(): AndroidInjector<Activity> {
|
|
return dispatchingActivityInjector
|
|
}
|
|
|
|
override fun broadcastReceiverInjector(): AndroidInjector<BroadcastReceiver> {
|
|
return dispatchingBroadcastReceiverInjector
|
|
}
|
|
|
|
override fun serviceInjector(): AndroidInjector<Service> {
|
|
return dispatchingServiceInjector
|
|
}
|
|
|
|
} |