diff options
Diffstat (limited to 'InCallUI/src/com/android')
6 files changed, 68 insertions, 7 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 54ec52829..483d53e64 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -389,6 +389,16 @@ public class Call { private LogState mLogState = new LogState(); + private boolean mIsSpam; + + public void setSpam(boolean isSpam) { + mIsSpam = isSpam; + } + + public boolean isSpam() { + return mIsSpam; + } + /** * Used only to create mock calls for testing */ diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 785d3d3aa..54b37e578 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -130,6 +130,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private TextView mCallTypeLabel; private ImageView mHdAudioIcon; private ImageView mForwardIcon; + private ImageView mSpamIcon; private View mCallNumberAndLabel; private TextView mElapsedTime; private Drawable mPrimaryPhotoDrawable; @@ -280,6 +281,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallStateLabel = (TextView) view.findViewById(R.id.callStateLabel); mHdAudioIcon = (ImageView) view.findViewById(R.id.hdAudioIcon); mForwardIcon = (ImageView) view.findViewById(R.id.forwardIcon); + mSpamIcon = (ImageView) view.findViewById(R.id.spamIcon); mCallNumberAndLabel = view.findViewById(R.id.labelAndNumber); mCallTypeLabel = (TextView) view.findViewById(R.id.callTypeLabel); mElapsedTime = (TextView) view.findViewById(R.id.elapsedTime); @@ -1207,6 +1209,19 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mForwardIcon.setVisibility(visible ? View.VISIBLE : View.GONE); } + /** + * Changes the visibility of the spam icon. + * + * @param visible {@code true} if the UI should show the spam icon. + */ + @Override + public void showSpamIndicator(boolean visible) { + if (visible) { + mSpamIcon.setVisibility(View.VISIBLE); + mNumberLabel.setText(R.string.label_spam_caller); + mPhoneNumber.setVisibility(View.GONE); + } + } /** * Changes the visibility of the "manage conference call" button. diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 36af7e2d8..5cc6bc096 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -458,6 +458,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> getUi().showHdAudioIndicator(showHdAudioIndicator); } + private void maybeShowSpamIconAndLabel() { + getUi().showSpamIndicator(mPrimary.isSpam()); + } + /** * Only show the conference call button if we can manage the conference. */ @@ -826,6 +830,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> boolean isEmergencyCall = mPrimary.isEmergencyCall(); mEmergencyCallListener.onCallUpdated((BaseFragment) ui, isEmergencyCall); } + maybeShowSpamIconAndLabel(); } private void updateSecondaryDisplayInfo() { @@ -1162,6 +1167,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> void setProgressSpinnerVisible(boolean visible); void showHdAudioIndicator(boolean visible); void showForwardIndicator(boolean visible); + void showSpamIndicator(boolean visible); void showManageConferenceCallButton(boolean visible); boolean isManageConferenceVisible(); boolean isCallSubjectVisible(); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index d0f3c1000..a3a9d743e 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -23,8 +23,8 @@ import android.telecom.DisconnectCause; import android.telecom.PhoneAccount; import com.android.contacts.common.testing.NeededForTesting; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.logging.Logger; +import com.android.dialer.service.ExtendedCallInfoService; import com.android.incallui.util.TelecomCallUtil; import com.google.common.base.Preconditions; @@ -69,7 +69,7 @@ public class CallList { .newHashMap(); private final Set<Call> mPendingDisconnectCalls = Collections.newSetFromMap( new ConcurrentHashMap<Call, Boolean>(8, 0.9f, 1)); - private FilteredNumberAsyncQueryHandler mFilteredQueryHandler; + private ExtendedCallInfoService mExtendedCallInfoService; /** * Static singleton accessor method. @@ -94,6 +94,17 @@ public class CallList { if (call.getState() == Call.State.INCOMING || call.getState() == Call.State.CALL_WAITING) { onIncoming(call, call.getCannedSmsResponses()); + if (mExtendedCallInfoService != null) { + String number = TelecomCallUtil.getNumber(telecomCall); + mExtendedCallInfoService.getExtendedCallInfo(number, + new ExtendedCallInfoService.Listener() { + @Override + public void onComplete(boolean isSpam) { + call.setSpam(isSpam); + onUpdate(call); + } + }); + } } else { onUpdate(call); } @@ -615,8 +626,8 @@ public class CallList { } }; - public void setFilteredNumberQueryHandler(FilteredNumberAsyncQueryHandler handler) { - mFilteredQueryHandler = handler; + public void setExtendedCallInfoService(ExtendedCallInfoService service) { + mExtendedCallInfoService = service; } /** diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 5a27b4ca0..2a3fd3ed7 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -341,7 +341,8 @@ public class InCallPresenter implements CallList.Listener, mFilteredQueryHandler = new FilteredNumberAsyncQueryHandler(context.getContentResolver()); mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); - mCallList.setFilteredNumberQueryHandler(mFilteredQueryHandler); + mCallList.setExtendedCallInfoService( + com.android.dialerbind.ObjectFactory.newExtendedCallInfoService(context)); Log.d(this, "Finished InCallPresenter.setUp"); } @@ -1744,7 +1745,14 @@ public class InCallPresenter implements CallList.Listener, if (call == null) { return getColorsFromPhoneAccountHandle(mPendingPhoneAccountHandle); } else { - return getColorsFromPhoneAccountHandle(call.getAccountHandle()); + if (call.isSpam()) { + Resources resources = mContext.getResources(); + return new InCallUIMaterialColorMapUtils( + resources).calculatePrimaryAndSecondaryColor( + resources.getColor(R.color.incall_call_spam_background_color)); + } else { + return getColorsFromPhoneAccountHandle(call.getAccountHandle()); + } } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 7d212aa8e..21bf38970 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -33,7 +33,9 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.media.AudioAttributes; import android.net.Uri; import android.provider.ContactsContract.Contacts; @@ -52,6 +54,7 @@ import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; +import com.android.dialer.service.ExtendedCallInfoService; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallState; @@ -463,6 +466,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) { largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap(); } + if (call.isSpam()) { + Drawable drawable = mContext.getResources().getDrawable(R.drawable.blocked_contact); + largeIcon = CallCardFragment.drawableToBitmap(drawable); + } return largeIcon; } @@ -524,7 +531,11 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, if (call.hasProperty(Details.PROPERTY_WIFI)) { resId = R.string.notification_incoming_call_wifi; } else { - resId = R.string.notification_incoming_call; + if (call.isSpam()) { + resId = R.string.notification_incoming_spam_call; + } else { + resId = R.string.notification_incoming_call; + } } } else if (call.getState() == Call.State.ONHOLD) { resId = R.string.notification_on_hold; |