Skip to content

Commit cd84f96

Browse files
authored
Merge pull request #15 from webex/develop
release 2.7.0
2 parents 576e560 + 5707cb3 commit cd84f96

File tree

11 files changed

+235
-30
lines changed

11 files changed

+235
-30
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016-2020 Cisco Systems, Inc.
3+
Copyright (c) 2016-2021 Cisco Systems, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ repositories {
5353
}
5454

5555
dependencies {
56-
implementation('com.ciscowebex:androidsdk:2.6.0@aar', {
56+
implementation('com.ciscowebex:androidsdk:2.7.0@aar', {
5757
transitive = true
5858
changing = true
5959
})

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/actions/WebexAgent.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,30 @@ public boolean isScreenSharing() {
316316
}
317317
return false;
318318
}
319+
320+
public void enableAudioBNR(boolean enable) {
321+
if (phone != null) {
322+
phone.enableAudioBNR(enable);
323+
}
324+
}
325+
326+
public boolean isAudioBNREnable() {
327+
if (phone != null) {
328+
return phone.isAudioBNREnable();
329+
}
330+
return false;
331+
}
332+
333+
public void setAudioBNRMode(Phone.AudioBRNMode mode) {
334+
if (phone != null) {
335+
phone.setAudioBNRMode(mode);
336+
}
337+
}
338+
339+
public Phone.AudioBRNMode getAudioBNRMode() {
340+
if (phone != null) {
341+
return phone.getAudioBNRMode();
342+
}
343+
return null;
344+
}
319345
}

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/actions/commands/ToggleSpeakerAction.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323

2424
package com.ciscowebex.androidsdk.kitchensink.actions.commands;
2525

26+
import android.bluetooth.BluetoothAdapter;
2627
import android.content.Context;
2728

2829
import com.ciscowebex.androidsdk.kitchensink.actions.IAction;
2930
import com.ciscowebex.androidsdk.kitchensink.actions.WebexAgent;
31+
import com.ciscowebex.androidsdk.phone.Call;
32+
import com.ciscowebex.androidsdk.phone.internal.CallImpl;
3033

3134

3235
/**
@@ -36,17 +39,36 @@
3639
public class ToggleSpeakerAction implements IAction {
3740
private boolean on;
3841
private Context context;
42+
private CallImpl call;
3943

40-
public ToggleSpeakerAction(Context context, boolean on) {
44+
public ToggleSpeakerAction(Context context, CallImpl call, boolean on) {
4145
this.context = context;
4246
this.on = on;
47+
this.call = call;
4348
}
4449

4550
@Override
4651
public void execute() {
47-
android.media.AudioManager am = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
48-
am.setMode(android.media.AudioManager.MODE_IN_COMMUNICATION);
49-
am.setSpeakerphoneOn(on);
52+
if (call != null) {
53+
android.media.AudioManager am = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
54+
if (on) {
55+
call.switchAudioOutput(Call.AudioOutputMode.SPEAKER);
56+
} else {
57+
if (isBluetoothHeadsetConnected()) {
58+
call.switchAudioOutput(Call.AudioOutputMode.BLUETOOTH_HEADSET);
59+
} else if (am.isWiredHeadsetOn()) {
60+
call.switchAudioOutput(Call.AudioOutputMode.HEADSET);
61+
} else {
62+
call.switchAudioOutput(Call.AudioOutputMode.PHONE);
63+
}
64+
}
65+
}
66+
5067
WebexAgent.getInstance().setSpeakerPhoneOn(on);
5168
}
69+
70+
private boolean isBluetoothHeadsetConnected() {
71+
return BluetoothAdapter.getDefaultAdapter().getProfileConnectionState(android.bluetooth.BluetoothProfile.HEADSET)
72+
!= android.bluetooth.BluetoothProfile.STATE_DISCONNECTED;
73+
}
5274
}

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/actions/events/OnScheduleChangedEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 Cisco Systems Inc
2+
* Copyright 2016-2021 Cisco Systems Inc
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/actions/events/SearchActiveSpaceCompleteEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 Cisco Systems Inc
2+
* Copyright 2016-2021 Cisco Systems Inc
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/launcher/fragments/CallFragment.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import android.app.NotificationManager;
3030
import android.app.PendingIntent;
3131
import android.app.PictureInPictureParams;
32+
import android.bluetooth.BluetoothDevice;
33+
import android.content.BroadcastReceiver;
3234
import android.content.ComponentName;
3335
import android.content.Context;
3436
import android.content.Intent;
@@ -95,6 +97,7 @@
9597
import com.ciscowebex.androidsdk.phone.CallObserver;
9698
import com.ciscowebex.androidsdk.phone.MediaRenderView;
9799
import com.ciscowebex.androidsdk.phone.MultiStreamObserver;
100+
import com.ciscowebex.androidsdk.phone.internal.CallImpl;
98101
import com.github.benoitdion.ln.Ln;
99102
import com.squareup.picasso.Picasso;
100103

@@ -406,7 +409,7 @@ public void onSwitchCallAbility(Switch s) {
406409

407410
@OnCheckedChanged(R.id.switchLoudSpeaker)
408411
public void onSwitchLoudSpeakerChanged(Switch s) {
409-
new ToggleSpeakerAction(getActivity(), s.isChecked()).execute();
412+
new ToggleSpeakerAction(getActivity(), (CallImpl) agent.getActiveCall(), s.isChecked()).execute();
410413
}
411414

412415
@OnClick(R.id.radioBackCam)
@@ -549,6 +552,9 @@ public void onEventMainThread(DialEvent event) {
549552
if (!event.isSuccessful()) {
550553
if (event.getError() != null && event.getError().getErrorCode() == WebexError.ErrorCode.HOST_PIN_OR_MEETING_PASSWORD_REQUIRED.getCode()) {
551554
showPasswordDialog();
555+
} else if (event.getError() != null && event.getError().getErrorCode() == WebexError.ErrorCode.VIEW_H264_LICENSE.getCode()) {
556+
Toast.makeText(getActivity(), "View license, stop dial", Toast.LENGTH_SHORT).show();
557+
feedback();
552558
} else {
553559
Toast.makeText(getActivity(), "Dial failed!", Toast.LENGTH_SHORT).show();
554560
feedback();
@@ -934,6 +940,13 @@ public void onEventMainThread(OnCallMembershipEvent event) {
934940
Ln.d("people: " + r.getData());
935941
updatePersonInfoForParticipants(personId, r.getData());
936942
});
943+
} else if (event.callEvent instanceof CallObserver.MembershipAudioMutedControlledEvent) {
944+
Ln.d("MembershipAudioMutedControlledEvent: ");
945+
Ln.d(membership.getPersonId() + (membership.isAudioMutedControlled() ? " muted by " : " unmuted by ") + membership.audioModifiedBy());
946+
if (membership.audioModifiedBy() != null) {
947+
String text = membership.getEmail() + (membership.isAudioMutedControlled() ? " muted" : " unmuted") + " by others";
948+
toast(text);
949+
}
937950
}
938951
}
939952

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/launcher/fragments/SetupFragment.java

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626

2727
import android.view.View;
28+
import android.widget.CompoundButton;
2829
import android.widget.RadioButton;
2930
import android.widget.Spinner;
3031
import android.widget.Switch;
@@ -35,6 +36,7 @@
3536
import com.ciscowebex.androidsdk.kitchensink.actions.commands.ToggleSpeakerAction;
3637
import com.ciscowebex.androidsdk.kitchensink.actions.events.PermissionAcquiredEvent;
3738
import com.ciscowebex.androidsdk.kitchensink.ui.BaseFragment;
39+
import com.ciscowebex.androidsdk.phone.Phone;
3840

3941
import org.greenrobot.eventbus.Subscribe;
4042

@@ -78,6 +80,15 @@ public class SetupFragment extends BaseFragment {
7880
@BindView(R.id.spinnerBandWidth)
7981
Spinner maxBandwidth;
8082

83+
@BindView(R.id.setupBNR)
84+
Switch switchBNR;
85+
86+
@BindView(R.id.bnr_hp)
87+
RadioButton radioHP;
88+
89+
@BindView(R.id.bnr_lp)
90+
RadioButton radioLP;
91+
8192
public SetupFragment() {
8293
// Required empty public constructor
8394
setLayout(R.layout.fragment_setup);
@@ -131,6 +142,14 @@ private void setupWidgetStates() {
131142
index = 4;
132143
}
133144
maxBandwidth.setSelection(index);
145+
146+
// Setup Audio BNR
147+
switchBNR.setEnabled(true);
148+
switchBNR.setChecked(agent.isAudioBNREnable());
149+
if (agent.getAudioBNRMode() != null) {
150+
radioHP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.HP);
151+
radioLP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.LP);
152+
}
134153
}
135154

136155
@OnClick({R.id.audioCallOnly, R.id.audioVideoCall})
@@ -162,7 +181,34 @@ public void onSelectCamera(View v) {
162181

163182
@OnCheckedChanged(R.id.setupLoudSpeaker)
164183
public void onSetupLoadSpeakerChanged(Switch s) {
165-
new ToggleSpeakerAction(getActivity(), s.isChecked() ? true : false).execute();
184+
new ToggleSpeakerAction(getActivity(), null, s.isChecked()).execute();
185+
}
186+
187+
@OnCheckedChanged(R.id.setupBNR)
188+
public void onSetupBNRChanged(Switch s) {
189+
radioHP.setEnabled(s.isChecked());
190+
radioLP.setEnabled(s.isChecked());
191+
agent.enableAudioBNR(s.isChecked());
192+
if (s.isChecked()) {
193+
if (agent.getAudioBNRMode() != null) {
194+
radioHP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.HP);
195+
radioLP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.LP);
196+
}
197+
}
198+
}
199+
200+
@OnCheckedChanged({R.id.bnr_hp, R.id.bnr_lp})
201+
public void onRadioBNRChanged(CompoundButton button, boolean isChecked) {
202+
if (isChecked) {
203+
switch (button.getId()) {
204+
case R.id.bnr_hp:
205+
agent.setAudioBNRMode(Phone.AudioBRNMode.HP);
206+
break;
207+
case R.id.bnr_lp:
208+
agent.setAudioBNRMode(Phone.AudioBRNMode.LP);
209+
break;
210+
}
211+
}
166212
}
167213

168214
private void closeCamera() {

app/src/main/java/com/ciscowebex/androidsdk/kitchensink/launcher/fragments/pagers/SpaceFragment.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
import android.widget.TextView;
1414

1515
import com.ciscowebex.androidsdk.kitchensink.R;
16+
import com.ciscowebex.androidsdk.kitchensink.actions.WebexAgent;
1617
import com.ciscowebex.androidsdk.kitchensink.actions.commands.SearchSpaceAction;
1718
import com.ciscowebex.androidsdk.kitchensink.actions.events.SearchActiveSpaceCompleteEvent;
1819
import com.ciscowebex.androidsdk.kitchensink.actions.events.SearchSpaceCompleteEvent;
1920
import com.ciscowebex.androidsdk.kitchensink.launcher.LauncherActivity;
2021
import com.ciscowebex.androidsdk.kitchensink.launcher.fragments.DialPagersFragment;
2122
import com.ciscowebex.androidsdk.kitchensink.ui.BaseFragment;
2223
import com.ciscowebex.androidsdk.space.Space;
24+
import com.ciscowebex.androidsdk.space.SpaceObserver;
2325

2426
import org.greenrobot.eventbus.Subscribe;
2527

@@ -68,6 +70,14 @@ public void onActivityCreated(Bundle saved) {
6870
super.onActivityCreated(saved);
6971
SpaceAdapter adapter = new SpaceAdapter(getActivity(), R.layout.listview_person, spaceList);
7072
listView.setAdapter(adapter);
73+
setObserver();
74+
}
75+
76+
@Override
77+
public void onDestroy() {
78+
super.onDestroy();
79+
WebexAgent webex = WebexAgent.getInstance();
80+
webex.getWebex().spaces().setSpaceObserver(null);
7181
}
7282

7383
class SpaceAdapter extends ArrayAdapter<Space> {
@@ -121,6 +131,29 @@ public void onEventMainThread(SearchSpaceCompleteEvent event) {
121131
}
122132
}
123133

134+
private void setObserver() {
135+
WebexAgent webex = WebexAgent.getInstance();
136+
webex.getWebex().spaces().setSpaceObserver(event -> {
137+
boolean ongoingVisible = false;
138+
String spaceId = null;
139+
if (event instanceof SpaceObserver.SpaceCallStarted) {
140+
ongoingVisible = true;
141+
spaceId = ((SpaceObserver.SpaceCallStarted) event).getSpaceId();
142+
} else if (event instanceof SpaceObserver.SpaceCallEnded) {
143+
ongoingVisible = false;
144+
spaceId = ((SpaceObserver.SpaceCallEnded) event).getSpaceId();
145+
}
146+
if (spaceId != null) {
147+
for (Space space : spaceList) {
148+
if (spaceId.equals(space.getId())) {
149+
int position = spaceList.indexOf(space);
150+
listView.getChildAt(position).findViewById(R.id.ongoing).setVisibility(ongoingVisible ? View.VISIBLE : View.GONE);
151+
}
152+
}
153+
}
154+
});
155+
}
156+
124157
@SuppressWarnings("unused")
125158
@Subscribe
126159
public void onEventMainThread(SearchActiveSpaceCompleteEvent event) {

0 commit comments

Comments
 (0)