diff options
author | Andrew Lee <anwlee@google.com> | 2014-07-15 11:54:17 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-07-16 11:04:51 -0700 |
commit | 77701216b331f54d2d7ccb95b97f2cf98f2c3957 (patch) | |
tree | baf9f7a25d7e963b384b6561c1a4c699a843233e /InCallUI | |
parent | 10a7a7b70665c43850602fb77e97a00cbf768e19 (diff) |
Add video call handling for heads up notifications.
- Add isVideo method to the InCallUI call.
- Added cases and actions for isVideo to StatusBarNotifier.
- Added cases for isVideo for processing incoming call in the
full-screen experience in AnswerPresenter.
- Did what I figured would be some cleanup, to consolidate some
helper methods only ever called once, and reorder some methods
to be more alphabetical.
- Added new intent type for video calls (and revised old one for
audio calls), which are dispatched by the StatusBarNotifier and
received by the InCallApp.
- Update icons used, and deleted unused icons.
Bug: 16013878
Change-Id: If0a8d04e2ee6eaf8258ce6a677b22d55a584f9ab
Diffstat (limited to 'InCallUI')
17 files changed, 99 insertions, 78 deletions
diff --git a/InCallUI/AndroidManifest.xml b/InCallUI/AndroidManifest.xml index 1ab6936c5..62443dab9 100644 --- a/InCallUI/AndroidManifest.xml +++ b/InCallUI/AndroidManifest.xml @@ -60,7 +60,8 @@ <receiver android:name="InCallApp$NotificationBroadcastReceiver" android:exported="false"> <intent-filter> <action android:name="com.android.incallui.ACTION_HANG_UP_ONGOING_CALL" /> - <action android:name="com.android.incallui.ACTION_ANSWER_INCOMING_CALL" /> + <action android:name="com.android.incallui.ACTION_ANSWER_VIDEO_INCOMING_CALL" /> + <action android:name="com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL" /> <action android:name="com.android.incallui.ACTION_DECLINE_INCOMING_CALL" /> </intent-filter> </receiver> diff --git a/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index 7eda84ca5..000000000 --- a/InCallUI/res/drawable-hdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png Binary files differdeleted file mode 100644 index bc7493751..000000000 --- a/InCallUI/res/drawable-hdpi/stat_sys_phone_call_end.png +++ /dev/null diff --git a/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index e0f33f88c..000000000 --- a/InCallUI/res/drawable-ldrtl-hdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index d771d87bf..000000000 --- a/InCallUI/res/drawable-ldrtl-mdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index 86af9c202..000000000 --- a/InCallUI/res/drawable-ldrtl-xhdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index 70a4bbe71..000000000 --- a/InCallUI/res/drawable-mdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png Binary files differdeleted file mode 100644 index 15e7e67fc..000000000 --- a/InCallUI/res/drawable-mdpi/stat_sys_phone_call_end.png +++ /dev/null diff --git a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index 1bb434076..000000000 --- a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png Binary files differdeleted file mode 100644 index b0b1bc1c8..000000000 --- a/InCallUI/res/drawable-xhdpi/stat_sys_phone_call_end.png +++ /dev/null diff --git a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png b/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png Binary files differdeleted file mode 100644 index 934838484..000000000 --- a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call.png +++ /dev/null diff --git a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png b/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png Binary files differdeleted file mode 100644 index 1f3a81bb5..000000000 --- a/InCallUI/res/drawable-xxhdpi/stat_sys_phone_call_end.png +++ /dev/null diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml index 3c1030225..19ba8a6c8 100644 --- a/InCallUI/res/values/strings.xml +++ b/InCallUI/res/values/strings.xml @@ -211,10 +211,10 @@ scenarios such as accepting an incoming call or accepting a video call request. [CHAR LIMIT=40] --> <string name="notification_action_accept">Accept</string> - <!-- Label for "Decline" notification action. This is somewhat generic, and may refer to + <!-- Label for "Dismiss" notification action. This is somewhat generic, and may refer to scenarios such as declining an incoming call or declining a video call request. [CHAR LIMIT=40] --> - <string name="notification_action_decline">Decline</string> + <string name="notification_action_dismiss">Dismiss</string> <!-- Message for "call back" Action, which is displayed in the missed call notificaiton. The user will be able to call back to the person or the phone number. diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index 188fabb52..86594545b 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -93,11 +93,21 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> final List<String> textMsgs = CallList.getInstance().getTextResponses(call.getId()); getUi().showAnswerUi(true); - if (call.can(CallCapabilities.RESPOND_VIA_TEXT) && textMsgs != null) { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS); - getUi().configureMessageDialog(textMsgs); + boolean withSms = call.can(CallCapabilities.RESPOND_VIA_TEXT) && textMsgs != null; + if (call.isVideoCall()) { + if (withSms) { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); + getUi().configureMessageDialog(textMsgs); + } else { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITHOUT_SMS); + } } else { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS); + if (withSms) { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS); + getUi().configureMessageDialog(textMsgs); + } else { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS); + } } } diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 835de2cb2..6a4ee985d 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -21,6 +21,7 @@ import android.telecomm.CallCapabilities; import android.telecomm.PhoneAccount; import android.telecomm.RemoteCallVideoProvider; import android.telecomm.GatewayInfo; +import android.telecomm.VideoCallProfile; import android.telephony.DisconnectCause; import java.util.ArrayList; @@ -158,7 +159,6 @@ public final class Call { private int mDisconnectCause; private String mParentCallId; private final List<String> mChildCallIds = new ArrayList<>(); - private int mVideoState; private InCallVideoClient mCallVideoClient; @@ -322,8 +322,10 @@ public final class Call { return mParentCallId; } - public int getVideoState() { - return mVideoState; + public boolean isVideoCall() { + int videoState = mTelecommCall.getDetails().getVideoState(); + return (videoState & VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL) + == VideoCallProfile.VIDEO_STATE_BIDIRECTIONAL; } @Override diff --git a/InCallUI/src/com/android/incallui/InCallApp.java b/InCallUI/src/com/android/incallui/InCallApp.java index 759f391b8..77fac7f53 100644 --- a/InCallUI/src/com/android/incallui/InCallApp.java +++ b/InCallUI/src/com/android/incallui/InCallApp.java @@ -32,12 +32,14 @@ public class InCallApp extends Application { * choose first ringing call, first active call, or first background call (typically in * HOLDING state). */ - public static final String ACTION_HANG_UP_ONGOING_CALL = - "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL"; - public static final String ACTION_ANSWER_INCOMING_CALL = - "com.android.incallui.ACTION_ANSWER_INCOMING_CALL"; public static final String ACTION_DECLINE_INCOMING_CALL = "com.android.incallui.ACTION_DECLINE_INCOMING_CALL"; + public static final String ACTION_HANG_UP_ONGOING_CALL = + "com.android.incallui.ACTION_HANG_UP_ONGOING_CALL"; + public static final String ACTION_ANSWER_VIDEO_INCOMING_CALL = + "com.android.incallui.ACTION_ANSWER_VIDEO_INCOMING_CALL"; + public static final String ACTION_ANSWER_VOICE_INCOMING_CALL = + "com.android.incallui.ACTION_ANSWER_VOICE_INCOMING_CALL"; public InCallApp() { } @@ -64,12 +66,15 @@ public class InCallApp extends Application { Log.i(this, "Broadcast from Notification: " + action); // TODO: Commands of this nature should exist in the CallList. - if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) { - InCallPresenter.getInstance().hangUpOngoingCall(context); - } else if (action.equals(ACTION_ANSWER_INCOMING_CALL)) { - InCallPresenter.getInstance().answerIncomingCall(context); - } else if (action.equals(ACTION_DECLINE_INCOMING_CALL)) { + if (action.equals(ACTION_DECLINE_INCOMING_CALL)) { InCallPresenter.getInstance().declineIncomingCall(context); + } else if (action.equals(ACTION_ANSWER_VOICE_INCOMING_CALL)) { + InCallPresenter.getInstance().answerIncomingCall(context); + } else if (action.equals(ACTION_ANSWER_VIDEO_INCOMING_CALL)) { + //TODO: Answer as a video call here instead of an audio call. + InCallPresenter.getInstance().answerIncomingCall(context); + } else if (action.equals(ACTION_HANG_UP_ONGOING_CALL)) { + InCallPresenter.getInstance().hangUpOngoingCall(context); } } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 1208527a7..f2f883a9e 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -225,21 +225,22 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { // it has available, and may make a subsequent call later (same thread) if it had to // call into the contacts provider for more data. mContactInfoCache.findInfo(call, isIncoming, new ContactInfoCacheCallback() { - @Override - public void onContactInfoComplete(String callId, ContactCacheEntry entry) { - Call call = CallList.getInstance().getCallById(callId); - if (call != null) { - buildAndSendNotification(call, entry); - } + @Override + public void onContactInfoComplete(String callId, ContactCacheEntry entry) { + Call call = CallList.getInstance().getCallById(callId); + if (call != null) { + buildAndSendNotification(call, entry); } + } - @Override - public void onImageLoadComplete(String callId, ContactCacheEntry entry) { - Call call = CallList.getInstance().getCallById(callId); - if (call != null) { - buildAndSendNotification(call, entry); - } - } }); + @Override + public void onImageLoadComplete(String callId, ContactCacheEntry entry) { + Call call = CallList.getInstance().getCallById(callId); + if (call != null) { + buildAndSendNotification(call, entry); + } + } + }); } /** @@ -300,12 +301,14 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { state == Call.State.ONHOLD || Call.State.isDialing(state)) { addHangupAction(builder); - } - // Add answer/decline options for incomng calls (incoming | call_waiting) - if (state == Call.State.INCOMING || - state == Call.State.CALL_WAITING) { - addDeclineAction(builder); - addAnswerAction(builder); + } else if (state == Call.State.INCOMING || state == Call.State.CALL_WAITING) { + addDismissAction(builder); + if (call.isVideoCall()) { + addVoiceAction(builder); + addVideoCallAction(builder); + } else { + addAnswerAction(builder); + } } addPersonReference(builder, contactInfo, call); @@ -420,7 +423,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { if (call.getState() == Call.State.ONHOLD) { return R.drawable.stat_sys_phone_call_on_hold; } - return R.drawable.stat_sys_phone_call; + return R.drawable.fab_ic_call; } /** @@ -459,31 +462,54 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { return call; } + private void addAnswerAction(Notification.Builder builder) { + Log.i(this, "Will show \"answer\" action in the incoming call Notification"); + + PendingIntent answerVoicePendingIntent = createNotificationPendingIntent( + mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + builder.addAction(R.drawable.fab_ic_call, + mContext.getText(R.string.description_target_answer), + answerVoicePendingIntent); + } + + private void addDismissAction(Notification.Builder builder) { + Log.i(this, "Will show \"dismiss\" action in the incoming call Notification"); + + PendingIntent declinePendingIntent = + createNotificationPendingIntent(mContext, InCallApp.ACTION_DECLINE_INCOMING_CALL); + builder.addAction(R.drawable.ic_close_dk, + mContext.getText(R.string.notification_action_dismiss), + declinePendingIntent); + } + private void addHangupAction(Notification.Builder builder) { Log.i(this, "Will show \"hang-up\" action in the ongoing active call Notification"); - // TODO: use better asset. - builder.addAction(R.drawable.stat_sys_phone_call_end, + PendingIntent hangupPendingIntent = + createNotificationPendingIntent(mContext, InCallApp.ACTION_HANG_UP_ONGOING_CALL); + builder.addAction(R.drawable.fab_ic_end_call, mContext.getText(R.string.notification_action_end_call), - createHangUpOngoingCallPendingIntent(mContext)); + hangupPendingIntent); } - private void addAnswerAction(Notification.Builder builder) { - Log.i(this, "Will show \"answer\" action in the incoming call Notification"); + private void addVideoCallAction(Notification.Builder builder) { + Log.i(this, "Will show \"video\" action in the incoming call Notification"); - // TODO: use better asset and string - builder.addAction(R.drawable.stat_sys_phone_call, - mContext.getText(R.string.description_target_answer), - createAnswerCallPendingIntent(mContext)); + PendingIntent answerVideoPendingIntent = createNotificationPendingIntent( + mContext, InCallApp.ACTION_ANSWER_VIDEO_INCOMING_CALL); + builder.addAction(R.drawable.ic_videocam, + mContext.getText(R.string.notification_action_answer_video), + answerVideoPendingIntent); } - private void addDeclineAction(Notification.Builder builder) { - Log.i(this, "Will show \"decline\" action in the incoming call Notification"); + private void addVoiceAction(Notification.Builder builder) { + Log.i(this, "Will show \"voice\" action in the incoming call Notification"); - // TODO: use better asset and string - builder.addAction(R.drawable.stat_sys_phone_call_end, - mContext.getText(R.string.description_target_decline), - createDeclineCallPendingIntent(mContext)); + PendingIntent answerVoicePendingIntent = createNotificationPendingIntent( + mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + builder.addAction(R.drawable.fab_ic_call, + mContext.getText(R.string.notification_action_answer_voice), + answerVoicePendingIntent); } /** @@ -545,6 +571,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { return builder; } + private PendingIntent createLaunchPendingIntent() { final Intent intent = InCallPresenter.getInstance().getInCallIntent( @@ -561,30 +588,6 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { } /** - * Returns PendingIntent for hanging up ongoing phone call. This will typically be used from - * Notification context. - */ - private static PendingIntent createHangUpOngoingCallPendingIntent(Context context) { - return createNotificationPendingIntent(context, InCallApp.ACTION_HANG_UP_ONGOING_CALL); - } - - /** - * Returns PendingIntent for answering a phone call. This will typically be used from - * Notification context. - */ - private static PendingIntent createAnswerCallPendingIntent(Context context) { - return createNotificationPendingIntent(context, InCallApp.ACTION_ANSWER_INCOMING_CALL); - } - - /** - * Returns PendingIntent for declining a phone call. This will typically be used from - * Notification context. - */ - private static PendingIntent createDeclineCallPendingIntent(Context context) { - return createNotificationPendingIntent(context, InCallApp.ACTION_DECLINE_INCOMING_CALL); - } - - /** * Returns PendingIntent for answering a phone call. This will typically be used from * Notification context. */ |