adding Leak Canary

This commit is contained in:
tibbi 2017-11-21 15:58:24 +01:00
parent 2bd75568ac
commit 9799148e3d
4 changed files with 24 additions and 4 deletions

View File

@ -20,10 +20,14 @@ android {
} }
buildTypes { buildTypes {
debug {
buildConfigField "boolean", "USE_LEAK_CANARY", "true"
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release signingConfig signingConfigs.release
buildConfigField "boolean", "USE_LEAK_CANARY", "false"
} }
} }
@ -37,8 +41,15 @@ android {
} }
} }
ext {
leakCanaryVersion = '1.5.4'
}
dependencies { 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() Properties props = new Properties()

View File

@ -1,12 +1,20 @@
package com.simplemobiletools.camera package com.simplemobiletools.camera
import android.app.Application import android.app.Application
import com.simplemobiletools.camera.BuildConfig.USE_LEAK_CANARY
import com.simplemobiletools.camera.extensions.config import com.simplemobiletools.camera.extensions.config
import com.squareup.leakcanary.LeakCanary
import java.util.* import java.util.*
class App : Application() { class App : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (USE_LEAK_CANARY) {
if (LeakCanary.isInAnalyzerProcess(this)) {
return
}
LeakCanary.install(this)
}
if (config.useEnglish) { if (config.useEnglish) {
val conf = resources.configuration val conf = resources.configuration

View File

@ -141,8 +141,8 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} }
private fun hideToggleModeAbout() { private fun hideToggleModeAbout() {
toggle_photo_video.visibility = View.GONE toggle_photo_video.beGone()
settings.visibility = View.GONE settings.beGone()
} }
private fun tryInitCamera() { private fun tryInitCamera() {

View File

@ -13,6 +13,7 @@ import com.simplemobiletools.commons.extensions.updateTextColors
import com.simplemobiletools.commons.extensions.useEnglishToggled import com.simplemobiletools.commons.extensions.useEnglishToggled
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.commons.helpers.LICENSE_LEAK_CANARY
import kotlinx.android.synthetic.main.activity_settings.* import kotlinx.android.synthetic.main.activity_settings.*
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -48,7 +49,7 @@ class SettingsActivity : SimpleActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { 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) else -> super.onOptionsItemSelected(item)
} }
return true return true