Update dependencies

This includes a migration to Firebase Crashlytics with Google Analytics instead of Fabric Crashlytics which has been deprecated and is on the way out.
This commit is contained in:
William Brawner 2020-04-20 16:13:49 -07:00
parent f01909eb83
commit 551e1f1f57
6 changed files with 27 additions and 18 deletions

View file

@ -3,6 +3,7 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco'
apply plugin: 'com.google.firebase.crashlytics'
def keystoreProperties = new Properties()
try {
@ -40,8 +41,8 @@ android {
applicationId "com.wbrawner.simplemarkdown"
minSdkVersion 21
targetSdkVersion 29
versionCode 24
versionName "0.8.2"
versionCode 25
versionName "0.8.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "false"
}
@ -96,9 +97,10 @@ dependencies {
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'com.commonsware.cwac:anddown:0.3.0'
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.android.billingclient:billing:2.2.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation "androidx.core:core-ktx:1.2.0"
implementation 'androidx.browser:browser:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

View file

@ -14,12 +14,11 @@ class MarkdownApplication : Application() {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyDeath()
.penaltyLog()
.build())
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDeath()
.build())
}
super.onCreate()

View file

@ -1,24 +1,19 @@
package com.wbrawner.simplemarkdown.utility
import android.content.Context
import android.util.Log
import com.crashlytics.android.Crashlytics
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.wbrawner.simplemarkdown.BuildConfig
import io.fabric.sdk.android.Fabric
import java.util.concurrent.atomic.AtomicBoolean
interface ErrorHandler {
fun init(context: Context)
fun enable(enable: Boolean)
fun reportException(t: Throwable, message: String? = null)
}
class CrashlyticsErrorHandler : ErrorHandler {
private val isInitialized = AtomicBoolean(false)
private val crashlytics = FirebaseCrashlytics.getInstance()
override fun init(context: Context) {
if (!isInitialized.getAndSet(true)) {
Fabric.with(context, Crashlytics())
}
override fun enable(enable: Boolean) {
crashlytics.setCrashlyticsCollectionEnabled(enable)
}
override fun reportException(t: Throwable, message: String?) {
@ -27,7 +22,6 @@ class CrashlyticsErrorHandler : ErrorHandler {
Log.e("CrashlyticsErrorHandler", "Caught exception: $message", t)
return
}
if (!isInitialized.get()) return
Crashlytics.logException(t)
crashlytics.recordException(t)
}
}

View file

@ -20,6 +20,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import androidx.preference.PreferenceManager
import com.wbrawner.simplemarkdown.MarkdownApplication
import com.wbrawner.simplemarkdown.R
import com.wbrawner.simplemarkdown.utility.hideKeyboard
import com.wbrawner.simplemarkdown.view.adapter.EditPagerAdapter
@ -69,6 +70,17 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes
}
}
override fun onStart() {
super.onStart()
launch {
withContext(Dispatchers.IO) {
val enableErrorReports = PreferenceManager.getDefaultSharedPreferences(this@MainActivity)
.getBoolean(getString(R.string.error_reports_enabled), true)
(application as MarkdownApplication).errorHandler.enable(enableErrorReports)
}
}
}
override fun onUserLeaveHint() {
super.onUserLeaveHint()
launch {

View file

@ -33,6 +33,7 @@ class SupportActivity : AppCompatActivity(), BillingClientStateListener, Purchas
supportActionBar?.setDisplayHomeAsUpEnabled(true)
billingClient = BillingClient.newBuilder(applicationContext)
.setListener(this)
.enablePendingPurchases()
.build()
billingClient.startConnection(this)
githubButton.setOnClickListener {

View file

@ -9,6 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}