|
@@ -64,9 +64,9 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
|
|
|
voip.putExtra(CallSingleActivity.EXTRA_USER_NAME, inviteUserName);
|
|
|
voip.putExtra(CallSingleActivity.EXTRA_AUDIO_ONLY, isAudioOnly);
|
|
|
voip.putExtra(CallSingleActivity.EXTRA_FROM_FLOATING_VIEW, false);
|
|
|
- if (isClearTop) {
|
|
|
- voip.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
- }
|
|
|
+ //if (isClearTop) {
|
|
|
+ // voip.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
+ //}
|
|
|
return voip;
|
|
|
}
|
|
|
|
|
@@ -74,12 +74,8 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
|
|
|
public static void openActivity(Context context, String targetId, boolean isOutgoing, String inviteUserName,
|
|
|
boolean isAudioOnly, boolean isClearTop) {
|
|
|
Intent intent = getCallIntent(context, targetId, isOutgoing, inviteUserName, isAudioOnly, isClearTop);
|
|
|
- //if (context instanceof Activity) {
|
|
|
- // context.startActivity(intent);
|
|
|
- //} else {
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
- context.startActivity(intent);
|
|
|
- //}
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
+ context.startActivity(intent);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -104,31 +100,7 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
|
|
|
isOutgoing = intent.getBooleanExtra(EXTRA_MO, false);
|
|
|
isAudioOnly = intent.getBooleanExtra(EXTRA_AUDIO_ONLY, false);
|
|
|
|
|
|
- if (isFromFloatingView) {
|
|
|
- //Intent serviceIntent = new Intent(this, FloatingVoipService.class);
|
|
|
- //stopService(serviceIntent);
|
|
|
- //init(targetId, false, isAudioOnly, false);
|
|
|
- } else {
|
|
|
- // 权限检测
|
|
|
- String[] per;
|
|
|
- if (isAudioOnly) {
|
|
|
- per = new String[]{Manifest.permission.RECORD_AUDIO};
|
|
|
- } else {
|
|
|
- per = new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA};
|
|
|
- }
|
|
|
- Permissions.request(this, per, integer -> {
|
|
|
- Log.d(TAG, "Permissions.request integer = " + integer);
|
|
|
- if (integer == 0) {
|
|
|
- // 权限同意
|
|
|
- init(targetId, isOutgoing, isAudioOnly);
|
|
|
- } else {
|
|
|
- Toast.makeText(this, "权限被拒绝", Toast.LENGTH_SHORT).show();
|
|
|
- // 权限拒绝
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
+ init(targetId, isOutgoing, isAudioOnly);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -179,72 +151,12 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
|
|
|
if (session == null) {
|
|
|
finish();
|
|
|
} else {
|
|
|
- /*if (session.isAudioOnly() && !audioOnly) { //这种情况是,对方切换成音频的时候,activity还没启动,这里启动后需要切换一下
|
|
|
- isAudioOnly = session.isAudioOnly();
|
|
|
- fragment.didChangeMode(true);
|
|
|
- }*/
|
|
|
session.setSessionCallback(this);
|
|
|
- //session.toggleSpeaker(true);
|
|
|
-
|
|
|
- //之前已经通过tcp接受了,此时sip通话建立,直接接通
|
|
|
- /*if (session.getState() == EnumType.CallState.Incoming) {
|
|
|
- session.joinHome(session.getRoomId());
|
|
|
- } else {
|
|
|
- session.sendRefuse();
|
|
|
- }*/
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void init(String targetId, boolean outgoing, boolean audioOnly, boolean isReplace) {
|
|
|
- SingleCallFragment fragment;
|
|
|
- if (audioOnly) {
|
|
|
- fragment = new FragmentAudio();
|
|
|
- } else {
|
|
|
- fragment = new FragmentVideo();
|
|
|
- }
|
|
|
- FragmentManager fragmentManager = getSupportFragmentManager();
|
|
|
- currentFragment = fragment;
|
|
|
- if (isReplace) {
|
|
|
- fragmentManager.beginTransaction()
|
|
|
- .replace(android.R.id.content, fragment)
|
|
|
- .commit();
|
|
|
- } else {
|
|
|
- fragmentManager.beginTransaction()
|
|
|
- .add(android.R.id.content, fragment)
|
|
|
- .commit();
|
|
|
- }
|
|
|
- if (outgoing && !isReplace) {
|
|
|
- // 创建会话
|
|
|
- room = UUID.randomUUID().toString() + System.currentTimeMillis();
|
|
|
- boolean b = gEngineKit.startOutCall(getApplicationContext(), room, targetId, audioOnly);
|
|
|
- if (!b) {
|
|
|
- finish();
|
|
|
- return;
|
|
|
- }
|
|
|
- //App.getInstance().setRoomId(room);
|
|
|
- //App.getInstance().setOtherUserId(targetId);
|
|
|
- CallSession session = gEngineKit.getCurrentSession();
|
|
|
- if (session == null) {
|
|
|
- finish();
|
|
|
- } else {
|
|
|
- session.setSessionCallback(this);
|
|
|
- }
|
|
|
- } else {
|
|
|
- CallSession session = gEngineKit.getCurrentSession();
|
|
|
- if (session == null) {
|
|
|
- finish();
|
|
|
- } else {
|
|
|
- //if (session.isAudioOnly() && !audioOnly) { //这种情况是,对方切换成音频的时候,activity还没启动,这里启动后需要切换一下
|
|
|
- // isAudioOnly = session.isAudioOnly();
|
|
|
- // fragment.didChangeMode(true);
|
|
|
- //}
|
|
|
- session.setSessionCallback(this);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
public SkyEngineKit getEngineKit() {
|
|
|
return gEngineKit;
|
|
@@ -259,19 +171,6 @@ public class CallSingleActivity extends BaseActivity implements CallSession.Call
|
|
|
return isFromFloatingView;
|
|
|
}
|
|
|
|
|
|
- // 显示小窗
|
|
|
- /*public void showFloatingView() {
|
|
|
- if (!checkOverlayPermission()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Intent intent = new Intent(this, FloatingVoipService.class);
|
|
|
- intent.putExtra(EXTRA_TARGET, targetId);
|
|
|
- intent.putExtra(EXTRA_AUDIO_ONLY, isAudioOnly);
|
|
|
- intent.putExtra(EXTRA_MO, isOutgoing);
|
|
|
- startService(intent);
|
|
|
- finish();
|
|
|
- }*/
|
|
|
-
|
|
|
// 切换到语音通话
|
|
|
public void switchAudio() {
|
|
|
//init(targetId, isOutgoing, true, true);
|