X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2Fpanes%2FContactDetails.java;h=06c88fc9ec02a66f71011f6842ecb54d6e1e0603;hb=6b6a62ca3293ed5f52ee07ee3d39e920d42ba887;hp=8aeac19f27002419035c58ba6218cf36a692bc82;hpb=f82bad11bbabc89805a5a8000f59a3b1df3e5c3d;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java index 8aeac19..06c88fc 100644 --- a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java +++ b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java @@ -1,10 +1,10 @@ package be.nikiroo.jvcard.tui.panes; import java.awt.Image; -import java.util.Base64; import java.util.LinkedList; import java.util.List; +import javax.xml.bind.DatatypeConverter; import javax.swing.ImageIcon; import be.nikiroo.jvcard.Contact; @@ -62,19 +62,16 @@ public class ContactDetails extends MainContent { /** * Change the enclosed {@link Contact} from this {@link ContactDetails}. + * Also re-set the image. * * @param contact * the new {@link Contact} */ public void setContact(Contact contact) { - if (this.contact == contact) - return; - this.contact = contact; + image = null; - if (contact == null) { - image = null; - } else { + if (contact != null) { infoPanel.removeAllComponents(); String name = contact.getPreferredDataValue("FN"); @@ -106,21 +103,20 @@ public class ContactDetails extends MainContent { Data photo = contact.getPreferredData("PHOTO"); if (photo != null) { TypeInfo encoding = null; - TypeInfo type = null; for (int index = 0; index < photo.size(); index++) { TypeInfo info = photo.get(index); if (info.getName() != null) { if (info.getName().equalsIgnoreCase("ENCODING")) encoding = info; - if (info.getName().equalsIgnoreCase("TYPE")) - type = info; + // We don't check for the "TYPE" anymore, we just defer + // it to ImageIcon } } if (encoding != null && encoding.getValue() != null && encoding.getValue().equalsIgnoreCase("b")) { - image = new ImageIcon(Base64.getDecoder().decode( + image = new ImageIcon(DatatypeConverter.parseBase64Binary( photo.getValue())).getImage(); } } @@ -170,6 +166,14 @@ public class ContactDetails extends MainContent { return false; } }); + // TODO: add "normal" edit and remove this one into RAW edit + actions.add(new KeyAction(Mode.CONTACT_DETAILS_RAW, 'e', + Trans.StringId.KEY_ACTION_EDIT_CONTACT) { + @Override + public Object getObject() { + return contact; + } + }); return actions; }