From ddd958a8d6042a2db61caceedd2eebea928c2b90 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 18 Mar 2023 21:53:50 +0530 Subject: fix(app): control LeakCanary lifecycle more explicitly --- app/src/main/java/app/passwordstore/Application.kt | 10 +++++++--- app/src/main/res/values/bools.xml | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/passwordstore/Application.kt b/app/src/main/java/app/passwordstore/Application.kt index 35e1ae22..984adde4 100644 --- a/app/src/main/java/app/passwordstore/Application.kt +++ b/app/src/main/java/app/passwordstore/Application.kt @@ -46,15 +46,19 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere override fun onCreate() { super.onCreate() instance = this - LeakCanary.config = - LeakCanary.config.copy(eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader) + val eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader if ( BuildConfig.ENABLE_DEBUG_FEATURES || prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false) ) { LogcatLogger.install(AndroidLogcatLogger(DEBUG)) - AppWatcher.manualInstall(this) setVmPolicy() + LeakCanary.config.copy(dumpHeap = true, eventListeners = eventListeners) + LeakCanary.showLeakDisplayActivityLauncherIcon(true) + AppWatcher.manualInstall(this) + } else { + LeakCanary.config.copy(dumpHeap = false, eventListeners = eventListeners) + LeakCanary.showLeakDisplayActivityLauncherIcon(false) } prefs.registerOnSharedPreferenceChangeListener(this) setNightMode() diff --git a/app/src/main/res/values/bools.xml b/app/src/main/res/values/bools.xml index 78f5307a..02c5129a 100644 --- a/app/src/main/res/values/bools.xml +++ b/app/src/main/res/values/bools.xml @@ -5,5 +5,6 @@ true + false true -- cgit v1.2.3