Added Crashlytics custom key so that the crash reports include the last visited screen, that could help track crashes where the crash report alone does not include enough information.

This commit is contained in:
Severiano Jaramillo 2019-02-21 11:16:04 -06:00
parent 29c85d3d3c
commit 3c0c3a5114
14 changed files with 60 additions and 1 deletions

View file

@ -29,6 +29,7 @@ import java.io.IOException
import java.io.InputStreamReader import java.io.InputStreamReader
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.models.FaucetRequest import cy.agorise.bitsybitshareswallet.models.FaucetRequest
import cy.agorise.bitsybitshareswallet.models.FaucetResponse import cy.agorise.bitsybitshareswallet.models.FaucetResponse
import cy.agorise.bitsybitshareswallet.network.ServiceGenerator import cy.agorise.bitsybitshareswallet.network.ServiceGenerator
@ -70,6 +71,8 @@ class CreateAccountFragment : BaseAccountFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Use RxJava Debounce to check the validity and availability of the user's proposed account name // Use RxJava Debounce to check the validity and availability of the user's proposed account name
mDisposables.add( mDisposables.add(
tietAccountName.textChanges() tietAccountName.textChanges()

View file

@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import androidx.navigation.fragment.navArgs import androidx.navigation.fragment.navArgs
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail
@ -32,6 +33,8 @@ import java.util.*
class EReceiptFragment : Fragment() { class EReceiptFragment : Fragment() {
companion object { companion object {
private const val TAG = "EReceiptFragment"
private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100 private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100
} }
@ -49,6 +52,8 @@ class EReceiptFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
mLocale = ConfigurationCompat.getLocales(resources.configuration)[0] mLocale = ConfigurationCompat.getLocales(resources.configuration)[0]
val userId = PreferenceManager.getDefaultSharedPreferences(context) val userId = PreferenceManager.getDefaultSharedPreferences(context)

View file

@ -14,9 +14,11 @@ import androidx.core.os.ConfigurationCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.adapters.BalancesDetailsAdapter import cy.agorise.bitsybitshareswallet.adapters.BalancesDetailsAdapter
import cy.agorise.bitsybitshareswallet.database.joins.BalanceDetail import cy.agorise.bitsybitshareswallet.database.joins.BalanceDetail
import cy.agorise.bitsybitshareswallet.utils.Constants
import cy.agorise.bitsybitshareswallet.viewmodels.BalanceDetailViewModel import cy.agorise.bitsybitshareswallet.viewmodels.BalanceDetailViewModel
import cy.agorise.bitsybitshareswallet.views.DatePickerFragment import cy.agorise.bitsybitshareswallet.views.DatePickerFragment
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -32,6 +34,7 @@ import kotlin.collections.ArrayList
class FilterOptionsDialog : DialogFragment() { class FilterOptionsDialog : DialogFragment() {
companion object { companion object {
private const val TAG = "FilterOptionsDialog"
const val KEY_FILTER_TRANSACTION_DIRECTION = "key_filter_transaction_direction" const val KEY_FILTER_TRANSACTION_DIRECTION = "key_filter_transaction_direction"
const val KEY_FILTER_DATE_RANGE_ALL = "key_filter_date_range_all" const val KEY_FILTER_DATE_RANGE_ALL = "key_filter_date_range_all"
@ -167,6 +170,8 @@ class FilterOptionsDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
onAttachToParentFragment(parentFragment!!) onAttachToParentFragment(parentFragment!!)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Initialize handler for communication with the DatePicker // Initialize handler for communication with the DatePicker
mDatePickerHandler = DatePickerHandler() mDatePickerHandler = DatePickerHandler()

View file

@ -20,10 +20,15 @@ import cy.agorise.bitsybitshareswallet.utils.Constants
import cy.agorise.bitsybitshareswallet.viewmodels.UserAccountViewModel import cy.agorise.bitsybitshareswallet.viewmodels.UserAccountViewModel
import kotlinx.android.synthetic.main.fragment_home.* import kotlinx.android.synthetic.main.fragment_home.*
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.crashlytics.android.Crashlytics
class HomeFragment : Fragment() { class HomeFragment : Fragment() {
companion object {
private const val TAG ="HomeFragment"
}
private lateinit var mUserAccountViewModel: UserAccountViewModel private lateinit var mUserAccountViewModel: UserAccountViewModel
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
@ -56,6 +61,8 @@ class HomeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Get version number of the last agreed license version // Get version number of the last agreed license version
val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context) val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context)
.getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) .getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0)

View file

@ -14,6 +14,7 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.callbacks.onDismiss import com.afollestad.materialdialogs.callbacks.onDismiss
import com.afollestad.materialdialogs.list.customListAdapter import com.afollestad.materialdialogs.list.customListAdapter
import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.crashlytics.android.Crashlytics
import com.jakewharton.rxbinding3.widget.textChanges import com.jakewharton.rxbinding3.widget.textChanges
import cy.agorise.bitsybitshareswallet.BuildConfig import cy.agorise.bitsybitshareswallet.BuildConfig
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
@ -82,6 +83,8 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Use RxJava Debounce to update the PIN error only after the user stops writing for > 500 ms // Use RxJava Debounce to update the PIN error only after the user stops writing for > 500 ms
mDisposables.add( mDisposables.add(
tietPin.textChanges() tietPin.textChanges()

View file

@ -8,12 +8,17 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.Constants
import kotlinx.android.synthetic.main.fragment_license.* import kotlinx.android.synthetic.main.fragment_license.*
class LicenseFragment : Fragment() { class LicenseFragment : Fragment() {
companion object {
private const val TAG = "LicenseFragment"
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Remove up navigation icon from the toolbar // Remove up navigation icon from the toolbar
val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar) val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar)
@ -25,6 +30,8 @@ class LicenseFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Get version number of the last agreed license version // Get version number of the last agreed license version
val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context) val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context)
.getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) .getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0)

View file

@ -22,6 +22,7 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import com.crashlytics.android.Crashlytics
import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback import com.google.android.gms.maps.OnMapReadyCallback
@ -123,6 +124,8 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Dynamically obtain status bar and navigation bar heights, and account for the status bar height to add // Dynamically obtain status bar and navigation bar heights, and account for the status bar height to add
// the correct top margin to the Toolbar and place it just below the status bar // the correct top margin to the Toolbar and place it just below the status bar
view.setOnApplyWindowInsetsListener { v, insets -> view.setOnApplyWindowInsetsListener { v, insets ->

View file

@ -7,6 +7,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import com.crashlytics.android.Crashlytics
import com.jakewharton.rxbinding3.widget.textChanges import com.jakewharton.rxbinding3.widget.textChanges
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.Constants
@ -34,6 +35,8 @@ class PINSecurityLockDialog : BaseSecurityLockDialog() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Request focus to the PIN EditText and automatically show the keyboard when the dialog appears. // Request focus to the PIN EditText and automatically show the keyboard when the dialog appears.
tietPIN.requestFocus() tietPIN.requestFocus()
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

View file

@ -9,6 +9,7 @@ import cy.agorise.bitsybitshareswallet.R
import kotlinx.android.synthetic.main.dialog_pattern_security_lock.* import kotlinx.android.synthetic.main.dialog_pattern_security_lock.*
import com.andrognito.patternlockview.PatternLockView import com.andrognito.patternlockview.PatternLockView
import com.andrognito.patternlockview.listener.PatternLockViewListener import com.andrognito.patternlockview.listener.PatternLockViewListener
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.Constants
import cy.agorise.bitsybitshareswallet.utils.CryptoUtils import cy.agorise.bitsybitshareswallet.utils.CryptoUtils
@ -32,6 +33,8 @@ class PatternSecurityLockDialog : BaseSecurityLockDialog() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
setupScreen() setupScreen()
patternLockView.addPatternLockListener(mPatternLockViewListener) patternLockView.addPatternLockListener(mPatternLockViewListener)

View file

@ -15,6 +15,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import com.crashlytics.android.Crashlytics
import com.google.common.primitives.UnsignedLong import com.google.common.primitives.UnsignedLong
import com.google.zxing.BarcodeFormat import com.google.zxing.BarcodeFormat
import com.google.zxing.EncodeHintType import com.google.zxing.EncodeHintType
@ -101,6 +102,8 @@ class ReceiveTransactionFragment : ConnectedFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
// Configure UserAccountViewModel to show the current account // Configure UserAccountViewModel to show the current account
mUserAccountViewModel = ViewModelProviders.of(this).get(UserAccountViewModel::class.java) mUserAccountViewModel = ViewModelProviders.of(this).get(UserAccountViewModel::class.java)

View file

@ -17,6 +17,7 @@ import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs import androidx.navigation.fragment.navArgs
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import com.crashlytics.android.Crashlytics
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.common.primitives.UnsignedLong import com.google.common.primitives.UnsignedLong
import com.google.zxing.BarcodeFormat import com.google.zxing.BarcodeFormat
@ -132,6 +133,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
val userId = PreferenceManager.getDefaultSharedPreferences(context) val userId = PreferenceManager.getDefaultSharedPreferences(context)
.getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: "" .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: ""

View file

@ -15,6 +15,7 @@ import com.afollestad.materialdialogs.callbacks.onDismiss
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.list.customListAdapter import com.afollestad.materialdialogs.list.customListAdapter
import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.BuildConfig import cy.agorise.bitsybitshareswallet.BuildConfig
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.adapters.FullNodesAdapter import cy.agorise.bitsybitshareswallet.adapters.FullNodesAdapter
@ -71,6 +72,8 @@ class SettingsFragment : Fragment(), ServiceConnection, BaseSecurityLockDialog.O
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
initAutoCloseSwitch() initAutoCloseSwitch()
initNightModeSwitch() initNightModeSwitch()

View file

@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.crashlytics.android.Crashlytics
import com.jakewharton.rxbinding3.appcompat.queryTextChangeEvents import com.jakewharton.rxbinding3.appcompat.queryTextChangeEvents
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
import cy.agorise.bitsybitshareswallet.adapters.TransfersDetailsAdapter import cy.agorise.bitsybitshareswallet.adapters.TransfersDetailsAdapter
@ -33,6 +34,8 @@ import kotlin.collections.ArrayList
class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSelectedListener { class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSelectedListener {
companion object { companion object {
private const val TAG = "TransactionsFragment"
private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100 private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100
} }
@ -67,6 +70,8 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG)
val userId = PreferenceManager.getDefaultSharedPreferences(context) val userId = PreferenceManager.getDefaultSharedPreferences(context)
.getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: "" .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: ""
@ -175,7 +180,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
if (!filterAssetAll && transferDetail.assetSymbol != filterAsset) if (!filterAssetAll && transferDetail.assetSymbol != filterAsset)
continue continue
// // Filter by equivalent value // Filter by equivalent value
if (!filterEquivalentValueAll && ((transferDetail.fiatAmount ?: -1 ) < filterFromEquivalentValue if (!filterEquivalentValueAll && ((transferDetail.fiatAmount ?: -1 ) < filterFromEquivalentValue
|| (transferDetail.fiatAmount ?: -1) > filterToEquivalentValue)) || (transferDetail.fiatAmount ?: -1) > filterToEquivalentValue))
continue continue

View file

@ -121,4 +121,10 @@ object Constants {
/** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/ /** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/
const val EXTERNAL_STORAGE_FOLDER = "BiTSy" const val EXTERNAL_STORAGE_FOLDER = "BiTSy"
/////////////////////// Crashlytics custom keys ///////////////////////
/** Key used to add the last visited fragment name to the Crashlytics report */
const val CRASHLYTICS_KEY_LAST_SCREEN = "crashlytics_key_last_screen"
} }