summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlavio Lerda <flerda@google.com>2011-08-10 00:44:38 +0100
committerFlavio Lerda <flerda@google.com>2011-08-10 01:35:58 +0100
commitd5ef5903570e533a501abe6a8e3d533fdb5318fc (patch)
treebc826b8e40244f49cb4feb12d3a72b4aa498ccec
parent90c8ee22fca69ca110f12def28c31659ff4e1797 (diff)
downloadpackages_providers_ContactsProvider-d5ef5903570e533a501abe6a8e3d533fdb5318fc.zip
packages_providers_ContactsProvider-d5ef5903570e533a501abe6a8e3d533fdb5318fc.tar.gz
packages_providers_ContactsProvider-d5ef5903570e533a501abe6a8e3d533fdb5318fc.tar.bz2
Convert status updates to HTML.
Since stream items text is HTML but status updates are text only, convert the text to HTML when inserting a status update into the stream items. Bug: 5122642 Change-Id: I61e3d9802e527c6977e7d29660ffd137ae899dae
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java6
-rw-r--r--tests/src/com/android/providers/contacts/ContactsProvider2Test.java27
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 49e7ab5..3ec0931 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 &#39;", StatusUpdates.CAPABILITY_HAS_VOICE);
+
+ ContentValues expectedValues = new ContentValues();
+ expectedValues.put(StreamItems.RAW_CONTACT_ID, rawContactId);
+ expectedValues.put(StreamItems.TEXT, "<p>&amp; &lt;b&gt; test &amp;#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(),