RustAssistant/app/src/main/java/com/coldmint/rust/pro/RustApplication.kt

79 lines
2.8 KiB
Kotlin
Raw Normal View History

2022-04-04 14:03:10 +00:00
package com.coldmint.rust.pro
import android.app.Application
import android.content.Context
2022-07-12 23:53:18 +00:00
import android.os.Environment
2022-07-07 15:06:31 +00:00
import android.util.Log
2022-04-04 14:03:10 +00:00
import cat.ereza.customactivityoncrash.config.CaocConfig
import com.coldmint.rust.core.debug.LogCat
import com.coldmint.rust.core.debug.LogCatObserver
2022-07-12 23:53:18 +00:00
import com.coldmint.rust.core.web.ServerConfiguration
2022-07-07 15:06:31 +00:00
import com.coldmint.rust.pro.tool.AppSettings
2022-08-19 06:51:28 +00:00
import com.coldmint.rust.pro.tool.CompletionItemConverter
2022-07-12 23:53:18 +00:00
import com.coldmint.rust.pro.tool.GlobalMethod
2022-07-02 10:11:56 +00:00
import com.google.android.material.color.DynamicColors
import com.google.android.material.color.DynamicColorsOptions
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
2022-07-08 12:01:14 +00:00
import com.hjq.language.MultiLanguages
import com.youth.banner.BuildConfig
2022-07-12 23:53:18 +00:00
import java.util.*
2022-04-04 14:03:10 +00:00
class RustApplication : Application() {
companion object {
private lateinit var instanceObject: RustApplication
/**
* 获取实例对象
*/
fun getInstance(): RustApplication {
return instanceObject
}
}
2022-04-04 14:03:10 +00:00
override fun onCreate() {
super.onCreate()
instanceObject = this
2022-08-14 02:43:53 +00:00
AppSettings.initAppSettings(this)
2022-07-07 15:06:31 +00:00
//动态颜色
2022-07-08 14:34:22 +00:00
val options = DynamicColorsOptions.Builder()
.setPrecondition { activity, theme ->
2022-08-14 02:43:53 +00:00
AppSettings
2022-07-08 14:34:22 +00:00
.getValue(
AppSettings.Setting.DynamicColor,
DynamicColors.isDynamicColorAvailable()
)
}.build()
2022-07-07 15:06:31 +00:00
DynamicColors.applyToActivitiesIfAvailable(this, options)
LogCat.attachObserver(object : LogCatObserver {
override fun onReceiveLog(msg: String) {
Firebase.crashlytics.log(msg)
}
})
LogCat.setEnable(!BuildConfig.DEBUG)
2022-07-08 12:01:14 +00:00
//程序崩溃
2022-04-04 14:03:10 +00:00
CaocConfig.Builder.create()
.backgroundMode(CaocConfig.BACKGROUND_MODE_SILENT) //default: CaocConfig.BACKGROUND_MODE_SHOW_CUSTOM
.enabled(true) //default: true
.showErrorDetails(true) //default: true
.showRestartButton(true) //default: true
.logErrorOnRestart(true) //default: true
.trackActivities(false) //default: false
.minTimeBetweenCrashesMs(2000) //default: 3000
// .errorDrawable(R.drawable.ic_custom_drawable) //default: bug image
.restartActivity(MainActivity::class.java) //default: null (your app's launch activity)
.errorActivity(ErrorActivity::class.java) //default: null (default error activity)
.apply()
2022-07-08 12:01:14 +00:00
MultiLanguages.init(this);
2022-04-04 14:03:10 +00:00
2022-07-08 12:01:14 +00:00
}
2022-07-12 23:53:18 +00:00
2022-07-08 12:01:14 +00:00
override fun attachBaseContext(base: Context?) {
super.attachBaseContext(MultiLanguages.attach(base))
}
2022-04-04 14:03:10 +00:00
}