summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2016-01-21 09:58:16 -0800
committerTyler Gunn <tgunn@google.com>2016-01-27 13:27:52 -0800
commit8f5f0cba1d5970f305ee7263cdd6d739f13967ea (patch)
tree4d5a72e5ffa2ca0fce30e74a759071160016749a
parentc4b26262269f0db8cfd14d68a0596801642219ff (diff)
Add downgrade to audio button for video calls.
- Add downgrade to audio button for video calls where the call capabilities indicates that it is supported. - Requires N SDK or higher. Bug: 22728624 Change-Id: I92aaf1d1e77da82c2ad982a57bb2eae599cff4da
-rw-r--r--InCallUI/res/drawable/btn_change_to_voice.xml31
-rw-r--r--InCallUI/res/layout/call_button_fragment.xml7
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonFragment.java22
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonPresenter.java19
4 files changed, 71 insertions, 8 deletions
diff --git a/InCallUI/res/drawable/btn_change_to_voice.xml b/InCallUI/res/drawable/btn_change_to_voice.xml
new file mode 100644
index 000000000..86a7f21d5
--- /dev/null
+++ b/InCallUI/res/drawable/btn_change_to_voice.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2014 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:id="@+id/backgroundItem"
+ android:drawable="@drawable/btn_background" />
+
+ <item>
+ <bitmap android:src="@drawable/ic_toolbar_audio_phone"
+ android:gravity="center"
+ android:tint="@color/selectable_icon_tint"
+ android:autoMirrored="true" />
+ </item>
+
+</layer-list> \ 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 0cdaf23f7..db7576404 100644
--- a/InCallUI/res/layout/call_button_fragment.xml
+++ b/InCallUI/res/layout/call_button_fragment.xml
@@ -129,6 +129,13 @@
android:contentDescription="@string/onscreenPauseVideoText"
android:visibility="gone" />
+ <!-- "Change to audio call" for video calls. -->
+ <ImageButton android:id="@+id/changeToVoiceButton"
+ style="@style/InCallButton"
+ android:background="@drawable/btn_change_to_voice"
+ android:contentDescription="@string/onscreenChangeToVoiceText"
+ android:visibility="gone" />
+
<!-- "Add Call" -->
<ImageButton android:id="@+id/addButton"
style="@style/InCallButton"
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 653847486..1904ab041 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -20,6 +20,7 @@ import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_ADD_CALL;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_AUDIO;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_COUNT;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_DIALPAD;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_DOWNGRADE_TO_AUDIO;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_HOLD;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_MANAGE_VIDEO_CONFERENCE;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_MERGE;
@@ -81,11 +82,12 @@ public class CallButtonFragment
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;
+ public static final int BUTTON_DOWNGRADE_TO_AUDIO = 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;
}
private SparseIntArray mButtonVisibilityMap = new SparseIntArray(BUTTON_COUNT);
@@ -96,6 +98,7 @@ public class CallButtonFragment
private CompoundButton mHoldButton;
private ImageButton mSwapButton;
private ImageButton mChangeToVideoButton;
+ private ImageButton mChangeToVoiceButton;
private CompoundButton mSwitchCameraButton;
private ImageButton mAddCallButton;
private ImageButton mMergeButton;
@@ -155,6 +158,8 @@ public class CallButtonFragment
mSwapButton.setOnClickListener(this);
mChangeToVideoButton = (ImageButton) parent.findViewById(R.id.changeToVideoButton);
mChangeToVideoButton.setOnClickListener(this);
+ mChangeToVoiceButton = (ImageButton) parent.findViewById(R.id.changeToVoiceButton);
+ mChangeToVoiceButton.setOnClickListener(this);
mSwitchCameraButton = (CompoundButton) parent.findViewById(R.id.switchCameraButton);
mSwitchCameraButton.setOnClickListener(this);
mAddCallButton = (ImageButton) parent.findViewById(R.id.addButton);
@@ -222,6 +227,9 @@ public class CallButtonFragment
case R.id.changeToVideoButton:
getPresenter().changeToVideoClicked();
break;
+ case R.id.changeToVoiceButton:
+ getPresenter().changeToVoiceClicked();
+ break;
case R.id.switchCameraButton:
getPresenter().switchCameraClicked(
mSwitchCameraButton.isSelected() /* useFrontFacingCamera */);
@@ -273,6 +281,7 @@ public class CallButtonFragment
ImageButton[] normalButtons = {
mSwapButton,
mChangeToVideoButton,
+ mChangeToVoiceButton,
mAddCallButton,
mMergeButton,
mOverflowButton
@@ -362,6 +371,7 @@ public class CallButtonFragment
mHoldButton.setEnabled(isEnabled);
mSwapButton.setEnabled(isEnabled);
mChangeToVideoButton.setEnabled(isEnabled);
+ mChangeToVoiceButton.setEnabled(isEnabled);
mSwitchCameraButton.setEnabled(isEnabled);
mAddCallButton.setEnabled(isEnabled);
mMergeButton.setEnabled(isEnabled);
@@ -397,6 +407,8 @@ public class CallButtonFragment
return mSwapButton;
case BUTTON_UPGRADE_TO_VIDEO:
return mChangeToVideoButton;
+ case BUTTON_DOWNGRADE_TO_AUDIO:
+ return mChangeToVoiceButton;
case BUTTON_SWITCH_CAMERA:
return mSwitchCameraButton;
case BUTTON_ADD_CALL:
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 34298c3fa..dde62954f 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -19,6 +19,7 @@ package com.android.incallui;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_ADD_CALL;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_AUDIO;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_DIALPAD;
+import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_DOWNGRADE_TO_AUDIO;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_HOLD;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_MERGE;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_MUTE;
@@ -33,6 +34,7 @@ import android.os.Bundle;
import android.telecom.InCallService.VideoCall;
import android.telecom.VideoProfile;
+import com.android.contacts.common.compat.CallSdkCompat;
import com.android.contacts.common.compat.SdkVersionOverride;
import com.android.dialer.compat.CallAudioStateCompat;
import com.android.dialer.compat.UserManagerCompat;
@@ -260,8 +262,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
return;
}
- VideoProfile videoProfile = new VideoProfile(
- VideoProfile.STATE_AUDIO_ONLY, VideoProfile.QUALITY_DEFAULT);
+ VideoProfile videoProfile = new VideoProfile(VideoProfile.STATE_AUDIO_ONLY);
videoCall.sendSessionModifyRequest(videoProfile);
}
@@ -384,7 +385,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
final boolean showMerge = call.can(
android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE);
final boolean showUpgradeToVideo = !isVideo && hasVideoCallCapabilities(call);
-
+ final boolean showDowngradeToAudio = isVideo && isDowngradeToAudioSupported(call);
final boolean showMute = call.can(android.telecom.Call.Details.CAPABILITY_MUTE);
ui.showButton(BUTTON_AUDIO, true);
@@ -394,6 +395,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
ui.showButton(BUTTON_MUTE, showMute);
ui.showButton(BUTTON_ADD_CALL, showAddCall);
ui.showButton(BUTTON_UPGRADE_TO_VIDEO, showUpgradeToVideo);
+ ui.showButton(BUTTON_DOWNGRADE_TO_AUDIO, showDowngradeToAudio);
ui.showButton(BUTTON_SWITCH_CAMERA, isVideo);
ui.showButton(BUTTON_PAUSE_VIDEO, isVideo);
ui.showButton(BUTTON_DIALPAD, true);
@@ -411,6 +413,17 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
return call.can(android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_TX);
}
+ /**
+ * Determines if downgrading from a video call to an audio-only call is supported. In order to
+ * support downgrade to audio, the SDK version must be >= N and the call should NOT have the
+ * {@link android.telecom.Call.Details#CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO}.
+ * @param call The call.
+ * @return {@code true} if downgrading to an audio-only call from a video call is supported.
+ */
+ private boolean isDowngradeToAudioSupported(Call call) {
+ return !call.can(CallSdkCompat.Details.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO);
+ }
+
public void refreshMuteState() {
// Restore the previous mute state
if (mAutomaticallyMuted &&