Remove ACRA

This commit is contained in:
William Brawner 2021-01-26 21:45:25 -07:00
parent c0ca8c8b29
commit a58b97c0e9
6 changed files with 24 additions and 100 deletions

View file

@ -3,17 +3,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
def acraProperties = new Properties()
try {
def acraPropertiesFile = project.file("acra.properties")
acraProperties.load(new FileInputStream(acraPropertiesFile))
} catch (FileNotFoundException ignored) {
logger.warn("Unable to load ACRA properties. Error reporting won't be available")
acraProperties['url'] = ""
acraProperties['user'] = ""
acraProperties['pass'] = ""
}
android { android {
compileSdkVersion 30 compileSdkVersion 30
compileOptions { compileOptions {
@ -33,9 +22,6 @@ android {
useSupportLibrary = true useSupportLibrary = true
} }
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "ACRA_URL", "\"${acraProperties['url']}\""
buildConfigField "String", "ACRA_USER", "\"${acraProperties['user']}\""
buildConfigField "String", "ACRA_PASS", "\"${acraProperties['pass']}\""
} }
buildTypes { buildTypes {
release { release {
@ -74,8 +60,6 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
implementation "ch.acra:acra-http:$acra_version"
implementation "ch.acra:acra-advanced-scheduler:$acra_version"
debugImplementation "com.willowtreeapps.hyperion:hyperion-core:$hyperion" debugImplementation "com.willowtreeapps.hyperion:hyperion-core:$hyperion"
debugImplementation "com.willowtreeapps.hyperion:hyperion-attr:$hyperion" debugImplementation "com.willowtreeapps.hyperion:hyperion-attr:$hyperion"

View file

@ -1,12 +1,21 @@
package com.wbrawner.budget package com.wbrawner.budget
import android.app.Application
import android.util.Log
import com.wbrawner.budget.common.util.ErrorHandler import com.wbrawner.budget.common.util.ErrorHandler
import com.wbrawner.budget.util.AcraErrorHandler
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
@Module @Module
class AppModule { class AppModule {
@Provides @Provides
fun provideErrorHandler(): ErrorHandler = AcraErrorHandler() fun provideErrorHandler(): ErrorHandler = object : ErrorHandler {
override fun init(application: Application) {
// no-op
}
override fun reportException(t: Throwable, message: String?) {
Log.e("ErrorHandler", "Report exception: $message", t)
}
}
} }

View file

@ -1,6 +1,5 @@
package com.wbrawner.budget.ui.transactions package com.wbrawner.budget.ui.transactions
import android.app.DatePickerDialog
import android.app.TimePickerDialog import android.app.TimePickerDialog
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -15,6 +14,7 @@ import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NavUtils import androidx.core.app.NavUtils
import androidx.core.app.TaskStackBuilder import androidx.core.app.TaskStackBuilder
import com.google.android.material.datepicker.MaterialDatePicker
import com.wbrawner.budget.AllowanceApplication import com.wbrawner.budget.AllowanceApplication
import com.wbrawner.budget.R import com.wbrawner.budget.R
import com.wbrawner.budget.common.budget.Budget import com.wbrawner.budget.common.budget.Budget
@ -77,17 +77,17 @@ class TransactionFormActivity : AppCompatActivity(), CoroutineScope {
transactionDate.setOnClickListener { transactionDate.setOnClickListener {
val currentDate = DateFormat.getDateFormat(this@TransactionFormActivity) val currentDate = DateFormat.getDateFormat(this@TransactionFormActivity)
.parse(transactionDate.text.toString()) ?: Date() .parse(transactionDate.text.toString()) ?: Date()
DatePickerDialog( MaterialDatePicker.Builder.datePicker()
this@TransactionFormActivity, .setSelection(currentDate.time)
{ _, year, month, dayOfMonth -> .setTheme(R.style.DateTimePickerDialogTheme)
.build()
.also { picker ->
picker.addOnPositiveButtonClickListener {
transactionDate.text = DateFormat.getDateFormat(this@TransactionFormActivity) transactionDate.text = DateFormat.getDateFormat(this@TransactionFormActivity)
.format(Date(year, month, dayOfMonth)) .format(Date(it))
}, }
currentDate.year + 1900, }
currentDate.month, .show(supportFragmentManager, null)
currentDate.date
)
.show()
} }
transactionTime.setOnClickListener { transactionTime.setOnClickListener {
val currentDate = DateFormat.getTimeFormat(this@TransactionFormActivity) val currentDate = DateFormat.getTimeFormat(this@TransactionFormActivity)

View file

@ -56,7 +56,7 @@ class TransactionListFragment : ListWithAddButtonFragment<Transaction, Transacti
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }
// TODO: Launch a Google Drive-style search/filter screen // TODO: Launch a Google Drive-style search/filter screen
AlertDialog.Builder(requireContext()) AlertDialog.Builder(requireContext(), R.style.DialogTheme)
.setTitle("Filter Transactions") .setTitle("Filter Transactions")
.setPositiveButton(R.string.action_submit) { _, _ -> .setPositiveButton(R.string.action_submit) { _, _ ->
reloadItems() reloadItems()

View file

@ -1,68 +0,0 @@
package com.wbrawner.budget.util
import android.app.Application
import android.app.job.JobInfo
import android.util.Log
import com.wbrawner.budget.BuildConfig
import com.wbrawner.budget.common.util.ErrorHandler
import org.acra.ACRA
import org.acra.ReportField
import org.acra.config.CoreConfigurationBuilder
import org.acra.config.HttpSenderConfigurationBuilder
import org.acra.config.SchedulerConfigurationBuilder
import org.acra.data.StringFormat
import org.acra.sender.HttpSender
class AcraErrorHandler : ErrorHandler {
override fun init(application: Application) {
if (BuildConfig.ACRA_URL.isBlank()
|| BuildConfig.ACRA_USER.isBlank()
|| BuildConfig.ACRA_PASS.isBlank()) {
return
}
val builder = CoreConfigurationBuilder(application)
.setBuildConfigClass(BuildConfig::class.java)
.setReportFormat(StringFormat.JSON)
.setReportContent(
ReportField.ANDROID_VERSION,
ReportField.APP_VERSION_CODE,
ReportField.APP_VERSION_NAME,
ReportField.APPLICATION_LOG,
ReportField.AVAILABLE_MEM_SIZE,
ReportField.BRAND,
ReportField.BUILD_CONFIG,
ReportField.CRASH_CONFIGURATION,
ReportField.CUSTOM_DATA, // Not currently used, but might be useful in the future
ReportField.INITIAL_CONFIGURATION,
ReportField.PACKAGE_NAME,
ReportField.PHONE_MODEL,
ReportField.SHARED_PREFERENCES,
ReportField.STACK_TRACE,
ReportField.STACK_TRACE_HASH,
ReportField.THREAD_DETAILS,
ReportField.TOTAL_MEM_SIZE,
ReportField.USER_APP_START_DATE,
ReportField.USER_CRASH_DATE
)
builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder::class.java)
.setUri(BuildConfig.ACRA_URL)
.setHttpMethod(HttpSender.Method.POST)
.setBasicAuthLogin(BuildConfig.ACRA_USER)
.setBasicAuthPassword(BuildConfig.ACRA_PASS)
.setEnabled(true)
builder.getPluginConfigurationBuilder(SchedulerConfigurationBuilder::class.java)
.setRequiresNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
.setRequiresBatteryNotLow(true)
.setEnabled(true)
ACRA.init(application, builder)
}
override fun reportException(t: Throwable, message: String?) {
@Suppress("ConstantConditionIf")
if (BuildConfig.DEBUG) {
Log.e("AcraErrorHandler", "Caught exception: $message", t)
}
ACRA.getErrorReporter().handleException(t)
}
}

View file

@ -1,7 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.acra_version = '5.7.0'
ext.dagger = '2.23.1' ext.dagger = '2.23.1'
ext.hyperion = '0.9.27' ext.hyperion = '0.9.27'
ext.kotlin_version = '1.4.21' ext.kotlin_version = '1.4.21'