diff options
author | jaffersulaiman <jaffersulaiman.mh@sasken.com> | 2016-04-18 16:50:51 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-08-28 20:43:01 -0700 |
commit | ebada54422b89dbf023f782c8a45d5c522c3dfe5 (patch) | |
tree | f5d852337d1c463aa5c2048e246d5c578961fbec | |
parent | c758da8d3dd91f8beda6c59d10f1f81cc2717ebe (diff) | |
download | android_packages_apps_Messaging-ebada54422b89dbf023f782c8a45d5c522c3dfe5.tar.gz android_packages_apps_Messaging-ebada54422b89dbf023f782c8a45d5c522c3dfe5.tar.bz2 android_packages_apps_Messaging-ebada54422b89dbf023f782c8a45d5c522c3dfe5.zip |
Showing Normalized number instead of denormalize number
Normalized Number is showing for Regex BlackList
Number
Bug:CYNGNOS-2113
Change-Id: Ie01e6938b9f3357cf7e8ffa59aa4c32c5e32d71f
4 files changed, 35 insertions, 9 deletions
diff --git a/src/com/android/messaging/datamodel/data/ParticipantData.java b/src/com/android/messaging/datamodel/data/ParticipantData.java index 521c354..1f9d945 100644 --- a/src/com/android/messaging/datamodel/data/ParticipantData.java +++ b/src/com/android/messaging/datamodel/data/ParticipantData.java @@ -227,13 +227,34 @@ public class ParticipantData implements Parcelable { * @return instance */ public static ParticipantData getFromRawPhoneBySystemLocale(final String phoneNumber) { + return getFromRawPhoneBySystemLocale(phoneNumber, null); + } + + /** + * Get an instance from a raw phone number and using system locale to normalize it. + * + * Use this when creating a participant that is for displaying UI and not associated + * with a specific SIM. For example, when creating a conversation using user entered + * phone number. + * + * @param phoneNumber The raw phone number + * @param formattedNumber If non-null, use that number as displayed destination + * instead of using a formatted version of phoneNumber. + * @return instance + */ + public static ParticipantData getFromRawPhoneBySystemLocale( + final String phoneNumber, final String formattedNumber) { final ParticipantData pd = getFromRawPhone(phoneNumber); pd.mNormalizedDestination = pd.mIsEmailAddress ? pd.mSendDestination : PhoneUtils.getDefault().getCanonicalBySystemLocale(pd.mSendDestination); - pd.mDisplayDestination = pd.mIsEmailAddress ? - pd.mNormalizedDestination : - PhoneUtils.getDefault().formatForDisplay(pd.mNormalizedDestination); + if (formattedNumber != null) { + pd.mDisplayDestination = formattedNumber; + } else { + pd.mDisplayDestination = pd.mIsEmailAddress ? + pd.mNormalizedDestination : + PhoneUtils.getDefault().formatForDisplay(pd.mNormalizedDestination); + } pd.maybeSetupUnknownSender(); return pd; } diff --git a/src/com/android/messaging/datamodel/data/ParticipantListItemData.java b/src/com/android/messaging/datamodel/data/ParticipantListItemData.java index f6c9b5f..4d366b4 100644 --- a/src/com/android/messaging/datamodel/data/ParticipantListItemData.java +++ b/src/com/android/messaging/datamodel/data/ParticipantListItemData.java @@ -44,7 +44,7 @@ public class ParticipantListItemData extends PersonItemData { mLookupKey = participant.getLookupKey(); mNormalizedDestination = participant.getNormalizedDestination(); if (TextUtils.isEmpty(participant.getFullName())) { - mDisplayName = participant.getSendDestination(); + mDisplayName = participant.getDisplayDestination(); mDetails = null; } else { mDisplayName = participant.getFullName(); diff --git a/src/com/android/messaging/util/BlacklistObserver.java b/src/com/android/messaging/util/BlacklistObserver.java index 0e4b88c..a7c341e 100644 --- a/src/com/android/messaging/util/BlacklistObserver.java +++ b/src/com/android/messaging/util/BlacklistObserver.java @@ -31,7 +31,6 @@ import com.android.messaging.datamodel.action.UpdateConversationArchiveStatusAct import com.android.messaging.datamodel.data.ParticipantData; import com.android.messaging.util.LogUtil; - // ContentObserver class to monitor changes to the Framework Blacklist DB public class BlacklistObserver extends ContentObserver { @@ -63,7 +62,8 @@ public class BlacklistObserver extends ContentObserver { cursor = mResolver.query(uri, null, null, null, null); int normalizedNumberIndex = cursor.getColumnIndex("normalized_number"); int blockedIndex = cursor.getColumnIndex("message"); - + int nonNormalizedNumberIndex = cursor.getColumnIndex("number"); + int regexIndex = cursor.getColumnIndex("is_regex"); // if the column indices are not valid, don't perform the queries if (normalizedNumberIndex < 0 || blockedIndex < 0) { if (cursor != null) { @@ -78,7 +78,8 @@ public class BlacklistObserver extends ContentObserver { String number = cursor.getString(normalizedNumberIndex); String blocked = cursor.getString(blockedIndex); boolean isBlocked = blocked.compareTo("1") == 0; - + String formattedNumber = cursor.getInt(regexIndex) != 0 + ? cursor.getString(nonNormalizedNumberIndex) : null; // don't update the framework db - the 'false' argument int updateCount = BugleDatabaseOperations.updateDestination(db, number, isBlocked, false); @@ -88,7 +89,7 @@ public class BlacklistObserver extends ContentObserver { // create a new participant // and insert him into the local participants database ParticipantData participant = - ParticipantData.getFromRawPhoneBySystemLocale(number); + ParticipantData.getFromRawPhoneBySystemLocale(number, formattedNumber); BugleDatabaseOperations.getOrCreateParticipantInTransaction(db, participant); BugleDatabaseOperations.updateDestination(db, number, diff --git a/src/com/android/messaging/util/BlacklistSync.java b/src/com/android/messaging/util/BlacklistSync.java index 44253c4..3ab14d8 100644 --- a/src/com/android/messaging/util/BlacklistSync.java +++ b/src/com/android/messaging/util/BlacklistSync.java @@ -54,6 +54,8 @@ public class BlacklistSync extends AsyncTask<Void, Void, Void> { if (cursor != null && cursor.getCount() > 0) { int normalizedNumberIndex = cursor.getColumnIndex("normalized_number"); int blockedIndex = cursor.getColumnIndex("message"); + int nonNormalizedNumberIndex = cursor.getColumnIndex("number"); + int regexIndex = cursor.getColumnIndex("is_regex"); int updateCount; if (normalizedNumberIndex < 0 || blockedIndex < 0) { cursor.close(); @@ -66,6 +68,8 @@ public class BlacklistSync extends AsyncTask<Void, Void, Void> { String number = cursor.getString(normalizedNumberIndex); String blocked = cursor.getString(blockedIndex); boolean isBlocked = blocked.compareTo("1") == 0; + String formattedNumber = cursor.getInt(regexIndex) != 0 + ? cursor.getString(nonNormalizedNumberIndex) : null; updateCount = BugleDatabaseOperations.updateDestination(db, number, isBlocked, false); if (updateCount == 0) { @@ -75,7 +79,7 @@ public class BlacklistSync extends AsyncTask<Void, Void, Void> { db.beginTransaction(); try { ParticipantData participant = ParticipantData - .getFromRawPhoneBySystemLocale(number); + .getFromRawPhoneBySystemLocale(number, formattedNumber); BugleDatabaseOperations.getOrCreateParticipantInTransaction(db, participant); BugleDatabaseOperations.updateDestination(db, number, |