diff --git a/app/build.gradle b/app/build.gradle index bfbb14e26..68fde1b89 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,9 +33,15 @@ android { sourceSets { main.java.srcDirs += 'src/main/kotlin' + debug.java.srcDirs += 'src/debug/kotlin' + release.java.srcDirs += 'src/release/kotlin' } } +ext { + leakCanaryVersion = '1.5.2' +} + dependencies { compile 'com.simplemobiletools:commons:2.25.3' compile 'joda-time:joda-time:2.9.1' @@ -44,6 +50,8 @@ dependencies { compile 'com.android.support:multidex:1.0.1' compile 'com.google.code.gson:gson:2.8.0' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" + releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" } buildscript { diff --git a/app/src/debug/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt b/app/src/debug/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt new file mode 100644 index 000000000..3d106084c --- /dev/null +++ b/app/src/debug/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt @@ -0,0 +1,14 @@ +package com.simplemobiletools.calendar + +import com.squareup.leakcanary.LeakCanary + +open class BuildVariantApplication : BaseApp() { + override fun onCreate() { + super.onCreate() + LeakCanary.install(this); + } + + override fun shouldInit(): Boolean { + return !LeakCanary.isInAnalyzerProcess(this) + } +} diff --git a/app/src/debug/res/drawable-hdpi/leak_canary_icon.png b/app/src/debug/res/drawable-hdpi/leak_canary_icon.png new file mode 100644 index 000000000..e10f62503 Binary files /dev/null and b/app/src/debug/res/drawable-hdpi/leak_canary_icon.png differ diff --git a/app/src/debug/res/drawable-xhdpi/leak_canary_icon.png b/app/src/debug/res/drawable-xhdpi/leak_canary_icon.png new file mode 100644 index 000000000..462db1d63 Binary files /dev/null and b/app/src/debug/res/drawable-xhdpi/leak_canary_icon.png differ diff --git a/app/src/debug/res/drawable-xxhdpi/leak_canary_icon.png b/app/src/debug/res/drawable-xxhdpi/leak_canary_icon.png new file mode 100644 index 000000000..047eedcae Binary files /dev/null and b/app/src/debug/res/drawable-xxhdpi/leak_canary_icon.png differ diff --git a/app/src/debug/res/drawable-xxxhdpi/leak_canary_icon.png b/app/src/debug/res/drawable-xxxhdpi/leak_canary_icon.png new file mode 100644 index 000000000..6c264e807 Binary files /dev/null and b/app/src/debug/res/drawable-xxxhdpi/leak_canary_icon.png differ diff --git a/app/src/debug/res/values/strings.xml b/app/src/debug/res/values/strings.xml new file mode 100644 index 000000000..c7ff04099 --- /dev/null +++ b/app/src/debug/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Calendar Leaks + \ No newline at end of file diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt index 2b28a75da..a55f7ddb6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/App.kt @@ -1,11 +1,13 @@ package com.simplemobiletools.calendar -import android.support.multidex.MultiDexApplication import com.facebook.stetho.Stetho -class App : MultiDexApplication() { +class App : BuildVariantApplication() { override fun onCreate() { super.onCreate() + if (!shouldInit()) { + return + } Stetho.initializeWithDefaults(this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/BaseApp.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/BaseApp.kt new file mode 100644 index 000000000..2eeb822af --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/BaseApp.kt @@ -0,0 +1,9 @@ +package com.simplemobiletools.calendar + +import android.support.multidex.MultiDexApplication + +abstract class BaseApp : MultiDexApplication() { + open fun shouldInit(): Boolean { + return true + } +} diff --git a/app/src/release/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt b/app/src/release/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt new file mode 100644 index 000000000..79e64e374 --- /dev/null +++ b/app/src/release/kotlin/com/simplemobiletools/calendar/BuildVariantApplication.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.calendar + +open class BuildVariantApplication : BaseApp()