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.

This commit is contained in:
Severiano Jaramillo 2019-01-16 09:02:18 -06:00
parent 887d9a249f
commit 7165df42cb

View file

@ -208,7 +208,7 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
*/ */
private fun verifyBrainKey(switchCase: Boolean) { private fun verifyBrainKey(switchCase: Boolean) {
//showDialog("", getString(R.string.importing_your_wallet)) //showDialog("", getString(R.string.importing_your_wallet))
val brainKey = tietBrainKey.text.toString() val brainKey = tietBrainKey.text.toString().trim()
// Should we switch the brainkey case? // Should we switch the brainkey case?
if (switchCase) { if (switchCase) {
if (Character.isUpperCase(brainKey.toCharArray()[brainKey.length - 1])) { if (Character.isUpperCase(brainKey.toCharArray()[brainKey.length - 1])) {
@ -262,13 +262,10 @@ class ImportBrainkeyFragment : BaseAccountFragment() {
* specified BrainKey * specified BrainKey
*/ */
private fun handleBrainKeyAccountReferences(result: Any?) { private fun handleBrainKeyAccountReferences(result: Any?) {
if (result !is List<*>) if (result !is List<*> || result[0] !is List<*>) {
return context?.toast(getString(R.string.error__invalid_brainkey))
val list = result[0] as? List<*> ?: return
if (list[0] !is UserAccount)
return return
}
val resp = result as List<List<UserAccount>> val resp = result as List<List<UserAccount>>
val accountList: List<UserAccount> = resp[0].distinct() val accountList: List<UserAccount> = resp[0].distinct()