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) {
//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<List<UserAccount>>
val accountList: List<UserAccount> = resp[0].distinct()