ability to add distrusted contacts

reproducible
Zlatin Balevsky 2021-04-30 12:24:35 +01:00
parent b4c4dca953
commit bc7aec00c1
No known key found for this signature in database
GPG Key ID: A72832072D525E41
3 changed files with 16 additions and 1 deletions

View File

@ -27,7 +27,8 @@ class AddContactController {
Persona p
try {
p = new Persona(new ByteArrayInputStream(Base64.decode(text)))
TrustEvent e = new TrustEvent(persona : p, level : TrustLevel.TRUSTED, reason : view.reasonArea.getText())
TrustLevel tl = model.trusted ? TrustLevel.TRUSTED : TrustLevel.DISTRUSTED
TrustEvent e = new TrustEvent(persona : p, level : tl, reason : view.reasonArea.getText())
model.core.eventBus.publish(e)
cancel()
} catch (Exception e) {

View File

@ -9,4 +9,5 @@ import griffon.metadata.ArtifactProviderFor
@ArtifactProviderFor(GriffonModel)
class AddContactModel {
Core core
@Observable boolean trusted = true
}

View File

@ -2,6 +2,8 @@ package com.muwire.gui
import griffon.core.artifact.GriffonView
import java.awt.event.ActionListener
import static com.muwire.gui.Translator.trans
import java.awt.BorderLayout
@ -54,6 +56,9 @@ class AddContactView {
reasonArea = textArea(editable : true, lineWrap : true, wrapStyleWord : true)
}
panel(constraints : BorderLayout.SOUTH) {
buttonGroup(id : "trustLevel")
radioButton(text : trans("TRUSTED"), selected : bind {model.trusted}, buttonGroup : trustLevel, actionPerformed : setTrusted )
radioButton(text : trans("DISTRUSTED"), selected : bind {!model.trusted}, buttonGroup: trustLevel, actionPerformed : setDistrusted )
button(text : trans("ADD_CONTACT_SPECIFIC"), addAction)
button(text : trans("CANCEL"), cancelAction)
}
@ -73,4 +78,12 @@ class AddContactView {
})
dialog.show()
}
def setTrusted = {
model.trusted = true
}
def setDistrusted = {
model.trusted = false
}
}