diff options
author | Flavio Lerda <flerda@google.com> | 2011-08-12 00:26:52 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-12 00:26:52 -0700 |
commit | 43e6f3b14e00a7bab4876d288d77adfa6787d622 (patch) | |
tree | 156180a291b18ef3d06fb91567e3dc07e1b106c6 | |
parent | 3ae32e20bc3f7a278471475efa300b6544b1112e (diff) | |
parent | d5ef5903570e533a501abe6a8e3d533fdb5318fc (diff) | |
download | packages_providers_ContactsProvider-43e6f3b14e00a7bab4876d288d77adfa6787d622.zip packages_providers_ContactsProvider-43e6f3b14e00a7bab4876d288d77adfa6787d622.tar.gz packages_providers_ContactsProvider-43e6f3b14e00a7bab4876d288d77adfa6787d622.tar.bz2 |
Merge "Convert status updates to HTML."
-rw-r--r-- | src/com/android/providers/contacts/ContactsProvider2.java | 6 | ||||
-rw-r--r-- | tests/src/com/android/providers/contacts/ContactsProvider2Test.java | 27 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index 6d33836..412cf7c 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -136,6 +136,8 @@ import android.provider.OpenableColumns; import android.provider.SyncStateContract; import android.telephony.PhoneNumberUtils; import android.telephony.TelephonyManager; +import android.text.Html; +import android.text.SpannableString; import android.text.TextUtils; import android.util.Log; @@ -3037,7 +3039,9 @@ public class ContactsProvider2 extends SQLiteContentProvider implements OnAccoun if (rawContactId != -1 && !TextUtils.isEmpty(status)) { ContentValues streamItemValues = new ContentValues(); streamItemValues.put(StreamItems.RAW_CONTACT_ID, rawContactId); - streamItemValues.put(StreamItems.TEXT, status); + // Status updates are text only but stream items are HTML. + streamItemValues.put(StreamItems.TEXT, + Html.toHtml(new SpannableString(status))); streamItemValues.put(StreamItems.COMMENTS, ""); streamItemValues.put(StreamItems.RES_PACKAGE, resPackage); streamItemValues.put(StreamItems.RES_ICON, iconResource); diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java index d9dd358..d8a5854 100644 --- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java +++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java @@ -16,7 +16,6 @@ package com.android.providers.contacts; -import com.android.common.contacts.DataUsageStatUpdater; import com.android.internal.util.ArrayUtils; import com.android.providers.contacts.ContactsDatabaseHelper.AggregationExceptionColumns; import com.android.providers.contacts.ContactsDatabaseHelper.DataUsageStatColumns; @@ -3697,7 +3696,29 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { ContentValues expectedValues = new ContentValues(); expectedValues.put(StreamItems.RAW_CONTACT_ID, rawContactId); - expectedValues.put(StreamItems.TEXT, "hacking"); + expectedValues.put(StreamItems.TEXT, "<p>hacking</p>\n"); + assertStoredValues(RawContacts.CONTENT_URI.buildUpon() + .appendPath(String.valueOf(rawContactId)) + .appendPath(RawContacts.StreamItems.CONTENT_DIRECTORY).build(), + expectedValues); + } + + public void testStreamItemInsertedOnStatusUpdate_HtmlQuoting() { + + // This method of creating a raw contact automatically inserts a status update with + // the status message "hacking". + ContentValues values = new ContentValues(); + long rawContactId = createRawContact(values, "18004664411", + "goog411@acme.com", StatusUpdates.INVISIBLE, 4, 1, 0, + StatusUpdates.CAPABILITY_HAS_VOICE); + + // Insert a new status update for the raw contact. + insertStatusUpdate(Im.PROTOCOL_GOOGLE_TALK, null, "goog411@acme.com", + StatusUpdates.INVISIBLE, "& <b> test '", StatusUpdates.CAPABILITY_HAS_VOICE); + + ContentValues expectedValues = new ContentValues(); + expectedValues.put(StreamItems.RAW_CONTACT_ID, rawContactId); + expectedValues.put(StreamItems.TEXT, "<p>& <b> test &#39;</p>\n"); assertStoredValues(RawContacts.CONTENT_URI.buildUpon() .appendPath(String.valueOf(rawContactId)) .appendPath(RawContacts.StreamItems.CONTENT_DIRECTORY).build(), @@ -3720,7 +3741,7 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test { ContentValues expectedValues = new ContentValues(); expectedValues.put(StreamItems.RAW_CONTACT_ID, rawContactId); - expectedValues.put(StreamItems.TEXT, "finished hacking"); + expectedValues.put(StreamItems.TEXT, "<p>finished hacking</p>\n"); assertStoredValues(RawContacts.CONTENT_URI.buildUpon() .appendPath(String.valueOf(rawContactId)) .appendPath(RawContacts.StreamItems.CONTENT_DIRECTORY).build(), |