Wholphin/app/src/main/java/com/github/damontecres/wholphin/WholphinApplication.kt
Ray 8935067c5a
Add option to delete media (#1014)
## Description
Adds a setting to enable "Media management" which adds a context menu
item to delete media. This is accessible using either the More button or
long clicking.

You can delete episodes, seasons, series and movies/videos.

If order for the option to appear the current user must have server-side
settings for "Allow media deletion from" enabled for the library and the
in-app setting under Settings->Advanced Settings->"Show media management
options".

### Related issues
Closes #104 

### Testing
Emulator

## Screenshots
### Context menu
![delete_context_2
Large](https://github.com/user-attachments/assets/cabc3c24-1b43-4f88-8d71-b7275f9eadc4)


### Confirmation
![delete_confirm
Large](https://github.com/user-attachments/assets/8036dde1-8a51-424b-bbdd-f2826dd3e0ab)

## AI or LLM usage
None
2026-03-02 15:38:41 -05:00

124 lines
3.9 KiB
Kotlin

package com.github.damontecres.wholphin
import android.app.Application
import android.os.Build
import android.os.StrictMode
import android.util.Log
import androidx.compose.runtime.Composer
import androidx.compose.runtime.ExperimentalComposeRuntimeApi
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import dagger.hilt.android.HiltAndroidApp
import okhttp3.OkHttp
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
import javax.inject.Inject
@OptIn(ExperimentalComposeRuntimeApi::class)
@HiltAndroidApp
class WholphinApplication :
Application(),
Configuration.Provider {
init {
instance = this
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()
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy
.Builder()
.detectNetwork()
.penaltyLog()
.penaltyDeathOnNetwork()
.build(),
)
// StrictMode.setVmPolicy(
// StrictMode.VmPolicy
// .Builder()
// .detectAll()
// .penaltyLog()
// .build(),
// )
}
OkHttp.initialize(this)
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())
}
@Inject
lateinit var workerFactory: HiltWorkerFactory
override val workManagerConfiguration: Configuration
get() =
Configuration
.Builder()
.setWorkerFactory(workerFactory)
.build()
companion object {
lateinit var instance: WholphinApplication
private set
}
}