Refresh data on "Back", allow configuration of View + border
[jvcard.git] / src / be / nikiroo / jvcard / Contact.java
index 4c6d5d443b9075d42823af98660df19c904c88d9..1b888961466737bace2f6f647ee5d9d21b2b739b 100644 (file)
@@ -11,7 +11,7 @@ import java.util.UUID;
 
 import be.nikiroo.jvcard.parsers.Format;
 import be.nikiroo.jvcard.parsers.Parser;
-import be.nikiroo.jvcard.tui.StringUtils;
+import be.nikiroo.jvcard.resources.StringUtils;
 
 /**
  * A contact is the information that represent a contact person or organisation.
@@ -47,13 +47,9 @@ public class Contact extends BaseClass<Data> {
                for (Data data : getData(name)) {
                        if (first == null)
                                first = data;
-                       for (int index = 0; index < data.size(); index++) {
-                               TypeInfo type = data.get(index);
-                               if (type.getName().equals("TYPE")
-                                               && type.getValue().equals("pref")) {
-                                       return data;
-                               }
-                       }
+
+                       if (data.isPreferred())
+                               return data;
                }
 
                return first;
@@ -103,7 +99,14 @@ public class Contact extends BaseClass<Data> {
         */
        public String toString(Format format, int startingBKey) {
                updateBKeys(false);
-               return Parser.toString(this, format, startingBKey);
+
+               StringBuilder builder = new StringBuilder();
+               for (String line : Parser.toStrings(this, format, startingBKey)) {
+                       builder.append(line);
+                       builder.append("\r\n");
+               }
+
+               return builder.toString();
        }
 
        /**
@@ -411,7 +414,7 @@ public class Contact extends BaseClass<Data> {
 
        @Override
        public String getState() {
-               return "" + getPreferredDataValue("UID");
+               return getId();
        }
 
        /**