diff options
author | Mohamed Zenadi <mohamed@zenadi.com> | 2017-07-25 17:27:48 +0100 |
---|---|---|
committer | Mohamed Zenadi <zeapo@users.noreply.github.com> | 2017-08-10 11:10:29 +0200 |
commit | 7cb474804b0cbb42895d1a69e7d8422d6a16c4c5 (patch) | |
tree | 2a912f1b8e4c0484107d30b20697ebeb3432c95f /app/src/main/java | |
parent | 2f75559ac286b755d96ca145be4183cdb851c8b3 (diff) |
get rid of double bang
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/UserPreference.kt | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index e288ade3..725339a8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -334,9 +334,13 @@ class UserPreference : AppCompatActivity() { @Throws(IOException::class) private fun copySshKey(uri: Uri) { val sshKey = this.contentResolver.openInputStream(uri) - val privateKey = IOUtils.toByteArray(sshKey!!) - FileUtils.writeByteArrayToFile(File(filesDir.toString() + "/.ssh_key"), privateKey) - sshKey.close() + if (sshKey != null) { + val privateKey = IOUtils.toByteArray(sshKey) + FileUtils.writeByteArrayToFile(File(filesDir.toString() + "/.ssh_key"), privateKey) + sshKey.close() + } else { + Toast.makeText(this, "Unable to open the ssh private key, please check that the file exists", Toast.LENGTH_LONG).show() + } } // Returns whether the autofill service is enabled |