summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-12-15 02:57:43 -0700
committerLinux Build Service Account <lnxbuild@localhost>2016-12-15 02:57:43 -0700
commit74bad7b51484365268e87af615c7300f96ca0e0a (patch)
tree3e46c77c266e4aea92049e6fc5215ee9cc70c21d
parentb326ec3affa36711808bd56513cd86e77b9a1343 (diff)
parent614627d79dfeca636c3581e4d01f7fcc3a914d50 (diff)
downloadandroid_packages_apps_Messaging-74bad7b51484365268e87af615c7300f96ca0e0a.tar.gz
android_packages_apps_Messaging-74bad7b51484365268e87af615c7300f96ca0e0a.tar.bz2
android_packages_apps_Messaging-74bad7b51484365268e87af615c7300f96ca0e0a.zip
Merge 614627d79dfeca636c3581e4d01f7fcc3a914d50 on remote branch
Change-Id: I6ac3e451f82c212bbcf1cc6284a68669d6088ddc
-rw-r--r--res/layout/conversation_list_item_view.xml51
-rw-r--r--res/values/versions.xml2
-rw-r--r--res/xml-mcc302-mnc610/mms_config.xml2
-rw-r--r--src/com/android/messaging/datamodel/BugleDatabaseOperations.java5
-rw-r--r--src/com/android/messaging/datamodel/DatabaseHelper.java14
-rw-r--r--src/com/android/messaging/datamodel/DatabaseUpgradeHelper.java57
-rw-r--r--src/com/android/messaging/datamodel/data/ConversationListItemData.java32
-rw-r--r--src/com/android/messaging/ui/conversationlist/ConversationListItemView.java7
8 files changed, 145 insertions, 25 deletions
diff --git a/res/layout/conversation_list_item_view.xml b/res/layout/conversation_list_item_view.xml
index da1ca4e..636616b 100644
--- a/res/layout/conversation_list_item_view.xml
+++ b/res/layout/conversation_list_item_view.xml
@@ -118,25 +118,40 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:background="@android:color/transparent">
+ <ImageView
+ android:id="@+id/conversation_notification_bell"
+ style="@style/ConversationListNotificationBellPaddingStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_notifications_off_small_light"
+ android:visibility="gone"
+ android:importantForAccessibility="no"
+ android:contentDescription="@null"
+ android:layout_gravity="center_vertical"
+ android:background="@android:color/transparent" />
+ <TextView
+ android:id="@+id/conversation_name"
+ style="@style/ConversationListItemViewConversationNameStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:layout_gravity="center_vertical"
+ android:paddingBottom="2dp" />
+ </LinearLayout>
<ImageView
- android:id="@+id/conversation_notification_bell"
- style="@style/ConversationListNotificationBellPaddingStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_notifications_off_small_light"
- android:visibility="gone"
- android:importantForAccessibility="no"
- android:contentDescription="@null"
- android:layout_gravity="center_vertical"
- android:background="@android:color/transparent" />
- <TextView
- android:id="@+id/conversation_name"
- style="@style/ConversationListItemViewConversationNameStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:layout_gravity="center_vertical"
- android:paddingBottom="2dp" />
+ android:id="@+id/work_profile_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:background="@android:color/transparent"
+ android:scaleType="center"
+ android:src="@drawable/ic_work_profile"
+ android:visibility="gone"/>
</LinearLayout>
<TextView
android:id="@+id/conversation_subject"
diff --git a/res/values/versions.xml b/res/values/versions.xml
index e82b79e..14c6b47 100644
--- a/res/values/versions.xml
+++ b/res/values/versions.xml
@@ -16,7 +16,7 @@
-->
<resources>
<!-- DB version -->
- <string name="database_version" translatable="false">1</string>
+ <string name="database_version" translatable="false">2</string>
<!-- Version for shared preferences. This is used for handling prefs migration when old pref
keys are moved or renamed. You don't need to bump up the version number if you are just
diff --git a/res/xml-mcc302-mnc610/mms_config.xml b/res/xml-mcc302-mnc610/mms_config.xml
index 576b5c1..7c0183e 100644
--- a/res/xml-mcc302-mnc610/mms_config.xml
+++ b/res/xml-mcc302-mnc610/mms_config.xml
@@ -50,6 +50,4 @@
<!-- Disable SMS to MMS conversion for multiple recipient SMS -->
<bool name="enableGroupMms">false</bool>
- <!-- Disable the link to the cell broadcast -->
- <bool name="config_cellBroadcastAppLinks">false</bool>
</mms_config>
diff --git a/src/com/android/messaging/datamodel/BugleDatabaseOperations.java b/src/com/android/messaging/datamodel/BugleDatabaseOperations.java
index 8c40177..d30cec4 100644
--- a/src/com/android/messaging/datamodel/BugleDatabaseOperations.java
+++ b/src/com/android/messaging/datamodel/BugleDatabaseOperations.java
@@ -841,6 +841,11 @@ public class BugleDatabaseOperations {
values.put(ConversationColumns.NAME,
getDefaultConversationName(participants));
+ // Fill in IS_ENTERPRISE.
+ final boolean hasAnyEnterpriseContact =
+ ConversationListItemData.hasAnyEnterpriseContact(participants);
+ values.put(ConversationColumns.IS_ENTERPRISE, hasAnyEnterpriseContact);
+
fillParticipantData(values, participants);
// Used by background thread when refreshing conversation so conversation could be deleted.
diff --git a/src/com/android/messaging/datamodel/DatabaseHelper.java b/src/com/android/messaging/datamodel/DatabaseHelper.java
index f16bb3c..2025e2c 100644
--- a/src/com/android/messaging/datamodel/DatabaseHelper.java
+++ b/src/com/android/messaging/datamodel/DatabaseHelper.java
@@ -149,6 +149,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// is present (TP-Reply-Path), so that we could use it for the subsequent message to send.
// Refer to TS 23.040 D.6 and SmsMessageSender.java in Android Messaging app.
public static final String SMS_SERVICE_CENTER = "sms_service_center";
+
+ // A conversation is enterprise if one of the participant is a enterprise contact.
+ public static final String IS_ENTERPRISE = "IS_ENTERPRISE";
}
// Conversation table SQL
@@ -182,7 +185,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ ConversationColumns.NOTIFICATION_SOUND_URI + " TEXT, "
+ ConversationColumns.NOTIFICATION_VIBRATION + " INT DEFAULT(1), "
+ ConversationColumns.INCLUDE_EMAIL_ADDRESS + " INT DEFAULT(0), "
- + ConversationColumns.SMS_SERVICE_CENTER + " TEXT "
+ + ConversationColumns.SMS_SERVICE_CENTER + " TEXT ,"
+ + ConversationColumns.IS_ENTERPRISE + " INT DEFAULT(0)"
+ ");";
private static final String CONVERSATIONS_TABLE_SMS_THREAD_ID_INDEX_SQL =
@@ -668,6 +672,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
}
}
+ public static void rebuildAllViews(final DatabaseWrapper db) {
+ for (final String sql : DatabaseHelper.CREATE_VIEW_SQLS) {
+ db.execSQL(sql);
+ }
+ }
+
/**
* Drops all user-defined tables from the given database.
*/
@@ -733,7 +743,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
/**
* Drops all user-defined views from the given database.
*/
- private static void dropAllViews(final SQLiteDatabase db) {
+ public static void dropAllViews(final SQLiteDatabase db) {
final Cursor viewCursor =
db.query(MASTER_TABLE, MASTER_COLUMNS, "type='view'", null, null, null, null);
if (viewCursor != null) {
diff --git a/src/com/android/messaging/datamodel/DatabaseUpgradeHelper.java b/src/com/android/messaging/datamodel/DatabaseUpgradeHelper.java
index d112533..96aba86 100644
--- a/src/com/android/messaging/datamodel/DatabaseUpgradeHelper.java
+++ b/src/com/android/messaging/datamodel/DatabaseUpgradeHelper.java
@@ -15,8 +15,10 @@
*/
package com.android.messaging.datamodel;
+import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
+import com.android.messaging.Factory;
import com.android.messaging.util.Assert;
import com.android.messaging.util.LogUtil;
@@ -30,8 +32,61 @@ public class DatabaseUpgradeHelper {
}
LogUtil.i(TAG, "Database upgrade started from version " + oldVersion + " to " + newVersion);
+ try {
+ doUpgradeWithExceptions(db, oldVersion, newVersion);
+ LogUtil.i(TAG, "Finished database upgrade");
+ } catch (final Exception ex) {
+ LogUtil.e(TAG, "Failed to perform db upgrade from version " +
+ oldVersion + " to version " + newVersion, ex);
+ DatabaseHelper.rebuildTables(db);
+ }
+ }
+
+ public void doUpgradeWithExceptions(final SQLiteDatabase db, final int oldVersion,
+ final int newVersion) throws Exception {
+ int currentVersion = oldVersion;
+ if (currentVersion < 2) {
+ currentVersion = upgradeToVersion2(db);
+ }
+ // Rebuild all the views
+ final Context context = Factory.get().getApplicationContext();
+ DatabaseHelper.dropAllViews(db);
+ DatabaseHelper.rebuildAllViews(new DatabaseWrapper(context, db));
+ // Finally, check if we have arrived at the final version.
+ checkAndUpdateVersionAtReleaseEnd(currentVersion, Integer.MAX_VALUE, newVersion);
+ }
- // Add future upgrade code here
+ private int upgradeToVersion2(final SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE " + DatabaseHelper.CONVERSATIONS_TABLE + " ADD COLUMN " +
+ DatabaseHelper.ConversationColumns.IS_ENTERPRISE + " INT DEFAULT(0)");
+ LogUtil.i(TAG, "Ugraded database to version 2");
+ return 2;
+ }
+
+ /**
+ * Checks db version correctness at the end of each milestone release. If target database
+ * version lies beyond the version range that the current release may handle, we snap the
+ * current version to the end of the release, so that we may go on to the next release' upgrade
+ * path. Otherwise, if target version is within reach of the current release, but we are not
+ * at the target version, then throw an exception to force a table rebuild.
+ */
+ private int checkAndUpdateVersionAtReleaseEnd(final int currentVersion,
+ final int maxVersionForRelease, final int targetVersion) throws Exception {
+ if (maxVersionForRelease < targetVersion) {
+ // Target version is beyond the current release. Snap to max version for the
+ // current release so we can go on to the upgrade path for the next release.
+ return maxVersionForRelease;
+ }
+
+ // If we are here, this means the current release' upgrade handler should upgrade to
+ // target version...
+ if (currentVersion != targetVersion) {
+ // No more upgrade handlers. So we can't possibly upgrade to the final version.
+ throw new Exception("Missing upgrade handler from version " +
+ currentVersion + " to version " + targetVersion);
+ }
+ // Upgrade succeeded.
+ return targetVersion;
}
public void onDowngrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
diff --git a/src/com/android/messaging/datamodel/data/ConversationListItemData.java b/src/com/android/messaging/datamodel/data/ConversationListItemData.java
index b2e6e1c..f627a09 100644
--- a/src/com/android/messaging/datamodel/data/ConversationListItemData.java
+++ b/src/com/android/messaging/datamodel/data/ConversationListItemData.java
@@ -28,6 +28,7 @@ import com.android.messaging.datamodel.DatabaseHelper.ParticipantColumns;
import com.android.messaging.datamodel.DatabaseWrapper;
import com.android.messaging.datamodel.action.DeleteConversationAction;
import com.android.messaging.util.Assert;
+import com.android.messaging.util.ContactUtil;
import com.android.messaging.util.Dates;
import com.google.common.base.Joiner;
@@ -66,6 +67,7 @@ public class ConversationListItemData {
private String mDraftSubject;
private String mSnippetSenderFirstName;
private String mSnippetSenderDisplayDestination;
+ private boolean mIsEnterprise;
public ConversationListItemData() {
}
@@ -117,6 +119,7 @@ public class ConversationListItemData {
mSnippetSenderFirstName = cursor.getString(INDEX_SNIPPET_SENDER_FIRST_NAME);
mSnippetSenderDisplayDestination =
cursor.getString(INDEX_SNIPPET_SENDER_DISPLAY_DESTINATION);
+ mIsEnterprise = cursor.getInt(INDEX_IS_ENTERPRISE) == 1;
}
public String getConversationId() {
@@ -155,10 +158,22 @@ public class ConversationListItemData {
return mPreviewContentType;
}
+ /**
+ * @see ConversationColumns#PARTICIPANT_CONTACT_ID
+ * @return the contact id of the participant if it is a 1:1 conversation, -1 for group.
+ */
public long getParticipantContactId() {
return mParticipantContactId;
}
+ /**
+ * @see ConversationColumns#IS_ENTERPRISE
+ * @return whether the conversation is enterprise.
+ */
+ public boolean isEnterprise() {
+ return mIsEnterprise;
+ }
+
public String getParticipantLookupKey() {
return mParticipantLookupKey;
}
@@ -331,7 +346,9 @@ public class ConversationListItemData {
+ DatabaseHelper.PARTICIPANTS_TABLE + '.' + ParticipantColumns.FIRST_NAME
+ " as " + ConversationListViewColumns.SNIPPET_SENDER_FIRST_NAME + ", "
+ DatabaseHelper.PARTICIPANTS_TABLE + '.' + ParticipantColumns.DISPLAY_DESTINATION
- + " as " + ConversationListViewColumns.SNIPPET_SENDER_DISPLAY_DESTINATION;
+ + " as " + ConversationListViewColumns.SNIPPET_SENDER_DISPLAY_DESTINATION + ", "
+ + DatabaseHelper.CONVERSATIONS_TABLE + '.' + ConversationColumns.IS_ENTERPRISE
+ + " as " + ConversationListViewColumns.IS_ENTERPRISE;
private static final String JOIN_PARTICIPANTS =
" LEFT JOIN " + DatabaseHelper.PARTICIPANTS_TABLE + " ON ("
@@ -390,6 +407,7 @@ public class ConversationListItemData {
static final String SNIPPET_SENDER_FIRST_NAME = "snippet_sender_first_name";
static final String SNIPPET_SENDER_DISPLAY_DESTINATION =
"snippet_sender_display_destination";
+ static final String IS_ENTERPRISE = ConversationColumns.IS_ENTERPRISE;
}
public static final String[] PROJECTION = {
@@ -422,6 +440,7 @@ public class ConversationListItemData {
ConversationListViewColumns.MESSAGE_RAW_TELEPHONY_STATUS,
ConversationListViewColumns.SNIPPET_SENDER_FIRST_NAME,
ConversationListViewColumns.SNIPPET_SENDER_DISPLAY_DESTINATION,
+ ConversationListViewColumns.IS_ENTERPRISE,
};
private static final int INDEX_ID = 0;
@@ -453,9 +472,20 @@ public class ConversationListItemData {
private static final int INDEX_MESSAGE_RAW_TELEPHONY_STATUS = 26;
private static final int INDEX_SNIPPET_SENDER_FIRST_NAME = 27;
private static final int INDEX_SNIPPET_SENDER_DISPLAY_DESTINATION = 28;
+ private static final int INDEX_IS_ENTERPRISE = 29;
private static final String DIVIDER_TEXT = ", ";
+ public static boolean hasAnyEnterpriseContact(
+ final List<ParticipantData> participants) {
+ for (final ParticipantData participant : participants) {
+ if (ContactUtil.isEnterpriseContactId(participant.getContactId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Get a conversation from the local DB based on the conversation id.
*
diff --git a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java
index 9b8c5ff..6b02eb3 100644
--- a/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java
+++ b/src/com/android/messaging/ui/conversationlist/ConversationListItemView.java
@@ -118,6 +118,7 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
private ViewGroup mCrossSwipeBackground;
private ViewGroup mSwipeableContent;
private TextView mConversationNameView;
+ private ImageView mWorkProfileIconView;
private TextView mSnippetTextView;
private TextView mSubjectTextView;
private TextView mTimestampTextView;
@@ -145,6 +146,7 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
mConversationNameView = (TextView) findViewById(R.id.conversation_name);
mSnippetTextView = (TextView) findViewById(R.id.conversation_snippet);
mSubjectTextView = (TextView) findViewById(R.id.conversation_subject);
+ mWorkProfileIconView = (ImageView) findViewById(R.id.work_profile_icon);
mTimestampTextView = (TextView) findViewById(R.id.conversation_timestamp);
mContactIconView = (ContactIconView) findViewById(R.id.conversation_icon);
mContactCheckmarkView = (ImageView) findViewById(R.id.conversation_checkmark);
@@ -183,6 +185,10 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
}
}
+ private void setWorkProfileIcon() {
+ mWorkProfileIconView.setVisibility(mData.isEnterprise() ? View.VISIBLE : View.GONE);
+ }
+
private void setConversationName() {
if (mData.getIsRead() || mData.getShowDraft()) {
mConversationNameView.setTextColor(mListItemReadColor);
@@ -391,6 +397,7 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
setSnippet();
setConversationName();
setSubject();
+ setWorkProfileIcon();
setContentDescription(buildContentDescription(resources, mData,
mConversationNameView.getPaint()));