diff options
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/UserPreference.kt | 2 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index bce432ea..469e3773 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -481,7 +481,7 @@ class UserPreference : AppCompatActivity() { // TODO: This is fragile. Workaround until PasswordItem is backed by DocumentFile val docId = DocumentsContract.getTreeDocumentId(uri) val split = docId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() - val repoPath = "${Environment.getExternalStorageDirectory()}/${split[1]}" + val repoPath = "${Environment.getExternalStorageDirectory()}/${split[1] ?: split[0]}" Timber.tag(TAG).d("Selected repository path is $repoPath") diff --git a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt index a44b3599..e3395d41 100644 --- a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/ShowSshKeyFragment.kt @@ -22,18 +22,17 @@ import org.apache.commons.io.FileUtils class ShowSshKeyFragment : DialogFragment() { - private lateinit var activity: SshKeyGenActivity private lateinit var builder: MaterialAlertDialogBuilder private lateinit var publicKey: TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - activity = requireActivity() as SshKeyGenActivity - builder = MaterialAlertDialogBuilder(activity) + builder = MaterialAlertDialogBuilder(requireActivity()) } @SuppressLint("InflateParams") override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + val activity = requireActivity() val view = activity.layoutInflater.inflate(R.layout.fragment_show_ssh_key, null) publicKey = view.findViewById(R.id.public_key) readKeyFromFile() @@ -53,13 +52,13 @@ class ShowSshKeyFragment : DialogFragment() { private fun createMaterialDialog(view: View) { builder.setView(view) builder.setTitle(getString(R.string.your_public_key)) - builder.setPositiveButton(getString(R.string.dialog_ok)) { _, _ -> activity.finish() } + builder.setPositiveButton(getString(R.string.dialog_ok)) { _, _ -> requireActivity().finish() } builder.setNegativeButton(getString(R.string.dialog_cancel), null) builder.setNeutralButton(resources.getString(R.string.ssh_keygen_copy), null) } private fun readKeyFromFile() { - val file = File(activity.filesDir.toString() + "/.ssh_key.pub") + val file = File(requireActivity().filesDir.toString() + "/.ssh_key.pub") try { publicKey.text = FileUtils.readFileToString(file, StandardCharsets.UTF_8) } catch (e: Exception) { |