Meshtastic-Android/app/src/main/java/com/geeksville/mesh/MeshUtilApplication.kt

44 lines
1.5 KiB
Kotlin
Raw Normal View History

2020-01-22 21:46:41 -08:00
package com.geeksville.mesh
2020-01-22 09:28:59 -08:00
import android.os.Debug
import com.geeksville.android.BuildUtils.isEmulator
2020-01-22 09:28:59 -08:00
import com.geeksville.android.GeeksvilleApplication
2020-02-14 07:47:20 -08:00
import com.geeksville.android.Logging
2020-02-24 15:33:35 -08:00
import com.geeksville.util.Exceptions
import com.google.firebase.crashlytics.FirebaseCrashlytics
2020-03-11 14:45:49 -07:00
import com.mapbox.mapboxsdk.Mapbox
2020-01-22 09:28:59 -08:00
2020-03-15 21:43:12 -07:00
class MeshUtilApplication : GeeksvilleApplication() {
override fun onCreate() {
super.onCreate()
2020-02-14 07:47:20 -08:00
Logging.showLogs = BuildConfig.DEBUG
2020-04-11 13:20:30 -07:00
// We default to off in the manifest - we turn on here if the user approves
// leave off when running in the debugger
if (!isEmulator && (!BuildConfig.DEBUG || !Debug.isDebuggerConnected())) {
2020-02-24 15:33:35 -08:00
val crashlytics = FirebaseCrashlytics.getInstance()
2020-04-11 13:20:30 -07:00
crashlytics.setCrashlyticsCollectionEnabled(isAnalyticsAllowed)
crashlytics.setCustomKey("debug_build", BuildConfig.DEBUG)
2020-02-24 15:33:35 -08:00
// Attach to our exception wrapper
Exceptions.reporter = { exception, _, _ ->
crashlytics.recordException(exception)
}
if (isAnalyticsAllowed) {
val standardLogger = Logging.printlog
// send all log messages through crashyltics, so if we do crash we'll have those in the report
Logging.printlog = { level, tag, message ->
crashlytics.log("$tag: $message")
standardLogger(level, tag, message)
}
}
2020-02-24 15:33:35 -08:00
}
2020-03-11 14:45:49 -07:00
Mapbox.getInstance(this, getString(R.string.mapbox_access_token))
}
}