Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 9156a81

Browse files
committed
feat(leakcanary): migrate to manual initialization
1 parent 8e3b442 commit 9156a81

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ dependencies {
108108
debugImplementation(libs.thirdparty.whatthestack)
109109
}
110110

111-
debugImplementation(libs.thirdparty.leakcanary)
111+
implementation(libs.thirdparty.leakcanary.core)
112112
nonFreeImplementation(libs.thirdparty.nonfree.googlePlayAuthApiPhone)
113113
nonFreeImplementation(libs.thirdparty.nonfree.sentry)
114114
freeImplementation(projects.sentryStub)

app/src/main/java/app/passwordstore/Application.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ package app.passwordstore
77
import android.content.SharedPreferences
88
import android.os.Build
99
import android.os.StrictMode
10-
import androidx.appcompat.app.AppCompatDelegate
1110
import androidx.appcompat.app.AppCompatDelegate.*
1211
import app.passwordstore.injection.context.FilesDirPath
1312
import app.passwordstore.injection.prefs.SettingsPreferences
1413
import app.passwordstore.util.extensions.getString
1514
import app.passwordstore.util.features.Feature
1615
import app.passwordstore.util.features.Features
1716
import app.passwordstore.util.git.sshj.setUpBouncyCastleForSshj
17+
import app.passwordstore.util.leaks.SentryLeakUploader
1818
import app.passwordstore.util.proxy.ProxyUtils
1919
import app.passwordstore.util.settings.GitSettings
2020
import app.passwordstore.util.settings.PreferenceKeys
@@ -25,6 +25,8 @@ import io.sentry.Sentry
2525
import io.sentry.protocol.User
2626
import java.util.concurrent.Executors
2727
import javax.inject.Inject
28+
import leakcanary.AppWatcher
29+
import leakcanary.LeakCanary
2830
import logcat.AndroidLogcatLogger
2931
import logcat.LogPriority.DEBUG
3032
import logcat.LogPriority.VERBOSE
@@ -44,11 +46,14 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
4446
override fun onCreate() {
4547
super.onCreate()
4648
instance = this
49+
LeakCanary.config =
50+
LeakCanary.config.copy(eventListeners = LeakCanary.config.eventListeners + SentryLeakUploader)
4751
if (
4852
BuildConfig.ENABLE_DEBUG_FEATURES ||
4953
prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false)
5054
) {
5155
LogcatLogger.install(AndroidLogcatLogger(DEBUG))
56+
AppWatcher.manualInstall(this)
5257
setVmPolicy()
5358
}
5459
prefs.registerOnSharedPreferenceChangeListener(this)
@@ -117,7 +122,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere
117122
}
118123

119124
private fun setNightMode() {
120-
AppCompatDelegate.setDefaultNightMode(
125+
setDefaultNightMode(
121126
when (prefs.getString(PreferenceKeys.APP_THEME) ?: getString(R.string.app_theme_def)) {
122127
"light" -> MODE_NIGHT_NO
123128
"dark" -> MODE_NIGHT_YES

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ thirdparty-fastscroll = "me.zhanghai.android.fastscroll:library:1.1.8"
8383
thirdparty-flowbinding-android = { module = "io.github.reactivecircus.flowbinding:flowbinding-android", version.ref = "flowbinding" }
8484
thirdparty-jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r"
8585
thirdparty-kotlinResult = "com.michael-bull.kotlin-result:kotlin-result:1.1.16"
86-
thirdparty-leakcanary = { module = "com.squareup.leakcanary:leakcanary-android-startup", version.ref = "leakcanary" }
86+
thirdparty-leakcanary-core = { module = "com.squareup.leakcanary:leakcanary-android-core", version.ref = "leakcanary" }
8787
thirdparty-logcat = "com.squareup.logcat:logcat:0.1"
8888
thirdparty-modernAndroidPrefs = "de.maxr1998:modernandroidpreferences:2.3.1"
8989
thirdparty-nonfree-googlePlayAuthApiPhone = "com.google.android.gms:play-services-auth-api-phone:18.0.1"

0 commit comments

Comments
 (0)