From 3c0c3a51149f2bd1c743c93d1e2655841292e9a4 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 21 Feb 2019 11:16:04 -0600 Subject: [PATCH] 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. --- .../fragments/CreateAccountFragment.kt | 3 +++ .../bitsybitshareswallet/fragments/EReceiptFragment.kt | 5 +++++ .../bitsybitshareswallet/fragments/FilterOptionsDialog.kt | 5 +++++ .../agorise/bitsybitshareswallet/fragments/HomeFragment.kt | 7 +++++++ .../fragments/ImportBrainkeyFragment.kt | 3 +++ .../bitsybitshareswallet/fragments/LicenseFragment.kt | 7 +++++++ .../bitsybitshareswallet/fragments/MerchantsFragment.kt | 3 +++ .../fragments/PINSecurityLockDialog.kt | 3 +++ .../fragments/PatternSecurityLockDialog.kt | 3 +++ .../fragments/ReceiveTransactionFragment.kt | 3 +++ .../fragments/SendTransactionFragment.kt | 3 +++ .../bitsybitshareswallet/fragments/SettingsFragment.kt | 3 +++ .../bitsybitshareswallet/fragments/TransactionsFragment.kt | 7 ++++++- .../cy/agorise/bitsybitshareswallet/utils/Constants.kt | 6 ++++++ 14 files changed, 60 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt index 467c7ed..5524ccb 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt @@ -29,6 +29,7 @@ import java.io.IOException import java.io.InputStreamReader import java.util.concurrent.TimeUnit import com.afollestad.materialdialogs.MaterialDialog +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.models.FaucetRequest import cy.agorise.bitsybitshareswallet.models.FaucetResponse import cy.agorise.bitsybitshareswallet.network.ServiceGenerator @@ -70,6 +71,8 @@ class CreateAccountFragment : BaseAccountFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 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 mDisposables.add( tietAccountName.textChanges() diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt index 882d3c8..20cfd9f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/EReceiptFragment.kt @@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import androidx.navigation.fragment.navArgs +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.database.joins.TransferDetail @@ -32,6 +33,8 @@ import java.util.* class EReceiptFragment : Fragment() { companion object { + private const val TAG = "EReceiptFragment" + private const val REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION = 100 } @@ -49,6 +52,8 @@ class EReceiptFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + mLocale = ConfigurationCompat.getLocales(resources.configuration)[0] val userId = PreferenceManager.getDefaultSharedPreferences(context) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt index 2029ee0..86bae06 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/FilterOptionsDialog.kt @@ -14,9 +14,11 @@ import androidx.core.os.ConfigurationCompat import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.Observer +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.adapters.BalancesDetailsAdapter import cy.agorise.bitsybitshareswallet.database.joins.BalanceDetail +import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.viewmodels.BalanceDetailViewModel import cy.agorise.bitsybitshareswallet.views.DatePickerFragment import java.text.SimpleDateFormat @@ -32,6 +34,7 @@ import kotlin.collections.ArrayList class FilterOptionsDialog : DialogFragment() { companion object { + private const val TAG = "FilterOptionsDialog" const val KEY_FILTER_TRANSACTION_DIRECTION = "key_filter_transaction_direction" 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 { onAttachToParentFragment(parentFragment!!) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + // Initialize handler for communication with the DatePicker mDatePickerHandler = DatePickerHandler() diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt index 23d9bef..0bbc399 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/HomeFragment.kt @@ -20,10 +20,15 @@ import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.viewmodels.UserAccountViewModel import kotlinx.android.synthetic.main.fragment_home.* import androidx.appcompat.app.AppCompatActivity +import com.crashlytics.android.Crashlytics class HomeFragment : Fragment() { + companion object { + private const val TAG ="HomeFragment" + } + private lateinit var mUserAccountViewModel: UserAccountViewModel override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -56,6 +61,8 @@ class HomeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + // Get version number of the last agreed license version val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context) .getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt index 9160775..7c9f034 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt @@ -14,6 +14,7 @@ import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.callbacks.onDismiss import com.afollestad.materialdialogs.list.customListAdapter import com.afollestad.materialdialogs.list.listItemsSingleChoice +import com.crashlytics.android.Crashlytics import com.jakewharton.rxbinding3.widget.textChanges import cy.agorise.bitsybitshareswallet.BuildConfig import cy.agorise.bitsybitshareswallet.R @@ -82,6 +83,8 @@ class ImportBrainkeyFragment : BaseAccountFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 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 mDisposables.add( tietPin.textChanges() diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/LicenseFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/LicenseFragment.kt index 0d4a584..368d24a 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/LicenseFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/LicenseFragment.kt @@ -8,12 +8,17 @@ import android.view.ViewGroup import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.utils.Constants import kotlinx.android.synthetic.main.fragment_license.* class LicenseFragment : Fragment() { + companion object { + private const val TAG = "LicenseFragment" + } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { // Remove up navigation icon from the toolbar val toolbar: Toolbar? = activity?.findViewById(R.id.toolbar) @@ -25,6 +30,8 @@ class LicenseFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + // Get version number of the last agreed license version val agreedLicenseVersion = PreferenceManager.getDefaultSharedPreferences(context) .getInt(Constants.KEY_LAST_AGREED_LICENSE_VERSION, 0) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt index a5f5c58..5091b59 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/MerchantsFragment.kt @@ -22,6 +22,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.customview.customView +import com.crashlytics.android.Crashlytics import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.OnMapReadyCallback @@ -123,6 +124,8 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 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 // the correct top margin to the Toolbar and place it just below the status bar view.setOnApplyWindowInsetsListener { v, insets -> diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PINSecurityLockDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PINSecurityLockDialog.kt index ed2f28d..b85330f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PINSecurityLockDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PINSecurityLockDialog.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import android.view.inputmethod.EditorInfo +import com.crashlytics.android.Crashlytics import com.jakewharton.rxbinding3.widget.textChanges import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.utils.Constants @@ -34,6 +35,8 @@ class PINSecurityLockDialog : BaseSecurityLockDialog() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 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. tietPIN.requestFocus() dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt index 4a1de16..b28607e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/PatternSecurityLockDialog.kt @@ -9,6 +9,7 @@ import cy.agorise.bitsybitshareswallet.R import kotlinx.android.synthetic.main.dialog_pattern_security_lock.* import com.andrognito.patternlockview.PatternLockView import com.andrognito.patternlockview.listener.PatternLockViewListener +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.bitsybitshareswallet.utils.CryptoUtils @@ -32,6 +33,8 @@ class PatternSecurityLockDialog : BaseSecurityLockDialog() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + setupScreen() patternLockView.addPatternLockListener(mPatternLockViewListener) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt index 562323e..a27e9be 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt @@ -15,6 +15,7 @@ import androidx.appcompat.widget.Toolbar import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders +import com.crashlytics.android.Crashlytics import com.google.common.primitives.UnsignedLong import com.google.zxing.BarcodeFormat import com.google.zxing.EncodeHintType @@ -101,6 +102,8 @@ class ReceiveTransactionFragment : ConnectedFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + // Configure UserAccountViewModel to show the current account mUserAccountViewModel = ViewModelProviders.of(this).get(UserAccountViewModel::class.java) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt index 58bb546..5ae30a6 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SendTransactionFragment.kt @@ -17,6 +17,7 @@ import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.customview.customView +import com.crashlytics.android.Crashlytics import com.google.android.material.snackbar.Snackbar import com.google.common.primitives.UnsignedLong import com.google.zxing.BarcodeFormat @@ -132,6 +133,8 @@ class SendTransactionFragment : ConnectedFragment(), ZXingScannerView.ResultHand override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + val userId = PreferenceManager.getDefaultSharedPreferences(context) .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: "" diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SettingsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SettingsFragment.kt index 571f452..2cafe0b 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SettingsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/SettingsFragment.kt @@ -15,6 +15,7 @@ import com.afollestad.materialdialogs.callbacks.onDismiss import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.list.customListAdapter import com.afollestad.materialdialogs.list.listItemsSingleChoice +import com.crashlytics.android.Crashlytics import cy.agorise.bitsybitshareswallet.BuildConfig import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.adapters.FullNodesAdapter @@ -71,6 +72,8 @@ class SettingsFragment : Fragment(), ServiceConnection, BaseSecurityLockDialog.O override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + initAutoCloseSwitch() initNightModeSwitch() diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt index 64d318c..9f3e988 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt @@ -16,6 +16,7 @@ import androidx.lifecycle.ViewModelProviders import androidx.recyclerview.widget.LinearLayoutManager import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.list.listItemsMultiChoice +import com.crashlytics.android.Crashlytics import com.jakewharton.rxbinding3.appcompat.queryTextChangeEvents import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.adapters.TransfersDetailsAdapter @@ -33,6 +34,8 @@ import kotlin.collections.ArrayList class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSelectedListener { companion object { + private const val TAG = "TransactionsFragment" + 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?) { super.onViewCreated(view, savedInstanceState) + Crashlytics.setString(Constants.CRASHLYTICS_KEY_LAST_SCREEN, TAG) + val userId = PreferenceManager.getDefaultSharedPreferences(context) .getString(Constants.KEY_CURRENT_ACCOUNT_ID, "") ?: "" @@ -175,7 +180,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele if (!filterAssetAll && transferDetail.assetSymbol != filterAsset) continue -// // Filter by equivalent value + // Filter by equivalent value if (!filterEquivalentValueAll && ((transferDetail.fiatAmount ?: -1 ) < filterFromEquivalentValue || (transferDetail.fiatAmount ?: -1) > filterToEquivalentValue)) continue diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt index 25167e1..4a7cd0e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt @@ -121,4 +121,10 @@ object Constants { /** Name of the external storage folder used to save files like PDF and CSV exports and Backups **/ 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" }