From da22420b4755d441ecd554646720662d98db6d08 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 26 Sep 2019 18:06:55 -0700 Subject: [PATCH] Removed ACRA crash reporting. --- app/build.gradle | 3 - app/src/main/AndroidManifest.xml | 6 -- .../erik/android/tesremoteprogrammer/App.kt | 20 +---- .../reporting/CrashEmail.kt | 68 ----------------- .../reporting/CrashEmailFactory.kt | 28 ------- .../reporting/CrashReportActivity.kt | 73 ------------------- .../main/res/layout/crash_report_dialog.xml | 38 ---------- app/src/main/res/values/strings.xml | 5 -- 8 files changed, 4 insertions(+), 237 deletions(-) delete mode 100644 app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmail.kt delete mode 100644 app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmailFactory.kt delete mode 100644 app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashReportActivity.kt delete mode 100644 app/src/main/res/layout/crash_report_dialog.xml diff --git a/app/build.gradle b/app/build.gradle index 7b51672..579e0ef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -65,9 +65,6 @@ dependencies { //implementation 'com.github.daniel-stoneuk:material-about-library:2.2.1' implementation "com.android.support:animated-vector-drawable:$support_version" implementation "com.android.support:cardview-v7:$support_version" - - // https://github.com/ACRA/acra - implementation 'ch.acra:acra:4.11' } repositories { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f6839c7..471b7aa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -32,12 +32,6 @@ - diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/App.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/App.kt index c4ab1f7..fac43d8 100644 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/App.kt +++ b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/App.kt @@ -18,23 +18,11 @@ package net.thauvin.erik.android.tesremoteprogrammer import android.app.Application -import android.content.Context -import net.thauvin.erik.android.tesremoteprogrammer.reporting.CrashEmailFactory -import net.thauvin.erik.android.tesremoteprogrammer.reporting.CrashReportActivity -import org.acra.ACRA -import org.acra.ReportingInteractionMode -import org.acra.annotation.ReportsCrashes @Suppress("unused") -@ReportsCrashes( - mailTo = "erik@thauvin.net", - mode = ReportingInteractionMode.DIALOG, - reportSenderFactoryClasses = [CrashEmailFactory::class], - reportDialogClass = CrashReportActivity::class -) + open class App : Application() { - override fun attachBaseContext(base: Context) { - super.attachBaseContext(base) - ACRA.init(this) - } +// override fun attachBaseContext(base: Context) { +// super.attachBaseContext(base) +// } } diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmail.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmail.kt deleted file mode 100644 index 4d765d3..0000000 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmail.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CrashEmail.kt - * - * Copyright 2016-2019 Erik C. Thauvin (erik@thauvin.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.thauvin.erik.android.tesremoteprogrammer.reporting - -import android.content.Context -import android.content.Intent -import android.net.Uri -import android.text.TextUtils -import net.thauvin.erik.android.tesremoteprogrammer.R -import org.acra.ACRAConstants -import org.acra.ReportField -import org.acra.collections.ImmutableSet -import org.acra.collector.CrashReportData -import org.acra.config.ACRAConfiguration -import org.acra.sender.ReportSender -import org.acra.sender.ReportSenderException - -class CrashEmail(private val config: ACRAConfiguration) : ReportSender { - - @Throws(ReportSenderException::class) - override fun send(context: Context, errorContent: CrashReportData) { - - val subject = context.getString( - R.string.crash_report_subject, - context.getString(R.string.app_name) - ) - val body = buildBody(errorContent) - - val emailIntent = Intent(android.content.Intent.ACTION_SENDTO) - emailIntent.data = Uri.fromParts("mailto", config.mailTo(), null) - emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject) - emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body) - context.startActivity(emailIntent) - } - - private fun buildBody(errorContent: CrashReportData): String { - var fields: Set = config.reportContent() - if (fields.isEmpty()) { - fields = ImmutableSet(*ACRAConstants.DEFAULT_MAIL_REPORT_FIELDS) - } - val builder = StringBuilder() - fields.forEach { field -> - builder.append(field.toString()).append('=') - val value = errorContent[field] - if (value != null) { - builder.append(TextUtils.join("\n\t", value.flatten())) - } - builder.append('\n') - } - return builder.toString() - } -} diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmailFactory.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmailFactory.kt deleted file mode 100644 index 5320adf..0000000 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashEmailFactory.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * CrashEmailFactory.kt - * - * Copyright 2016-2019 Erik C. Thauvin (erik@thauvin.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.thauvin.erik.android.tesremoteprogrammer.reporting - -import android.content.Context -import org.acra.config.ACRAConfiguration -import org.acra.sender.ReportSender -import org.acra.sender.ReportSenderFactory - -class CrashEmailFactory : ReportSenderFactory { - override fun create(context: Context, config: ACRAConfiguration): ReportSender = - CrashEmail(config) -} diff --git a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashReportActivity.kt b/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashReportActivity.kt deleted file mode 100644 index dc1b964..0000000 --- a/app/src/main/java/net/thauvin/erik/android/tesremoteprogrammer/reporting/CrashReportActivity.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * CrashReportActivity.kt - * - * Copyright 2016-2019 Erik C. Thauvin (erik@thauvin.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.thauvin.erik.android.tesremoteprogrammer.reporting - -import android.content.DialogInterface -import android.os.Bundle -import android.support.v7.app.AlertDialog -import android.widget.EditText - -import net.thauvin.erik.android.tesremoteprogrammer.R - -import org.acra.dialog.BaseCrashReportDialog -import org.jetbrains.anko.find - -class CrashReportActivity : BaseCrashReportDialog(), DialogInterface.OnDismissListener, - DialogInterface.OnClickListener { - private var comment: EditText? = null - - companion object { - private const val STATE_USER_COMMENT = "comment" - } - - override fun init(savedInstanceState: Bundle?) { - super.init(savedInstanceState) - - val dialog = AlertDialog.Builder(this) - .setTitle(getString(R.string.crash_dialog_title, getString(R.string.app_name))) - .setView(R.layout.crash_report_dialog) - .setPositiveButton(R.string.ok, this) - .setNegativeButton(R.string.cancel, this) - .create() - - dialog.setCanceledOnTouchOutside(false) - dialog.setOnDismissListener(this) - dialog.show() - - comment = dialog.find(android.R.id.input) - if (savedInstanceState != null) { - comment!!.setText(savedInstanceState.getString(STATE_USER_COMMENT)) - } - } - - override fun onDismiss(dialog: DialogInterface) = finish() - - override fun onClick(dialog: DialogInterface, which: Int) { - if (which == DialogInterface.BUTTON_POSITIVE) { - sendCrash(comment!!.text.toString(), "") - } else { - cancelReports() - } - finish() - } - - override fun onSaveInstanceState(outState: Bundle) { - outState.putString(STATE_USER_COMMENT, comment!!.text.toString()) - super.onSaveInstanceState(outState) - } -} diff --git a/app/src/main/res/layout/crash_report_dialog.xml b/app/src/main/res/layout/crash_report_dialog.xml deleted file mode 100644 index 2f06351..0000000 --- a/app/src/main/res/layout/crash_report_dialog.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index df8137f..7a00b91 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -12,11 +12,6 @@ Configuration Errors TES Remote Programmer Cancel - You may add your comments about the problem below: - An unexpected error occurred forcing the app to stop. Would you like to e-mail a crash report to help fix the issue? - %1$s has crashed - %1$s Crash Report - Generating Crash Report Import Invalid Invalid DTMF: %1$s