summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2015-05-21 17:33:49 -0700
committerEtan Cohen <etancohen@google.com>2015-05-21 17:33:49 -0700
commit75618722a6a796dc0650a534e0bac8cc728618c5 (patch)
treefabdc816a435f7a07c0ac30bcd3b8abd4868935e /InCallUI
parenta4d01f700648cce804215b36ee8223770b84610f (diff)
parentfd640ab7b1efe30574c96a12b06627f365d0432a (diff)
Merge commit 'f28f4a3' into merge
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/res/layout/incall_screen.xml1
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java40
-rw-r--r--InCallUI/src/com/android/incallui/CallCardPresenter.java24
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java47
4 files changed, 88 insertions, 24 deletions
diff --git a/InCallUI/res/layout/incall_screen.xml b/InCallUI/res/layout/incall_screen.xml
index d46778c1c..3922ea073 100644
--- a/InCallUI/res/layout/incall_screen.xml
+++ b/InCallUI/res/layout/incall_screen.xml
@@ -18,5 +18,6 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@android:color/black"
android:id="@+id/main" >
</FrameLayout>
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java
index 4ef4818aa..468b36baa 100644
--- a/InCallUI/src/com/android/incallui/CallCardFragment.java
+++ b/InCallUI/src/com/android/incallui/CallCardFragment.java
@@ -448,10 +448,16 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
}
+ /**
+ * Sets the primary image for the contact photo.
+ *
+ * @param image The drawable to set.
+ * @param isVisible Whether the contact photo should be visible after being set.
+ */
@Override
- public void setPrimaryImage(Drawable image) {
+ public void setPrimaryImage(Drawable image, boolean isVisible) {
if (image != null) {
- setDrawableToImageView(mPhoto, image);
+ setDrawableToImageView(mPhoto, image, isVisible);
}
}
@@ -479,9 +485,21 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
+ /**
+ * Sets the primary caller information.
+ *
+ * @param number The caller phone number.
+ * @param name The caller name.
+ * @param nameIsNumber {@code true} if the name should be shown in place of the phone number.
+ * @param label The label.
+ * @param photo The contact photo drawable.
+ * @param isSipCall {@code true} if this is a SIP call.
+ * @param isContactPhotoShown {@code true} if the contact photo should be shown (it will be
+ * updated even if it is not shown).
+ */
@Override
public void setPrimary(String number, String name, boolean nameIsNumber, String label,
- Drawable photo, boolean isSipCall) {
+ Drawable photo, boolean isSipCall, boolean isContactPhotoShown) {
Log.d(this, "Setting primary call");
// set the name field.
setPrimaryName(name, nameIsNumber);
@@ -501,7 +519,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
showInternetCallLabel(isSipCall);
- setDrawableToImageView(mPhoto, photo);
+ setDrawableToImageView(mPhoto, photo, isContactPhotoShown);
}
@Override
@@ -642,6 +660,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
Log.v(this, "DisconnectCause " + disconnectCause.toString());
Log.v(this, "gateway " + connectionLabel + gatewayNumber);
+ // Check for video state change and update the visibility of the contact photo. The contact
+ // photo is hidden when the incoming video surface is shown.
+ // The contact photo visibility can also change in setPrimary().
+ boolean showContactPhoto = !VideoCallPresenter.showIncomingVideo(videoState, state);
+ mPhoto.setVisibility(showContactPhoto ? View.VISIBLE : View.GONE);
+
if (TextUtils.equals(callStateLabel.getCallStateLabel(), mCallStateLabel.getText())) {
// Nothing to do if the labels are the same
if (state == Call.State.ACTIVE || state == Call.State.CONFERENCED) {
@@ -809,7 +833,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
}
}
- private void setDrawableToImageView(ImageView view, Drawable photo) {
+ private void setDrawableToImageView(ImageView view, Drawable photo, boolean isVisible) {
if (photo == null) {
photo = ContactInfoCache.getInstance(
view.getContext()).getDefaultContactPhotoDrawable();
@@ -823,13 +847,15 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
final Drawable current = view.getDrawable();
if (current == null) {
view.setImageDrawable(photo);
- AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION);
+ if (isVisible) {
+ AnimUtils.fadeIn(mElapsedTime, AnimUtils.DEFAULT_DURATION);
+ }
} else {
// 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);
+ view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
}
}
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 7786d9466..892b07707 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -488,7 +488,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
if (entry.photo != null) {
if (mPrimary != null && callId.equals(mPrimary.getId())) {
- getUi().setPrimaryImage(entry.photo);
+ boolean showContactPhoto = !VideoCallPresenter.showIncomingVideo(
+ mPrimary.getVideoState(), mPrimary.getState());
+ getUi().setPrimaryImage(entry.photo, showContactPhoto);
}
}
}
@@ -512,7 +514,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
* @param ignore A call to ignore if found.
*/
private Call getCallToDisplay(CallList callList, Call ignore, boolean skipDisconnected) {
-
// Active calls come second. An active call always gets precedent.
Call retval = callList.getActiveCall();
if (retval != null && retval != ignore) {
@@ -556,10 +557,15 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
if (mPrimary == null) {
// Clear the primary display info.
- ui.setPrimary(null, null, false, null, null, false);
+ ui.setPrimary(null, null, false, null, null, false, false);
return;
}
+ // Hide the contact photo if we are in a video call and the incoming video surface is
+ // showing.
+ boolean showContactPhoto = !VideoCallPresenter
+ .showIncomingVideo(mPrimary.getVideoState(), mPrimary.getState());
+
if (mPrimary.isConferenceCall()) {
Log.d(TAG, "Update primary display info for conference call.");
@@ -569,7 +575,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
false /* nameIsNumber */,
null /* label */,
getConferencePhoto(mPrimary),
- false /* isSipCall */);
+ false /* isSipCall */,
+ showContactPhoto);
} else if (mPrimaryContactInfo != null) {
Log.d(TAG, "Update primary display info for " + mPrimaryContactInfo);
@@ -582,10 +589,11 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
nameIsNumber,
mPrimaryContactInfo.label,
mPrimaryContactInfo.photo,
- mPrimaryContactInfo.isSipCall);
+ mPrimaryContactInfo.isSipCall,
+ showContactPhoto);
} else {
// Clear the primary display info.
- ui.setPrimary(null, null, false, null, null, false);
+ ui.setPrimary(null, null, false, null, null, false, false);
}
if (mEmergencyCallListener != null) {
@@ -836,7 +844,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
void setVisible(boolean on);
void setCallCardVisible(boolean visible);
void setPrimary(String number, String name, boolean nameIsNumber, String label,
- Drawable photo, boolean isSipCall);
+ Drawable photo, boolean isSipCall, boolean isContactPhotoShown);
void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
String providerLabel, boolean isConference, boolean isVideoCall,
boolean isFullscreen);
@@ -847,7 +855,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
boolean isConference);
void setPrimaryCallElapsedTime(boolean show, long duration);
void setPrimaryName(String name, boolean nameIsNumber);
- void setPrimaryImage(Drawable image);
+ void setPrimaryImage(Drawable image, boolean isVisible);
void setPrimaryPhoneNumber(String phoneNumber);
void setPrimaryLabel(String label);
void setEndCallButtonEnabled(boolean enabled, boolean animate);
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 47950dd16..6763fbe8c 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -784,15 +784,16 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
Log.e(this, "showVideoUi, VideoCallUi is null returning");
return;
}
- boolean isPaused = VideoProfile.VideoState.isPaused(videoState);
- boolean isCallActive = callState == Call.State.ACTIVE;
- if (VideoProfile.VideoState.isBidirectional(videoState)) {
- ui.showVideoViews(true, !isPaused && isCallActive);
- } else if (VideoProfile.VideoState.isTransmissionEnabled(videoState)) {
- ui.showVideoViews(true, false);
- } else if (VideoProfile.VideoState.isReceptionEnabled(videoState)) {
- ui.showVideoViews(false, !isPaused && isCallActive);
- loadProfilePhotoAsync();
+ boolean showIncomingVideo = showIncomingVideo(videoState, callState);
+ boolean showOutgoingVideo = showOutgoingVideo(videoState);
+ Log.v(this, "showVideoUi : showIncoming = " + showIncomingVideo + " showOutgoing = "
+ + showOutgoingVideo);
+ if (showIncomingVideo || showOutgoingVideo) {
+ ui.showVideoViews(showOutgoingVideo, showIncomingVideo);
+
+ if (VideoProfile.VideoState.isReceptionEnabled(videoState)) {
+ loadProfilePhotoAsync();
+ }
} else {
ui.hideVideoUi();
}
@@ -802,6 +803,34 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
}
/**
+ * Determines if the incoming video surface should be shown based on the current videoState and
+ * callState. The video surface is shown when incoming video is not paused, the call is active,
+ * and video reception is enabled.
+ *
+ * @param videoState The current video state.
+ * @param callState The current call state.
+ * @return {@code true} if the incoming video surface should be shown, {@code false} otherwise.
+ */
+ public static boolean showIncomingVideo(int videoState, int callState) {
+ boolean isPaused = VideoProfile.VideoState.isPaused(videoState);
+ boolean isCallActive = callState == Call.State.ACTIVE;
+
+ return !isPaused && isCallActive && VideoProfile.VideoState.isReceptionEnabled(videoState);
+ }
+
+ /**
+ * Determines if the outgoing video surface should be shown based on the current videoState.
+ * The video surface is shown if video transmission is enabled.
+ *
+ * @param videoState The current video state.
+ * @return {@code true} if the the outgoing video surface should be shown, {@code false}
+ * otherwise.
+ */
+ public static boolean showOutgoingVideo(int videoState) {
+ return VideoProfile.VideoState.isTransmissionEnabled(videoState);
+ }
+
+ /**
* Handles peer video pause state changes.
*
* @param call The call which paused or un-pausedvideo transmission.