From 9799148e3deda147f84526b04ee27f6fbd480cd6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 21 Nov 2017 15:58:24 +0100 Subject: [PATCH] adding Leak Canary --- app/build.gradle | 13 ++++++++++++- .../main/kotlin/com/simplemobiletools/camera/App.kt | 8 ++++++++ .../camera/activities/MainActivity.kt | 4 ++-- .../camera/activities/SettingsActivity.kt | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index aaef9e89..f12e32d1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,10 +20,14 @@ android { } buildTypes { + debug { + buildConfigField "boolean", "USE_LEAK_CANARY", "true" + } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release + buildConfigField "boolean", "USE_LEAK_CANARY", "false" } } @@ -37,8 +41,15 @@ android { } } +ext { + leakCanaryVersion = '1.5.4' +} + dependencies { - compile 'com.simplemobiletools:commons:2.41.5' + implementation 'com.simplemobiletools:commons:2.41.5' + + debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" + releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" } Properties props = new Properties() diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/App.kt b/app/src/main/kotlin/com/simplemobiletools/camera/App.kt index 5a5898e4..738c4fd3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/App.kt @@ -1,12 +1,20 @@ package com.simplemobiletools.camera import android.app.Application +import com.simplemobiletools.camera.BuildConfig.USE_LEAK_CANARY import com.simplemobiletools.camera.extensions.config +import com.squareup.leakcanary.LeakCanary import java.util.* class App : Application() { override fun onCreate() { super.onCreate() + if (USE_LEAK_CANARY) { + if (LeakCanary.isInAnalyzerProcess(this)) { + return + } + LeakCanary.install(this) + } if (config.useEnglish) { val conf = resources.configuration diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 6d7d1710..d8ce8597 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -141,8 +141,8 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave } private fun hideToggleModeAbout() { - toggle_photo_video.visibility = View.GONE - settings.visibility = View.GONE + toggle_photo_video.beGone() + settings.beGone() } private fun tryInitCamera() { diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt index 44a81810..aaef382e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.useEnglishToggled import com.simplemobiletools.commons.helpers.LICENSE_GLIDE import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN +import com.simplemobiletools.commons.helpers.LICENSE_LEAK_CANARY import kotlinx.android.synthetic.main.activity_settings.* import java.io.File import java.util.* @@ -48,7 +49,7 @@ class SettingsActivity : SimpleActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.about -> startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE, BuildConfig.VERSION_NAME) + R.id.about -> startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_GLIDE or LICENSE_LEAK_CANARY, BuildConfig.VERSION_NAME) else -> super.onOptionsItemSelected(item) } return true