X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2Fpanes%2FContactDetails.java;fp=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2Fpanes%2FContactDetails.java;h=791d57c6944f801680c23523c430a88ec103dc5e;hp=9bab007ebfae7e383db2e623e0709b8f81c386c4;hb=d5260eeb873fcf2ef9855dedcd9e2a3a3a990582;hpb=f06c81000632cfb5f525ca458f719338f55f9f66 diff --git a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java index 9bab007..791d57c 100644 --- a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java +++ b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java @@ -116,22 +116,27 @@ public class ContactDetails extends MainContent { boolean hl = false; boolean all = false; - if (info.contains("+") || info.contains("#")) + if (info.contains("+") || info.contains("#")) { hl = true; - if (info.contains("*") || info.contains("#")) + } + if (info.contains("*") || info.contains("#")) { all = true; + } if (all || hl || info.contains("=")) { ColorOption el = hl ? ColorOption.VIEW_CONTACT_HIGHLIGHT : ColorOption.VIEW_CONTACT_NORMAL; int index = info.indexOf('='); - if (index < 0) + if (index < 0) { index = info.indexOf('+'); - if (index < 0) + } + if (index < 0) { index = info.indexOf('#'); - if (index < 0) + } + if (index < 0) { index = info.indexOf('*'); + } String label = info.substring(0, index); String field = info.substring(index + 1); @@ -152,8 +157,9 @@ public class ContactDetails extends MainContent { } } else { String val = contact.getPreferredDataValue(field); - if (val == null) + if (val == null) { val = ""; + } infoPanel.addComponent(UiColors.createLabel(el, StringUtils.padString(label, labelSize) + val)); } @@ -170,8 +176,9 @@ public class ContactDetails extends MainContent { ColorOption.VIEW_CONTACT_NORMAL, "")); String notes = contact.getPreferredDataValue("NOTE"); - if (notes == null) + if (notes == null) { notes = ""; + } note.setText(notes); Data photo = contact.getPreferredData("PHOTO"); @@ -188,7 +195,6 @@ public class ContactDetails extends MainContent { if (encoding != null && encoding.getValue() != null && encoding.getValue().equalsIgnoreCase("b")) { - try { image = ImageUtils.fromBase64(photo.getValue()); } catch (Exception e) { @@ -270,15 +276,17 @@ public class ContactDetails extends MainContent { private void setImage(Image image) { this.image = image; - if (txtImage != null && top.containsComponent(txtImage)) + if (txtImage != null && top.containsComponent(txtImage)) { top.removeComponent(txtImage); + } TerminalSize size = getTxtSize(); if (size != null) { - if (txtImage != null) + if (txtImage != null) { txtImage.setSize(size); - else + } else { txtImage = new ImageTextControl(image, size); + } } if (size != null) { @@ -299,15 +307,16 @@ public class ContactDetails extends MainContent { && getSize().getRows() > 0) { if (fullscreenImage) { return getSize(); - } else { - // TODO: configure size? - int w = getSize().getColumns() - 40; - int h = getSize().getRows() - 9; - if (w <= 0 || h <= 0) - return null; + } - return new TerminalSize(w, h); + // TODO: configure size? + int w = getSize().getColumns() - 40; + int h = getSize().getRows() - 9; + if (w <= 0 || h <= 0) { + return null; } + + return new TerminalSize(w, h); } return null;