Migrate to leakcanary 2.2

This commit is contained in:
ligi 2020-02-16 04:45:57 +01:00
parent 38f0706855
commit 0d206f62bc
No known key found for this signature in database
GPG key ID: 8E81894010ABF23D
5 changed files with 11 additions and 15 deletions

View file

@ -158,6 +158,8 @@ dependencies {
implementation 'com.larswerkman:HoloColorPicker:1.5' implementation 'com.larswerkman:HoloColorPicker:1.5'
implementation 'com.google.code.findbugs:jsr305:3.0.2' implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.squareup.okio:okio:2.2.2'
implementation 'com.squareup.moshi:moshi:1.9.0' implementation 'com.squareup.moshi:moshi:1.9.0'
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.0") kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.0")
@ -174,8 +176,7 @@ dependencies {
//noinspection GradleDependency //noinspection GradleDependency
implementation 'com.google.zxing:core:3.3.0' implementation 'com.google.zxing:core:3.3.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
// requires minSDK 16 according to docs, not sure if it causes an issue // requires minSDK 16 according to docs, not sure if it causes an issue
withAnalyticsImplementation 'com.google.android.gms:play-services-analytics:17.0.0' withAnalyticsImplementation 'com.google.android.gms:play-services-analytics:17.0.0'

View file

@ -35,8 +35,6 @@ class TestApp : App() {
bind<EventBus>() with singleton { mock(EventBus::class.java) } bind<EventBus>() with singleton { mock(EventBus::class.java) }
} }
override fun installLeakCanary() = Unit
companion object { companion object {

View file

@ -4,7 +4,6 @@ import android.app.Application
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import com.github.salomonbrys.kodein.* import com.github.salomonbrys.kodein.*
import com.jakewharton.threetenabp.AndroidThreeTen import com.jakewharton.threetenabp.AndroidThreeTen
import com.squareup.leakcanary.LeakCanary
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.json_adapter.ColorAdapter import org.ligi.passandroid.json_adapter.ColorAdapter
@ -27,7 +26,6 @@ open class App : Application() {
} }
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
installLeakCanary()
AndroidThreeTen.init(this) AndroidThreeTen.init(this)
initTraceDroid() initTraceDroid()
@ -47,10 +45,6 @@ open class App : Application() {
bind<EventBus>() with singleton { EventBus.getDefault() } bind<EventBus>() with singleton { EventBus.getDefault() }
} }
open fun installLeakCanary() {
LeakCanary.install(this)
}
private fun initTraceDroid() { private fun initTraceDroid() {
TraceDroid.init(this) TraceDroid.init(this)
Log.setTAG("PassAndroid") Log.setTAG("PassAndroid")

View file

@ -3,7 +3,9 @@ package org.ligi.passandroid.model
import android.content.Context import android.content.Context
import com.squareup.moshi.JsonDataException import com.squareup.moshi.JsonDataException
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import okio.Okio import okio.buffer
import okio.sink
import okio.source
import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.EventBus
import org.ligi.passandroid.App import org.ligi.passandroid.App
import org.ligi.passandroid.BuildConfig import org.ligi.passandroid.BuildConfig
@ -36,7 +38,7 @@ class AndroidFileSystemPassStore(private val context: Context, settings: Setting
pathForID.mkdirs() pathForID.mkdirs()
} }
val buffer = Okio.buffer(Okio.sink(File(pathForID, "main.json"))) val buffer = File(pathForID, "main.json").sink().buffer()
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
val of = com.squareup.moshi.JsonWriter.of(buffer) val of = com.squareup.moshi.JsonWriter.of(buffer)
@ -67,7 +69,7 @@ class AndroidFileSystemPassStore(private val context: Context, settings: Setting
val jsonAdapter = moshi.adapter(PassImpl::class.java) val jsonAdapter = moshi.adapter(PassImpl::class.java)
dirty = false dirty = false
try { try {
result = jsonAdapter.fromJson(Okio.buffer(Okio.source(file))) result = jsonAdapter.fromJson(file.source().buffer())
} catch (ignored: JsonDataException) { } catch (ignored: JsonDataException) {
App.tracker.trackException("invalid main.json", false) App.tracker.trackException("invalid main.json", false)
} }

View file

@ -8,7 +8,8 @@ import android.os.Build
import android.os.ParcelFileDescriptor import android.os.ParcelFileDescriptor
import net.lingala.zip4j.ZipFile import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.exception.ZipException import net.lingala.zip4j.exception.ZipException
import okio.Okio import okio.buffer
import okio.source
import org.json.JSONObject import org.json.JSONObject
import org.ligi.passandroid.App import org.ligi.passandroid.App
import org.ligi.passandroid.functions.createPassForImageImport import org.ligi.passandroid.functions.createPassForImageImport
@ -107,7 +108,7 @@ object UnzipPassController {
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
try { try {
val file = File(spec.zipFileString) val file = File(spec.zipFileString)
val readUtf8 = Okio.buffer(Okio.source(file)).readUtf8(4) val readUtf8 = file.source().buffer().readUtf8(4)
if (readUtf8 == "%PDF") { if (readUtf8 == "%PDF") {
val open = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY) val open = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY)
val pdfRenderer = PdfRenderer(open) val pdfRenderer = PdfRenderer(open)