aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.kt10
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