Skip to content

Commit

Permalink
Merge pull request #15 from webex/develop
Browse files Browse the repository at this point in the history
release 2.7.0
  • Loading branch information
KunNiu authored Dec 11, 2020
2 parents 576e560 + 5707cb3 commit cd84f96
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 30 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repositories {
}

dependencies {
implementation('com.ciscowebex:androidsdk:2.6.0@aar', {
implementation('com.ciscowebex:androidsdk:2.7.0@aar', {
transitive = true
changing = true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,30 @@ public boolean isScreenSharing() {
}
return false;
}

public void enableAudioBNR(boolean enable) {
if (phone != null) {
phone.enableAudioBNR(enable);
}
}

public boolean isAudioBNREnable() {
if (phone != null) {
return phone.isAudioBNREnable();
}
return false;
}

public void setAudioBNRMode(Phone.AudioBRNMode mode) {
if (phone != null) {
phone.setAudioBNRMode(mode);
}
}

public Phone.AudioBRNMode getAudioBNRMode() {
if (phone != null) {
return phone.getAudioBNRMode();
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@

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

import android.bluetooth.BluetoothAdapter;
import android.content.Context;

import com.ciscowebex.androidsdk.kitchensink.actions.IAction;
import com.ciscowebex.androidsdk.kitchensink.actions.WebexAgent;
import com.ciscowebex.androidsdk.phone.Call;
import com.ciscowebex.androidsdk.phone.internal.CallImpl;


/**
Expand All @@ -36,17 +39,36 @@
public class ToggleSpeakerAction implements IAction {
private boolean on;
private Context context;
private CallImpl call;

public ToggleSpeakerAction(Context context, boolean on) {
public ToggleSpeakerAction(Context context, CallImpl call, boolean on) {
this.context = context;
this.on = on;
this.call = call;
}

@Override
public void execute() {
android.media.AudioManager am = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setMode(android.media.AudioManager.MODE_IN_COMMUNICATION);
am.setSpeakerphoneOn(on);
if (call != null) {
android.media.AudioManager am = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (on) {
call.switchAudioOutput(Call.AudioOutputMode.SPEAKER);
} else {
if (isBluetoothHeadsetConnected()) {
call.switchAudioOutput(Call.AudioOutputMode.BLUETOOTH_HEADSET);
} else if (am.isWiredHeadsetOn()) {
call.switchAudioOutput(Call.AudioOutputMode.HEADSET);
} else {
call.switchAudioOutput(Call.AudioOutputMode.PHONE);
}
}
}

WebexAgent.getInstance().setSpeakerPhoneOn(on);
}

private boolean isBluetoothHeadsetConnected() {
return BluetoothAdapter.getDefaultAdapter().getProfileConnectionState(android.bluetooth.BluetoothProfile.HEADSET)
!= android.bluetooth.BluetoothProfile.STATE_DISCONNECTED;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Cisco Systems Inc
* Copyright 2016-2021 Cisco Systems Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 Cisco Systems Inc
* Copyright 2016-2021 Cisco Systems Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.PictureInPictureParams;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -95,6 +97,7 @@
import com.ciscowebex.androidsdk.phone.CallObserver;
import com.ciscowebex.androidsdk.phone.MediaRenderView;
import com.ciscowebex.androidsdk.phone.MultiStreamObserver;
import com.ciscowebex.androidsdk.phone.internal.CallImpl;
import com.github.benoitdion.ln.Ln;
import com.squareup.picasso.Picasso;

Expand Down Expand Up @@ -406,7 +409,7 @@ public void onSwitchCallAbility(Switch s) {

@OnCheckedChanged(R.id.switchLoudSpeaker)
public void onSwitchLoudSpeakerChanged(Switch s) {
new ToggleSpeakerAction(getActivity(), s.isChecked()).execute();
new ToggleSpeakerAction(getActivity(), (CallImpl) agent.getActiveCall(), s.isChecked()).execute();
}

@OnClick(R.id.radioBackCam)
Expand Down Expand Up @@ -549,6 +552,9 @@ public void onEventMainThread(DialEvent event) {
if (!event.isSuccessful()) {
if (event.getError() != null && event.getError().getErrorCode() == WebexError.ErrorCode.HOST_PIN_OR_MEETING_PASSWORD_REQUIRED.getCode()) {
showPasswordDialog();
} else if (event.getError() != null && event.getError().getErrorCode() == WebexError.ErrorCode.VIEW_H264_LICENSE.getCode()) {
Toast.makeText(getActivity(), "View license, stop dial", Toast.LENGTH_SHORT).show();
feedback();
} else {
Toast.makeText(getActivity(), "Dial failed!", Toast.LENGTH_SHORT).show();
feedback();
Expand Down Expand Up @@ -934,6 +940,13 @@ public void onEventMainThread(OnCallMembershipEvent event) {
Ln.d("people: " + r.getData());
updatePersonInfoForParticipants(personId, r.getData());
});
} else if (event.callEvent instanceof CallObserver.MembershipAudioMutedControlledEvent) {
Ln.d("MembershipAudioMutedControlledEvent: ");
Ln.d(membership.getPersonId() + (membership.isAudioMutedControlled() ? " muted by " : " unmuted by ") + membership.audioModifiedBy());
if (membership.audioModifiedBy() != null) {
String text = membership.getEmail() + (membership.isAudioMutedControlled() ? " muted" : " unmuted") + " by others";
toast(text);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.Switch;
Expand All @@ -35,6 +36,7 @@
import com.ciscowebex.androidsdk.kitchensink.actions.commands.ToggleSpeakerAction;
import com.ciscowebex.androidsdk.kitchensink.actions.events.PermissionAcquiredEvent;
import com.ciscowebex.androidsdk.kitchensink.ui.BaseFragment;
import com.ciscowebex.androidsdk.phone.Phone;

import org.greenrobot.eventbus.Subscribe;

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

@BindView(R.id.setupBNR)
Switch switchBNR;

@BindView(R.id.bnr_hp)
RadioButton radioHP;

@BindView(R.id.bnr_lp)
RadioButton radioLP;

public SetupFragment() {
// Required empty public constructor
setLayout(R.layout.fragment_setup);
Expand Down Expand Up @@ -131,6 +142,14 @@ private void setupWidgetStates() {
index = 4;
}
maxBandwidth.setSelection(index);

// Setup Audio BNR
switchBNR.setEnabled(true);
switchBNR.setChecked(agent.isAudioBNREnable());
if (agent.getAudioBNRMode() != null) {
radioHP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.HP);
radioLP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.LP);
}
}

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

@OnCheckedChanged(R.id.setupLoudSpeaker)
public void onSetupLoadSpeakerChanged(Switch s) {
new ToggleSpeakerAction(getActivity(), s.isChecked() ? true : false).execute();
new ToggleSpeakerAction(getActivity(), null, s.isChecked()).execute();
}

@OnCheckedChanged(R.id.setupBNR)
public void onSetupBNRChanged(Switch s) {
radioHP.setEnabled(s.isChecked());
radioLP.setEnabled(s.isChecked());
agent.enableAudioBNR(s.isChecked());
if (s.isChecked()) {
if (agent.getAudioBNRMode() != null) {
radioHP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.HP);
radioLP.setChecked(agent.getAudioBNRMode() == Phone.AudioBRNMode.LP);
}
}
}

@OnCheckedChanged({R.id.bnr_hp, R.id.bnr_lp})
public void onRadioBNRChanged(CompoundButton button, boolean isChecked) {
if (isChecked) {
switch (button.getId()) {
case R.id.bnr_hp:
agent.setAudioBNRMode(Phone.AudioBRNMode.HP);
break;
case R.id.bnr_lp:
agent.setAudioBNRMode(Phone.AudioBRNMode.LP);
break;
}
}
}

private void closeCamera() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import android.widget.TextView;

import com.ciscowebex.androidsdk.kitchensink.R;
import com.ciscowebex.androidsdk.kitchensink.actions.WebexAgent;
import com.ciscowebex.androidsdk.kitchensink.actions.commands.SearchSpaceAction;
import com.ciscowebex.androidsdk.kitchensink.actions.events.SearchActiveSpaceCompleteEvent;
import com.ciscowebex.androidsdk.kitchensink.actions.events.SearchSpaceCompleteEvent;
import com.ciscowebex.androidsdk.kitchensink.launcher.LauncherActivity;
import com.ciscowebex.androidsdk.kitchensink.launcher.fragments.DialPagersFragment;
import com.ciscowebex.androidsdk.kitchensink.ui.BaseFragment;
import com.ciscowebex.androidsdk.space.Space;
import com.ciscowebex.androidsdk.space.SpaceObserver;

import org.greenrobot.eventbus.Subscribe;

Expand Down Expand Up @@ -68,6 +70,14 @@ public void onActivityCreated(Bundle saved) {
super.onActivityCreated(saved);
SpaceAdapter adapter = new SpaceAdapter(getActivity(), R.layout.listview_person, spaceList);
listView.setAdapter(adapter);
setObserver();
}

@Override
public void onDestroy() {
super.onDestroy();
WebexAgent webex = WebexAgent.getInstance();
webex.getWebex().spaces().setSpaceObserver(null);
}

class SpaceAdapter extends ArrayAdapter<Space> {
Expand Down Expand Up @@ -121,6 +131,29 @@ public void onEventMainThread(SearchSpaceCompleteEvent event) {
}
}

private void setObserver() {
WebexAgent webex = WebexAgent.getInstance();
webex.getWebex().spaces().setSpaceObserver(event -> {
boolean ongoingVisible = false;
String spaceId = null;
if (event instanceof SpaceObserver.SpaceCallStarted) {
ongoingVisible = true;
spaceId = ((SpaceObserver.SpaceCallStarted) event).getSpaceId();
} else if (event instanceof SpaceObserver.SpaceCallEnded) {
ongoingVisible = false;
spaceId = ((SpaceObserver.SpaceCallEnded) event).getSpaceId();
}
if (spaceId != null) {
for (Space space : spaceList) {
if (spaceId.equals(space.getId())) {
int position = spaceList.indexOf(space);
listView.getChildAt(position).findViewById(R.id.ongoing).setVisibility(ongoingVisible ? View.VISIBLE : View.GONE);
}
}
}
});
}

@SuppressWarnings("unused")
@Subscribe
public void onEventMainThread(SearchActiveSpaceCompleteEvent event) {
Expand Down
Loading

0 comments on commit cd84f96

Please sign in to comment.