+
+ // List of infos:
+ int labelSize = -1;
+ try {
+ labelSize = Integer.parseInt(map
+ .getString("CONTACT_DETAILS_LABEL_WIDTH"));
+
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ labelSize = -1;
+ } catch (MissingResourceException e) {
+ labelSize = -1;
+ }
+
+ String infoFormat = "";
+ try {
+ infoFormat = map.getString("CONTACT_DETAILS_INFO");
+ } catch (MissingResourceException e) {
+ e.printStackTrace();
+ }
+
+ String[] infos = infoFormat.split("\\|");
+ for (String info : infos) {
+ // # - "=FIELD" will take the preferred value for this field
+ // # - "+FIELD" will take the preferred value for this field and
+ // highlight it
+ // # - "#FIELD" will take all the values with this field's name
+ // # - "*FIELD" will take all the values with this field's name,
+ // highlighting the preferred one
+ // #
+
+ boolean hl = false;
+ boolean all = false;
+ if (info.contains("+") || info.contains("#"))
+ hl = true;
+ if (info.contains("*") || info.contains("#"))
+ all = true;
+
+ if (all || hl || info.contains("=")) {
+ UiColors.Element el = hl ? UiColors.Element.VIEW_CONTACT_HIGHLIGHT
+ : UiColors.Element.VIEW_CONTACT_NORMAL;
+
+ int index = info.indexOf('=');
+ if (index < 0)
+ index = info.indexOf('+');
+ if (index < 0)
+ index = info.indexOf('#');
+ if (index < 0)
+ index = info.indexOf('*');
+
+ String label = info.substring(0, index);
+ String field = info.substring(index + 1);
+
+ if (all) {
+ for (Data data : contact.getData(field)) {
+ if (data.isPreferred()) {
+ infoPanel
+ .addComponent(el.createLabel(StringUtils
+ .padString(label, labelSize)
+ + contact
+ .getPreferredDataValue(field)));
+ } else {
+ infoPanel
+ .addComponent(UiColors.Element.VIEW_CONTACT_NORMAL.createLabel(StringUtils
+ .padString(label, labelSize)
+ + contact
+ .getPreferredDataValue(field)));
+ }
+ }
+ } else {
+ infoPanel.addComponent(el.createLabel(StringUtils
+ .padString(label, labelSize)
+ + contact.getPreferredDataValue(field)));
+ }
+ } else {
+ String label = info;
+ infoPanel.addComponent(UiColors.Element.VIEW_CONTACT_NORMAL
+ .createLabel(StringUtils
+ .padString(label, labelSize)));
+ }
+ }
+ // end of list
+