aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-12-03 17:46:51 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2022-12-03 18:07:47 +0530
commit9156a81ad772a70198737e84ea9f7a06870b43dc (patch)
treeec3b26c354a2833f7bd5b29df90ead592eee73be /app
parent8e3b4422a933f87c1a36a6efd583ebf0803891a1 (diff)
feat(leakcanary): migrate to manual initialization
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle.kts2
-rw-r--r--app/src/main/java/app/passwordstore/Application.kt9
2 files changed, 8 insertions, 3 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index c125dd5a..62e1f857 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -108,7 +108,7 @@ dependencies {
debugImplementation(libs.thirdparty.whatthestack)
}
- debugImplementation(libs.thirdparty.leakcanary)
+ implementation(libs.thirdparty.leakcanary.core)
nonFreeImplementation(libs.thirdparty.nonfree.googlePlayAuthApiPhone)
nonFreeImplementation(libs.thirdparty.nonfree.sentry)
freeImplementation(projects.sentryStub)
diff --git a/app/src/main/java/app/passwordstore/Application.kt b/app/src/main/java/app/passwordstore/Application.kt
index d52dfacf..35e1ae22 100644
--- a/app/src/main/java/app/passwordstore/Application.kt
+++ b/app/src/main/java/app/passwordstore/Application.kt
@@ -7,7 +7,6 @@ package app.passwordstore
import android.content.SharedPreferences
import android.os.Build
import android.os.StrictMode
-import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.app.AppCompatDelegate.*
import app.passwordstore.injection.context.FilesDirPath
import app.passwordstore.injection.prefs.SettingsPreferences
@@ -15,6 +14,7 @@ import app.passwordstore.util.extensions.getString
import app.passwordstore.util.features.Feature
import app.passwordstore.util.features.Features
import app.passwordstore.util.git.sshj.setUpBouncyCastleForSshj
+import app.passwordstore.util.leaks.SentryLeakUploader
import app.passwordstore.util.proxy.ProxyUtils
import app.passwordstore.util.settings.GitSettings
import app.passwordstore.util.settings.PreferenceKeys
@@ -25,6 +25,8 @@ import io.sentry.Sentry
import io.sentry.protocol.User
import java.util.concurrent.Executors
import javax.inject.Inject
+import leakcanary.AppWatcher
+import leakcanary.LeakCanary
import logcat.AndroidLogcatLogger
import logcat.LogPriority.DEBUG
import logcat.LogPriority.VERBOSE
@@ -44,11 +46,14 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
override fun onCreate() {
super.onCreate()
instance = this
+ LeakCanary.config =
+ LeakCanary.config.copy(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()
}
prefs.registerOnSharedPreferenceChangeListener(this)
@@ -117,7 +122,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
}
private fun setNightMode() {
- AppCompatDelegate.setDefaultNightMode(
+ setDefaultNightMode(
when (prefs.getString(PreferenceKeys.APP_THEME) ?: getString(R.string.app_theme_def)) {
"light" -> MODE_NIGHT_NO
"dark" -> MODE_NIGHT_YES