mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Fixes thread used by changes from #359 Also create the device direct play profile lazily-ish off of the main thread because this can take some time to create. Should help address some of the "too much work" reported in #363, and also fixes the network-on-main exception in the logs on #363
101 lines
3.3 KiB
Kotlin
101 lines
3.3 KiB
Kotlin
package com.github.damontecres.wholphin
|
|
|
|
import android.app.Application
|
|
import android.os.Build
|
|
import android.os.StrictMode
|
|
import android.os.StrictMode.ThreadPolicy
|
|
import android.util.Log
|
|
import androidx.compose.runtime.Composer
|
|
import androidx.compose.runtime.ExperimentalComposeRuntimeApi
|
|
import dagger.hilt.android.HiltAndroidApp
|
|
import org.acra.ACRA
|
|
import org.acra.ReportField
|
|
import org.acra.config.dialog
|
|
import org.acra.data.StringFormat
|
|
import org.acra.ktx.initAcra
|
|
import timber.log.Timber
|
|
|
|
@OptIn(ExperimentalComposeRuntimeApi::class)
|
|
@HiltAndroidApp
|
|
class WholphinApplication : Application() {
|
|
init {
|
|
instance = this
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
StrictMode.setThreadPolicy(
|
|
ThreadPolicy
|
|
.Builder()
|
|
.detectNetwork()
|
|
.penaltyLog()
|
|
.build(),
|
|
)
|
|
}
|
|
|
|
if (BuildConfig.DEBUG) {
|
|
Timber.plant(Timber.DebugTree())
|
|
} else {
|
|
Timber.plant(
|
|
object : Timber.Tree() {
|
|
override fun isLoggable(
|
|
tag: String?,
|
|
priority: Int,
|
|
): Boolean = priority >= Log.INFO
|
|
|
|
override fun log(
|
|
priority: Int,
|
|
tag: String?,
|
|
message: String,
|
|
t: Throwable?,
|
|
) {
|
|
Log.println(priority, tag ?: "Wholphin", message)
|
|
}
|
|
},
|
|
)
|
|
}
|
|
|
|
Composer.setDiagnosticStackTraceEnabled(BuildConfig.DEBUG)
|
|
}
|
|
|
|
override fun onCreate() {
|
|
super.onCreate()
|
|
initAcra {
|
|
buildConfigClass = BuildConfig::class.java
|
|
reportFormat = StringFormat.JSON
|
|
excludeMatchingSharedPreferencesKeys = listOf()
|
|
reportContent =
|
|
listOf(
|
|
ReportField.ANDROID_VERSION,
|
|
ReportField.APP_VERSION_CODE,
|
|
ReportField.APP_VERSION_NAME,
|
|
ReportField.BRAND,
|
|
// ReportField.BUILD_CONFIG,
|
|
// ReportField.BUILD,
|
|
ReportField.CUSTOM_DATA,
|
|
ReportField.LOGCAT,
|
|
ReportField.PHONE_MODEL,
|
|
ReportField.PRODUCT,
|
|
ReportField.REPORT_ID,
|
|
ReportField.SHARED_PREFERENCES,
|
|
ReportField.STACK_TRACE,
|
|
ReportField.USER_COMMENT,
|
|
ReportField.USER_CRASH_DATE,
|
|
)
|
|
dialog {
|
|
text =
|
|
"Wholphin has crashed! Would you like to attempt to " +
|
|
"send a crash report to your Jellyfin server?"
|
|
title = "Wholphin Crash Report"
|
|
positiveButtonText = "Send"
|
|
negativeButtonText = "Do not send"
|
|
}
|
|
reportSendFailureToast = "Crash report failed to send"
|
|
reportSendSuccessToast = "Sent crash report!"
|
|
}
|
|
ACRA.errorReporter.putCustomData("SDK_INT", Build.VERSION.SDK_INT.toString())
|
|
}
|
|
|
|
companion object {
|
|
lateinit var instance: WholphinApplication
|
|
private set
|
|
}
|
|
}
|