Commit 4a218bb6 authored by Christophe Henry's avatar Christophe Henry

Perform cleanup when app crashes

parent 8234a38c
Pipeline #3468 failed with stage
......@@ -118,6 +118,7 @@ dependencies {
def android_navigation = "1.0.0"
def jsoup_version = "1.12.1"
def acraVersion = "5.1.3"
def autoservice_version = "1.0-rc6"
// Linter
ktlint "com.github.shyiko:ktlint:0.31.0"
......@@ -183,6 +184,8 @@ dependencies {
implementation "eu.davidea:flexible-adapter:5.1.0"
implementation "eu.davidea:flexible-adapter-ui:1.0.0"
implementation "org.jsoup:jsoup:$jsoup_version"
compileOnly "com.google.auto.service:auto-service-annotations:$autoservice_version"
kapt "com.google.auto.service:auto-service:$autoservice_version"
// Bug report
implementation "ch.acra:acra-http:$acraVersion"
......
......@@ -11,10 +11,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.room.Room
import fr.chenry.android.freshrss.RefresherService.RefresherBinder
import fr.chenry.android.freshrss.store.FreshRSSPreferences
import fr.chenry.android.freshrss.store.Store
import fr.chenry.android.freshrss.store.database.FreshRSSDabatabase
import fr.chenry.android.freshrss.store.database.FreshRSSDabatabase_Migrations
import fr.chenry.android.freshrss.utils.Try
import fr.chenry.android.freshrss.utils.whenNotNull
import nl.komponents.kovenant.android.startKovenant
import nl.komponents.kovenant.android.stopKovenant
......@@ -22,7 +20,6 @@ import org.acra.ACRA
import org.acra.annotation.*
import org.acra.data.StringFormat
import org.acra.sender.HttpSender
import java.util.Properties
@AcraCore(reportFormat = StringFormat.JSON)
@AcraHttpSender(
......@@ -67,12 +64,6 @@ class FreshRSSApplication: Application() {
bindService(Intent(this, RefresherService::class.java), serviceConnection, Context.BIND_AUTO_CREATE)
Store.debugMode = Try {
val properties = Properties()
properties.load(baseContext.assets.open("config.properties"))
properties.getProperty("debug", "false")!!.toBoolean()
}.getOrDefault(false)
// Debug
//Stetho.initializeWithDefaults(this)
}
......
......@@ -18,7 +18,6 @@ import java.util.concurrent.ConcurrentHashMap
import kotlin.math.max
object Store {
var debugMode = false
val totalUnreadCount = MutableLiveData<Int>()
val subscriptionsSection =
MutableLiveData<SubscriptionSection>().apply {this.value = SubscriptionSection.ALL}
......
package fr.chenry.android.freshrss.utils
import android.content.Context
import androidx.core.app.NotificationManagerCompat
import com.google.auto.service.AutoService
import fr.chenry.android.freshrss.FreshRSSApplication
import org.acra.config.CoreConfiguration
import org.acra.config.ReportingAdministrator
import org.acra.data.CrashReportData
/**
* This class will be autowired to Acra intialization.
* Function shouldSendReport() is used to perform cleanups when application crashes
*/
@AutoService(ReportingAdministrator::class)
class CleanupReportingAdministrator: ReportingAdministrator {
override fun shouldSendReport(
context: Context,
config: CoreConfiguration,
crashReportData: CrashReportData
): Boolean {
val app = context.applicationContext
if(app is FreshRSSApplication) {
NotificationManagerCompat.from(app).cancelAll()
}
return super.shouldSendReport(context, config, crashReportData)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment