From 6fe13d90997476ca2fa726d7debe13bea0311c28 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Sat, 16 Mar 2019 22:04:24 -0600 Subject: [PATCH] Added custom key to crashlytics to obtain the device language in the crash reports. --- .../fragments/ConnectedFragment.kt | 5 +++++ .../fragments/CreateAccountFragment.kt | 14 ++++++-------- .../bitsybitshareswallet/utils/Constants.kt | 3 +++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ConnectedFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ConnectedFragment.kt index a1c5346..0e2d9c1 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ConnectedFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ConnectedFragment.kt @@ -8,8 +8,10 @@ import android.os.Bundle import android.os.IBinder import android.util.Log import android.view.View +import androidx.core.os.ConfigurationCompat import androidx.fragment.app.Fragment import com.crashlytics.android.Crashlytics +import cy.agorise.bitsybitshareswallet.utils.Constants import cy.agorise.graphenej.api.ConnectionStatusUpdate import cy.agorise.graphenej.api.android.NetworkService import cy.agorise.graphenej.api.android.RxBus @@ -39,6 +41,9 @@ abstract class ConnectedFragment : Fragment(), ServiceConnection { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 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 mDisposables.add( RxBus.getBusInstance() 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 5524ccb..28f5bce 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/CreateAccountFragment.kt @@ -6,6 +6,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.collection.LongSparseArray import androidx.navigation.fragment.findNavController import com.jakewharton.rxbinding3.widget.textChanges import cy.agorise.bitsybitshareswallet.R @@ -35,7 +36,6 @@ import cy.agorise.bitsybitshareswallet.models.FaucetResponse import cy.agorise.bitsybitshareswallet.network.ServiceGenerator import retrofit2.Call import retrofit2.Response -import java.util.* class CreateAccountFragment : BaseAccountFragment() { @@ -60,7 +60,7 @@ class CreateAccountFragment : BaseAccountFragment() { private var isAccountValidAndAvailable = false // Map used to keep track of request and response id pairs - private val responseMap = HashMap() + private val responseMap = LongSparseArray() override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { setHasOptionsMenu(true) @@ -121,7 +121,7 @@ class CreateAccountFragment : BaseAccountFragment() { val id = mNetworkService?.sendMessage(GetAccountByName(accountName), GetAccountByName.REQUIRED_API) if (id != null) - responseMap[id] = RESPONSE_GET_ACCOUNT_BY_NAME_VALIDATION + responseMap.append(id, RESPONSE_GET_ACCOUNT_BY_NAME_VALIDATION) } enableDisableCreateButton() @@ -181,9 +181,7 @@ class CreateAccountFragment : BaseAccountFragment() { } } - override fun handleConnectionStatusUpdate(connectionStatusUpdate: ConnectionStatusUpdate) { - // TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } + override fun handleConnectionStatusUpdate(connectionStatusUpdate: ConnectionStatusUpdate) { } /** * 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) if (id != null) - responseMap[id] = RESPONSE_GET_ACCOUNT_BY_NAME_CREATED + responseMap.append(id, RESPONSE_GET_ACCOUNT_BY_NAME_CREATED) } else { Log.d(TAG, "Private account creation failed ") val content = if (faucetResponse?.error?.base?.size ?: 0 > 0) { @@ -287,7 +285,7 @@ class CreateAccountFragment : BaseAccountFragment() { mBrainKey = BrainKey(brainKeySuggestion, 0) val address = Address(ECKey.fromPublicOnly(mBrainKey?.privateKey?.pubKey)) Log.d(TAG, "brain key: $brainKeySuggestion") - Log.d(TAG, "address would be: " + address.toString()) + Log.d(TAG, "address would be: $address") mAddress = address.toString() tvBrainKey.text = mBrainKey?.brainKey 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 4a7cd0e..bb01c6e 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/utils/Constants.kt @@ -127,4 +127,7 @@ object Constants { /** Key used to add the last visited fragment name to the Crashlytics report */ 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" }