From 2959abb6caf89ceb0260dbf574c678fb0b7ed915 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 11:09:08 +0300 Subject: [PATCH 01/24] NY-10234: [AN]: Issue with swiping in video conferences --- .../data/conference/ConferenceVideoModule.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java index bf856e2b93..95e50ef935 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java @@ -134,8 +134,11 @@ public class ConferenceVideoModule { } public int getWidthDividerLength(int position) { - if (mActiveVideoParticipantsCount/MAX_VIDEO_FEEDS_COLUIMN_SIZE <= MAX_VIDEO_FEEDS_ROW_SIZE) { - return mActiveVideoParticipantsCount / MAX_VIDEO_FEEDS_COLUIMN_SIZE + 1; //MAX_VIDEO_FEEDS_ROW_SIZE + 1; + if (mActiveVideoParticipantsCount <= MAX_VIDEO_FEEDS_COUNT_PER_PAGE) { + if (mActiveVideoParticipantsCount/MAX_VIDEO_FEEDS_COLUIMN_SIZE <= MAX_VIDEO_FEEDS_ROW_SIZE) { + if (mActiveVideoParticipantsCount <= MAX_VIDEO_FEEDS_COLUIMN_SIZE) return 0; + return MAX_VIDEO_FEEDS_ROW_SIZE + 1; + } } int lastPageBeginer = ((mActiveVideoParticipantsCount / MAX_VIDEO_FEEDS_COUNT_PER_PAGE) * MAX_VIDEO_FEEDS_COUNT_PER_PAGE); if (mActiveVideoParticipantsCount == lastPageBeginer) { @@ -143,15 +146,16 @@ public class ConferenceVideoModule { } if (position < lastPageBeginer) { - return MAX_VIDEO_FEEDS_COUNT_PER_PAGE / MAX_VIDEO_FEEDS_COLUIMN_SIZE - 1; + return MAX_VIDEO_FEEDS_COUNT_PER_PAGE / MAX_VIDEO_FEEDS_COLUIMN_SIZE; } int row = (mActiveVideoParticipantsCount - lastPageBeginer)/MAX_VIDEO_FEEDS_COLUIMN_SIZE; if (row <= MAX_VIDEO_FEEDS_ROW_SIZE) { int rest = (mActiveVideoParticipantsCount - lastPageBeginer)%MAX_VIDEO_FEEDS_COLUIMN_SIZE; if (rest == 0) { + if (row == MAX_VIDEO_FEEDS_ROW_SIZE) return MAX_VIDEO_FEEDS_ROW_SIZE; + if (row == 1) return row; if (row < MAX_VIDEO_FEEDS_ROW_SIZE) return row; - if (position/lastPageBeginer == 1) return row + 1; return row - 1; } return row + 1; @@ -194,7 +198,7 @@ public class ConferenceVideoModule { } private int lastPageWidthDivider2(int lastPageCount) { - if (lastPageCount < MAX_VIDEO_FEEDS_COLUIMN_SIZE) return 1; + //if (lastPageCount < MAX_VIDEO_FEEDS_COLUIMN_SIZE) return 1; return MAX_VIDEO_FEEDS_ROW_SIZE; } -- GitLab From bf522ae61e511c5de10110d0f2390abe0527c71d Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 11:19:06 +0300 Subject: [PATCH 02/24] NY-10231: [AN]: The "local feed" label currently shows your user name. Make it like on the iPhone - show - "Me". --- .../adapters/viewholders/conference/ConferenceVideoItemVh.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java index 8c4e016561..0bb05f5ebb 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java @@ -141,6 +141,7 @@ public class ConferenceVideoItemVh extends BaseVH { drawIsFeedVideoIfNeeded(item.hasVideo); if (mItem != null) { if (mItem != null && mItem.isMe) { + mName.setText(R.string.call_me); mFeedFrameLayout.setBackgroundResource(R.drawable.video_feed_square_stroke_red); mSwithCamera.setOnClickListener(null); if (mListener != null) { -- GitLab From 0c6521b431fe642a992bb9ed69bf698ea90c90ea Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 11:42:47 +0300 Subject: [PATCH 03/24] NY-10232: [AN]: Change the position of switch camera button in video feed --- .../main/res/layout/li_conference_video.xml | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/layout/li_conference_video.xml b/app/src/main/res/layout/li_conference_video.xml index dfc71020c7..73895476f8 100644 --- a/app/src/main/res/layout/li_conference_video.xml +++ b/app/src/main/res/layout/li_conference_video.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" - android:padding="@dimen/padding_small"> + android:padding="@dimen/padding_tiny"> - - + + Date: Fri, 8 May 2020 12:05:18 +0300 Subject: [PATCH 04/24] NY-10242: [AN]: After some add/remove, Android gets feeds flickering on top of each other. --- .../ui/adapters/conference/ConferenceVideoAdapter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java index 0956d049d7..d955a0a396 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java @@ -21,6 +21,8 @@ import com.nynja.mobile.communicator.ui.base.BaseVH; import java.util.HashSet; import java.util.List; +import timber.log.Timber; + import static com.nynja.mobile.communicator.data.conference.ConferenceVideoModule.MAX_VIDEO_FEEDS_COLUIMN_SIZE; import static com.nynja.mobile.communicator.data.conference.ConferenceVideoModule.MAX_VIDEO_FEEDS_ROW_SIZE; @@ -48,7 +50,9 @@ public class ConferenceVideoAdapter> exten @Override public long getItemId(int position) { if (position < getItemCount()) { - return getItem(position).hashCode(); + Timber.d("getItemId(): participantId = %s; feed ID = %d", getItem(position).participantId, + getItem(position).participantId.hashCode()); + return getItem(position).participantId.hashCode(); } return -1L; } -- GitLab From b8760b257504c1b584abf6215c2eee0733ac34f9 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 13:01:13 +0300 Subject: [PATCH 05/24] NY-10119: [AN]: Cannot start SS if there is at least one camera started in the Video Conference --- .../communicator/data/sdk/calls/ConferenceSDKModule.java | 2 +- .../mvp/presenters/ConferenceCallPresenter.java | 4 ++-- .../ui/fragments/conference/ConferenceCallFragment.java | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 3af7bfeabc..5e8066ed33 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -3277,7 +3277,7 @@ public class ConferenceSDKModule extends BaseSDKModule { if (mActiveConference.mConference == null) return false; return (mActiveConference.mConference.hasRemoteScreenShare() - || !mActiveConference.mData.mActiveTracks.isEmpty()); + || !mActiveConference.mData.mActiveParticipanSSTracks.isEmpty()); } public boolean isScreenSharing() { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java index f4bb992891..0e76c78047 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java @@ -445,8 +445,8 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter public void onClickScreenShare(boolean isShareOn) { if (getAttachedViews().size() == 0) return; ActiveConferenceCall call = mDataManager.getConferenceSDK().getActiveConference(); - if (call != null && !call.isModerator() && !mDataManager.getConferenceSDK().isP2P()) { - if (!isScreenSharing() && hasRemoteScreenShare()) { + if (call != null && !mDataManager.getConferenceSDK().isP2P()) { + if (/*!call.isModerator() &&*/ !isScreenSharing() && hasRemoteScreenShare()) { getViewState().showFirstStopScreenSharingWarning(call); return; } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java index 216afa43a9..00e46d5ecc 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java @@ -1603,11 +1603,7 @@ public class ConferenceCallFragment extends BaseFragment implements CallView, @Override public void showFirstStopScreenSharingWarning(ActiveConferenceCall call){ if (call == null) return; - String message = getString(R.string.call_ask_to_stop_ss_first, call.getConferenceSSOwner()); - if (call.isConference() && call.mData.hasRemoteVideoTrack) { - message = getString(R.string.call_ask_to_stop_camera_first, call.getConferenceSSOwner()); - } - final String msg = message; + final String msg = getString(R.string.call_ask_to_stop_ss_first, call.getConferenceSSOwner()); getActivity().runOnUiThread(() -> DialogFactory.showAlert(getActivity(), msg, getString(R.string.call_conference_alert_title), null)); -- GitLab From 3a9965efcb960a5e06c7ddd1a3709db21529a9bc Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 15:57:25 +0300 Subject: [PATCH 06/24] NY-10233: [AN]: Remove the empty space in the video feeds in conference call --- app/src/main/res/layout/li_conference_video.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/li_conference_video.xml b/app/src/main/res/layout/li_conference_video.xml index 73895476f8..a936623203 100644 --- a/app/src/main/res/layout/li_conference_video.xml +++ b/app/src/main/res/layout/li_conference_video.xml @@ -6,7 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center" - android:padding="@dimen/padding_tiny"> + android:padding="@dimen/margin_tiniest"> + android:padding="2dp"> -- GitLab From 96b8bc828b4c0c3ebd33f331ccb0d910b72d19d0 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 18:42:53 +0300 Subject: [PATCH 07/24] NY-10244: [AN]: Info message when screen and camera sharing at the same time --- .../presenters/ConferenceCallPresenter.java | 34 ++++++++++++++++- .../communicator/mvp/view/CallView.java | 7 ++++ .../conference/ConferenceCallFragment.java | 37 ++++++++++++++++++- app/src/main/res/values-en/strings.xml | 4 ++ app/src/main/res/values-es/strings.xml | 4 ++ app/src/main/res/values-ko/strings.xml | 4 ++ app/src/main/res/values-zh-rCN/strings.xml | 4 ++ app/src/main/res/values-zh/strings.xml | 4 ++ app/src/main/res/values/strings.xml | 4 ++ 9 files changed, 100 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java index 0e76c78047..ce146e11bd 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java @@ -446,6 +446,10 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter if (getAttachedViews().size() == 0) return; ActiveConferenceCall call = mDataManager.getConferenceSDK().getActiveConference(); if (call != null && !mDataManager.getConferenceSDK().isP2P()) { + if (isCameraRunning()) { + getViewState().showStopOwnCameraFirstgAlert(); + return; + } if (/*!call.isModerator() &&*/ !isScreenSharing() && hasRemoteScreenShare()) { getViewState().showFirstStopScreenSharingWarning(call); return; @@ -464,6 +468,23 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter } } + public void stopCameraAndContinueWithScreenshare() { + if (getAttachedViews().size() == 0) return; + if (!isScreenSharing()) { + stopCameraCapture(); + //startScreenCapture(); + getViewState().continueWithScreenshare(); + } + } + + public void continueWithScreenshare() { + if (getAttachedViews().size() == 0) return; + if (!isScreenSharing()) { + startScreenCapture(); + getViewState().setScreenShareOn(true); + } + } + public String getInvitationLink() { return mDataManager.getConferenceSDK().getActiveConferenceJoinLink(); } @@ -555,11 +576,22 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter } } + public void tryStartCameraCapture() { + if (getAttachedViews().size() == 0) return; + ActiveConferenceCall call = mDataManager.getConferenceSDK().getActiveConference(); + if (call != null && !mDataManager.getConferenceSDK().isP2P()) { + if (!isScreenSharing()) { + mDataManager.getConferenceSDK().startCameraCapture(); + return; + } + } + getViewState().showStopScreenShareFirstAlert(); + } + public void startCameraCapture() { mDataManager.getConferenceSDK().startCameraCapture(); } - public void stopCameraCapture() { mDataManager.getConferenceSDK().stopCameraCapture(); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/view/CallView.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/view/CallView.java index d718d095ff..c2c9ea0f0f 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/view/CallView.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/view/CallView.java @@ -83,4 +83,11 @@ public interface CallView extends ErrorMvpView { void setScreenShareOn(boolean shareOn); void showFirstStopScreenSharingWarning(ActiveConferenceCall call); + + void showStopOwnCameraFirstgAlert(); + + void showStopScreenShareFirstAlert(); + + void continueWithScreenshare(); + } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java index 00e46d5ecc..3441886a6b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceCallFragment.java @@ -373,7 +373,7 @@ public class ConferenceCallFragment extends BaseFragment implements CallView, .subscribe(permission -> { if (permission.granted) { videoOnOf.setChecked(true); - mConferencePresenter.startCameraCapture(); + mConferencePresenter.tryStartCameraCapture(); } else if (!permission.shouldShowRequestPermissionRationale) { PermissionHelper.getInstance().showPermissionDialog(getActivity(), mConferencePresenter.getPermissionDialogListener(), Manifest.permission.CAMERA); @@ -1602,6 +1602,9 @@ public class ConferenceCallFragment extends BaseFragment implements CallView, @Override public void showFirstStopScreenSharingWarning(ActiveConferenceCall call){ + if (getActivity() == null || !isAdded() || audioSpeaker == null) { + return; + } if (call == null) return; final String msg = getString(R.string.call_ask_to_stop_ss_first, call.getConferenceSSOwner()); getActivity().runOnUiThread(() -> DialogFactory.showAlert(getActivity(), @@ -1609,6 +1612,38 @@ public class ConferenceCallFragment extends BaseFragment implements CallView, getString(R.string.call_conference_alert_title), null)); } + + @Override + public void showStopOwnCameraFirstgAlert() { + if (getActivity() == null || !isAdded() || audioSpeaker == null) { + return; + } + DialogFactory.showAlert(getActivity(), getString(R.string.call_conference_alert_title), + getString(R.string.call_start_conference_ss_alert), + getString(R.string.call_continue_button), getString(R.string.cancel), + (dialog, which) -> mConferencePresenter.stopCameraAndContinueWithScreenshare(), + null); + } + + @Override + public void showStopScreenShareFirstAlert() { + if (getActivity() == null || !isAdded() || audioSpeaker == null) { + return; + } + videoOnOf.setChecked(false); + DialogFactory.showAlert(getActivity(), + getString(R.string.call_start_conference_camera_alert), + getString(R.string.call_conference_alert_title), null); + } + + @Override + public void continueWithScreenshare() { + new Handler(Looper.getMainLooper()).postDelayed(() -> { + videoOnOf.setChecked(false); + mConferencePresenter.continueWithScreenshare(); + }, Consts.DELAY_300); + } + @Override public void onBluetoothDeviceDisconnected() { //mConferencePresenter.bluetoothDisconnected(); diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 7c4abf8019..4b8c7a2ef6 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -1337,4 +1337,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index bf1a90442a..a93d6de9c0 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1336,4 +1336,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index c13526f956..3fb29a0c69 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1336,4 +1336,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 355a75c596..4716478128 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -1336,4 +1336,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 355a75c596..4716478128 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1336,4 +1336,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 398d5866d8..d18544ed30 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1338,4 +1338,8 @@ Cannot start screen share because it has been already started by another participant Start camera is not available for groups + To share your screen, you need to stop your camera first. Tap \"Continue\" below and we will stop your camera for you and start screen sharing. + To start your camera, you need to stop screen sharing first. + Continue + -- GitLab From d4336b8e09d5e24a1b8bfe34753f7bd7939c0582 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 8 May 2020 19:07:43 +0300 Subject: [PATCH 08/24] -fixed Firebase crash: ConferenceSDKModule.java line 3099 com.nynja.mobile.communicator.data.sdk.calls.ConferenceSDKModule.lambda$onConferenceConnected$33 --- .../data/sdk/calls/ConferenceSDKModule.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 5e8066ed33..dbc5d90c7f 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -3095,17 +3095,22 @@ public class ConferenceSDKModule extends BaseSDKModule { final String callId = iConference.callId(); mActiveConference.isRinging = false; new Handler(Looper.getMainLooper()).post(() -> { - onCallReady(callId, videoEnabled); - if (mActiveConference.mInitialStartCapturer && - mActiveConference.mData.isOwnStreamActive && - mActiveConference.isOutgoingCall && - mActiveConference.mConference.isModerator()) { - mActiveConference.mConference.startCamera(); - mActiveConference.mInitialStartCapturer = false; - } + onConferenceConnectedInternal(callId, videoEnabled); }); } } + private synchronized void onConferenceConnectedInternal(String callId, boolean videoEnabled) { + onCallReady(callId, videoEnabled); + if (mActiveConference != null && + mActiveConference.mInitialStartCapturer && + mActiveConference.mData.isOwnStreamActive && + mActiveConference.isOutgoingCall && + mActiveConference.mConference != null && + mActiveConference.mConference.isModerator()) { + mActiveConference.mConference.startCamera(); + mActiveConference.mInitialStartCapturer = false; + } + } private void onCallReady(String callId, boolean videoEnabled) { onCallReady(callId, videoEnabled, false); -- GitLab From ca5daa32ed2c5b619543f04b1411f646ba481431 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Sat, 9 May 2020 17:49:32 +0300 Subject: [PATCH 09/24] -multiple feed minor chages; -added dots for video pages --- .../conference/ConferenceVideoModule.java | 35 +++++++++++++++++-- .../data/sdk/calls/ConferenceCallData.java | 25 +++++++------ .../conference/ConferenceVideoAdapter.java | 14 +++++++- .../communicator/ui/base/BaseAdapter.java | 8 +++++ .../conference/ConferenceVideoFragment.java | 18 ++++------ .../views/CirclePagerIndicatorDecoration.java | 28 ++++++++++----- 6 files changed, 95 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java index 95e50ef935..8634010cd7 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java @@ -12,6 +12,7 @@ import org.webrtc.SurfaceViewRenderer; import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import java.util.Set; import kotlin.jvm.Synchronized; @@ -90,16 +91,35 @@ public class ConferenceVideoModule { if (activeConferenceCall == null) return new ArrayList<>(); Set participatIds = mActiveVideoParticipantsMap.keySet(); mActiveVideoParticipantsMap.clear(); - synchronized (activeConferenceCall.mData.mParticipantArray) { + synchronized (activeConferenceCall.mData) { if (activeConferenceCall.mData.mParticipantArray != null) { for (int index = 0; index < activeConferenceCall.mData.mParticipantArray.size(); index++) { NYNCallParticipant participant = activeConferenceCall.mData.mParticipantArray.get(index); - if (participant.hasVideo() || (participant.isMe() && activeConferenceCall.mData.isOwnStreamActive)) { + if (participant.hasVideo() || + (participant.isMe() && activeConferenceCall.mData.isOwnStreamActive) + || activeConferenceCall.mData.mActiveParticipanTracks.containsKey(participant.getParticipantId()) + ) { ConferenceListItem item = conferenceParticipant(participant, participant.isOwner(), activeConferenceCall.mData.isOwnStreamActive); + item.hasVideo = true; mActiveVideoParticipantsMap.put(item.participantId, item); } } } +// if (activeConferenceCall.mData.mActiveParticipanTracks != null) { +// for (Map.Entry set : activeConferenceCall.mData.mActiveParticipanTracks.entrySet()) { +// NYNCallParticipant participant = activeConferenceCall.mConference.getParticipantByTrackId(set.getKey()); +// if (participant == null) participant = activeConferenceCall.mConference.getParticipantById(set.getValue()); +// if (participant != null && +// (participant.hasVideo() || +// (participant.isMe() && activeConferenceCall.mData.isOwnStreamActive) || +// activeConferenceCall.mData.mActiveParticipanTracks.containsKey(participant.getParticipantId()))) { +// ConferenceListItem item = conferenceParticipant(participant, participant.isOwner(), activeConferenceCall.mData.isOwnStreamActive); +// item.hasVideo = true; +// item.participantId = set.getValue(); +// mActiveVideoParticipantsMap.put(item.participantId, item); +// } +// } +// } } for (String participantId : participatIds) { @@ -153,7 +173,7 @@ public class ConferenceVideoModule { if (row <= MAX_VIDEO_FEEDS_ROW_SIZE) { int rest = (mActiveVideoParticipantsCount - lastPageBeginer)%MAX_VIDEO_FEEDS_COLUIMN_SIZE; if (rest == 0) { - if (row == MAX_VIDEO_FEEDS_ROW_SIZE) return MAX_VIDEO_FEEDS_ROW_SIZE; + if ((position + 1 - lastPageBeginer)/MAX_VIDEO_FEEDS_COLUIMN_SIZE == MAX_VIDEO_FEEDS_ROW_SIZE) return MAX_VIDEO_FEEDS_ROW_SIZE + 1; if (row == 1) return row; if (row < MAX_VIDEO_FEEDS_ROW_SIZE) return row; return row - 1; @@ -220,6 +240,15 @@ public class ConferenceVideoModule { return MAX_VIDEO_FEEDS_COLUIMN_SIZE; } + public int getItemsPageCount() { + if (mActiveVideoParticipantsCount <= MAX_VIDEO_FEEDS_COLUIMN_SIZE) { + return 1; + } + int count = (mActiveVideoParticipantsCount / MAX_VIDEO_FEEDS_COUNT_PER_PAGE); + if ((mActiveVideoParticipantsCount - count*MAX_VIDEO_FEEDS_COUNT_PER_PAGE) % MAX_VIDEO_FEEDS_COUNT_PER_PAGE > 0) count++; + return count; + } + protected ConferenceListItem conferenceParticipant(NYNCallParticipant participant, boolean isModerator, boolean isOwnStreamActive) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceCallData.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceCallData.java index 8f40428288..5fac62702a 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceCallData.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceCallData.java @@ -5,6 +5,7 @@ import com.nynja.sdk.NYNCallParticipant; import com.nynja.sdk.NYNCallParticipantArray; import java.util.HashMap; +import java.util.Map; /** * Created by Ergyun Syuleyman on 04/03/2020. @@ -19,8 +20,8 @@ public class ConferenceCallData { public String mRemoteSSTrackId; public String mRemoteVideoTrackId; public HashMap mActiveTracks; - public HashMap mActiveParticipanTracks; - public HashMap mActiveParticipanSSTracks; + public HashMap mActiveParticipanTracks; + public HashMap mActiveParticipanSSTracks; public boolean hasRemoteVideoTrack; public boolean hasRemoteScreenShareTrack; public boolean mIsConference; @@ -51,13 +52,13 @@ public class ConferenceCallData { public void onRemoteVideoAdded(String trackId, String participantId) { hasRemoteVideoTrack = true; mActiveTracks.put(trackId, participantId); - mActiveParticipanTracks.put(participantId, trackId); + mActiveParticipanTracks.put(trackId, participantId); mRemoteVideoTrackId = trackId; } public void onRemoteVideoRemoved(String trackId, String participantId) { mActiveTracks.remove(trackId); - mActiveParticipanTracks.remove(participantId); + mActiveParticipanTracks.remove(trackId); hasRemoteVideoTrack = !isRemoteVideoTracksEmpty(); mRemoteVideoTrackId = ""; } @@ -65,14 +66,14 @@ public class ConferenceCallData { public void onRemoteSSAdded(String trackId, String participantId) { hasRemoteScreenShareTrack = true; mActiveTracks.put(trackId, participantId); - mActiveParticipanSSTracks.put(participantId, trackId); + mActiveParticipanSSTracks.put(trackId, participantId); mRemoteSSTrackId = trackId; } public void onRemoteSSRemoved(String trackId, String participantId) { hasRemoteScreenShareTrack = false; mActiveTracks.remove(trackId); - mActiveParticipanSSTracks.remove(participantId); + mActiveParticipanSSTracks.remove(trackId); mRemoteSSTrackId = ""; } @@ -96,12 +97,16 @@ public class ConferenceCallData { protected String getTrackIdForParticipant(String participantId, boolean isVideo) { if (StringUtils.isEmpty(participantId)) return ""; if (isVideo) { - if (mActiveParticipanTracks.containsKey(participantId)) { - return mActiveParticipanTracks.get(participantId); + for (Map.Entry set : mActiveParticipanTracks.entrySet()) { + if (set.getValue().contentEquals(participantId)) { + return set.getKey(); + } } } else { - if (mActiveParticipanSSTracks.containsKey(participantId)) { - return mActiveParticipanSSTracks.get(participantId); + for (Map.Entry set : mActiveParticipanSSTracks.entrySet()) { + if (set.getValue().contentEquals(participantId)) { + return set.getKey(); + } } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java index d955a0a396..f40a88ae8f 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java @@ -54,7 +54,17 @@ public class ConferenceVideoAdapter> exten getItem(position).participantId.hashCode()); return getItem(position).participantId.hashCode(); } - return -1L; + return position; + } + + @Override + public int getItemsPageCount() { + return ConferenceVideoModule.getInstance().getItemsPageCount(); + } + + @Override + public int getMaxItemsPerPage() { + return ConferenceVideoModule.MAX_VIDEO_FEEDS_COUNT_PER_PAGE; } public void setIsModerator(boolean isModerator) { @@ -125,7 +135,9 @@ public class ConferenceVideoAdapter> exten } else { layoutParams.width = itemWidth - ConferenceVideoModule.getInstance().getWidthDividerLength(position); } + holder.itemView.setBottom(itemHeight - 32); holder.itemView.setLayoutParams(layoutParams); + holder.itemView.requestLayout(); } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/base/BaseAdapter.java b/app/src/main/java/com/nynja/mobile/communicator/ui/base/BaseAdapter.java index fe33b3d069..c88465c9a1 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/base/BaseAdapter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/base/BaseAdapter.java @@ -44,6 +44,14 @@ public abstract class BaseAdapter> extends RecyclerVie } } + public int getItemsPageCount() { + return getItemCount(); + } + + public int getMaxItemsPerPage() { + return 1; + } + public List getItems() { return mList; } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java index eaad10fb5c..7a7e0b48eb 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java @@ -4,6 +4,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.GridLayoutManager; @@ -30,6 +31,7 @@ import com.nynja.mobile.communicator.ui.activities.calls.CallActivity; import com.nynja.mobile.communicator.ui.adapters.conference.ConferenceVideoAdapter; import com.nynja.mobile.communicator.ui.adapters.viewholders.conference.ConferenceVideoItemVh; import com.nynja.mobile.communicator.ui.base.BaseFragment; +import com.nynja.mobile.communicator.ui.views.CirclePagerIndicatorDecoration; import com.nynja.mobile.communicator.utils.ActionSheetDialog; import com.nynja.mobile.communicator.utils.DialogFactory; import com.nynja.mobile.communicator.utils.StringUtils; @@ -166,23 +168,17 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV MAX_VIDEO_FEEDS_COLUIMN_SIZE, LinearLayoutManager.HORIZONTAL, false); -// mGridLayoutManager.setSpanCount(2); -// mGridLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); -// mGridLayoutManager.setReverseLayout(false); -// mGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { -// @Override -// public int getSpanSize(int position) { -// return (int)ConferenceVideoModule.getInstance().getSpanSize(position); -// } -// }); mGridLayoutManager.setItemPrefetchEnabled(true); mRecyclerView.setLayoutManager(mGridLayoutManager); mRecyclerView.setHasFixedSize(true); mRecyclerView.setAdapter(mConfParticipantsAdapter); - SnapHelper snapHelper = new LinearSnapHelper(); - snapHelper.attachToRecyclerView(mRecyclerView); + mRecyclerView.addItemDecoration(new CirclePagerIndicatorDecoration(12, 24, 64, + ContextCompat.getColor(getActivity(), R.color.icon_spreadsheet_files), + ContextCompat.getColor(getActivity(), R.color.active_call_bg))); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.HORIZONTAL)); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); + SnapHelper snapHelper = new LinearSnapHelper(); + snapHelper.attachToRecyclerView(mRecyclerView); // mRecyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() { // @Override // public void onChildViewAttachedToWindow(View view) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/views/CirclePagerIndicatorDecoration.java b/app/src/main/java/com/nynja/mobile/communicator/ui/views/CirclePagerIndicatorDecoration.java index 898677c168..0caaba0297 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/views/CirclePagerIndicatorDecoration.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/views/CirclePagerIndicatorDecoration.java @@ -2,14 +2,19 @@ package com.nynja.mobile.communicator.ui.views; import android.content.res.Resources; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.support.annotation.ColorInt; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.View; +import com.nynja.mobile.communicator.R; +import com.nynja.mobile.communicator.ui.base.BaseAdapter; + import org.jetbrains.annotations.NotNull; /** @@ -48,29 +53,35 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration public void onDrawOver(@NotNull Canvas c, @NotNull RecyclerView parent, @NotNull RecyclerView.State state) { super.onDrawOver(c, parent, state); - final RecyclerView.Adapter adapter = parent.getAdapter(); + final BaseAdapter adapter = (BaseAdapter) parent.getAdapter(); if (adapter == null) { return; } - int itemCount = adapter.getItemCount(); + int pageCount = adapter.getItemsPageCount(); + if (pageCount <= 1) { + return; + } + + int maxItemsPerPage = adapter.getMaxItemsPerPage(); // center horizontally, calculate width and subtract half from center - float totalLength = this.radius * 2 * itemCount; - float paddingBetweenItems = Math.max(0, itemCount - 1) * indicatorItemPadding; + float totalLength = this.radius * 2 * pageCount; + float paddingBetweenItems = Math.max(0, pageCount - 1) * indicatorItemPadding; float indicatorTotalWidth = totalLength + paddingBetweenItems; float indicatorStartX = (parent.getWidth() - indicatorTotalWidth) / 2f; // center vertically in the allotted space float indicatorPosY = parent.getHeight() - indicatorHeight / 2f; - drawInactiveDots(c, indicatorStartX, indicatorPosY, itemCount); + drawInactiveDots(c, indicatorStartX, indicatorPosY, pageCount); - final int activePosition; + int activePosition; if (parent.getLayoutManager() instanceof GridLayoutManager) { - activePosition = ((GridLayoutManager) parent.getLayoutManager()).findFirstVisibleItemPosition(); + activePosition = ((GridLayoutManager) parent.getLayoutManager()).findFirstCompletelyVisibleItemPosition(); +// activePosition = ((GridLayoutManager) parent.getLayoutManager()).findFirstVisibleItemPosition(); } else if (parent.getLayoutManager() instanceof LinearLayoutManager) { activePosition = ((LinearLayoutManager) parent.getLayoutManager()).findFirstVisibleItemPosition(); } else { @@ -87,6 +98,7 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration if (activeChild == null) { return; } + activePosition = activePosition/maxItemsPerPage; drawActiveDot(c, indicatorStartX, indicatorPosY, activePosition); } @@ -107,7 +119,7 @@ public class CirclePagerIndicatorDecoration extends RecyclerView.ItemDecoration // width of item indicator including padding final float itemWidth = this.radius * 2 + indicatorItemPadding; float highlightStart = indicatorStartX + radius + itemWidth * highlightPosition; - c.drawCircle(highlightStart, indicatorPosY, radius, activePaint); + c.drawCircle(highlightStart, indicatorPosY, radius+2, activePaint); } @Override -- GitLab From 88f2c6dcf9b0e1a8b844921dd368efb919766631 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Sat, 9 May 2020 18:45:45 +0300 Subject: [PATCH 10/24] -added trace logs for conference video feeds --- .../conference/ConferenceVideoModule.java | 4 ++++ .../conference/ConferenceVideoAdapter.java | 5 +++-- .../conference/ConferenceVideoItemVh.java | 19 +++++++++++++++++++ .../conference/ConferenceVideoFragment.java | 14 +++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java index 8634010cd7..34651f1489 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Set; import kotlin.jvm.Synchronized; +import timber.log.Timber; public class ConferenceVideoModule { @@ -101,6 +102,7 @@ public class ConferenceVideoModule { ) { ConferenceListItem item = conferenceParticipant(participant, participant.isOwner(), activeConferenceCall.mData.isOwnStreamActive); item.hasVideo = true; + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): updated video feed item participant name=%s; ID=%s", item.name, item.participantId); mActiveVideoParticipantsMap.put(item.participantId, item); } } @@ -124,6 +126,7 @@ public class ConferenceVideoModule { for (String participantId : participatIds) { if (!mActiveVideoParticipantsMap.containsKey(participantId)) { + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): removed participant with ID=%s", participantId); enableVideoForTrack(participantId, false); String trackId = getTrackIdByParticipantId(participantId); setVideoRendererForTrack(null, trackId, StringUtils.isEmpty(trackId)); @@ -131,6 +134,7 @@ public class ConferenceVideoModule { } ArrayList items = new ArrayList<>(mActiveVideoParticipantsMap.values()); mActiveVideoParticipantsCount = items.size(); + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): items new size=%d", mActiveVideoParticipantsCount); return items; } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java index f40a88ae8f..349fd10ab4 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java @@ -50,8 +50,8 @@ public class ConferenceVideoAdapter> exten @Override public long getItemId(int position) { if (position < getItemCount()) { - Timber.d("getItemId(): participantId = %s; feed ID = %d", getItem(position).participantId, - getItem(position).participantId.hashCode()); + Timber.d("ConferenceVideoAdapter::getItemId(): participantId=%s; feedID=%d, position=%d", getItem(position).participantId, + getItem(position).participantId.hashCode(), position); return getItem(position).participantId.hashCode(); } return position; @@ -112,6 +112,7 @@ public class ConferenceVideoAdapter> exten @Override public void onBindViewHolder(T holder, int position) { + Timber.d("ConferenceVideoAdapter::onBindViewHolder(): item ID=%d; pos=%s", holder.getItemId(), position); super.onBindViewHolder(holder, position); if (mScreenWidth > 0) { float divWidth = ConferenceVideoModule.getInstance().getWidthDiv(position); diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java index 0bb05f5ebb..12cd8ce9d4 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java @@ -56,6 +56,7 @@ public class ConferenceVideoItemVh extends BaseVH { } @Override public void bind(ConferenceListItem item, int position) { + Timber.d("ConferenceVideoItemVh::bind(): item participant ID=%s, position=%d", item.participantId, position); mPosition = position; if (mUnbinder != null) { //mUnbinder.unbind(); @@ -98,25 +99,30 @@ public class ConferenceVideoItemVh extends BaseVH { onViewAttachedToWindow(); } } + Timber.d("ConferenceVideoItemVh::setData(): item participant name=%s; ID=%s", item.name, item.participantId); } public void onViewAttachedToWindow() { initVideoCallRenderer(); setVideoRendererForTrack(); enableVideoForTrack(true); + Timber.d("ConferenceVideoItemVh::onViewAttachedToWindow(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); } public void onViewDetachedFromWindow() { enableVideoForTrack(false); //removeVideoRendererForTrack(); + Timber.d("ConferenceVideoItemVh::onViewDetachedFromWindow(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); } public void onViewRecycled() { enableVideoForTrack(false); + Timber.d("ConferenceVideoItemVh::onViewRecycled(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); } @Synchronized public void releaseVideoCallRrenderers() { + Timber.d("ConferenceVideoItemVh::releaseVideoCallRrenderers(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); removeVideoRendererForTrack(); if (!mIsRenderersInitialized) return; if (mVideoFeed != null) { @@ -128,6 +134,7 @@ public class ConferenceVideoItemVh extends BaseVH { ///////////////////////////////////////////////////////////////////////////////////// // Internal Helpers private void setupInConference(ConferenceListItem item) { + Timber.d("ConferenceVideoItemVh::setupInConference(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); initVideoCallRenderer(); if (item.participantId == null || !item.isActive) { // in Conference - but not joined yet @@ -187,6 +194,7 @@ public class ConferenceVideoItemVh extends BaseVH { } private void drawIsFeedVideoIfNeeded(boolean visible) { + Timber.d("ConferenceVideoItemVh::drawIsFeedVideoIfNeeded(): item participant ID=%s; visible=%s", mItem.participantId, visible? "true":"false"); if (visible) { mVideoFeed.setVisibility(View.VISIBLE); } else { @@ -196,6 +204,7 @@ public class ConferenceVideoItemVh extends BaseVH { } private void refreshFeedVideo() { + Timber.d("ConferenceVideoItemVh::refreshFeedVideo(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); if (mVideoFeed != null) { mVideoFeed.invalidate(); mVideoFeed.refreshDrawableState(); @@ -213,7 +222,9 @@ public class ConferenceVideoItemVh extends BaseVH { @Synchronized private void initVideoCallRenderer() { + Timber.d("ConferenceVideoItemVh::initVideoCallRenderer(): item participant ID=%s; mIsRenderersInitialized=%s", mItem.participantId, mIsRenderersInitialized? "true":"false"); if (mIsRenderersInitialized) return; + Timber.d("ConferenceVideoItemVh::initVideoCallRenderer():2"); try { mVideoFeed.init(createRootEglBase().getEglBaseContext(), null); mVideoFeed.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT); @@ -229,23 +240,29 @@ public class ConferenceVideoItemVh extends BaseVH { @Synchronized private void setVideoRendererForTrack() { + Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); if (!mIsRenderersInitialized) return; if (mItem == null) return; if (mItem.isTrackActive == 1) return; String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(mItem.participantId); + Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, trackId); if (StringUtils.isNotEmpty(trackId) || mItem.isMe) { mItem.isTrackActive = 1; + Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); ConferenceVideoModule.getInstance().setVideoRendererForTrack(mVideoFeed, trackId, mItem.isMe); } } @Synchronized private void removeVideoRendererForTrack() { + Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); if (!mIsRenderersInitialized) return; if (mItem == null) return; if (mItem.isTrackActive == 0) return; String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(mItem.participantId); + Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, trackId); if (StringUtils.isNotEmpty(trackId) || mItem.isMe) { + Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, mItem.isMe); mItem.isTrackActive = 0; } @@ -253,6 +270,8 @@ public class ConferenceVideoItemVh extends BaseVH { @Synchronized private void enableVideoForTrack(boolean enable) { + Timber.d("setVideoRendererForTrack::enableVideoForTrack(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); + Timber.d("ConferenceVideoItemVh::enableVideoForTrack(): item participant ID=%s; enable=%s", mItem.participantId, enable? "true":"false"); if (!mIsRenderersInitialized) return; if (mItem == null) return; if (StringUtils.isNotEmpty(mItem.participantId)) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java index 7a7e0b48eb..3df985a89c 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java @@ -40,6 +40,7 @@ import org.webrtc.ContextUtils; import org.webrtc.EglBase; import java.util.ArrayList; +import java.util.List; import butterknife.BindView; import timber.log.Timber; @@ -343,6 +344,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV } public void setActiveState(boolean active) { + Timber.d("ConferenceVideoFragment::setActiveState(): active=%s", active? "true" : "false"); ActiveConferenceCall activeConferenceCall = mConferencePresenter.getActiveConference(); isActive = active; if (activeConferenceCall == null) return; @@ -489,6 +491,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV } private void loadConferenceMembers(ArrayList members) { + Timber.d("ConferenceVideoFragment::loadConferenceMembers()"); mConfParticipantsAdapter.setItems(members); } @@ -499,6 +502,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (!activeConferenceCall.mConference.isConference()) return; if (!activeConferenceCall.isVideoEnabled) return; + Timber.d("ConferenceVideoFragment::setRemoteVideoRenderer()"); mConferencePresenter.loadConferenceParticipants(activeConferenceCall); } @@ -510,6 +514,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (!activeConferenceCall.isVideoEnabled) return; if (StringUtils.isNotEmpty(trackId)) { + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderer()"); ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, false); } @@ -518,10 +523,15 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV private void removeRemoteVideoRenderers(ActiveConferenceCall activeConferenceCall) { if (activeConferenceCall == null) return; + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers()"); ArrayList members = mConferencePresenter.getConferenceVideoMembers(activeConferenceCall); - for (ConferenceListItem item : members) { + List list = mConfParticipantsAdapter.getItems(); + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): members size=%d", members.size()); + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): list size=%d", list.size()); + for (ConferenceListItem item : list) { //members) { String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(item.participantId); if (StringUtils.isNotEmpty(trackId) || item.isMe) { + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): participantID=%s", item.participantId); ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, item.isMe); } } @@ -531,6 +541,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (activeConferenceCall == null) return; if (activeConferenceCall.mConference == null) return; if (!activeConferenceCall.isVideoEnabled) return; + Timber.d("ConferenceVideoFragment::setLocalVideoRenderer()"); mConferencePresenter.loadConferenceParticipants(activeConferenceCall); } @@ -540,6 +551,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (activeConferenceCall.mConference == null) return; if (!activeConferenceCall.mConference.isRunning()) return; if (!activeConferenceCall.isVideoEnabled) return; + Timber.d("ConferenceVideoFragment::removeLocalVideoRenderer()"); mConferencePresenter.loadConferenceParticipants(activeConferenceCall); } -- GitLab From b4e8f6998c079048097e5a7b0168aedab30c11ae Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Mon, 11 May 2020 03:25:37 +0300 Subject: [PATCH 11/24] vide conference feeds logic refactoring to fix feeds flikering --- .../conference/ConferenceVideoModule.java | 101 +++++++++++++----- .../data/sdk/ConferenceSDKPresenter.java | 2 +- .../data/sdk/calls/ConferenceListItem.java | 4 +- .../data/sdk/calls/ConferenceSDKListener.java | 2 +- .../data/sdk/calls/ConferenceSDKModule.java | 2 +- .../mvp/presenters/CallActivityPresenter.java | 2 +- .../presenters/ConferenceCallPresenter.java | 2 +- .../presenters/ConferenceVideoPresenter.java | 5 +- .../communicator/mvp/view/CallView.java | 8 +- .../mvp/view/ConferenceVideoView.java | 2 +- .../conference/ConferenceVideoAdapter.java | 56 ++++++++-- .../conference/ConferenceVideoItemVh.java | 7 +- .../conference/ConferenceVideoFragment.java | 38 +++---- .../main/res/layout/li_conference_video.xml | 22 ++-- 14 files changed, 173 insertions(+), 80 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java index 34651f1489..21c32cc160 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/conference/ConferenceVideoModule.java @@ -12,6 +12,9 @@ import org.webrtc.SurfaceViewRenderer; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -30,7 +33,7 @@ public class ConferenceVideoModule { private ActiveConferenceCall mCurrentActiveCall; public int mActiveVideoParticipantsCount = 0; - public HashMap mActiveVideoParticipantsMap= new HashMap<>(); + public LinkedHashSet mActiveVideoParticipants= new LinkedHashSet<>(); private ConferenceVideoModule() { @@ -53,7 +56,7 @@ public class ConferenceVideoModule { public void reset() { // ToDo:... - mActiveVideoParticipantsMap.clear(); + mActiveVideoParticipants.clear(); mCurrentActiveCall = null; } @@ -87,23 +90,36 @@ public class ConferenceVideoModule { return trackId; } - @Synchronized - public ArrayList getConferenceVideoMembers(ActiveConferenceCall activeConferenceCall) { + public synchronized ArrayList getConferenceVideoMembers(ActiveConferenceCall activeConferenceCall) { if (activeConferenceCall == null) return new ArrayList<>(); - Set participatIds = mActiveVideoParticipantsMap.keySet(); - mActiveVideoParticipantsMap.clear(); + HashSet mTempActiveVideoParticipants= new HashSet<>(); + HashSet tempParticipants= new HashSet<>(); synchronized (activeConferenceCall.mData) { if (activeConferenceCall.mData.mParticipantArray != null) { for (int index = 0; index < activeConferenceCall.mData.mParticipantArray.size(); index++) { NYNCallParticipant participant = activeConferenceCall.mData.mParticipantArray.get(index); - if (participant.hasVideo() || - (participant.isMe() && activeConferenceCall.mData.isOwnStreamActive) - || activeConferenceCall.mData.mActiveParticipanTracks.containsKey(participant.getParticipantId()) - ) { - ConferenceListItem item = conferenceParticipant(participant, participant.isOwner(), activeConferenceCall.mData.isOwnStreamActive); + ConferenceListItem item = conferenceParticipant(participant, participant.isOwner(), activeConferenceCall.mData.isOwnStreamActive); + tempParticipants.add(item); + if (//participant.hasVideo() || + activeConferenceCall.mData.mActiveParticipanTracks.containsValue(participant.getParticipantId())) { + ////////////////////////////////////////////////////////////////////////////////////////////////// + // WORKAROUND !!!!!!!!!! item.hasVideo = true; + item.isMe = false; + ////////////////////////////////////////////////////////////////////////////////////////////////// Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): updated video feed item participant name=%s; ID=%s", item.name, item.participantId); - mActiveVideoParticipantsMap.put(item.participantId, item); + mTempActiveVideoParticipants.add(item); + } else if (//participant.hasVideo() && + participant.getParticipantId().contentEquals(activeConferenceCall.mConference.participantId()) && + participant.isMe() && + activeConferenceCall.mData.isOwnStreamActive) { + ////////////////////////////////////////////////////////////////////////////////////////////////// + // WORKAROUND !!!!!!!!!! + item.hasVideo = true; + item.isMe = true; + ////////////////////////////////////////////////////////////////////////////////////////////////// + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): updated video feed item participant name=%s; ID=%s", item.name, item.participantId); + mTempActiveVideoParticipants.add(item); } } } @@ -122,25 +138,62 @@ public class ConferenceVideoModule { // } // } // } - } - - for (String participantId : participatIds) { - if (!mActiveVideoParticipantsMap.containsKey(participantId)) { - Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): removed participant with ID=%s", participantId); - enableVideoForTrack(participantId, false); - String trackId = getTrackIdByParticipantId(participantId); - setVideoRendererForTrack(null, trackId, StringUtils.isEmpty(trackId)); + Iterator itr = mActiveVideoParticipants.iterator(); + while(itr.hasNext()) { + ConferenceListItem item = itr.next(); + if (!mTempActiveVideoParticipants.contains(item)) { + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): removed participant with ID=%s", item.participantId); + enableVideoForTrack(item.participantId, false); + if (item.isMe) { + setVideoRendererForTrack(null, "", true); + } else { + String trackId = getTrackIdByParticipantId(item.participantId); + if (StringUtils.isNotEmpty(trackId)) { + setVideoRendererForTrack(null, trackId, false); + } + } + itr.remove(); + } else if (tempParticipants.contains(item)) { + Iterator itr2 = tempParticipants.iterator(); + while(itr2.hasNext()) { + ConferenceListItem item2 = itr2.next(); + if (item2.equals(item)) { + item.update(item2); + break; + } + } + } + } + Iterator itr2 = mTempActiveVideoParticipants.iterator(); + while(itr2.hasNext()) { + ConferenceListItem item = itr2.next(); + if (!mActiveVideoParticipants.contains(item)) { + Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): added participant with ID=%s", item.participantId); + mActiveVideoParticipants.add(item); + } } } - ArrayList items = new ArrayList<>(mActiveVideoParticipantsMap.values()); + mTempActiveVideoParticipants.clear(); + ArrayList items = new ArrayList<>(mActiveVideoParticipants); mActiveVideoParticipantsCount = items.size(); Timber.d("ConferenceVideoModule::getConferenceVideoMembers(): items new size=%d", mActiveVideoParticipantsCount); return items; } - @Synchronized - public ArrayList getUpdatedActiveSpeakersParticipants(ArrayList participantIds) { - ArrayList items = new ArrayList<>(mActiveVideoParticipantsMap.values()); + public synchronized void participantRemoved(String participantId) { + Iterator itr = mActiveVideoParticipants.iterator(); + while(itr.hasNext()) { + ConferenceListItem item = itr.next(); + if (!participantId.contentEquals(item.participantId)) { + itr.remove(); + break; + } + } + mActiveVideoParticipantsCount = mActiveVideoParticipants.size(); + } + + public synchronized ArrayList getUpdatedActiveSpeakersParticipants(ArrayList participantIds) { + ArrayList items = new ArrayList<>(mActiveVideoParticipants); for (ConferenceListItem item : items) { item.isSpeaking = false; for (String participandId : participantIds) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java index 9c1ae7305c..cf1044ccef 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/ConferenceSDKPresenter.java @@ -63,7 +63,7 @@ public abstract class ConferenceSDKPresenter extends Bas @Override public void onRemoteVideoTrackAdded(ActiveConferenceCall activeConferenceCall, String trackId) {} - @Override public void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId) {} + @Override public void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId, String participantId) {} @Override public void onLocalVideoCapturerStarted(ActiveConferenceCall activeConferenceCall) {} diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java index e44ee8610c..518fd344c7 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java @@ -135,8 +135,8 @@ public class ConferenceListItem extends Object { this.hasScreen = participant.hasScreen; this.isVideoPaused = participant.isVideoPaused; this.isScreenPaused = participant.isScreenPaused; - this.isTrackActive = 0; - this.isMe = participant.isMe; +// this.isTrackActive = 0; +// this.isMe = participant.isMe; this.isFriend = participant.isFriend; this.isMuted = participant.isMuted; this.isSpeaking = participant.isSpeaking; diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java index 4710d6de07..b6bbde5325 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKListener.java @@ -48,7 +48,7 @@ public interface ConferenceSDKListener { void onRemoteVideoTrackAdded(ActiveConferenceCall activeConferenceCall, String trackId) ; - void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId) ; + void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId, String participantId) ; void onLocalVideoCapturerStarted(ActiveConferenceCall activeConferenceCall) ; diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index dbc5d90c7f..911f83e288 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -1678,7 +1678,7 @@ public class ConferenceSDKModule extends BaseSDKModule { if (mActiveConference.mConference == null) return; if (mActiveConference.mConference.callId().contentEquals(callId)) { for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) { - conferenceSDKListener.onRemoteVideoTrackRemoved(mActiveConference, trackId); + conferenceSDKListener.onRemoteVideoTrackRemoved(mActiveConference, trackId, participantId); } } // if (isConference) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallActivityPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallActivityPresenter.java index aedd916dd5..23b74d341e 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallActivityPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallActivityPresenter.java @@ -43,7 +43,7 @@ public class CallActivityPresenter extends ConferenceSDKPresenter @Override public void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, - String trackId) { + String trackId, String participantId) { if (getAttachedViews().size() == 0) return; if (activeConferenceCall == null) return; if (activeConferenceCall.isConference()) return; diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceVideoPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceVideoPresenter.java index 93ff6234b0..c1e6df26d1 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceVideoPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceVideoPresenter.java @@ -135,8 +135,9 @@ public class ConferenceVideoPresenter extends ConferenceSDKPresenter> exten private DisplayMetrics mDisplayMetrics = new DisplayMetrics(); private int mScreenWidth = 0; private int mScreenHeight = 0; - HashSet mHoldersSet; + LinkedHashSet< ConferenceVideoItemVh> mHolders; public ConferenceVideoAdapter(List list, OnConferenceVideoFeedClickListener onConferenceItemClickListener) { super(list); this.mOnConferenceVideoFeedClickListener = onConferenceItemClickListener; - mHoldersSet = new HashSet<>(); + mHolders = new LinkedHashSet<>(); setHasStableIds(true); } @@ -75,13 +79,53 @@ public class ConferenceVideoAdapter> exten return this.mIsModerator; } - public void releaseVideoCallRrenderers() { - for (ConferenceVideoItemVh vh : mHoldersSet) { + public void releaseVideoCallRrenderer(String participantId, boolean pause, boolean notify) { + Iterator itr = mHolders.iterator(); + while(itr.hasNext()) { + ConferenceVideoItemVh vh = itr.next(); + if (vh.getItem().participantId.contentEquals(participantId)) { + if (pause) { + onViewRecycled((T)vh); + } else { + releaseVideoCallRrenderer(vh, notify); + itr.remove(); + } + break; + } + } + } + + private void releaseVideoCallRrenderer(ConferenceVideoItemVh vh, boolean notify) { + String participantId = null; + if (vh != null) { + participantId = vh.getItem().participantId; vh.onViewRecycled(); vh.releaseVideoCallRrenderers(); } - mHoldersSet.clear(); + if (participantId == null) return; + int pos = 0; + for (ConferenceListItem item : mList) { + if (item.participantId.contentEquals(participantId)) { + mList.remove(participantId); + ConferenceVideoModule.getInstance().participantRemoved(participantId); + if (notify) notifyItemRemoved(pos); + break; + } + pos++; + } + } + + public void releaseVideoCallRrenderer(ConferenceVideoItemVh vh) { + } + public void releaseVideoCallRrenderers() { + Iterator itr = mHolders.iterator(); + while(itr.hasNext()) { + ConferenceVideoItemVh vh = itr.next(); + releaseVideoCallRrenderer(vh, false); + itr.remove(); + } + mHolders.clear(); clear(); } @@ -106,7 +150,7 @@ public class ConferenceVideoAdapter> exten mScreenWidth = mDisplayMetrics.widthPixels; mScreenHeight = (int) (mDisplayMetrics.heightPixels - mDisplayMetrics.densityDpi/mDisplayMetrics.density); } - mHoldersSet.add(viewHolder); + mHolders.add(viewHolder); return (T) viewHolder; } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java index 12cd8ce9d4..6f9d022f1d 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java @@ -203,10 +203,10 @@ public class ConferenceVideoItemVh extends BaseVH { refreshFeedVideo(); } - private void refreshFeedVideo() { + public void refreshFeedVideo() { Timber.d("ConferenceVideoItemVh::refreshFeedVideo(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); if (mVideoFeed != null) { - mVideoFeed.invalidate(); + mVideoFeed.postInvalidate(); mVideoFeed.refreshDrawableState(); } } @@ -228,6 +228,7 @@ public class ConferenceVideoItemVh extends BaseVH { try { mVideoFeed.init(createRootEglBase().getEglBaseContext(), null); mVideoFeed.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT); + mVideoFeed.setWillNotDraw(false); mVideoFeed.setEnableHardwareScaler(true); if (mItem != null && mItem.isMe) { mVideoFeed.setMirror(true); @@ -250,6 +251,7 @@ public class ConferenceVideoItemVh extends BaseVH { mItem.isTrackActive = 1; Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); ConferenceVideoModule.getInstance().setVideoRendererForTrack(mVideoFeed, trackId, mItem.isMe); + refreshFeedVideo(); } } @@ -265,6 +267,7 @@ public class ConferenceVideoItemVh extends BaseVH { Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, mItem.isMe); mItem.isTrackActive = 0; + refreshFeedVideo(); } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java index 3df985a89c..af28f6a56f 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/fragments/conference/ConferenceVideoFragment.java @@ -256,10 +256,10 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV } @Override - public void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId) { + public void onRemoteVideoTrackRemoved(ActiveConferenceCall activeConferenceCall, String trackId, String participantId) { if (getActivity() == null || !isAdded()) return; getActivity().runOnUiThread(() -> { - removeRemoteVideoRenderer(activeConferenceCall, trackId); + removeRemoteVideoRenderer(activeConferenceCall, trackId, participantId); setConferenceState(activeConferenceCall); }); } @@ -277,7 +277,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV public void onLocalVideoCapturerStopped(ActiveConferenceCall activeConferenceCall) { if (getActivity() == null || !isAdded()) return; mHandler.post(() -> { - removeLocalVideoRenderer(activeConferenceCall); + removeLocalVideoRenderer(activeConferenceCall, false); setConferenceState(activeConferenceCall); }); } @@ -297,7 +297,6 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV @Override public void onSpeakerStateChanged(boolean isSpeakerOn) { if (getActivity() == null || !isAdded()) return; -// getActivity().runOnUiThread(() -> updateSpeakerState(isSpeakerOn)); } @Override @@ -363,10 +362,9 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (activeConferenceCall.isVideoEnabled) { if (activeConferenceCall.mData.isOwnStreamActive) { mConferencePresenter.pauseCallVideoCapturer(); - removeLocalVideoRenderer(mConferencePresenter.getActiveConference()); + removeLocalVideoRenderer(mConferencePresenter.getActiveConference(), true); } removeRemoteVideoRenderers(mConferencePresenter.getActiveConference()); - setConferenceState(activeConferenceCall); } } } @@ -493,6 +491,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV private void loadConferenceMembers(ArrayList members) { Timber.d("ConferenceVideoFragment::loadConferenceMembers()"); mConfParticipantsAdapter.setItems(members); + mConfParticipantsAdapter.notifyDataSetChanged(); } private void setRemoteVideoRenderer(ActiveConferenceCall activeConferenceCall) { @@ -506,7 +505,7 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV mConferencePresenter.loadConferenceParticipants(activeConferenceCall); } - private void removeRemoteVideoRenderer(ActiveConferenceCall activeConferenceCall, String trackId) { + private void removeRemoteVideoRenderer(ActiveConferenceCall activeConferenceCall, String trackId, String participantId) { if (activeConferenceCall == null) return; if (activeConferenceCall.mConference == null) return; if (!activeConferenceCall.mConference.isConference()) return; @@ -515,25 +514,22 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV if (StringUtils.isNotEmpty(trackId)) { Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderer()"); - ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, false); + if (StringUtils.isNotEmpty(participantId)) { + mConfParticipantsAdapter.releaseVideoCallRrenderer(participantId, false, true); + } } - mConfParticipantsAdapter.notifyDataSetChanged(); } private void removeRemoteVideoRenderers(ActiveConferenceCall activeConferenceCall) { if (activeConferenceCall == null) return; Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers()"); - ArrayList members = mConferencePresenter.getConferenceVideoMembers(activeConferenceCall); List list = mConfParticipantsAdapter.getItems(); - Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): members size=%d", members.size()); Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): list size=%d", list.size()); for (ConferenceListItem item : list) { //members) { String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(item.participantId); - if (StringUtils.isNotEmpty(trackId) || item.isMe) { - Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): participantID=%s", item.participantId); - ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, item.isMe); - } + Timber.d("ConferenceVideoFragment::removeRemoteVideoRenderers(): participantID=%s", item.participantId); + mConfParticipantsAdapter.releaseVideoCallRrenderer(item.participantId, true, true); } } @@ -546,14 +542,20 @@ public class ConferenceVideoFragment extends BaseFragment implements ConferenceV mConferencePresenter.loadConferenceParticipants(activeConferenceCall); } - private void removeLocalVideoRenderer(ActiveConferenceCall activeConferenceCall) { + private void removeLocalVideoRenderer(ActiveConferenceCall activeConferenceCall, boolean pause) { if (activeConferenceCall == null) return; if (activeConferenceCall.mConference == null) return; if (!activeConferenceCall.mConference.isRunning()) return; if (!activeConferenceCall.isVideoEnabled) return; Timber.d("ConferenceVideoFragment::removeLocalVideoRenderer()"); - - mConferencePresenter.loadConferenceParticipants(activeConferenceCall); + List list = mConfParticipantsAdapter.getItems(); + for (ConferenceListItem item : list) { + if (item.participantId.contentEquals(activeConferenceCall.mConference.participantId()) && + item.isMe) { + Timber.d("ConferenceVideoFragment::removeLocalVideoRenderer(): participantID=%s", item.participantId); + mConfParticipantsAdapter.releaseVideoCallRrenderer(item.participantId, pause,true); + } + } } private void setConferenceState(ActiveConferenceCall activeConferenceCall) { diff --git a/app/src/main/res/layout/li_conference_video.xml b/app/src/main/res/layout/li_conference_video.xml index a936623203..e3efcbbe91 100644 --- a/app/src/main/res/layout/li_conference_video.xml +++ b/app/src/main/res/layout/li_conference_video.xml @@ -24,22 +24,12 @@ android:layout_gravity="center" android:padding="2dp"> - - - - - + -- GitLab From 89303349cdff6d9317933e9c9e5f5c65759a6593 Mon Sep 17 00:00:00 2001 From: Angel Terziev Date: Mon, 11 May 2020 12:37:21 +0300 Subject: [PATCH 12/24] linked with NynjaSDK 1.21.1 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1f60baf084..178540588a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -682,8 +682,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Conference, Calls mobile SDK - implementation 'com.nynja.sdk:NynjaSdk:1.21@aar' - //implementation(name: 'NynjaSdk-1.21', ext: 'aar') + implementation 'com.nynja.sdk:NynjaSdk:1.21.1@aar' + //implementation(name: 'NynjaSdk-1.21.1', ext: 'aar') //ExoPlayer implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6' -- GitLab From 3aa9a849ea4a15c8bfeb14a2c3acb72a1eb29f7b Mon Sep 17 00:00:00 2001 From: Angel Terziev Date: Mon, 11 May 2020 12:54:00 +0300 Subject: [PATCH 13/24] NynjaSDK-1.21.2 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 178540588a..b9f41feab5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -682,8 +682,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Conference, Calls mobile SDK - implementation 'com.nynja.sdk:NynjaSdk:1.21.1@aar' - //implementation(name: 'NynjaSdk-1.21.1', ext: 'aar') + implementation 'com.nynja.sdk:NynjaSdk:1.21.2@aar' + //implementation(name: 'NynjaSdk-1.21.2', ext: 'aar') //ExoPlayer implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6' -- GitLab From 4e231e88380fe1c28b3d14fc4bb9e0570157b2f9 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Mon, 11 May 2020 21:20:10 +0300 Subject: [PATCH 14/24] -fix for feeds flikering --- .../data/sdk/calls/ConferenceListItem.java | 2 - .../conference/ConferenceVideoAdapter.java | 1 + .../conference/ConferenceVideoItemVh.java | 66 +++++++++++-------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java index 518fd344c7..7b3b85da4e 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceListItem.java @@ -135,12 +135,10 @@ public class ConferenceListItem extends Object { this.hasScreen = participant.hasScreen; this.isVideoPaused = participant.isVideoPaused; this.isScreenPaused = participant.isScreenPaused; -// this.isTrackActive = 0; // this.isMe = participant.isMe; this.isFriend = participant.isFriend; this.isMuted = participant.isMuted; this.isSpeaking = participant.isSpeaking; - this.isVideoFullScreen = false; } private void setActions(ArrayList itemActions) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java index 1531324f8c..f078dee5d9 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/conference/ConferenceVideoAdapter.java @@ -141,6 +141,7 @@ public class ConferenceVideoAdapter> exten @NonNull @Override public T onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { + Timber.d("ConferenceVideoAdapter::onBindViewHolder():"); ConferenceVideoItemVh viewHolder = new ConferenceVideoItemVh(viewGroup, mIsModerator); viewHolder.setOnClickListener(mOnConferenceVideoFeedClickListener); if (viewGroup.getContext() instanceof CallActivity) { diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java index 6f9d022f1d..bea30e0db3 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java @@ -40,6 +40,7 @@ public class ConferenceVideoItemVh extends BaseVH { private OnConferenceVideoFeedClickListener mListener; private boolean mIsModerator; private boolean mIsRenderersInitialized = false; + private String mTrackId = ""; public ConferenceVideoItemVh(ViewGroup parent, boolean isModerator) { super(parent, R.layout.li_conference_video); @@ -51,20 +52,20 @@ public class ConferenceVideoItemVh extends BaseVH { } - @Override public void bind() { - //mUnbinder = ButterKnife.bind(this, itemView); - } - - @Override public void bind(ConferenceListItem item, int position) { - Timber.d("ConferenceVideoItemVh::bind(): item participant ID=%s, position=%d", item.participantId, position); - mPosition = position; - if (mUnbinder != null) { - //mUnbinder.unbind(); - } else { - mUnbinder = ButterKnife.bind(this, itemView); - } - setData(item); - } +// @Override public void bind() { +// //mUnbinder = ButterKnife.bind(this, itemView); +// } +// +// @Override public void bind(ConferenceListItem item, int position) { +// Timber.d("ConferenceVideoItemVh::bind(): item participant ID=%s, position=%d", item.participantId, position); +// mPosition = position; +// if (mUnbinder != null) { +// //mUnbinder.unbind(); +// } else { +// mUnbinder = ButterKnife.bind(this, itemView); +// } +// setData(item); +// } public SurfaceViewRenderer getVideoFeed() { return mVideoFeed; @@ -75,6 +76,10 @@ public class ConferenceVideoItemVh extends BaseVH { } @Override public void setData(ConferenceListItem item) { + if (!item.equals(this.mItem) && this.mItem != null) { + enableVideoForTrack(false); + removeVideoRendererForTrack(); + } this.mItem = item; mSS.setAutoToggle(false); mActiveVideo.setAutoToggle(false); @@ -87,6 +92,7 @@ public class ConferenceVideoItemVh extends BaseVH { itemView.setOnLongClickListener(v -> mListener.onItemLongClick(item, mPosition)); } itemView.setTag(this); + mTrackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(mItem.participantId); if (item.type == ConferenceListItem.ConferenceItemType.Plus) { // mPhoto.setImageResource(R.drawable.v_add_member_voice_call); } else { @@ -123,8 +129,8 @@ public class ConferenceVideoItemVh extends BaseVH { @Synchronized public void releaseVideoCallRrenderers() { Timber.d("ConferenceVideoItemVh::releaseVideoCallRrenderers(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); - removeVideoRendererForTrack(); if (!mIsRenderersInitialized) return; + removeVideoRenderer(); if (mVideoFeed != null) { mVideoFeed.release(); } @@ -145,7 +151,7 @@ public class ConferenceVideoItemVh extends BaseVH { drawIsMutedIfNeeded(item); drawIsScfreenSharingIfNeeded(item); // drawIsActiveVideoIfNeeded(item); - drawIsFeedVideoIfNeeded(item.hasVideo); +// drawIsFeedVideoIfNeeded(item.hasVideo); if (mItem != null) { if (mItem != null && mItem.isMe) { mName.setText(R.string.call_me); @@ -244,13 +250,12 @@ public class ConferenceVideoItemVh extends BaseVH { Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); if (!mIsRenderersInitialized) return; if (mItem == null) return; - if (mItem.isTrackActive == 1) return; - String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(mItem.participantId); - Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, trackId); - if (StringUtils.isNotEmpty(trackId) || mItem.isMe) { + //if (mItem.isTrackActive == 1) return; + Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, mTrackId); + if (StringUtils.isNotEmpty(mTrackId) || mItem.isMe) { mItem.isTrackActive = 1; Timber.d("setVideoRendererForTrack::setVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); - ConferenceVideoModule.getInstance().setVideoRendererForTrack(mVideoFeed, trackId, mItem.isMe); + ConferenceVideoModule.getInstance().setVideoRendererForTrack(mVideoFeed, mTrackId, mItem.isMe); refreshFeedVideo(); } } @@ -261,14 +266,8 @@ public class ConferenceVideoItemVh extends BaseVH { if (!mIsRenderersInitialized) return; if (mItem == null) return; if (mItem.isTrackActive == 0) return; - String trackId = ConferenceVideoModule.getInstance().getTrackIdByParticipantId(mItem.participantId); - Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, trackId); - if (StringUtils.isNotEmpty(trackId) || mItem.isMe) { - Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); - ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, trackId, mItem.isMe); - mItem.isTrackActive = 0; - refreshFeedVideo(); - } + Timber.d("setVideoRendererForTrack::removeVideoRendererForTrack(): item participant ID=%s; trackId=%s", mItem.participantId, mTrackId); + removeVideoRenderer(); } @Synchronized @@ -282,4 +281,13 @@ public class ConferenceVideoItemVh extends BaseVH { refreshFeedVideo(); } } + + private void removeVideoRenderer() { + if (StringUtils.isNotEmpty(mTrackId) || mItem.isMe) { + Timber.d("setVideoRendererForTrack::removeVideoRenderer(): item participant ID=%s; isMe=%s", mItem.participantId, mItem.isMe? "true":"false"); + ConferenceVideoModule.getInstance().setVideoRendererForTrack(null, mTrackId, mItem.isMe); + mItem.isTrackActive = 0; + refreshFeedVideo(); + } + } } -- GitLab From fe6a7e435e766035ec376cfd76d334383c6443b0 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Mon, 11 May 2020 22:30:39 +0300 Subject: [PATCH 15/24] -fixed camera switch button visibilityon the video feeds --- .../conference/ConferenceVideoItemVh.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java index bea30e0db3..cd14239e36 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/adapters/viewholders/conference/ConferenceVideoItemVh.java @@ -79,6 +79,7 @@ public class ConferenceVideoItemVh extends BaseVH { if (!item.equals(this.mItem) && this.mItem != null) { enableVideoForTrack(false); removeVideoRendererForTrack(); + hideSwithCamera(); } this.mItem = item; mSS.setAutoToggle(false); @@ -96,14 +97,9 @@ public class ConferenceVideoItemVh extends BaseVH { if (item.type == ConferenceListItem.ConferenceItemType.Plus) { // mPhoto.setImageResource(R.drawable.v_add_member_voice_call); } else { - // item.type == ConferenceListItem.ConferenceItemType.Participant - if (item.memberId == null || item.memberId.isEmpty()) { -// mPhoto.setImageResource(R.drawable.participant_placeholder_grey); - } else { - // in Conference - setupInConference(item); - onViewAttachedToWindow(); - } + // in Conference + setupInConference(item); + onViewAttachedToWindow(); } Timber.d("ConferenceVideoItemVh::setData(): item participant name=%s; ID=%s", item.name, item.participantId); } @@ -117,7 +113,6 @@ public class ConferenceVideoItemVh extends BaseVH { public void onViewDetachedFromWindow() { enableVideoForTrack(false); - //removeVideoRendererForTrack(); Timber.d("ConferenceVideoItemVh::onViewDetachedFromWindow(): item participant name=%s; ID=%s", mItem.name, mItem.participantId); } @@ -145,7 +140,7 @@ public class ConferenceVideoItemVh extends BaseVH { if (item.participantId == null || !item.isActive) { // in Conference - but not joined yet mMutedIndicator.setVisibility(View.GONE); -// mPhoto.setImageResource(R.drawable.participant_placeholder_grey); + hideSwithCamera(); } else { // already joined in Conference drawIsMutedIfNeeded(item); @@ -163,21 +158,28 @@ public class ConferenceVideoItemVh extends BaseVH { } } else if (mItem != null && mItem.isSpeaking) { mFeedFrameLayout.setBackgroundResource(R.drawable.video_feed_square_stroke_green); + hideSwithCamera(); } else { mFeedFrameLayout.setBackgroundColor(Color.TRANSPARENT); + hideSwithCamera(); } } else { mFeedFrameLayout.setBackgroundColor(Color.TRANSPARENT); + hideSwithCamera(); } } } + private void hideSwithCamera() { + mSwithCamera.setOnClickListener(null); + mSwithCamera.setVisibility(View.GONE); + } + private void drawIsMutedIfNeeded(ConferenceListItem item) { if(item.isMuted) { mMutedIndicator.setVisibility(View.VISIBLE); } else { mMutedIndicator.setVisibility(View.GONE); -// ImageUtils.loadAvatarImage(item.avatar, mPhoto); } } -- GitLab From 49c55f1be6a62469c194e2156418b23849690467 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Wed, 13 May 2020 10:41:07 +0300 Subject: [PATCH 16/24] NY-10117: [AN]: Only ringing without ringing screen -added ore logs for incomming calls tracking --- .../data/FireBaseMessagingService.java | 18 +-- .../data/sdk/calls/ConferenceSDKModule.java | 10 +- .../utils/NotificationHelper.java | 113 ++++++++++++++---- 3 files changed, 106 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java index 48a6b942d1..a44a52deda 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java @@ -260,29 +260,29 @@ public class FireBaseMessagingService extends FirebaseMessagingService { public void sendCallPush(Context context, boolean isMainActivityIsActive, boolean hasActiveCall ) { Timber.i("Push.CALLING: sendCallPush() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX"); + Timber.i("Push.CALLING: sendCallPush(): check XX1"); String from = mDataManager.getConferenceSDK().getActiveConference().getCallerName(); String callId = mDataManager.getConferenceSDK().getActiveConference().mConference.callId(); - boolean isInBackground = mDataManager.isInBackground(); Notification notification = mNotificationHelper.createCallPushNotification(context, from, callId, - isInBackground, //isMainActivityIsActive, + isMainActivityIsActive, mDataManager.getSettingNotifications()); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXXX" + + Timber.i("Push.CALLING: sendCallPush(): check XX2" + "; hasActiveCall=" + (hasActiveCall?"true": "false")); - if (notification != null && !hasActiveCall && !isMainActivityIsActive - && context instanceof FireBaseMessagingService) { - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXXXX"); + if (notification != null && !hasActiveCall && context instanceof FireBaseMessagingService) { + Timber.i("Push.CALLING: sendCallPush(): check XX3"); ((FireBaseMessagingService)context).startForeground(ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID, notification); } } private synchronized void handleCallPush(byte[] decoded, boolean isMainActivityIsActive) { + Timber.i("Push.CALLING: handleCallPush() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); boolean hasActiveCall = mDataManager.getConferenceSDK().hasCreatedActiveCall(); boolean startActivity = !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q); boolean result = mDataManager.handleConferencePushNotification(decoded, isMainActivityIsActive, startActivity); boolean isCallRinging = mDataManager.getConferenceSDK().isCallRinging(); - Timber.i("Push.CALLING: handleConferencePushNotification()=" + (result?"true": "false") + "; isCallRinging="+ - (isCallRinging?"true": "false") + "; startActivity=" + (startActivity?"true": "false")); + Timber.i("Push.CALLING: handleCallPush()=" + (result?"true": "false") + "; isCallRinging="+ + (isCallRinging?"true": "false") + "; startActivity=" + (startActivity?"true": "false") + + "; hasActiveCall=" + (hasActiveCall?"true": "false")); if (result && !startActivity && isCallRinging && !hasActiveCall) { sendCallPush(this, isMainActivityIsActive, hasActiveCall); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 911f83e288..2ff3079665 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -475,6 +475,7 @@ public class ConferenceSDKModule extends BaseSDKModule { if (iConference != null) { if (iConference.isRinging()) { if (result) { + Timber.i("ConferenceSDKModule::handlePushNotification(): check 1 "); createIncomingConference(iConference, false); mActiveConference.isRinging = true; } @@ -2780,8 +2781,11 @@ public class ConferenceSDKModule extends BaseSDKModule { public boolean startIncommingConferenceActivity(boolean delayed, String callId, String screenKey) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && callId != null) { + Timber.d("startIncommingConferenceActivity with \'ConferenceId\'=\'" + callId + + "; delayed=" + (delayed?"true": "false")); + final String name = mActiveConference.getCallerName(); new Handler(Looper.getMainLooper()).post(() -> { - mNotificationHelper.createCallPushNotification(getContext(), mActiveConference.getCallerName(), callId, true, + mNotificationHelper.createCallPushNotification(getContext(), name, callId, true, mSettingNotifications); }); return true; @@ -2916,6 +2920,8 @@ public class ConferenceSDKModule extends BaseSDKModule { if (!hasCreatedActiveCall()) return false; mActiveConference.mData.isOwnStreamActive = false; initConferenceCall(startActivity); + Timber.d("createIncomingCallAndStartRinging with \'ConferenceId\'=\'" + callId + + "; startActivity=" + (startActivity?"true": "false")); if (startActivity) { if (Consts.SHOW_INCOMING_CALLS_AS_POPUP_NOTIFICATIONS) { new Handler(Looper.getMainLooper()).post(() -> { @@ -2932,6 +2938,8 @@ public class ConferenceSDKModule extends BaseSDKModule { private synchronized boolean createIncomingConference(NYNCall iConference, boolean startActivity) { if (iConference == null) return false; if (iConference.isOutgoing()) return false; + Timber.d("createIncomingConference with \'ConferenceId\'=\'" + iConference.callId() + + "; startActivity=" + (startActivity?"true": "false")); boolean isCallAccess = mSettingNotifications.isCallNotifications() || mStateDevice.isDeviceActive(); if (!hasCreatedActiveCall() && iConference != null && isCallAccess) { return createIncomingCallAndStartRinging(iConference, false, startActivity); diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java index 47aa822853..f4a507b546 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java @@ -18,6 +18,7 @@ import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationManagerCompat; import com.nynja.mobile.communicator.R; import com.nynja.mobile.communicator.data.DescManager; @@ -195,37 +196,34 @@ public class NotificationHelper extends ContextWrapper { return mManager; } - public Notification createCallPushNotification(String from, + public Notification createCallPushNotification(Context context, + String from, Intent intent, PendingIntent answerPendingIntent, PendingIntent rejectPendingIntent, boolean isMainActivityIsActive, SettingNotifications settingNotifications) { Uri notificationSoundUri = getNotificationSoundUri(settingNotifications.getDefaultNotificationSound()); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX1"); - - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX2"); + Timber.i("Push.CALLING: createCallPushNotification(): check XXX1"); + Notification notification = buildCallNotification(intent, answerPendingIntent, rejectPendingIntent, + settingNotifications, from, isMainActivityIsActive, notificationSoundUri); if (isMainActivityIsActive) { - Notification notification = buildCallNotification(intent, answerPendingIntent, rejectPendingIntent, - settingNotifications, from, isMainActivityIsActive, notificationSoundUri); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX3"); + Timber.i("Push.CALLING: createCallPushNotification(): check XXX2"); // clearCallPush(ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); -// Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX4"); - sendRingingNotify(notification, ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID, +// Timber.i("Push.CALLING: createCallPushNotification(): check XXX3"); + sendRingingNotify(context, notification, ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID, settingNotifications); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX5"); + Timber.i("Push.CALLING: createCallPushNotification(): check XXX4"); return null; } - return buildCallNotification(intent, answerPendingIntent, rejectPendingIntent, - settingNotifications, from, isMainActivityIsActive, notificationSoundUri); + return notification; } public synchronized Notification createCallPushNotification(Context context, String from, String callId, boolean isMainActivityIsActive, SettingNotifications settingNotifications) { - Timber.i("Push.CALLING: sendCallPush() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX"); + Timber.i("Push.CALLING: createCallPushNotification() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); Intent fullScreenIntent = MainActivity.getLaunchIntent(context, false, true); fullScreenIntent.putExtra(MainActivity.INTENT_FROM_CALL_NOTIFICATION, true); fullScreenIntent.putExtra(MainActivity.INTENT_NOTIFICATION_CALL_ID, callId); @@ -248,7 +246,8 @@ public class NotificationHelper extends ContextWrapper { context, 1, rejectIntent, PendingIntent.FLAG_UPDATE_CURRENT); - return createCallPushNotification(from, + return createCallPushNotification(context, + from, fullScreenIntent, answerPendingIntent, rejectPendingIntent, @@ -447,6 +446,7 @@ public class NotificationHelper extends ContextWrapper { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); + notificationBuilder.setPriority(NotificationManager.IMPORTANCE_HIGH); } else { notificationBuilder.setContentIntent(fullScreenPendingIntent); } @@ -497,22 +497,39 @@ public class NotificationHelper extends ContextWrapper { } } - public void sendRingingNotify(Notification notification, + public void sendRingingNotify(Context context, + Notification notification, int id, SettingNotifications settingNotifications) { - NotificationManager notificationManager = getManager(); - if (notificationManager != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + boolean playSound = false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + Timber.i("Push.CALLING: sendRingingNotify(): check 1"); + NotificationManager notificationManager = getManager(); + if (notificationManager != null) { + boolean isSoundEnabled = settingNotifications.isIncomingSoundInMutedChat(); + mNynjaSoundManager.updateShouldPlayRingingSound(isSoundEnabled, + settingNotifications.isInAppVibrate(), false); + Timber.i("Push.CALLING: sendRingingNotify(): mNynjaSoundManager.canPlayRingingSound="+(mNynjaSoundManager.canPlayRingingSound()? "true":"false")); + playSound = (areNotificationsEnabled(context, notificationManager, handleChannelIdToLatestOne(Push.CONFERENCE)) + // && settingNotifications.isSound() + && mNynjaSoundManager.canPlayRingingSound() + ); notificationManager.notify(getString(R.string.app_name), id, notification); - } else { - notificationManager.notify(id, notification); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX7"); - mNynjaSoundManager.playCallRinging(settingNotifications.getRingerSound(), false); - Timber.i("Push.CALLING: handleConferencePushNotification(): handleCallPush XXX8"); + } else { + Timber.i("Push.CALLING: sendRingingNotify(): check 2"); + NotificationManager notificationManager = getManager(); + if (notificationManager != null) { + playSound = (areNotificationsEnabled(context, notificationManager, handleChannelIdToLatestOne(Push.CONFERENCE))); + notificationManager.notify(id, notification); } } + Timber.i("Push.CALLING: sendRingingNotify(): playSound="+(playSound? "true":"false")); + if (playSound) { + Timber.i("Push.CALLING: sendRingingNotify(): check XXXX1"); + mNynjaSoundManager.playCallRinging(settingNotifications.getRingerSound(), false); + Timber.i("Push.CALLING: sendRingingNotify(): check XXXX2"); + } } public void clearPushMessageForChat(int notificationId) { @@ -603,4 +620,50 @@ public class NotificationHelper extends ContextWrapper { return Uri.parse(path); } + + private Uri getCallNotificationSoundUri(Context context, String soundName) { + soundName = soundName == null ? "" : soundName; + if (Consts.NOTIFICATION_SOUND_NO_SOUND.equalsIgnoreCase(soundName)) { + return null; + } + + String basePath = context.getResources().getAssets().toString() + "/"; + if (soundName.isEmpty()) { + soundName = Consts.NotificationSounds.NYNJA.getDisplayName(); + } + String path = basePath + soundName; + if (path == null) { + path = basePath + R.raw.nynja; + } + + return Uri.parse(path); + } + + public boolean areNotificationsEnabled(Context context, NotificationManager manager, String channelId) { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 1"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (!manager.areNotificationsEnabled()) { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 2"); + return false; + } + if(StringUtils.isNotEmpty(channelId)) { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 3"); + NotificationChannel channel = manager.getNotificationChannel(channelId); + if (channel != null) { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 4"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 5"); + return channel.getImportance() == NotificationManager.IMPORTANCE_HIGH; + } else { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 6"); + return channel.getImportance() != NotificationManager.IMPORTANCE_NONE; + } + } + } + return false; + } else { + Timber.i("Push.CALLING: areNotificationsEnabled(): check 7"); + return NotificationManagerCompat.from(context).areNotificationsEnabled(); + } + } } -- GitLab From cf9fac253ec68d9e86be9d39c663fd69b2d86d30 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Thu, 14 May 2020 02:19:28 +0300 Subject: [PATCH 17/24] -additional fixes for NY-10117 issue --- .../communicator/data/FireBaseMessagingService.java | 10 ++++++---- .../data/sdk/calls/ConferenceSDKModule.java | 4 ++-- .../communicator/utils/NotificationHelper.java | 12 +++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java index a44a52deda..03626d70d2 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/FireBaseMessagingService.java @@ -107,7 +107,7 @@ public class FireBaseMessagingService extends FirebaseMessagingService { if(model == null) break; Timber.i(model.toString()); if (mDataManager.getSettingNotifications().isCallNotifications()) { - boolean isMainActivityIsActive = !mDataManager.isInBackground();//isMainActivityIsActive(); + boolean isMainActivityIsActive = mDataManager.isMainActivityIsActive();//!mDataManager.isInBackground();// if (!isMainActivityIsActive) { mDataManager.reconnectConference(); } @@ -263,9 +263,11 @@ public class FireBaseMessagingService extends FirebaseMessagingService { Timber.i("Push.CALLING: sendCallPush(): check XX1"); String from = mDataManager.getConferenceSDK().getActiveConference().getCallerName(); String callId = mDataManager.getConferenceSDK().getActiveConference().mConference.callId(); + boolean isInBackground = mDataManager.isInBackground(); Notification notification = mNotificationHelper.createCallPushNotification(context, from, callId, - isMainActivityIsActive, - mDataManager.getSettingNotifications()); + isMainActivityIsActive || isInBackground, + mDataManager.getSettingNotifications(), + true); Timber.i("Push.CALLING: sendCallPush(): check XX2" + "; hasActiveCall=" + (hasActiveCall?"true": "false")); if (notification != null && !hasActiveCall && context instanceof FireBaseMessagingService) { @@ -283,7 +285,7 @@ public class FireBaseMessagingService extends FirebaseMessagingService { Timber.i("Push.CALLING: handleCallPush()=" + (result?"true": "false") + "; isCallRinging="+ (isCallRinging?"true": "false") + "; startActivity=" + (startActivity?"true": "false") + "; hasActiveCall=" + (hasActiveCall?"true": "false")); - if (result && !startActivity && isCallRinging && !hasActiveCall) { + if (result && !startActivity && isCallRinging && !hasActiveCall){ sendCallPush(this, isMainActivityIsActive, hasActiveCall); } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 2ff3079665..52b29ced9e 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -2786,7 +2786,7 @@ public class ConferenceSDKModule extends BaseSDKModule { final String name = mActiveConference.getCallerName(); new Handler(Looper.getMainLooper()).post(() -> { mNotificationHelper.createCallPushNotification(getContext(), name, callId, true, - mSettingNotifications); + mSettingNotifications, false); }); return true; } else if (!mStateDevice.isDeviceActive()) { @@ -2926,7 +2926,7 @@ public class ConferenceSDKModule extends BaseSDKModule { if (Consts.SHOW_INCOMING_CALLS_AS_POPUP_NOTIFICATIONS) { new Handler(Looper.getMainLooper()).post(() -> { mNotificationHelper.createCallPushNotification(getContext(), mActiveConference.getCallerName(), callId, true, - mSettingNotifications); + mSettingNotifications, false); }); } else if (!startIncommingConferenceActivity(delayed, callId, null)) { startIncommingActivity(delayed, NynjaNavigator.MAIN_NEW_CALL); diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java index f4a507b546..2d7f33a946 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java @@ -222,8 +222,9 @@ public class NotificationHelper extends ContextWrapper { public synchronized Notification createCallPushNotification(Context context, String from, String callId, boolean isMainActivityIsActive, - SettingNotifications settingNotifications) { - Timber.i("Push.CALLING: createCallPushNotification() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); + SettingNotifications settingNotifications, + boolean isPush) { + Timber.i((isPush?"Push.CALLING": "Grpc.CALLING")+"Push.CALLING: createCallPushNotification() isMainActivityIsActive=" + (isMainActivityIsActive?"true": "false")); Intent fullScreenIntent = MainActivity.getLaunchIntent(context, false, true); fullScreenIntent.putExtra(MainActivity.INTENT_FROM_CALL_NOTIFICATION, true); fullScreenIntent.putExtra(MainActivity.INTENT_NOTIFICATION_CALL_ID, callId); @@ -414,7 +415,7 @@ public class NotificationHelper extends ContextWrapper { int iconRes = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) ? R.mipmap.ic_launcher : R.drawable.ic_notification; PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(this, 0, - fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_CANCEL_CURRENT); + fullScreenIntent, 0);// | PendingIntent.FLAG_CANCEL_CURRENT); String contentText = getString(R.string.call_notification_incoming_from, from); Bundle args = new Bundle(); args.putInt(MainActivity.INTENT_CALL_NOTIFICATION_ID, ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); @@ -446,14 +447,15 @@ public class NotificationHelper extends ContextWrapper { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { notificationBuilder.setFullScreenIntent(fullScreenPendingIntent, true); - notificationBuilder.setPriority(NotificationManager.IMPORTANCE_HIGH); + notificationBuilder.setPriority(NotificationManager.IMPORTANCE_MAX); + //notificationBuilder.setPriority(NotificationManager.IMPORTANCE_HIGH); } else { notificationBuilder.setContentIntent(fullScreenPendingIntent); } Notification notification = notificationBuilder.build(); - if (!(isMainActivityIsActive && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)) { + if (!(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)) { if (settingNotifications.isSound() && mNynjaSoundManager.canPlayRingingSound()) { notification.sound = notificationSoundUri; notification.flags |= (Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR); -- GitLab From 670e4278b55c35555f5f0a503901e5ef16a1f8a9 Mon Sep 17 00:00:00 2001 From: Angel Terziev Date: Thu, 14 May 2020 18:19:01 +0300 Subject: [PATCH 18/24] NynjaSDK-1.21.3 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b9f41feab5..99432f9ccc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -682,7 +682,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Conference, Calls mobile SDK - implementation 'com.nynja.sdk:NynjaSdk:1.21.2@aar' + implementation 'com.nynja.sdk:NynjaSdk:1.21.3@aar' //implementation(name: 'NynjaSdk-1.21.2', ext: 'aar') //ExoPlayer -- GitLab From 7766633ef6a57a7dc3245f26c21f86863234e7c2 Mon Sep 17 00:00:00 2001 From: Angel Terziev Date: Thu, 14 May 2020 19:38:23 +0300 Subject: [PATCH 19/24] NynjaSDK 1.21.4 --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b9f41feab5..6a8ef336b9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -682,7 +682,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Conference, Calls mobile SDK - implementation 'com.nynja.sdk:NynjaSdk:1.21.2@aar' + implementation 'com.nynja.sdk:NynjaSdk:1.21.4@aar' //implementation(name: 'NynjaSdk-1.21.2', ext: 'aar') //ExoPlayer -- GitLab From 4cd4273392b58f79384576825e1a7e3fdc2797bd Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Thu, 14 May 2020 22:03:20 +0300 Subject: [PATCH 20/24] NY-9545: [AN]: Cannot reconnect to bluetooth after rejected PSTN call --- .../data/sdk/calls/ConferenceSDKModule.java | 49 ++++++++++++------- .../presenters/CallTapToSpeakPresenter.java | 4 -- .../presenters/ConferenceCallPresenter.java | 4 -- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 2ff3079665..f435c04a32 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -144,6 +144,7 @@ public class ConferenceSDKModule extends BaseSDKModule { private HashMap mConferenceWaitingRoomLNames = new HashMap<>(); private HashMap mMyAcceptedElsewhereCalls = new HashMap<>(); + private int mLastPhoneCallState = TelephonyManager.CALL_STATE_IDLE; private enum States { Connecting, Connected, Disconnecting, Disconnected @@ -571,6 +572,10 @@ public class ConferenceSDKModule extends BaseSDKModule { } public void setSpeakerState(boolean on, boolean forced) { + setSpeakerState(on, forced, true); + } + + public void setSpeakerState(boolean on, boolean forced, boolean event) { if (mConferenceAudioManager == null) { mConferenceAudioManager = AppRTCAudioManager.create(getContext()); } @@ -587,38 +592,37 @@ public class ConferenceSDKModule extends BaseSDKModule { } + if (!event) return; for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) { conferenceSDKListener.onSpeakerStateChanged(on); } } public void setAudioRoute(ActiveCallBase.AudioRouteType routeType) { - AudioManager audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); - if (audioManager == null) { - return; - } + setAudioRoute(routeType, true); + } - boolean isSpeakerOn = false; + public void setAudioRoute(ActiveCallBase.AudioRouteType routeType, boolean updateWith) { + if (mConferenceAudioManager == null) { + mConferenceAudioManager = AppRTCAudioManager.create(getContext()); + } switch (routeType) { case SPEAKER: - isSpeakerOn = true; - audioManager.setSpeakerphoneOn(true); - audioManager.setBluetoothScoOn(false); + setSpeakerState(true, true, false); + mConferenceAudioManager.selectAudioDevice(AppRTCAudioManager.AudioDevice.SPEAKER_PHONE); break; case EARPIECE: - audioManager.setBluetoothScoOn(false); - audioManager.setSpeakerphoneOn(false); + setSpeakerState(false, true, false); + mConferenceAudioManager.selectAudioDevice(AppRTCAudioManager.AudioDevice.EARPIECE); break; case BLUETOOTH: - audioManager.setBluetoothScoOn(true); - audioManager.setSpeakerphoneOn(false); + mConferenceAudioManager.selectAudioDevice(AppRTCAudioManager.AudioDevice.BLUETOOTH); break; } - if (hasCreatedActiveCall()) { + if (updateWith && hasCreatedActiveCall()) { mActiveConference.mAudioRouteType = routeType; - mActiveConference.isSpeakerOn = isSpeakerOn; } for (ConferenceSDKListener conferenceSDKListener : mConferenceSDKListener) @@ -3492,12 +3496,23 @@ public class ConferenceSDKModule extends BaseSDKModule { Timber.d("ConferenceModule::onReceive(): Telephony service event"); String action = intent.getAction(); if (action != null && action.equals(PHONE_STATE)) { + TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE); if (isConferenceActive()) { - TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE); - if (tm != null && tm.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) { - endActiveCall(); + if (tm != null) { + if (tm.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) { + endActiveCall(); + } else if (tm.getCallState() == TelephonyManager.CALL_STATE_RINGING) { + setAudioRoute(ActiveCallBase.AudioRouteType.EARPIECE, false); + //setSpeakerState(false, true, true); + } else if (mLastPhoneCallState == TelephonyManager.CALL_STATE_RINGING + && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) { + setAudioRoute(mActiveConference.mAudioRouteType, true); + } } } + if (tm != null) { + mLastPhoneCallState = tm.getCallState();//TelephonyManager.CALL_STATE_IDLE; + } } } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallTapToSpeakPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallTapToSpeakPresenter.java index 66989287c7..0cd79c84cc 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallTapToSpeakPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/CallTapToSpeakPresenter.java @@ -80,8 +80,4 @@ public class CallTapToSpeakPresenter extends ConferenceSDKPresenter } - public void bluetoothDisconnected() { - mDataManager.getConferenceSDK().setSpeakerState(getActiveConference().isSpeakerOn); - } - public void switchCamera() { if (getAttachedViews().size() == 0) return; ActiveConferenceCall activeConferenceCall = mDataManager.getConferenceSDK(). -- GitLab From c9a6353a2ea63817308f7e17cf05ee71c11a6507 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 15 May 2020 14:31:08 +0300 Subject: [PATCH 21/24] -fixed incoming calls when the app is killed for android < 10; NY-10385: [AN]: Nynja application is opened unexpectedly in front of screen when user is using other application. --- .../data/sdk/calls/ConferenceSDKModule.java | 39 +++++-------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index 4e6041437f..f88f25458e 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -469,40 +469,19 @@ public class ConferenceSDKModule extends BaseSDKModule { boolean isLoggedIn, boolean startActivity) { Timber.i("ConferenceSDKModule::handlePushNotification(): " + payload); if (isLoggedIn) { - boolean handled = false; - if (!startActivity) { - boolean result = (!hasCreatedActiveCall()); - NYNCall iConference = mCallManager.handleCallNotification(payload); - if (iConference != null) { - if (iConference.isRinging()) { - if (result) { - Timber.i("ConferenceSDKModule::handlePushNotification(): check 1 "); - createIncomingConference(iConference, false); - mActiveConference.isRinging = true; - } - return true; + boolean result = (!hasCreatedActiveCall()); + NYNCall iConference = mCallManager.handleCallNotification(payload); + if (iConference != null) { + if (iConference.isRinging()) { + if (result) { + Timber.i("ConferenceSDKModule::handlePushNotification(): check 1 "); + createIncomingConference(iConference, startActivity); + mActiveConference.isRinging = true; } - } - return false; - } - if (!isMainActivityIsActive || !hasCreatedActiveCall()) { - handled = mCallManager.handleNotification(payload); - } - if (handled) { - Timber.i("ConferenceSDKModule::handlePushNotification(): will try to catch it - core handling: " + payload); - if (!isMainActivityIsActive) { - Timber.i("ConferenceSDKModule::handlePushNotification(): push isMainActivityIsActive=" - + isMainActivityIsActive + ", start Application"); - Timber.i("ConferenceSDKModule::handlePushNotification(): push mStateDevice.isDeviceActive()=" - + mStateDevice.isDeviceActive() + ", start Application"); - startApplicationActivityForced(); - return true; - } else if (!hasCreatedActiveCall()) { - Timber.i("ConferenceSDKModule::handlePushNotification(): push mActiveConference=null"); - startApplicationActivity(); return true; } } + return false; } return false; } -- GitLab From 057a2266800e5719ad8407a470499b953d97b148 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 15 May 2020 14:47:55 +0300 Subject: [PATCH 22/24] -fixed starting Camera in P2P call issue --- .../mvp/presenters/ConferenceCallPresenter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java index a4e60998a2..94842bed4c 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java @@ -576,12 +576,12 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter if (getAttachedViews().size() == 0) return; ActiveConferenceCall call = mDataManager.getConferenceSDK().getActiveConference(); if (call != null && !mDataManager.getConferenceSDK().isP2P()) { - if (!isScreenSharing()) { - mDataManager.getConferenceSDK().startCameraCapture(); + if (isScreenSharing()) { + getViewState().showStopScreenShareFirstAlert(); return; } } - getViewState().showStopScreenShareFirstAlert(); + startCameraCapture(); } public void startCameraCapture() { -- GitLab From a8a454c0cacf5bf0299752db664c6afb64617769 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Sat, 16 May 2020 01:16:07 +0300 Subject: [PATCH 23/24] NY-10358: [AN]: The conference created after call escalation doesn't contains all participants and empty call screen after call is ended (cherry picked from commit 218ed9b35d00d75d8542fea18f1f5603f881a2d0) --- .../data/sdk/calls/ConferenceSDKModule.java | 58 +++++++++---------- .../mvp/presenters/ChooseUserPresenter.java | 16 +++-- .../presenters/ConferenceCallPresenter.java | 1 + .../mvp/presenters/MainActivityPresenter.kt | 10 ++++ .../ui/activities/MainActivity.java | 1 + 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index f88f25458e..791a9ce7c1 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -1465,19 +1465,7 @@ public class ConferenceSDKModule extends BaseSDKModule { @Override public void replaceCall(String oldCallId, NYNCall newCall) { - if (oldCallId != null) { - Timber.d("replaceCall old call \'CallId\'=\'" + - oldCallId + "\' with new \'CallId\'=\'" + newCall!=null? newCall.callId(): "null"+ "\'"); - if (hasCreatedActiveCall() && mActiveConference.mConference != null - && mActiveConference.mConference.callId().contentEquals(oldCallId)) { - mActiveConference.mConference.setListener(null); - final String callId = newCall.callId(); - onReplaceCall(callId); - } else if (newCall != null && !hasCreatedActiveCall() && oldCallId.contentEquals(newCall.replaceRef())) { - final String callId = newCall.callId(); - replaceNewCall(callId); - } - } + trySwitchP2pToConferenceCall(oldCallId, newCall); } @Override @@ -1587,6 +1575,24 @@ public class ConferenceSDKModule extends BaseSDKModule { } } + private synchronized void trySwitchP2pToConferenceCall(String oldCallId, NYNCall newCall) { + if (oldCallId != null) { + Timber.d("replaceCall old call \'CallId\'=\'" + + oldCallId + "\' with new \'CallId\'=\'" + newCall!=null? newCall.callId(): "null"+ "\'"); + if (hasCreatedActiveCall() && mActiveConference.mConference != null + && mActiveConference.mConference.callId().contentEquals(oldCallId)) { + Timber.d("replaceCall::trySwitchP2pToConferenceCall(): check 1"); + mActiveConference.mConference.setListener(null); + final String callId = newCall.callId(); + onReplaceCall(callId); + } else if (newCall != null && !hasCreatedActiveCall() && oldCallId.contentEquals(newCall.replaceRef())) { + Timber.d("replaceCall::trySwitchP2pToConferenceCall(): check 2"); + final String callId = newCall.callId(); + replaceNewCall(callId); + } + } + } + private void onScreenShareState(String callId, boolean active) { // not need twice for active call or not!!! for (ConferenceSDKListener conferenceListener : mConferenceSDKListener) { @@ -1900,24 +1906,14 @@ public class ConferenceSDKModule extends BaseSDKModule { if (!hasCreatedActiveCall() || StringUtils.isEmpty(conferenceId)) return; if (isP2P()) { if (replaceRef.contentEquals(mActiveConference.mConference.callId())) { - NYNCall conference = mCallManager.getCallById(conferenceId); - if (conference != null && conference.isConference()) { - // Escalate call to Conference - new Handler(Looper.getMainLooper()).post(() -> { - boolean isVideoConference = false;//NOT SUPPORTING VIDEO CONFERENCING YET!!!! mActiveConference.isVideoEnabled; - String subject = conference.getSubject(); - //conferenceHangUp(true); - mActiveConference.mConference.setListener(null); - endConference(false, false); - if (makeConferenceEx(conference, subject, roomId, null, isVideoConference, true)) { - mConferenceDetails.mCallId = conferenceId; - initConferenceCall(); - if (mHandler != null) mHandler.post( () -> { - onConferenceParticipantsUpdated(conferenceId); - }); - } - }); - } + // Escalate call to Conference + final NYNCall conference = mCallManager.getCallById(conferenceId); + if (conference == null || !conference.isConference()) return; + //////////////////////////////////////////////////////////////////////////////// + // !!!!!!!!!!! after that comes REPLACE event too ... + // so no needs to Recreate 2 time the new conference call !!! + trySwitchP2pToConferenceCall(replaceRef, conference); + //////////////////////////////////////////////////////////////////////////////// } } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChooseUserPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChooseUserPresenter.java index 9364873255..9d1444c78e 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChooseUserPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ChooseUserPresenter.java @@ -723,18 +723,22 @@ public class ChooseUserPresenter extends ConferenceSDKPresenter return contact; } - private ArrayList getOriginParticipantContacts(List items) { - return getOriginParticipantContacts(items, false); + private ArrayList getOriginParticipantContacts(List items, + ContactModel me) { + return getOriginParticipantContacts(items, me, false); } - private ArrayList getOriginParticipantContacts(List items, boolean isEscalateCall) { + private ArrayList getOriginParticipantContacts(List items, + ContactModel me, + boolean isEscalateCall) { ArrayList contacts = new ArrayList<>(); if (items != null) { if (mNewAllContacts != null) { for (int i = 0; i < items.size(); i++) { ContactModel contact = getOriginParticipantContact(mNewAllContacts, items.get(i)); if (isEscalateCall) { - contact.isMe = false; // check with real MY contact!!! + if (me.equals(contact)) continue; + contact.isMe = false; } contacts.add(contact); } @@ -845,8 +849,8 @@ public class ChooseUserPresenter extends ConferenceSDKPresenter String roomName; String roomId = null; if (mRoom != null) { - contacts = getOriginParticipantContacts(items); ContactModel me = mDataManager.getMyConferenceContact(); + contacts = getOriginParticipantContacts(items, me); if (me != null) { MemberModel memberMe = mRoom.findMemberById(me.phoneId); if (memberMe != null) { @@ -860,8 +864,8 @@ public class ChooseUserPresenter extends ConferenceSDKPresenter roomName = mRoom.name; roomId = mRoom.id; } else { - contacts = getOriginParticipantContacts(items, isEscalateCall); ContactModel me = mDataManager.getMyConferenceContact(); + contacts = getOriginParticipantContacts(items, me, isEscalateCall); if (me != null) { me.isMe = true; contacts.add(0, me); diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java index 94842bed4c..57fd65d479 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/ConferenceCallPresenter.java @@ -487,6 +487,7 @@ public class ConferenceCallPresenter extends ConferenceSDKPresenter @Nullable private ArrayList getConferenceParticipants() { + if (isP2PCall()) return null; if (mDataManager.getConferenceSDK(). getActiveConference().mData.mParticipantArray != null) { ArrayList currentContacts = new ArrayList<>(); diff --git a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt index 89994c6709..d3c2aa40e2 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt +++ b/app/src/main/java/com/nynja/mobile/communicator/mvp/presenters/MainActivityPresenter.kt @@ -888,4 +888,14 @@ class MainActivityPresenter : ConferenceSDKPresenter() { mDataManager.getConferenceSDK().declineConference() } + fun setContactForP2P() { + val activeConferenceCall = mDataManager.conferenceSDK.activeConference + val peerId = mDataManager.conferenceSDK.activeConferencePeerName // getConferenceRoomId() + if (mDataManager.conferenceSDK.isP2P) { + val contact = mDataManager.getContactByChatId(peerId) + if (contact != null) { + activeConferenceCall?.addMember(contact) + } + } + } } diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java index c11eb28521..d3ec2a1c17 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java @@ -402,6 +402,7 @@ public class MainActivity extends BaseActivity implements MainActivityView, if (permission.granted) { Timber.d("All permission(s) requests finished"); if (incomming) { + mPresenter.setContactForP2P(); mPresenter.navigateToActiveCall(); mPresenter.clearIncomingCallNotification(); } else { -- GitLab From b2096c64bd2ac6a15f5753482952c225cf238541 Mon Sep 17 00:00:00 2001 From: Angel Terziev Date: Mon, 18 May 2020 13:27:48 +0300 Subject: [PATCH 24/24] Linked with NynjaSDK 1.21.5 - which has debug symbols uploaded into firebase for stack trace --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6a8ef336b9..a42015c366 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -682,8 +682,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // Conference, Calls mobile SDK - implementation 'com.nynja.sdk:NynjaSdk:1.21.4@aar' - //implementation(name: 'NynjaSdk-1.21.2', ext: 'aar') + implementation 'com.nynja.sdk:NynjaSdk:1.21.5@aar' + //implementation(name: 'NynjaSdk-1.21.5', ext: 'aar') //ExoPlayer implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6' -- GitLab