diff --git a/android/build.gradle b/android/build.gradle index 3b76a10d..b0c39921 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -158,6 +158,8 @@ dependencies { implementation 'com.larswerkman:HoloColorPicker:1.5' 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' kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.0") @@ -174,8 +176,7 @@ dependencies { //noinspection GradleDependency implementation 'com.google.zxing:core:3.3.0' - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2' // requires minSDK 16 according to docs, not sure if it causes an issue withAnalyticsImplementation 'com.google.android.gms:play-services-analytics:17.0.0' diff --git a/android/src/androidTest/java/org/ligi/passandroid/TestApp.kt b/android/src/androidTest/java/org/ligi/passandroid/TestApp.kt index 0e40d9ae..a5272116 100644 --- a/android/src/androidTest/java/org/ligi/passandroid/TestApp.kt +++ b/android/src/androidTest/java/org/ligi/passandroid/TestApp.kt @@ -35,8 +35,6 @@ class TestApp : App() { bind() with singleton { mock(EventBus::class.java) } } - override fun installLeakCanary() = Unit - companion object { diff --git a/android/src/main/java/org/ligi/passandroid/App.kt b/android/src/main/java/org/ligi/passandroid/App.kt index 416c7196..7138b431 100644 --- a/android/src/main/java/org/ligi/passandroid/App.kt +++ b/android/src/main/java/org/ligi/passandroid/App.kt @@ -4,7 +4,6 @@ import android.app.Application import androidx.appcompat.app.AppCompatDelegate import com.github.salomonbrys.kodein.* import com.jakewharton.threetenabp.AndroidThreeTen -import com.squareup.leakcanary.LeakCanary import com.squareup.moshi.Moshi import org.greenrobot.eventbus.EventBus import org.ligi.passandroid.json_adapter.ColorAdapter @@ -27,7 +26,6 @@ open class App : Application() { } AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) - installLeakCanary() AndroidThreeTen.init(this) initTraceDroid() @@ -47,10 +45,6 @@ open class App : Application() { bind() with singleton { EventBus.getDefault() } } - open fun installLeakCanary() { - LeakCanary.install(this) - } - private fun initTraceDroid() { TraceDroid.init(this) Log.setTAG("PassAndroid") diff --git a/android/src/main/java/org/ligi/passandroid/model/AndroidFileSystemPassStore.kt b/android/src/main/java/org/ligi/passandroid/model/AndroidFileSystemPassStore.kt index 20426d9d..76262825 100644 --- a/android/src/main/java/org/ligi/passandroid/model/AndroidFileSystemPassStore.kt +++ b/android/src/main/java/org/ligi/passandroid/model/AndroidFileSystemPassStore.kt @@ -3,7 +3,9 @@ package org.ligi.passandroid.model import android.content.Context import com.squareup.moshi.JsonDataException import com.squareup.moshi.Moshi -import okio.Okio +import okio.buffer +import okio.sink +import okio.source import org.greenrobot.eventbus.EventBus import org.ligi.passandroid.App import org.ligi.passandroid.BuildConfig @@ -36,7 +38,7 @@ class AndroidFileSystemPassStore(private val context: Context, settings: Setting pathForID.mkdirs() } - val buffer = Okio.buffer(Okio.sink(File(pathForID, "main.json"))) + val buffer = File(pathForID, "main.json").sink().buffer() if (BuildConfig.DEBUG) { 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) dirty = false try { - result = jsonAdapter.fromJson(Okio.buffer(Okio.source(file))) + result = jsonAdapter.fromJson(file.source().buffer()) } catch (ignored: JsonDataException) { App.tracker.trackException("invalid main.json", false) } diff --git a/android/src/main/java/org/ligi/passandroid/ui/UnzipPassController.kt b/android/src/main/java/org/ligi/passandroid/ui/UnzipPassController.kt index 996cb277..6488ff58 100644 --- a/android/src/main/java/org/ligi/passandroid/ui/UnzipPassController.kt +++ b/android/src/main/java/org/ligi/passandroid/ui/UnzipPassController.kt @@ -8,7 +8,8 @@ import android.os.Build import android.os.ParcelFileDescriptor import net.lingala.zip4j.ZipFile import net.lingala.zip4j.exception.ZipException -import okio.Okio +import okio.buffer +import okio.source import org.json.JSONObject import org.ligi.passandroid.App import org.ligi.passandroid.functions.createPassForImageImport @@ -107,7 +108,7 @@ object UnzipPassController { if (Build.VERSION.SDK_INT >= 21) { try { val file = File(spec.zipFileString) - val readUtf8 = Okio.buffer(Okio.source(file)).readUtf8(4) + val readUtf8 = file.source().buffer().readUtf8(4) if (readUtf8 == "%PDF") { val open = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY) val pdfRenderer = PdfRenderer(open)