OSDN Git Service

show events in the UI
authorFred Quintana <fredq@google.com>
Thu, 1 Oct 2009 00:22:21 +0000 (17:22 -0700)
committerFred Quintana <fredq@google.com>
Thu, 1 Oct 2009 04:30:49 +0000 (21:30 -0700)
res/values/strings.xml
src/com/android/contacts/model/FallbackSource.java
src/com/android/contacts/model/GoogleSource.java

index e26b42e..60f784d 100644 (file)
     <string name="organizationLabelsGroup">Organization</string>
     <!-- Header that expands to list all website types when editing a website of a contact -->
     <string name="websiteLabelsGroup">Website</string>
+    <!-- Header that expands to list all event types when editing an event of a contact -->
+    <string name="eventLabelsGroup">Event</string>
 
     <!-- Single-character overlay for home phone numbers when creating desktop shortcuts -->
     <string name="type_short_home">H</string>
     <string name="split_label">Split</string>
     <!-- The explanation of what "split" will do. This needs word-smithing. -->
     <string name="split_explanation">Make this data its own contact.</string>
-    
+
     <!-- Formatting string for account name -->
     <string name="account_name_format">From <xliff:g id="source" example="Gmail">%1$s</xliff:g> account: <xliff:g id="account" example="user@gmail.com">%2$s</xliff:g></string>
 
index fa545be..ebef42b 100644 (file)
@@ -25,6 +25,7 @@ import android.content.res.Resources;
 import android.database.Cursor;
 import android.provider.ContactsContract.CommonDataKinds.BaseTypes;
 import android.provider.ContactsContract.CommonDataKinds.Email;
+import android.provider.ContactsContract.CommonDataKinds.Event;
 import android.provider.ContactsContract.CommonDataKinds.Im;
 import android.provider.ContactsContract.CommonDataKinds.Nickname;
 import android.provider.ContactsContract.CommonDataKinds.Note;
@@ -74,6 +75,7 @@ public class FallbackSource extends ContactsSource {
         inflatePhoto(inflateLevel);
         inflateNote(inflateLevel);
         inflateWebsite(inflateLevel);
+        inflateEvent(inflateLevel);
 
         setInflatedLevel(inflateLevel);
 
@@ -376,6 +378,19 @@ public class FallbackSource extends ContactsSource {
         return kind;
     }
 
+    protected DataKind inflateEvent(int inflateLevel) {
+        DataKind kind = getKindForMimetype(Event.CONTENT_ITEM_TYPE);
+        if (kind == null) {
+            kind = addKind(new DataKind(Event.CONTENT_ITEM_TYPE,
+                    R.string.eventLabelsGroup, -1, 150, false));
+            kind.secondary = true;
+            kind.actionHeader = new EventActionInflater();
+            kind.actionBody = new SimpleInflater(Event.START_DATE);
+        }
+
+        return kind;
+    }
+
     /**
      * Simple inflater that assumes a string resource has a "%s" that will be
      * filled from the given column.
@@ -558,6 +573,13 @@ public class FallbackSource extends ContactsSource {
         }
     }
 
+    public static class EventActionInflater extends CommonInflater {
+        @Override
+        protected int getTypeLabelResource(Integer type) {
+            return Event.getTypeResource(type);
+        }
+    }
+
     public static class PostalActionInflater extends CommonInflater {
         @Override
         protected int getTypeLabelResource(Integer type) {
index 6706ec0..010982c 100644 (file)
@@ -61,6 +61,7 @@ public class GoogleSource extends FallbackSource {
         inflatePhoto(inflateLevel);
         inflateNote(inflateLevel);
         inflateWebsite(inflateLevel);
+        inflateEvent(inflateLevel);
 
         // TODO: GOOGLE: GROUPMEMBERSHIP