diff options
author | Andrew Lee <anwlee@google.com> | 2014-08-11 14:44:18 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-08-12 10:19:05 -0700 |
commit | 9c98346835b8e902e0c2c11f14a35f4e91578e9f (patch) | |
tree | 83aefdcecd5d19d378f24b8dbd10c6896fdd2b27 /InCallUI/src/com/android/incallui/VideoCallPresenter.java | |
parent | c4abc8aee5ff3d92f1ca255ba271f6f46ecd6cc8 (diff) |
Add UI/functions to handle a video upgrade request.
+ Move session modification listener into the video call presenter.
+ Add new video accept/reject notification and full-screen UI.
+ Added "handling" which sends session modification response.
Bug: 16657915
Change-Id: I35ff04e383d4938cbfb4e76677730f82557fd918
Diffstat (limited to 'InCallUI/src/com/android/incallui/VideoCallPresenter.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallPresenter.java | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 025a863e2..73947e521 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -18,6 +18,7 @@ package com.android.incallui; import android.content.Context; import android.content.res.Configuration; +import android.os.Handler; import android.telecomm.CallAudioState; import android.telecomm.InCallService.VideoCall; import android.view.Surface; @@ -56,7 +57,8 @@ import java.util.Objects; */ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi> implements IncomingCallListener, InCallOrientationListener, InCallStateListener, - InCallDetailsListener, SurfaceChangeListener, VideoEventListener { + InCallDetailsListener, SurfaceChangeListener, VideoEventListener, + InCallVideoCallListenerNotifier.SessionModificationListener { /** * Determines the device orientation (portrait/lanscape). @@ -145,6 +147,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi */ private int mPreVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; + /** Handler which resets request state to NO_REQUEST after an interval. */ + private Handler mSessionModificationResetHandler; + private static final long SESSION_MODIFICATION_RESET_DELAY_MS = 3000; + /** * Initializes the presenter. * @@ -154,6 +160,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi mContext = Preconditions.checkNotNull(context); mMinimumVideoDimension = mContext.getResources().getDimension( R.dimen.video_preview_small_dimension); + mSessionModificationResetHandler = new Handler(); } /** @@ -173,6 +180,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi // Register for surface and video events from {@link InCallVideoCallListener}s. InCallVideoCallListenerNotifier.getInstance().addSurfaceChangeListener(this); InCallVideoCallListenerNotifier.getInstance().addVideoEventListener(this); + InCallVideoCallListenerNotifier.getInstance().addSessionModificationListener(this); mInCallCameraManager = InCallPresenter.getInstance().getInCallCameraManager(); mIsVideoCall = false; @@ -192,6 +200,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().removeOrientationListener(this); InCallVideoCallListenerNotifier.getInstance().removeSurfaceChangeListener(this); InCallVideoCallListenerNotifier.getInstance().removeVideoEventListener(this); + InCallVideoCallListenerNotifier.getInstance().removeSessionModificationListener(this); mInCallCameraManager = null; } @@ -516,6 +525,43 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi mDeviceOrientation = orientation; } + @Override + public void onUpgradeToVideoRequest(Call call) { + mPrimaryCall.setSessionModificationState( + Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST); + } + + @Override + public void onUpgradeToVideoSuccess(Call call) { + if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { + return; + } + + mPrimaryCall.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + } + + @Override + public void onUpgradeToVideoFail(Call call) { + if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { + return; + } + + call.setSessionModificationState(Call.SessionModificationState.REQUEST_FAILED); + + // Start handler to change state from REQUEST_FAILED to NO_REQUEST after an interval. + mSessionModificationResetHandler.postDelayed(new Runnable() { + @Override + public void run() { + mPrimaryCall.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + } + }, SESSION_MODIFICATION_RESET_DELAY_MS); + } + + @Override + public void onDowngradeToAudio(Call call) { + // Implementing to satsify interface. + } + /** * Sets the preview surface size based on the current device orientation. * See: {@link Configuration.ORIENTATION_LANDSCAPE}, {@link Configuration.ORIENTATION_PORTRAIT} |