added email error report for f-droid builds

This commit is contained in:
Mariotaku Lee 2017-05-08 20:47:28 +08:00
parent 046045eac3
commit a7c31769c2
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
7 changed files with 189 additions and 2 deletions

View File

@ -28,7 +28,7 @@ subprojects {
buildscript {
ext {
libVersions = [
Kotlin : '1.1.2-2',
Kotlin : '1.1.2-3',
SupportLib : '25.3.1',
MariotakuCommons : '0.9.15',
RestFu : '0.9.54',
@ -64,6 +64,7 @@ subprojects {
GlideTransformations : '2.0.1',
AndroidImageCropper : '2.4.0',
ExportablePreferences: '0.9.6',
ACRA : '4.9.2',
]
}

View File

@ -118,6 +118,7 @@ dependencies {
// END Non-FOSS component
fdroidCompile "org.osmdroid:osmdroid-android:${libVersions['OSMDroid']}"
fdroidCompile "ch.acra:acra:${libVersions['ACRA']}"
debugCompile "com.facebook.stetho:stetho:${libVersions['Stetho']}"
debugCompile "com.facebook.stetho:stetho-okhttp3:${libVersions['Stetho']}"

View File

@ -17,6 +17,15 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.mariotaku.twidere">
<application
android:fullBackupContent="true"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".activity.CrashReportDialogActivity"
android:theme="@style/Theme.Twidere.NoDisplay.DayNight"/>
</application>
</manifest>

View File

@ -0,0 +1,52 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.activity
import android.os.Bundle
import android.support.v4.widget.TextViewCompat
import android.view.View
import android.widget.TextView
import org.acra.dialog.CrashReportDialog
import org.mariotaku.twidere.R
/**
* Created by mariotaku on 2017/5/8.
*/
class CrashReportDialogActivity : CrashReportDialog() {
override fun buildCustomView(savedInstanceState: Bundle?): View {
val view = super.buildCustomView(savedInstanceState)
val padding = resources.getDimensionPixelSize(R.dimen.element_spacing_large)
view.setPadding(padding, padding, padding, padding)
return view
}
override fun getMainView(): View {
val text = TextView(this)
TextViewCompat.setTextAppearance(text, android.R.style.TextAppearance_DeviceDefault_Medium)
val dialogTextId = this.config.resDialogText()
if (dialogTextId != 0) {
text.text = this.getText(dialogTextId)
}
return text
}
}

View File

@ -0,0 +1,103 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.util
import android.accounts.Account
import android.accounts.AccountManager
import android.accounts.OnAccountsUpdateListener
import android.app.Activity
import android.app.Application
import android.content.SharedPreferences
import android.os.Build
import org.acra.ACRA
import org.acra.ReportingInteractionMode
import org.acra.config.ConfigurationBuilder
import org.mariotaku.kpreferences.get
import org.mariotaku.ktextension.addOnAccountsUpdatedListenerSafe
import org.mariotaku.twidere.BuildConfig
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.ACCOUNT_TYPE
import org.mariotaku.twidere.TwidereConstants.TWIDERE_PROJECT_EMAIL
import org.mariotaku.twidere.activity.CrashReportDialogActivity
import org.mariotaku.twidere.constant.themeBackgroundAlphaKey
import org.mariotaku.twidere.constant.themeBackgroundOptionKey
import org.mariotaku.twidere.constant.themeKey
/**
* Created by mariotaku on 2017/5/8.
*/
class ACRAAnalyzer : Analyzer() {
override fun log(priority: Int, tag: String, msg: String) {
}
override fun log(event: Event) {
}
override fun logException(throwable: Throwable) {
}
override fun init(application: Application) {
val config = ConfigurationBuilder(application)
.setReportingInteractionMode(ReportingInteractionMode.DIALOG)
.setResDialogText(R.string.message_app_crashed)
.setResDialogTheme(R.style.Theme_Twidere_NoDisplay_DayNight)
.setReportDialogClass(CrashReportDialogActivity::class.java)
.setMailTo(TWIDERE_PROJECT_EMAIL)
.build()
ACRA.init(application, config)
val reporter = ACRA.getErrorReporter()
reporter.putCustomData("debug", BuildConfig.DEBUG.toString())
reporter.putCustomData("build.brand", Build.BRAND)
reporter.putCustomData("build.device", Build.DEVICE)
reporter.putCustomData("build.display", Build.DISPLAY)
reporter.putCustomData("build.hardware", Build.HARDWARE)
reporter.putCustomData("build.manufacturer", Build.MANUFACTURER)
reporter.putCustomData("build.model", Build.MODEL)
reporter.putCustomData("build.product", Build.PRODUCT)
val am = AccountManager.get(application)
try {
am.addOnAccountsUpdatedListenerSafe(OnAccountsUpdateListener { accounts ->
reporter.putCustomData("twidere.accounts", accounts.filter { it.type == ACCOUNT_TYPE }
.joinToString(transform = Account::name))
}, updateImmediately = true)
} catch (e: SecurityException) {
// Permission managers (like some Xposed plugins) may block Twidere from getting accounts
}
}
override fun preferencesChanged(preferences: SharedPreferences) {
val reporter = ACRA.getErrorReporter()
reporter.putCustomData("preferences.theme", preferences[themeKey])
reporter.putCustomData("preferences.theme_bg_option", preferences[themeBackgroundOptionKey])
reporter.putCustomData("preferences.theme_bg_alpha", preferences[themeBackgroundAlphaKey].toString())
}
override fun activityResumed(activity: Activity) {
val reporter = ACRA.getErrorReporter()
val intent = activity.intent ?: run {
reporter.putCustomData("last_activity", "null intent")
return
}
reporter.putCustomData("last_activity", "${intent.action}: ${intent.data} (${activity.javaClass.simpleName})")
}
}

View File

@ -0,0 +1,20 @@
#
# Twidere - Twitter client for Android
#
# Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
org.mariotaku.twidere.util.ACRAAnalyzer

View File

@ -615,6 +615,7 @@
<string name="message_account_delete_confirm">This account will be deleted from Twidere.</string>
<string name="message_api_data_corrupted">API data corrupted.</string>
<string name="message_api_url_format_help">[DOMAIN]: Twitter API domain.\nExample: https://[DOMAIN].twitter.com/ will be replaced to https://api.twitter.com/.</string>
<string name="message_app_crashed">Twidere has crashed. Send a bug report to help me solve this issue.</string>
<string name="message_auto_refresh_confirm">Enable auto refresh to get new tweets automatically?</string>
<string name="message_blocked_user">Blocked <xliff:g id="user">%s</xliff:g>.</string>
<string name="message_buffer_delete_schedule_confirm">Delete this schedule?</string>