From 7165df42cb6d916f199082951f0d028e482b3015 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 16 Jan 2019 09:02:18 -0600 Subject: [PATCH] Fix crash when in ImportBrainkeyFragment when the user tries to import an account with an incorrect BrainKey. Also, removed trailing spaces from the written BrainKey before proceeding to verify it. --- .../fragments/ImportBrainkeyFragment.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 b47b5f2..690e727 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt @@ -208,7 +208,7 @@ class ImportBrainkeyFragment : BaseAccountFragment() { */ private fun verifyBrainKey(switchCase: Boolean) { //showDialog("", getString(R.string.importing_your_wallet)) - val brainKey = tietBrainKey.text.toString() + val brainKey = tietBrainKey.text.toString().trim() // Should we switch the brainkey case? if (switchCase) { if (Character.isUpperCase(brainKey.toCharArray()[brainKey.length - 1])) { @@ -262,13 +262,10 @@ class ImportBrainkeyFragment : BaseAccountFragment() { * specified BrainKey */ private fun handleBrainKeyAccountReferences(result: Any?) { - if (result !is List<*>) - return - - val list = result[0] as? List<*> ?: return - - if (list[0] !is UserAccount) + if (result !is List<*> || result[0] !is List<*>) { + context?.toast(getString(R.string.error__invalid_brainkey)) return + } val resp = result as List> val accountList: List = resp[0].distinct()