From 0155327bda129ddf72ead3a5da86a6d2ffe459ce Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 22 Apr 2015 14:04:21 -0700 Subject: Incoming video calls - accept only 2-way calls. - In AnswerPresenter, only show the video targets if the incoming call is a bi-directional video call. Bug: 20254835 Change-Id: I34f3fd79d126a2ae621afeb13ceb2b143bdca2ce --- InCallUI/src/com/android/incallui/AnswerPresenter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index 208532572..597975a69 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -261,13 +261,14 @@ public class AnswerPresenter extends Presenter } private void configureAnswerTargetsForSms(Call call, List textMsgs) { - final Context context = getUi().getContext(); - mHasTextMessages = textMsgs != null; boolean withSms = call.can(android.telecom.Call.Details.CAPABILITY_RESPOND_VIA_TEXT) && mHasTextMessages; - if (call.isVideoCall(context)) { + + // Only present the user with the option to answer as a video call if the incoming call is + // a bi-directional video call. + if (VideoProfile.VideoState.isBidirectional((call.getVideoState()))) { if (withSms) { getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); getUi().configureMessageDialog(textMsgs); -- cgit v1.2.3 From c1d4aef578dafd4ed130e664ea0fe025e25f5631 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 24 Apr 2015 16:19:06 -0700 Subject: Upgrade / downgrade requests - Remove unnecessary "change to voice" button. - Remove "modify call option" dialog that showed up in the past when pressing the "upgrade to video button". - Cleaned up some unnecessary Toasts for call session events, data usage, and video quality - Implemented the camera on/off functionality. - Change preview to show the user's profile photo when their camera is turned off, as well as a "camera off" icon. Bug: 20257400 Change-Id: I6b7bb3d2394467f1345a798557130b2a674337c4 --- InCallUI/res/drawable/btn_change_to_voice.xml | 31 ----- InCallUI/res/layout/call_button_fragment.xml | 9 +- InCallUI/res/layout/video_call_views.xml | 41 +++++- InCallUI/res/values/strings.xml | 26 ++-- InCallUI/src/com/android/incallui/Call.java | 8 +- .../com/android/incallui/CallButtonFragment.java | 105 ++------------ .../com/android/incallui/CallButtonPresenter.java | 27 ++-- InCallUI/src/com/android/incallui/CallUtils.java | 5 +- .../com/android/incallui/VideoCallFragment.java | 127 ++++++----------- .../com/android/incallui/VideoCallPresenter.java | 153 ++++++++++++++++----- 10 files changed, 233 insertions(+), 299 deletions(-) delete mode 100644 InCallUI/res/drawable/btn_change_to_voice.xml diff --git a/InCallUI/res/drawable/btn_change_to_voice.xml b/InCallUI/res/drawable/btn_change_to_voice.xml deleted file mode 100644 index 86a7f21d5..000000000 --- a/InCallUI/res/drawable/btn_change_to_voice.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/InCallUI/res/layout/call_button_fragment.xml b/InCallUI/res/layout/call_button_fragment.xml index 81c3f69c7..73d14eb2b 100644 --- a/InCallUI/res/layout/call_button_fragment.xml +++ b/InCallUI/res/layout/call_button_fragment.xml @@ -70,13 +70,6 @@ android:background="@drawable/btn_compound_audio" android:contentDescription="@string/audio_mode_speaker" /> - - - @@ -146,7 +139,7 @@ android:contentDescription="@string/onscreenMergeCallsText" android:visibility="gone" /> - + - + android:layout_height="120dp" + android:layout_gravity="bottom|right" + android:layout_margin="@dimen/video_preview_margin" > + + + + + + + + + + diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml index 332576d34..628d0bf59 100644 --- a/InCallUI/res/values/strings.xml +++ b/InCallUI/res/values/strings.xml @@ -294,13 +294,6 @@ More options - - Which type of call? - Video bidirectional - Video transmit - Video receive - Voice Only - Player Started @@ -444,17 +437,6 @@ Emergency number - - Video quality changed to \u0020 - - High - - Medium - - Low - - Unknown - 1 second @@ -470,4 +452,12 @@ 1 hour %d hours + + + Profile photo + + + Camera off diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 729d87c8c..3b97b0bab 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -484,9 +484,6 @@ public final class Call { mSessionModificationState = state; Log.d(this, "setSessionModificationState " + state + " mSessionModificationState=" + mSessionModificationState); - if (state != Call.SessionModificationState.WAITING_FOR_RESPONSE) { - setModifyToVideoState(VideoProfile.VideoState.AUDIO_ONLY); - } if (hasChanged) { update(); } @@ -518,7 +515,7 @@ public final class Call { @Override public String toString() { return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s, conferenceable:%s, " + - "videoState:%d, mSessionModificationState:%d, VideoSettings:%s]", + "videoState:%s, mSessionModificationState:%d, VideoSettings:%s]", mId, State.toString(getState()), android.telecom.Call.Details @@ -526,7 +523,8 @@ public final class Call { mChildCallIds, getParentId(), this.mTelecommCall.getConferenceableCalls(), - mTelecommCall.getDetails().getVideoState(), + VideoProfile.VideoState.videoStateToString( + mTelecommCall.getDetails().getVideoState()), mSessionModificationState, getVideoSettings()); } diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index e7cfe2c6b..6da66ba38 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -68,24 +68,22 @@ public class CallButtonFragment public interface Buttons { public static final int BUTTON_AUDIO = 0; - public static final int BUTTON_DOWNGRADE_TO_VOICE = 1; - public static final int BUTTON_MUTE = 2; - public static final int BUTTON_DIALPAD = 3; - public static final int BUTTON_HOLD = 4; - public static final int BUTTON_SWAP = 5; - public static final int BUTTON_UPGRADE_TO_VIDEO = 6; - public static final int BUTTON_SWITCH_CAMERA = 7; - public static final int BUTTON_ADD_CALL = 8; - public static final int BUTTON_MERGE = 9; - public static final int BUTTON_PAUSE_VIDEO = 10; - public static final int BUTTON_MANAGE_VIDEO_CONFERENCE = 11; - public static final int BUTTON_COUNT = 12; + public static final int BUTTON_MUTE = 1; + public static final int BUTTON_DIALPAD = 2; + public static final int BUTTON_HOLD = 3; + public static final int BUTTON_SWAP = 4; + public static final int BUTTON_UPGRADE_TO_VIDEO = 5; + public static final int BUTTON_SWITCH_CAMERA = 6; + public static final int BUTTON_ADD_CALL = 7; + public static final int BUTTON_MERGE = 8; + public static final int BUTTON_PAUSE_VIDEO = 9; + public static final int BUTTON_MANAGE_VIDEO_CONFERENCE = 10; + public static final int BUTTON_COUNT = 11; } private SparseIntArray mButtonVisibilityMap = new SparseIntArray(BUTTON_COUNT); private CompoundButton mAudioButton; - private ImageButton mChangeToVoiceButton; private CompoundButton mMuteButton; private CompoundButton mShowDialpadButton; private CompoundButton mHoldButton; @@ -138,8 +136,6 @@ public class CallButtonFragment mAudioButton = (CompoundButton) parent.findViewById(R.id.audioButton); mAudioButton.setOnClickListener(this); - mChangeToVoiceButton = (ImageButton) parent.findViewById(R.id.changeToVoiceButton); - mChangeToVoiceButton. setOnClickListener(this); mMuteButton = (CompoundButton) parent.findViewById(R.id.muteButton); mMuteButton.setOnClickListener(this); mShowDialpadButton = (CompoundButton) parent.findViewById(R.id.dialpadButton); @@ -196,10 +192,6 @@ public class CallButtonFragment case R.id.addButton: getPresenter().addCallClicked(); break; - case R.id.changeToVoiceButton: - // STOPSHIP One way video options - getPresenter().displayModifyCallOptions(); - break; case R.id.muteButton: { getPresenter().muteClicked(!mMuteButton.isSelected()); break; @@ -219,8 +211,7 @@ public class CallButtonFragment getPresenter().showDialpadClicked(!mShowDialpadButton.isSelected()); break; case R.id.changeToVideoButton: - // STOPSHIP One way video options - getPresenter().displayModifyCallOptions(); + getPresenter().changeToVideoClicked(); break; case R.id.switchCameraButton: getPresenter().switchCameraClicked( @@ -271,7 +262,6 @@ public class CallButtonFragment } ImageButton[] normalButtons = { - mChangeToVoiceButton, mSwapButton, mChangeToVideoButton, mAddCallButton, @@ -362,7 +352,6 @@ public class CallButtonFragment } mAudioButton.setEnabled(isEnabled); - mChangeToVoiceButton.setEnabled(isEnabled); mMuteButton.setEnabled(isEnabled); mShowDialpadButton.setEnabled(isEnabled); mHoldButton.setEnabled(isEnabled); @@ -393,8 +382,6 @@ public class CallButtonFragment switch (id) { case BUTTON_AUDIO: return mAudioButton; - case BUTTON_DOWNGRADE_TO_VOICE: - return mChangeToVoiceButton; case BUTTON_MUTE: return mMuteButton; case BUTTON_DIALPAD: @@ -448,74 +435,6 @@ public class CallButtonFragment } } - /**The function is called when Modify Call button gets pressed. The function creates and - * displays modify call options. - */ - @Override - public void displayModifyCallOptions() { - CallButtonPresenter.CallButtonUi ui = getUi(); - if (ui == null) { - Log.e(this, "Cannot display ModifyCallOptions as ui is null"); - return; - } - - Context context = getContext(); - - final ArrayList items = new ArrayList(); - final ArrayList itemToCallType = new ArrayList(); - final Resources res = ui.getContext().getResources(); - // Prepare the string array and mapping. - items.add(res.getText(R.string.modify_call_option_voice)); - itemToCallType.add(VideoProfile.VideoState.AUDIO_ONLY); - - items.add(res.getText(R.string.modify_call_option_vt_rx)); - itemToCallType.add(VideoProfile.VideoState.RX_ENABLED); - - items.add(res.getText(R.string.modify_call_option_vt_tx)); - itemToCallType.add(VideoProfile.VideoState.TX_ENABLED); - - items.add(res.getText(R.string.modify_call_option_vt)); - itemToCallType.add(VideoProfile.VideoState.BIDIRECTIONAL); - - AlertDialog.Builder builder = new AlertDialog.Builder(getUi().getContext()); - builder.setTitle(R.string.modify_call_option_title); - final AlertDialog alert; - - DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int item) { - Toast.makeText(getUi().getContext(), items.get(item), Toast.LENGTH_SHORT).show(); - final int selCallType = itemToCallType.get(item); - Log.v(this, "Videocall: ModifyCall: upgrade/downgrade to " - + fromCallType(selCallType)); - VideoProfile videoProfile = new VideoProfile(selCallType); - getPresenter().changeToVideoClicked(videoProfile); - dialog.dismiss(); - } - }; - int currVideoState = getPresenter().getCurrentVideoState(); - int currUnpausedVideoState = CallUtils.getUnPausedVideoState(currVideoState); - int index = itemToCallType.indexOf(currUnpausedVideoState); - if (index == INVALID_INDEX) { - return; - } - builder.setSingleChoiceItems(items.toArray(new CharSequence[0]), index, listener); - alert = builder.create(); - alert.show(); - } - - public static String fromCallType(int callType) { - switch (callType) { - case VideoProfile.VideoState.BIDIRECTIONAL: - return "VT"; - case VideoProfile.VideoState.TX_ENABLED: - return "VT_TX"; - case VideoProfile.VideoState.RX_ENABLED: - return "VT_RX"; - } - return ""; - } - private void addToOverflowMenu(int id, View button, PopupMenu menu) { button.setVisibility(View.GONE); menu.getMenu().add(Menu.NONE, id, Menu.NONE, button.getContentDescription()); diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 650649479..2544c5f92 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -258,20 +258,16 @@ public class CallButtonPresenter extends Presenter task = new AsyncTask() { + /** + * Performs asynchronous load of the user profile information. + * + * @param params The parameters of the task. + * + * @return {@code null}. + */ + @Override + protected Void doInBackground(Void... params) { + if (mProfileInfo == null) { + // Try and read the photo URI from the local profile. + mProfileInfo = new ContactInfoCache.ContactCacheEntry(); + final Cursor cursor = mContext.getContentResolver().query( + ContactsContract.Profile.CONTENT_URI, new String[]{ + ContactsContract.CommonDataKinds.Phone._ID, + ContactsContract.CommonDataKinds.Phone.PHOTO_URI, + ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY, + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, + }, null, null, null); + if (cursor != null) { + try { + if (cursor.moveToFirst()) { + mProfileInfo.lookupKey = cursor.getString(cursor.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY)); + String photoUri = cursor.getString(cursor.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.PHOTO_URI)); + mProfileInfo.displayPhotoUri = photoUri == null ? null + : Uri.parse(photoUri); + mProfileInfo.name = cursor.getString(cursor.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); + } + } finally { + cursor.close(); + } + } + } + + // If user profile information was found, issue an async request to load the user's + // profile photo. + if (mProfileInfo != null) { + if (mContactPhotoManager == null) { + mContactPhotoManager = ContactPhotoManager.getInstance(mContext); + } + ContactPhotoManager.DefaultImageRequest imageRequest = (mProfileInfo != null) + ? null : + new ContactPhotoManager.DefaultImageRequest(mProfileInfo.name, + mProfileInfo.lookupKey, false /* isCircularPhoto */); + + mContactPhotoManager + .loadDirectoryPhoto(ui.getPreviewPhotoView(), + mProfileInfo.displayPhotoUri, + false /* darkTheme */, false /* isCircular */, imageRequest); + } + return null; + } + + @Override + protected void onPostExecute(Void result) { + // No-op + } + }; + + task.execute(); + } + /** * Defines the VideoCallUI interactions. */ public interface VideoCallUi extends Ui { void showVideoViews(boolean showPreview, boolean showIncoming); void hideVideoUi(); - void showVideoQualityChanged(int videoQuality); boolean isDisplayVideoSurfaceCreated(); boolean isPreviewVideoSurfaceCreated(); Surface getDisplayVideoSurface(); @@ -1113,10 +1203,9 @@ public class VideoCallPresenter extends Presenter