diff --git a/ring-android/app/src/main/java/cx/ring/client/CallActivity.java b/ring-android/app/src/main/java/cx/ring/client/CallActivity.java index 9b2406cc6de6c5123a19465693d9ddf0fdf39495..84bf5961cb17c8e33106d25925e7264cb2407c0a 100644 --- a/ring-android/app/src/main/java/cx/ring/client/CallActivity.java +++ b/ring-android/app/src/main/java/cx/ring/client/CallActivity.java @@ -45,8 +45,6 @@ import cx.ring.services.NotificationService; import cx.ring.utils.KeyboardVisibilityManager; import cx.ring.utils.MediaButtonsHelper; -import static cx.ring.daemon.Ringservice.getPluginsEnabled; - public class CallActivity extends AppCompatActivity { public static final String ACTION_CALL = BuildConfig.APPLICATION_ID + ".action.call"; public static final String ACTION_CALL_ACCEPT = BuildConfig.APPLICATION_ID + ".action.CALL_ACCEPT"; diff --git a/ring-android/app/src/main/java/cx/ring/fragments/CallFragment.java b/ring-android/app/src/main/java/cx/ring/fragments/CallFragment.java index 436b3684133b9e0d2a34e01d078ec49e092043f2..85479997687cd6559c1fb565f68f6df46f8da2ec 100644 --- a/ring-android/app/src/main/java/cx/ring/fragments/CallFragment.java +++ b/ring-android/app/src/main/java/cx/ring/fragments/CallFragment.java @@ -315,6 +315,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements }else { if (binding.pluginPreviewContainer.getVisibility() == View.VISIBLE) { restartPreview = true; + presenter.stopPlugin(); } } } @@ -1328,6 +1329,8 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements .putExtra(KEY_CONF_ID, conferenceId), CallFragment.REQUEST_CODE_ADD_PARTICIPANT); } + + @Override public void toggleCallMediaHandler(String id, boolean toggle) { Ringservice.toggleCallMediaHandler(id, toggle); } @@ -1449,7 +1452,6 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements if (position > 0) { String callMediaId = callMediaHandlers.get(position-1); presenter.startPlugin(callMediaId); - //toggleCallMediaHandler(callMediaId, true); } } @@ -1458,7 +1460,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements String callMediaId = callMediaHandlers. get(previousPluginPosition-1); - toggleCallMediaHandler(callMediaId, false); + presenter.toggleCallMediaHandler(callMediaId, false); rp.scrollToPosition(previousPluginPosition); } presenter.stopPlugin(); @@ -1483,13 +1485,13 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements */ if (previousPluginPosition > 0) { String callMediaId = callMediaHandlers.get(previousPluginPosition-1); - toggleCallMediaHandler(callMediaId, false); + presenter.toggleCallMediaHandler(callMediaId, false); } if (position > 0) { previousPluginPosition = position; String callMediaId = callMediaHandlers.get(position-1); - toggleCallMediaHandler(callMediaId, true); + presenter.toggleCallMediaHandler(callMediaId, true); } } @@ -1507,7 +1509,7 @@ public class CallFragment extends BaseSupportFragment<CallPresenter> implements */ if (previousPluginPosition > 0) { String callMediaId = callMediaHandlers.get(previousPluginPosition-1); - toggleCallMediaHandler(callMediaId, false); + presenter.toggleCallMediaHandler(callMediaId, false); rp.scrollToPosition(previousPluginPosition); } diff --git a/ring-android/app/src/main/java/cx/ring/services/HardwareServiceImpl.java b/ring-android/app/src/main/java/cx/ring/services/HardwareServiceImpl.java index c19257110853dd3e3896f3cbd8437c2149e01011..a7d8793317b60ff6bd7f3d490bc01e4e4bd7c3b0 100644 --- a/ring-android/app/src/main/java/cx/ring/services/HardwareServiceImpl.java +++ b/ring-android/app/src/main/java/cx/ring/services/HardwareServiceImpl.java @@ -49,6 +49,7 @@ import java.util.Map; import cx.ring.daemon.IntVect; import cx.ring.daemon.Ringservice; +import cx.ring.daemon.StringMap; import cx.ring.daemon.UintVect; import cx.ring.model.Conference; import cx.ring.model.SipCall; @@ -58,6 +59,7 @@ import cx.ring.utils.Log; import cx.ring.utils.Ringer; import io.reactivex.Completable; +import static cx.ring.daemon.Ringservice.getCallMediaHandlerStatus; import static cx.ring.daemon.RingserviceJNI.toggleCallMediaHandler; public class HardwareServiceImpl extends HardwareService implements AudioManager.OnAudioFocusChangeListener, BluetoothWrapper.BluetoothChangeListener { @@ -89,7 +91,8 @@ public class HardwareServiceImpl extends HardwareService implements AudioManager private boolean mShouldSpeakerphone = false; private final boolean mHasSpeakerPhone; private boolean mIsChoosePlugin = false; - private String mMediaHandlerId; + private String mMediaHandlerId = ""; + private String mPluginCallId = ""; public HardwareServiceImpl(Context context) { mContext = context; @@ -544,7 +547,15 @@ public class HardwareServiceImpl extends HardwareService implements AudioManager new CameraService.CameraListener() { @Override public void onOpened() { - if(mIsChoosePlugin && !mMediaHandlerId.isEmpty()) + String currentCall = conf.getConfId(); + if (!mPluginCallId.isEmpty() && !currentCall.equals(mPluginCallId)) { + toggleCallMediaHandler("", false); + mIsChoosePlugin = false; + mMediaHandlerId = ""; + mPluginCallId = ""; + } + else if(mIsChoosePlugin && !mMediaHandlerId.isEmpty()) + mPluginCallId = conf.getConfId(); toggleMediaHandler(); } diff --git a/ring-android/app/src/main/java/cx/ring/tv/call/TVCallFragment.java b/ring-android/app/src/main/java/cx/ring/tv/call/TVCallFragment.java index c3481194b3d3c208b999b8052a71dea8f6ffa590..760615735e34450f4a9230a4d772719f6b4b495f 100644 --- a/ring-android/app/src/main/java/cx/ring/tv/call/TVCallFragment.java +++ b/ring-android/app/src/main/java/cx/ring/tv/call/TVCallFragment.java @@ -663,6 +663,11 @@ public class TVCallFragment extends BaseSupportFragment<CallPresenter> implement binding.participantLabelContainer.setVisibility(info.isEmpty() ? View.GONE : View.VISIBLE); } + @Override + public void toggleCallMediaHandler(String id, boolean toggle) { + cx.ring.daemon.RingserviceJNI.toggleCallMediaHandler(id, toggle); + } + @Override public void goToConversation(String accountId, String conversationId) { diff --git a/ring-android/libringclient/src/main/java/cx/ring/call/CallPresenter.java b/ring-android/libringclient/src/main/java/cx/ring/call/CallPresenter.java index ccd4ced88c3069e08b89be248e1cd04cb6c6fb9b..5fc46996df400cdd61b185e25f0560c36b68fb79 100644 --- a/ring-android/libringclient/src/main/java/cx/ring/call/CallPresenter.java +++ b/ring-android/libringclient/src/main/java/cx/ring/call/CallPresenter.java @@ -50,7 +50,6 @@ import io.reactivex.subjects.BehaviorSubject; import io.reactivex.subjects.Subject; import static cx.ring.daemon.Ringservice.listCallMediaHandlers; -import static cx.ring.daemon.Ringservice.toggleCallMediaHandler; public class CallPresenter extends RootPresenter<CallView> { @@ -618,6 +617,13 @@ public class CallPresenter extends RootPresenter<CallView> { } } + public void toggleCallMediaHandler(String id, boolean toggle) + { + if (mConference != null && mConference.isOnGoing() && mConference.hasVideo()) { + getView().toggleCallMediaHandler(id, toggle); + } + } + public boolean isSpeakerphoneOn() { return mHardwareService.isSpeakerPhoneOn(); } diff --git a/ring-android/libringclient/src/main/java/cx/ring/call/CallView.java b/ring-android/libringclient/src/main/java/cx/ring/call/CallView.java index 1b2a3a81d85c9520a111b795206fe7da0fa50859..9e57e1f49a4f8efd381945e2af2cc799a78c125a 100644 --- a/ring-android/libringclient/src/main/java/cx/ring/call/CallView.java +++ b/ring-android/libringclient/src/main/java/cx/ring/call/CallView.java @@ -84,4 +84,6 @@ public interface CallView { boolean displayPluginsButton(); void updateConfInfo(List<Conference.ParticipantInfo> info); + + void toggleCallMediaHandler(String id, boolean toggle); }