summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/CallDetailActivity.java
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-10-16 12:56:28 -0700
committerAndrew Lee <anwlee@google.com>2015-10-16 13:00:59 -0700
commitb67294e72e074ee5b67c692f6674cee296fe8927 (patch)
tree6d9e547a41384ade476bb86f00d84f7b4c232615 /src/com/android/dialer/CallDetailActivity.java
parent8d0847ca13ca46730756e1d3a3dff3d7d27fd18b (diff)
Fix up blocked photo scenarios.
+ Show blocked drawable in CallDetailActivity. Rearrange logic in the activity to facilitate updating the contact photo and block item action in accordance to blocked state. + Fix bug in FilterNumberDialogFragment where callback was not always invoked because of final/scope issues where it was possible for the callback to be unintentionally null and not invoked. + Clear blocked id cache when pausing the call log adapter, so that after changing the blocked state in the call detail activity the changes will be reflected in the call log. Bug: 24871853 Change-Id: I1d58b1e0c222ead90fa7b6c30a95bc3254a14776
Diffstat (limited to 'src/com/android/dialer/CallDetailActivity.java')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java137
1 files changed, 75 insertions, 62 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 654a96fcf..54367b1ee 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -106,17 +106,9 @@ public class CallDetailActivity extends AppCompatActivity
// All calls are from the same number and same contact, so pick the first detail.
mDetails = details[0];
- mNumber = TextUtils.isEmpty(mDetails.number) ?
- null : mDetails.number.toString();
+ mNumber = TextUtils.isEmpty(mDetails.number) ? null : mDetails.number.toString();
mDisplayNumber = mDetails.displayNumber;
final int numberPresentation = mDetails.numberPresentation;
- final Uri contactUri = mDetails.contactUri;
- final Uri photoUri = mDetails.photoUri;
- final PhoneAccountHandle accountHandle = mDetails.accountHandle;
-
- // Cache the details about the phone number.
- mIsVoicemailNumber =
- PhoneNumberUtil.isVoicemailNumber(mContext, accountHandle, mNumber);
final CharSequence callLocationOrType = getNumberTypeOrLocation(mDetails);
@@ -137,7 +129,8 @@ public class CallDetailActivity extends AppCompatActivity
}
}
- String accountLabel = PhoneAccountUtils.getAccountLabel(mContext, accountHandle);
+ String accountLabel =
+ PhoneAccountUtils.getAccountLabel(mContext, mDetails.accountHandle);
if (!TextUtils.isEmpty(accountLabel)) {
mAccountLabel.setText(accountLabel);
mAccountLabel.setVisibility(View.VISIBLE);
@@ -150,8 +143,10 @@ public class CallDetailActivity extends AppCompatActivity
mCallButton.setVisibility(canPlaceCallsTo ? View.VISIBLE : View.GONE);
final boolean isSipNumber = PhoneNumberUtil.isSipNumber(mNumber);
+ final boolean isVoicemailNumber =
+ PhoneNumberUtil.isVoicemailNumber(mContext, mDetails.accountHandle, mNumber);
final boolean showEditNumberBeforeCallAction =
- canPlaceCallsTo && !isSipNumber && !mIsVoicemailNumber;
+ canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
mEditBeforeCallActionItem.setVisibility(
showEditNumberBeforeCallAction ? View.VISIBLE : View.GONE);
@@ -160,31 +155,13 @@ public class CallDetailActivity extends AppCompatActivity
mReportActionItem.setVisibility(
showReportAction ? View.VISIBLE : View.GONE);
- updateBlockActionItem();
invalidateOptionsMenu();
mHistoryList.setAdapter(
new CallDetailHistoryAdapter(mContext, mInflater, mCallTypeHelper, details));
- String lookupKey = contactUri == null ? null
- : UriUtils.getLookupKeyFromUri(contactUri);
-
- final boolean isBusiness = mContactInfoHelper.isBusiness(mDetails.sourceType);
-
- final int contactType =
- mIsVoicemailNumber ? ContactPhotoManager.TYPE_VOICEMAIL :
- isBusiness ? ContactPhotoManager.TYPE_BUSINESS :
- ContactPhotoManager.TYPE_DEFAULT;
-
- String nameForDefaultImage;
- if (TextUtils.isEmpty(mDetails.name)) {
- nameForDefaultImage = mDetails.displayNumber;
- } else {
- nameForDefaultImage = mDetails.name.toString();
- }
+ updatePhotoAndBlockActionItem();
- loadContactPhotos(
- contactUri, photoUri, nameForDefaultImage, lookupKey, contactType);
findViewById(R.id.call_detail).setVisibility(View.VISIBLE);
}
@@ -217,7 +194,6 @@ public class CallDetailActivity extends AppCompatActivity
private PhoneCallDetails mDetails;
protected String mNumber;
private Uri mVoicemailUri;
- private boolean mIsVoicemailNumber;
private String mDefaultCountryIso;
private String mDisplayNumber;
@@ -275,6 +251,9 @@ public class CallDetailActivity extends AppCompatActivity
mCallButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
+ if (TextUtils.isEmpty(mNumber)) {
+ return;
+ }
mContext.startActivity(
new CallIntentBuilder(mNumber)
.setCallInitiationType(LogState.INITIATION_CALL_DETAILS)
@@ -339,21 +318,6 @@ public class CallDetailActivity extends AppCompatActivity
return uris;
}
- /** Load the contact photos and places them in the corresponding views. */
- private void loadContactPhotos(Uri contactUri, Uri photoUri, String displayName,
- String lookupKey, int contactType) {
-
- final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey,
- contactType, true /* isCircular */);
-
- mQuickContactBadge.assignContactUri(contactUri);
- mQuickContactBadge.setContentDescription(
- mResources.getString(R.string.description_contact_details, displayName));
-
- mContactPhotoManager.loadDirectoryPhoto(mQuickContactBadge, photoUri,
- false /* darkTheme */, true /* isCircular */, request);
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
final MenuItem deleteMenuItem = menu.add(
@@ -399,7 +363,7 @@ public class CallDetailActivity extends AppCompatActivity
mBlockedNumberId,
null /* normalizedNumber */,
mNumber,
- null /* countryIso */,
+ mDetails.countryIso,
mDisplayNumber,
R.id.call_detail,
getFragmentManager(),
@@ -420,32 +384,81 @@ public class CallDetailActivity extends AppCompatActivity
@Override
public void onChangeFilteredNumberSuccess() {
- updateBlockActionItem();
+ updatePhotoAndBlockActionItem();
}
@Override
public void onChangeFilteredNumberUndo() {
- updateBlockActionItem();
+ updatePhotoAndBlockActionItem();
}
- private void updateBlockActionItem() {
+ private void updatePhotoAndBlockActionItem() {
if (mDetails == null) {
return;
}
- mFilteredNumberAsyncQueryHandler.startBlockedQuery(new OnCheckBlockedListener() {
- @Override
- public void onCheckComplete(Integer id) {
- mBlockedNumberId = id;
- if (mBlockedNumberId == null) {
- mBlockNumberActionItem.setText(R.string.action_block_number);
- } else {
- mBlockNumberActionItem.setText(R.string.action_unblock_number);
- }
+ boolean failed = mFilteredNumberAsyncQueryHandler.startBlockedQuery(
+ new OnCheckBlockedListener() {
+ @Override
+ public void onCheckComplete(Integer id) {
+ mBlockedNumberId = id;
- mBlockNumberActionItem.setVisibility(View.VISIBLE);
- }
- }, null, mNumber, mDetails.countryIso);
+ updateContactPhoto();
+ updateBlockActionItem();
+ }
+ }, null, mNumber, mDetails.countryIso);
+
+ if (failed) {
+ updateContactPhoto();
+ updateBlockActionItem();
+ }
+ }
+
+ // Loads and displays the contact photo.
+ private void updateContactPhoto() {
+ if (mDetails == null) {
+ return;
+ }
+
+ if (mBlockedNumberId != null) {
+ mQuickContactBadge.setImageDrawable(mContext.getDrawable(R.drawable.blocked_contact));
+ return;
+ }
+
+ final boolean isVoicemailNumber =
+ PhoneNumberUtil.isVoicemailNumber(mContext, mDetails.accountHandle, mNumber);
+ final boolean isBusiness = mContactInfoHelper.isBusiness(mDetails.sourceType);
+ int contactType = ContactPhotoManager.TYPE_DEFAULT;
+ if (isVoicemailNumber) {
+ contactType = ContactPhotoManager.TYPE_VOICEMAIL;
+ } else if (isBusiness) {
+ contactType = ContactPhotoManager.TYPE_BUSINESS;
+ }
+
+ final String displayName = TextUtils.isEmpty(mDetails.name)
+ ? mDetails.displayNumber : mDetails.name.toString();
+ final String lookupKey = mDetails.contactUri == null
+ ? null : UriUtils.getLookupKeyFromUri(mDetails.contactUri);
+
+ final DefaultImageRequest request =
+ new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */);
+
+ mQuickContactBadge.assignContactUri(mDetails.contactUri);
+ mQuickContactBadge.setContentDescription(
+ mResources.getString(R.string.description_contact_details, displayName));
+
+ mContactPhotoManager.loadDirectoryPhoto(mQuickContactBadge, mDetails.photoUri,
+ false /* darkTheme */, true /* isCircular */, request);
+ }
+
+ private void updateBlockActionItem() {
+ if (mBlockedNumberId == null) {
+ mBlockNumberActionItem.setText(R.string.action_block_number);
+ } else {
+ mBlockNumberActionItem.setText(R.string.action_unblock_number);
+ }
+
+ mBlockNumberActionItem.setVisibility(View.VISIBLE);
}
private void closeSystemDialogs() {