diff options
Diffstat (limited to 'src/com/android/incallui/CallCardFragment.java')
-rw-r--r-- | src/com/android/incallui/CallCardFragment.java | 157 |
1 files changed, 125 insertions, 32 deletions
diff --git a/src/com/android/incallui/CallCardFragment.java b/src/com/android/incallui/CallCardFragment.java index a1d826db..d67ae11d 100644 --- a/src/com/android/incallui/CallCardFragment.java +++ b/src/com/android/incallui/CallCardFragment.java @@ -30,6 +30,7 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Point; +import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.os.Bundle; @@ -42,6 +43,7 @@ import android.telecom.VideoProfile; import android.telephony.PhoneNumberUtils; import android.text.format.DateUtils; import android.text.TextUtils; +import android.text.format.DateUtils; import android.view.ContextThemeWrapper; import android.view.Display; import android.text.format.DateUtils; @@ -68,7 +70,9 @@ import android.widget.Toast; import android.telecom.AudioState; +import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; import com.android.contacts.common.widget.FloatingActionButtonController; +import com.android.incallui.service.PhoneNumberService; import com.android.internal.telephony.util.BlacklistUtils; import com.android.phone.common.animation.AnimUtils; @@ -102,6 +106,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private TextView mElapsedTime; private ImageButton mMoreMenuButton; private MorePopupMenu mMoreMenu; + private Drawable mPrimaryPhotoDrawable; // Container view that houses the entire primary call card, including the call buttons private View mPrimaryCallCardContainer; @@ -125,7 +130,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private TextView mSecondaryCallName; private View mSecondaryCallProviderInfo; private TextView mSecondaryCallProviderLabel; - private ImageView mSecondaryCallProviderIcon; private View mSecondaryCallConferenceCallIcon; private View mProgressSpinner; @@ -189,6 +193,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private InCallActivity mInCallActivity; + private MaterialPalette mCurrentThemeColors; + @Override CallCardPresenter.CallCardUi getUi() { return this; @@ -326,7 +332,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void onClick(View v) { InCallActivity activity = (InCallActivity) getActivity(); - activity.showConferenceCallManager(); + activity.showConferenceCallManager(true); } }); @@ -492,7 +498,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr if (TextUtils.isEmpty(name)) { mPrimaryName.setText(null); } else { - mPrimaryName.setText(name); + mPrimaryName.setText(nameIsNumber + ? PhoneNumberUtils.ttsSpanAsPhoneNumber(name) + : name); // Set direction of the name field int nameDirection = View.TEXT_DIRECTION_INHERIT; @@ -517,7 +525,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPhoneNumber.setText(null); mPhoneNumber.setVisibility(View.GONE); } else { - mPhoneNumber.setText(number); + mPhoneNumber.setText(PhoneNumberUtils.ttsSpanAsPhoneNumber(number)); mPhoneNumber.setVisibility(View.VISIBLE); mPhoneNumber.setTextDirection(View.TEXT_DIRECTION_LTR); } @@ -545,8 +553,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr if (TextUtils.isEmpty(number) && TextUtils.isEmpty(label)) { mCallNumberAndLabel.setVisibility(View.GONE); + mElapsedTime.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); } else { mCallNumberAndLabel.setVisibility(View.VISIBLE); + mElapsedTime.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_END); } setPrimaryPhoneNumber(number); @@ -563,7 +573,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr @Override public void setSecondary(boolean show, String name, boolean nameIsNumber, String label, - String providerLabel, Drawable providerIcon, boolean isConference) { + String providerLabel, boolean isConference) { if (show != mSecondaryCallInfo.isShown()) { updateFabPositionForSecondaryCallInfo(); @@ -575,10 +585,11 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mSecondaryCallConferenceCallIcon.setVisibility(isConference ? View.VISIBLE : View.GONE); - mSecondaryCallName.setText(name); + mSecondaryCallName.setText(nameIsNumber + ? PhoneNumberUtils.ttsSpanAsPhoneNumber(name) + : name); if (hasProvider) { mSecondaryCallProviderLabel.setText(providerLabel); - mSecondaryCallProviderIcon.setImageDrawable(providerIcon); } int nameDirection = View.TEXT_DIRECTION_INHERIT; @@ -598,7 +609,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr int sessionModificationState, DisconnectCause disconnectCause, String connectionLabel, - Drawable connectionIcon, + Drawable callStateIcon, String gatewayNumber, boolean isWaitingForRemoteSide) { boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber); @@ -624,7 +635,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallStateLabel.setAlpha(1); mCallStateLabel.setVisibility(View.VISIBLE); - if (connectionIcon == null) { + if (callStateIcon == null) { mCallStateIcon.clearAnimation(); mCallStateIcon.setVisibility(View.GONE); } else { @@ -632,7 +643,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr // Invoke setAlpha(float) instead of setAlpha(int) to set the view's alpha. This is // needed because the pulse animation operates on the view alpha. mCallStateIcon.setAlpha(1.0f); - mCallStateIcon.setImageDrawable(connectionIcon); + mCallStateIcon.setImageDrawable(callStateIcon); } if (VideoProfile.VideoState.isVideo(videoState) @@ -645,7 +656,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) { mCallStateLabel.clearAnimation(); - mCallStateIcon.clearAnimation(); } else { mCallStateLabel.startAnimation(mPulseAnimation); if (mCallStateIcon.getVisibility() == View.VISIBLE) { @@ -653,17 +663,60 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } } } else { - mCallStateLabel.clearAnimation(); + Animation callStateLabelAnimation = mCallStateLabel.getAnimation(); + if (callStateLabelAnimation != null) { + callStateLabelAnimation.cancel(); + } mCallStateLabel.setText(null); mCallStateLabel.setAlpha(0); mCallStateLabel.setVisibility(View.GONE); + } + + if (callStateIcon != null) { + mCallStateIcon.setVisibility(View.VISIBLE); + // Invoke setAlpha(float) instead of setAlpha(int) to set the view's alpha. This is + // needed because the pulse animation operates on the view alpha. + mCallStateIcon.setAlpha(1.0f); + mCallStateIcon.setImageDrawable(callStateIcon); + + if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED + || TextUtils.isEmpty(callStateLabel)) { + mCallStateIcon.clearAnimation(); + } else { + mCallStateIcon.startAnimation(mPulseAnimation); + } + + if (callStateIcon instanceof AnimationDrawable) { + ((AnimationDrawable) callStateIcon).start(); + } + } else { + Animation callStateIconAnimation = mCallStateIcon.getAnimation(); + if (callStateIconAnimation != null) { + callStateIconAnimation.cancel(); + } + // Invoke setAlpha(float) instead of setAlpha(int) to set the view's alpha. This is // needed because the pulse animation operates on the view alpha. mCallStateIcon.setAlpha(0.0f); mCallStateIcon.setVisibility(View.GONE); + } + if (VideoProfile.VideoState.isBidirectional(videoState) + || (state == Call.State.ACTIVE && sessionModificationState + == Call.SessionModificationState.WAITING_FOR_RESPONSE)) { + mCallStateVideoCallIcon.setVisibility(View.VISIBLE); + } else { mCallStateVideoCallIcon.setVisibility(View.GONE); } + + if (state == Call.State.INCOMING) { + if (callStateLabel != null) { + getView().announceForAccessibility(callStateLabel); + } + if (mPrimaryName.getText() != null) { + getView().announceForAccessibility(mPrimaryName.getText()); + } + } } @Override @@ -702,12 +755,15 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } @Override - public void setPrimaryCallElapsedTime(boolean show, String callTimeElapsed) { + public void setPrimaryCallElapsedTime(boolean show, long duration) { if (show) { if (mElapsedTime.getVisibility() != View.VISIBLE) { AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION); } + String callTimeElapsed = DateUtils.formatElapsedTime(duration / 1000); + String durationDescription = InCallDateUtils.formatDetailedDuration(duration); mElapsedTime.setText(callTimeElapsed); + mElapsedTime.setContentDescription(durationDescription); } else { // hide() animation has no effect if it is already hidden. AnimUtils.fadeOut(mElapsedTime, AnimUtils.DEFAULT_DURATION); @@ -716,16 +772,24 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private void setDrawableToImageView(ImageView view, Drawable photo) { if (photo == null) { - photo = view.getResources().getDrawable(R.drawable.img_no_image); - photo.setAutoMirrored(true); + photo = ContactInfoCache.getInstance( + view.getContext()).getDefaultContactPhotoDrawable(); } + if (mPrimaryPhotoDrawable == photo) { + return; + } + mPrimaryPhotoDrawable = photo; + final Drawable current = view.getDrawable(); if (current == null) { view.setImageDrawable(photo); AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION); } else { - InCallAnimationUtils.startCrossFade(view, current, photo); + // Cross fading is buggy and not noticable due to the multiple calls to this method + // that switch drawables in the middle of the cross-fade animations. Just set the + // photo directly instead. + view.setImageDrawable(photo); view.setVisibility(View.VISIBLE); } } @@ -838,13 +902,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mSecondaryCallName = (TextView) getView().findViewById(R.id.secondaryCallName); mSecondaryCallConferenceCallIcon = getView().findViewById(R.id.secondaryCallConferenceCallIcon); - if (hasProvider) { - mSecondaryCallProviderInfo.setVisibility(View.VISIBLE); - mSecondaryCallProviderLabel = (TextView) getView() - .findViewById(R.id.secondaryCallProviderLabel); - mSecondaryCallProviderIcon = (ImageView) getView() - .findViewById(R.id.secondaryCallProviderIcon); - } + } + + if (mSecondaryCallProviderLabel == null && hasProvider) { + mSecondaryCallProviderInfo.setVisibility(View.VISIBLE); + mSecondaryCallProviderLabel = (TextView) getView() + .findViewById(R.id.secondaryCallProviderLabel); } } @@ -918,6 +981,22 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr return mManageConferenceCallButton.getVisibility() == View.VISIBLE; } + /** + * Get the overall InCallUI background colors and apply to call card. + */ + public void updateColors() { + MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors(); + + if (mCurrentThemeColors != null && mCurrentThemeColors.equals(themeColors)) { + return; + } + + mPrimaryCallCardContainer.setBackgroundColor(themeColors.mPrimaryColor); + mCallButtonsContainer.setBackgroundColor(themeColors.mPrimaryColor); + + mCurrentThemeColors = themeColors; + } + private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) { if (view == null) return; final List<CharSequence> eventText = event.getText(); @@ -929,9 +1008,9 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } } - public void animateForNewOutgoingCall(Point touchPoint) { + public void animateForNewOutgoingCall(final Point touchPoint, + final boolean showCircularReveal) { final ViewGroup parent = (ViewGroup) mPrimaryCallCardContainer.getParent(); - final Point startPoint = touchPoint; final ViewTreeObserver observer = getView().getViewTreeObserver(); @@ -962,19 +1041,16 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallTypeLabel.setAlpha(0); mCallNumberAndLabel.setAlpha(0); - final Animator revealAnimator = getRevealAnimator(startPoint); - final Animator shrinkAnimator = - getShrinkAnimator(parent.getHeight(), originalHeight); + final Animator animator = getOutgoingCallAnimator(touchPoint, + parent.getHeight(), originalHeight, showCircularReveal); - mAnimatorSet = new AnimatorSet(); - mAnimatorSet.playSequentially(revealAnimator, shrinkAnimator); - mAnimatorSet.addListener(new AnimatorListenerAdapter() { + animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setViewStatePostAnimation(listener); } }); - mAnimatorSet.start(); + animator.start(); } }); } @@ -1030,6 +1106,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr updateFabPosition(); } }); + + updateColors(); } /** @@ -1116,6 +1194,21 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr return valueAnimator; } + private Animator getOutgoingCallAnimator(Point touchPoint, int startHeight, int endHeight, + boolean showCircularReveal) { + + final Animator shrinkAnimator = getShrinkAnimator(startHeight, endHeight); + + if (!showCircularReveal) { + return shrinkAnimator; + } + + final Animator revealAnimator = getRevealAnimator(touchPoint); + final AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.playSequentially(revealAnimator, shrinkAnimator); + return animatorSet; + } + private void assignTranslateAnimation(View view, int offset) { view.setTranslationY(mTranslationOffset * offset); view.animate().translationY(0).alpha(1).withLayer() |