Added custom key to crashlytics to obtain the device language in the crash reports.

This commit is contained in:
Severiano Jaramillo 2019-03-16 22:04:24 -06:00
parent 0e11c67dfd
commit 6fe13d9099
3 changed files with 14 additions and 8 deletions

View file

@ -8,8 +8,10 @@ import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import androidx.core.os.ConfigurationCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import cy.agorise.bitsybitshareswallet.utils.Constants
import cy.agorise.graphenej.api.ConnectionStatusUpdate import cy.agorise.graphenej.api.ConnectionStatusUpdate
import cy.agorise.graphenej.api.android.NetworkService import cy.agorise.graphenej.api.android.NetworkService
import cy.agorise.graphenej.api.android.RxBus import cy.agorise.graphenej.api.android.RxBus
@ -39,6 +41,9 @@ abstract class ConnectedFragment : Fragment(), ServiceConnection {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val locale = ConfigurationCompat.getLocales(resources.configuration)[0]
Crashlytics.setString(Constants.CRASHLYTICS_KEY_LANGUAGE, locale.displayName)
// Connect to the RxBus, which receives events from the NetworkService // Connect to the RxBus, which receives events from the NetworkService
mDisposables.add( mDisposables.add(
RxBus.getBusInstance() RxBus.getBusInstance()

View file

@ -6,6 +6,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.collection.LongSparseArray
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.jakewharton.rxbinding3.widget.textChanges import com.jakewharton.rxbinding3.widget.textChanges
import cy.agorise.bitsybitshareswallet.R import cy.agorise.bitsybitshareswallet.R
@ -35,7 +36,6 @@ import cy.agorise.bitsybitshareswallet.models.FaucetResponse
import cy.agorise.bitsybitshareswallet.network.ServiceGenerator import cy.agorise.bitsybitshareswallet.network.ServiceGenerator
import retrofit2.Call import retrofit2.Call
import retrofit2.Response import retrofit2.Response
import java.util.*
class CreateAccountFragment : BaseAccountFragment() { class CreateAccountFragment : BaseAccountFragment() {
@ -60,7 +60,7 @@ class CreateAccountFragment : BaseAccountFragment() {
private var isAccountValidAndAvailable = false private var isAccountValidAndAvailable = false
// Map used to keep track of request and response id pairs // Map used to keep track of request and response id pairs
private val responseMap = HashMap<Long, Int>() private val responseMap = LongSparseArray<Int>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
setHasOptionsMenu(true) setHasOptionsMenu(true)
@ -121,7 +121,7 @@ class CreateAccountFragment : BaseAccountFragment() {
val id = mNetworkService?.sendMessage(GetAccountByName(accountName), GetAccountByName.REQUIRED_API) val id = mNetworkService?.sendMessage(GetAccountByName(accountName), GetAccountByName.REQUIRED_API)
if (id != null) if (id != null)
responseMap[id] = RESPONSE_GET_ACCOUNT_BY_NAME_VALIDATION responseMap.append(id, RESPONSE_GET_ACCOUNT_BY_NAME_VALIDATION)
} }
enableDisableCreateButton() enableDisableCreateButton()
@ -181,9 +181,7 @@ class CreateAccountFragment : BaseAccountFragment() {
} }
} }
override fun handleConnectionStatusUpdate(connectionStatusUpdate: ConnectionStatusUpdate) { override fun handleConnectionStatusUpdate(connectionStatusUpdate: ConnectionStatusUpdate) { }
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
/** /**
* Handles the response from the NetworkService's GetAccountByName call to decide if the user's suggested * Handles the response from the NetworkService's GetAccountByName call to decide if the user's suggested
@ -257,7 +255,7 @@ class CreateAccountFragment : BaseAccountFragment() {
GetAccountByName.REQUIRED_API) GetAccountByName.REQUIRED_API)
if (id != null) if (id != null)
responseMap[id] = RESPONSE_GET_ACCOUNT_BY_NAME_CREATED responseMap.append(id, RESPONSE_GET_ACCOUNT_BY_NAME_CREATED)
} else { } else {
Log.d(TAG, "Private account creation failed ") Log.d(TAG, "Private account creation failed ")
val content = if (faucetResponse?.error?.base?.size ?: 0 > 0) { val content = if (faucetResponse?.error?.base?.size ?: 0 > 0) {
@ -287,7 +285,7 @@ class CreateAccountFragment : BaseAccountFragment() {
mBrainKey = BrainKey(brainKeySuggestion, 0) mBrainKey = BrainKey(brainKeySuggestion, 0)
val address = Address(ECKey.fromPublicOnly(mBrainKey?.privateKey?.pubKey)) val address = Address(ECKey.fromPublicOnly(mBrainKey?.privateKey?.pubKey))
Log.d(TAG, "brain key: $brainKeySuggestion") Log.d(TAG, "brain key: $brainKeySuggestion")
Log.d(TAG, "address would be: " + address.toString()) Log.d(TAG, "address would be: $address")
mAddress = address.toString() mAddress = address.toString()
tvBrainKey.text = mBrainKey?.brainKey tvBrainKey.text = mBrainKey?.brainKey

View file

@ -127,4 +127,7 @@ object Constants {
/** Key used to add the last visited fragment name to the Crashlytics report */ /** Key used to add the last visited fragment name to the Crashlytics report */
const val CRASHLYTICS_KEY_LAST_SCREEN = "crashlytics_key_last_screen" const val CRASHLYTICS_KEY_LAST_SCREEN = "crashlytics_key_last_screen"
/** Key used to add the device language to the Crashlytics report */
const val CRASHLYTICS_KEY_LANGUAGE = "crashlytics_key_language"
} }