From f6e7ba0ca231fb5373510c6c622674a13e54ff99 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Fri, 18 Jul 2014 18:00:44 -0700 Subject: Implement new video-call-related buttons. - Implemented downgrade/upgrade, switch camera, pause camear. - Implemented code to find front/back-facing cameraIds. - Also, cleaned up listener logic in CallButtonFragment to be more consistent. Bug: 16014280 Change-Id: I267a73943dc768900b663bb4db6ec52f4a35cac5 --- InCallUI/src/com/android/incallui/Call.java | 6 +- .../com/android/incallui/CallButtonFragment.java | 89 ++++++++-------- .../com/android/incallui/CallButtonPresenter.java | 115 ++++++++++++++++++++- 3 files changed, 167 insertions(+), 43 deletions(-) (limited to 'InCallUI/src') diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 830b58114..f3986a4fa 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -327,8 +327,12 @@ public final class Call { return mParentCallId; } + public int getVideoState() { + return mTelecommCall.getDetails().getVideoState(); + } + public boolean isVideoCall() { - int videoState = mTelecommCall.getDetails().getVideoState(); + int videoState = getVideoState(); return (videoState & VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL) == VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL; } diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 077c8124b..80119a404 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -68,8 +68,7 @@ public class CallButtonFragment @Override CallButtonPresenter createPresenter() { - // TODO: find a cleaner way to include audio mode provider than - // having a singleton instance. + // TODO: find a cleaner way to include audio mode provider than having a singleton instance. return new CallButtonPresenter(); } @@ -91,50 +90,20 @@ public class CallButtonFragment mExtraRowButton = parent.findViewById(R.id.extraButtonRow); mManageConferenceButton = parent.findViewById(R.id.manageConferenceButton); - mManageConferenceButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - getPresenter().manageConferenceButtonClicked(); - } - }); + mManageConferenceButton.setOnClickListener(this); mGenericMergeButton = parent.findViewById(R.id.cdmaMergeButton); - mGenericMergeButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - getPresenter().mergeClicked(); - } - }); - - mMuteButton = (ImageButton) parent.findViewById(R.id.muteButton); - mMuteButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - final ImageButton button = (ImageButton) v; - getPresenter().muteClicked(!button.isSelected()); - } - }); + mGenericMergeButton.setOnClickListener(this); mAudioButton = (ImageButton) parent.findViewById(R.id.audioButton); - mAudioButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - onAudioButtonClicked(); - } - }); - - mHoldButton = (ImageButton) parent.findViewById(R.id.holdButton); - mHoldButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - final ImageButton button = (ImageButton) v; - getPresenter().holdClicked(!button.isSelected()); - } - }); - + mAudioButton.setOnClickListener(this); mChangeToVoiceButton = (ImageButton) parent.findViewById(R.id.changeToVoiceButton); mChangeToVoiceButton. setOnClickListener(this); + mMuteButton = (ImageButton) parent.findViewById(R.id.muteButton); + mMuteButton.setOnClickListener(this); mShowDialpadButton = (ImageButton) parent.findViewById(R.id.dialpadButton); mShowDialpadButton.setOnClickListener(this); + mHoldButton = (ImageButton) parent.findViewById(R.id.holdButton); + mHoldButton.setOnClickListener(this); mSwapButton = (ImageButton) parent.findViewById(R.id.swapButton); mSwapButton.setOnClickListener(this); mChangeToVideoButton = (ImageButton) parent.findViewById(R.id.changeToVideoButton); @@ -159,6 +128,7 @@ public class CallButtonFragment // set the buttons updateAudioButtons(getPresenter().getSupportedAudio()); + getPresenter().initializeCameraManager(getActivity().getApplicationContext()); } @Override @@ -179,24 +149,51 @@ public class CallButtonFragment Log.d(this, "onClick(View " + view + ", id " + id + ")..."); switch(id) { + case R.id.audioButton: + onAudioButtonClicked(); + break; case R.id.addButton: getPresenter().addCallClicked(); break; + case R.id.changeToVoiceButton: + getPresenter().changeToVoiceClicked(); + break; + case R.id.muteButton: { + final ImageButton button = (ImageButton) view; + getPresenter().muteClicked(!button.isSelected()); + break; + } + case R.id.cdmaMergeButton: case R.id.mergeButton: getPresenter().mergeClicked(); break; + case R.id.holdButton: { + final ImageButton button = (ImageButton) view; + getPresenter().holdClicked(!button.isSelected()); + break; + } case R.id.swapButton: getPresenter().swapClicked(); break; case R.id.dialpadButton: getPresenter().showDialpadClicked(!mShowDialpadButton.isSelected()); break; - case R.id.changeToVoiceButton: case R.id.changeToVideoButton: + getPresenter().changeToVideoClicked(); + break; case R.id.switchCameraButton: + getPresenter().switchCameraClicked( + mSwitchCameraButton.isSelected() /* useFrontFacingCamera */); + break; case R.id.pauseVideoButton: + getPresenter().pauseVideoClicked( + !mPauseVideoButton.isSelected() /* pause */); + break; case R.id.overflowButton: - // TODO: Implement these button behaviors. + // TODO: Implement. + break; + case R.id.manageConferenceButton: + getPresenter().manageConferenceButtonClicked(); break; default: Log.wtf(this, "onClick: unexpected"); @@ -281,6 +278,11 @@ public class CallButtonFragment mSwitchCameraButton.setVisibility(show ? View.VISIBLE : View.GONE); } + @Override + public void setSwitchCameraButton(boolean isBackFacingCamera) { + mSwitchCameraButton.setSelected(isBackFacingCamera); + } + @Override public void showAddCallButton(boolean show) { mAddCallButton.setVisibility(show ? View.VISIBLE : View.GONE); @@ -301,6 +303,11 @@ public class CallButtonFragment mPauseVideoButton.setVisibility(show ? View.VISIBLE : View.GONE); } + @Override + public void setPauseVideoButton(boolean isPaused) { + mPauseVideoButton.setSelected(isPaused); + } + @Override public void showOverflowButton(boolean show) { mOverflowButton.setVisibility(show ? View.VISIBLE : View.GONE); diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 4f457b8c2..6e841a1cc 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -16,7 +16,13 @@ package com.android.incallui; +import android.content.Context; +import android.hardware.camera2.CameraAccessException; +import android.hardware.camera2.CameraCharacteristics; +import android.hardware.camera2.CameraManager; import android.telecomm.CallCapabilities; +import android.telecomm.RemoteCallVideoProvider; +import android.telecomm.VideoCallProfile; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.contacts.common.util.TelephonyManagerUtils; @@ -37,15 +43,20 @@ public class CallButtonPresenter extends Presenter