Skip to content

Commit

Permalink
Merge pull request #22 from webex/develop
Browse files Browse the repository at this point in the history
2.8.0 Release
  • Loading branch information
KunNiu authored Apr 30, 2021
2 parents cd84f96 + 1edb6c4 commit a7bf769
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 72 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'

android {
compileSdkVersion 27
buildToolsVersion "28.0.3"
compileSdkVersion 30
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.ciscowebex.androidsdk.kitchensink"
minSdkVersion 21
targetSdkVersion 27
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.agent.AndroidJUnitRunner"
Expand Down Expand Up @@ -53,7 +53,7 @@ repositories {
}

dependencies {
implementation('com.ciscowebex:androidsdk:2.7.0@aar', {
implementation('com.ciscowebex:androidsdk:2.8.0@aar', {
transitive = true
changing = true
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,17 @@ public Phone.AudioBRNMode getAudioBNRMode() {
}
return null;
}

public void setVideoStreamMode(Phone.VideoStreamMode mode) {
if (phone != null) {
phone.setVideoStreamMode(mode);
}
}

public Phone.VideoStreamMode getVideoStreamMode() {
if (phone != null) {
return phone.getVideoStreamMode();
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,27 @@ public RequirePermissionAction(Activity activity) {

@Override
public void execute() {
int permissionCheck = ContextCompat.checkSelfPermission(activity,
Manifest.permission.READ_EXTERNAL_STORAGE);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
String[] permissions = {
Manifest.permission.READ_EXTERNAL_STORAGE
};
ActivityCompat.requestPermissions(activity, permissions, 0);
} else {
WebexAgentEvent.postEvent(new PermissionAcquiredEvent());
String[] permissions = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.CAMERA
};
for (String permission : permissions) {
int permissionCheck = ContextCompat.checkSelfPermission(activity, permission);
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity, permissions, 0);
return;
}
}
WebexAgentEvent.postEvent(new PermissionAcquiredEvent());
}

public static void PermissionsRequired(int requestCode, int[] grantResults) {
if (requestCode == 0 && grantResults.length == 1
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (requestCode == 0) {
for (int grant : grantResults) {
if (grant != PackageManager.PERMISSION_GRANTED) {
return;
}
}
WebexAgentEvent.postEvent(new PermissionAcquiredEvent());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.ciscowebex.androidsdk.kitchensink.actions.commands.RequirePermissionAction;
import com.ciscowebex.androidsdk.kitchensink.actions.events.OnCallMembershipEvent;
import com.ciscowebex.androidsdk.kitchensink.actions.events.OnMediaChangeEvent;
import com.ciscowebex.androidsdk.kitchensink.launcher.fragments.CallFragment;
import com.ciscowebex.androidsdk.kitchensink.launcher.fragments.LauncherFragment;
import com.ciscowebex.androidsdk.kitchensink.ui.BaseFragment;
import com.ciscowebex.androidsdk.phone.CallObserver;
Expand Down Expand Up @@ -123,7 +124,7 @@ public void onEventMainThread(OnMediaChangeEvent event) {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(OnCallMembershipEvent event) {
if (event.callEvent instanceof CallObserver.MembershipSendingSharingEvent) {
Ln.d("Activity CallMembership email: " + event.callEvent.getCallMembership().getEmail() +
Ln.d("Activity CallMembership displayName: " + event.callEvent.getCallMembership().getDisplayName() +
" isSendingSharing: " + event.callEvent.getCallMembership().isSendingSharing());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationChannel;
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 @@ -275,8 +275,7 @@ public void onLetInClick(ParticipantsAdapter.CallMembershipEntity entity) {
setViewAndChildrenEnabled(layout, false);
((SurfaceView) localView).setZOrderMediaOverlay(true);
((SurfaceView) screenShare).setZOrderMediaOverlay(true);
//requirePermission();
makeCall();
requirePermission();
}
}

Expand Down Expand Up @@ -320,6 +319,12 @@ private void requirePermission() {
new RequirePermissionAction(getActivity()).execute();
}

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(PermissionAcquiredEvent event) {
makeCall();
}

@Override
public void onStop() {
super.onStop();
Expand Down Expand Up @@ -391,14 +396,28 @@ public void onSwitchCallAbility(Switch s) {
agent.receiveAudio(s.isChecked());
break;
case R.id.switchShareContent:
if (s.isChecked())
agent.getActiveCall().startSharing(r -> {
if (s.isChecked()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel("screen_share_notification_channel", "screen_share_notification_channel", NotificationManager.IMPORTANCE_HIGH);
NotificationManager notifyManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
notifyManager.createNotificationChannel(mChannel);
}
Notification notification = new NotificationCompat.Builder(getActivity(), "screen_share_notification_channel")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Cisco Kitchensink")
.setContentText("Sharing screen to others")
.setTicker("Screen Sharing")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setDefaults(Notification.DEFAULT_SOUND)
.build();

agent.getActiveCall().startSharing(notification, 0xabcde, r -> {
Ln.d("startSharing result: " + r);
if (!r.isSuccessful()) {
switchShareContent.setChecked(false);
}
});
else
} else
agent.getActiveCall().stopSharing(r -> {
Ln.d("stopSharing result: " + r);
});
Expand Down Expand Up @@ -530,7 +549,7 @@ private void makeCall() {
agent.answer(localView, remoteView, screenShare, false, null);
return;
}

agent.startPreview(localView);
agent.dial(callee, localView, remoteView, screenShare, false, null);
new AddCallHistoryAction(callee, "out").execute();
setButtonsEnable(true);
Expand Down Expand Up @@ -682,9 +701,9 @@ private void updateParticipants() {
Ln.d("updateParticipants: " + callMemberships.size());
for (CallMembership membership : callMemberships) {
String personId = membership.getPersonId();
if (/*membership.getState() != CallMembership.State.JOINED || */personId == null || personId.isEmpty() || membership.getEmail() == null || membership.getEmail().isEmpty())
if (/*membership.getState() != CallMembership.State.JOINED || */personId == null || personId.isEmpty() || membership.getDisplayName() == null || membership.getDisplayName().isEmpty())
continue;
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getEmail(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getDisplayName(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
agent.getWebex().people().get(personId, r -> {
if (r == null || !r.isSuccessful() || r.getData() == null) return;
mIdPersonMap.put(personId, r.getData());
Expand All @@ -699,7 +718,7 @@ private void updatePersonInfoForParticipants(String personId, Person person) {
}

private void updatePersonInfoForActiveSpeaker(String personId, Person person) {
if (participantsAdapter.getActiveSpeaker() == null || personId == null || person == null || !participantsAdapter.getActiveSpeaker().equals(personId))
if (participantsAdapter.getActiveSpeaker() == null || person == null || !participantsAdapter.getActiveSpeaker().equals(personId))
return;
String avatar = person.getAvatar();
if (avatar == null || avatar.isEmpty()) {
Expand Down Expand Up @@ -744,13 +763,22 @@ public void onEventMainThread(OnDisconnectEvent event) {
@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEventMainThread(OnMediaChangeEvent event) {
if (event.callEvent instanceof RemoteSendingSharingEvent) {
if (event.callEvent instanceof CallObserver.RemoteSendingVideoEvent) {
Ln.d("RemoteSendingVideoEvent: " + ((CallObserver.RemoteSendingVideoEvent) event.callEvent).isSending());
} else if (event.callEvent instanceof RemoteSendingSharingEvent) {
Ln.d("RemoteSendingSharingEvent: " + ((RemoteSendingSharingEvent) event.callEvent).isSending());
if (((RemoteSendingSharingEvent) event.callEvent).isSending()) {
event.callEvent.getCall().setVideoRenderViews(new Pair<>(localView, screenShare));
event.callEvent.getCall().setSharingRenderView(remoteView);
} else {
event.callEvent.getCall().setSharingRenderView(null);
event.callEvent.getCall().setVideoRenderViews(new Pair<>(localView, remoteView));
}
updateScreenShareView();
} else if (event.callEvent instanceof SendingSharingEvent) {
Ln.d("SendingSharingEvent: " + ((SendingSharingEvent) event.callEvent).isSending());
if (((SendingSharingEvent) event.callEvent).isSending()) {
sendNotification();
// sendNotification();
backToHome();
}
} else if (event.callEvent instanceof CallObserver.ActiveSpeakerChangedEvent) {
Expand Down Expand Up @@ -859,7 +887,7 @@ public void onEventMainThread(OnAuxStreamEvent event) {
Person person = mIdPersonMap.get(personId);
auxStreamViewHolder.viewAvatar.setVisibility(membership.isSendingVideo() ? View.GONE : View.VISIBLE);
if (person == null) {
auxStreamViewHolder.textView.setText(membership.getEmail());
auxStreamViewHolder.textView.setText(membership.getDisplayName());
auxStreamViewHolder.viewAvatar.setImageResource(R.drawable.google_contacts_android);
agent.getWebex().people().get(personId, r -> {
if (!r.isSuccessful() || r.getData() == null) return;
Expand Down Expand Up @@ -890,9 +918,9 @@ public void onEventMainThread(OnCallMembershipEvent event) {
String personId = membership.getPersonId();
if (event.callEvent instanceof CallObserver.MembershipJoinedEvent) {
Ln.d("MembershipJoinedEvent: ");
if (membership.getState() != CallMembership.State.JOINED || personId == null || personId.isEmpty() || membership.getEmail() == null || membership.getEmail().isEmpty())
if (membership.getState() != CallMembership.State.JOINED || personId == null || personId.isEmpty() || membership.getDisplayName() == null || membership.getDisplayName().isEmpty())
return;
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getEmail(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getDisplayName(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
agent.getWebex().people().get(personId, r -> {
if (r == null || !r.isSuccessful() || r.getData() == null) return;
updatePersonInfoForParticipants(personId, r.getData());
Expand Down Expand Up @@ -932,9 +960,9 @@ public void onEventMainThread(OnCallMembershipEvent event) {
}
} else if (event.callEvent instanceof CallObserver.MembershipWaitingEvent) {
Ln.d("MembershipJoinedLobbyEvent: ");
if (membership.getState() != CallMembership.State.WAITING || personId == null || personId.isEmpty() || membership.getEmail() == null || membership.getEmail().isEmpty())
if (membership.getState() != CallMembership.State.WAITING || personId == null || personId.isEmpty() || membership.getDisplayName() == null || membership.getDisplayName().isEmpty())
return;
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getEmail(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
participantsAdapter.addOrUpdateItem(new ParticipantsAdapter.CallMembershipEntity(personId, membership.getDisplayName(), "", membership.isSendingAudio(), membership.isSendingVideo(), membership.getState()));
agent.getWebex().people().get(personId, r -> {
if (r == null || !r.isSuccessful() || r.getData() == null) return;
Ln.d("people: " + r.getData());
Expand All @@ -944,18 +972,12 @@ public void onEventMainThread(OnCallMembershipEvent event) {
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";
String text = membership.getDisplayName() + (membership.isAudioMutedControlled() ? " muted" : " unmuted") + " by others";
toast(text);
}
}
}

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(PermissionAcquiredEvent event) {
makeCall();
}

private void backToHome() {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
Expand Down
Loading

0 comments on commit a7bf769

Please sign in to comment.