Skip to content

Commit

Permalink
ssh: sshkeys instant view refresh (fixes #1303) (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyeh123 authored Aug 14, 2020
1 parent e604da8 commit 974be27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.treehouses.remote.Fragments.DialogFragments

import android.content.DialogInterface
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -18,6 +17,7 @@ class DeleteSSHKey : FullScreenDialogFragment() {
}
private lateinit var bind : DialogDeleteSshKeyBinding
private lateinit var keyToDelete : String
private lateinit var dismissListener : DialogInterface.OnDismissListener

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
bind = DialogDeleteSshKeyBinding.inflate(inflater, container, false)
Expand All @@ -40,7 +40,7 @@ class DeleteSSHKey : FullScreenDialogFragment() {
bind.deleteButton.setOnClickListener {
if (bind.deleteKeyConfirmation.text.toString() == keyToDelete) {
KeyUtils.deleteKey(requireContext(), keyToDelete)
Toast.makeText(requireContext(), "Deleted $keyToDelete. Please Refresh Screen to see changes.", Toast.LENGTH_LONG).show()
Toast.makeText(requireContext(), "Deleted $keyToDelete.", Toast.LENGTH_LONG).show()
dismiss()
}
}
Expand All @@ -55,4 +55,13 @@ class DeleteSSHKey : FullScreenDialogFragment() {
bind.deleteButton.isClickable = bool
}

fun setOnDismissListener(dl: DialogInterface.OnDismissListener) {
dismissListener = dl
}

override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (dismissListener != null) dismissListener.onDismiss(dialog)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.treehouses.remote.Fragments.DialogFragments
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -92,6 +93,7 @@ class SSHAllKeys : FullScreenDialogFragment(), KeyMenuListener {
putString(DeleteSSHKey.KEY_TO_DELETE, allKeys[position].nickname)
}
}
dialog.setOnDismissListener(DialogInterface.OnDismissListener { setUpKeys() })
dialog.show(parentFragmentManager, "Delete_key")
}

Expand Down

0 comments on commit 974be27

Please sign in to comment.