From adbb07da30d2998c7da7e66b90cb9729a25545d3 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 12 Apr 2023 13:52:40 -0700 Subject: [PATCH] using in call manager to adjust phone during call --- app/mobile/ios/Databag.xcodeproj/project.pbxproj | 8 ++++---- app/mobile/ios/Podfile.lock | 6 ++++++ app/mobile/package.json | 1 + app/mobile/src/context/useRingContext.hook.js | 10 +++++++++- app/mobile/src/session/Session.jsx | 10 +++++++++- app/mobile/yarn.lock | 5 +++++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/mobile/ios/Databag.xcodeproj/project.pbxproj b/app/mobile/ios/Databag.xcodeproj/project.pbxproj index 6c790877..3fe1d301 100644 --- a/app/mobile/ios/Databag.xcodeproj/project.pbxproj +++ b/app/mobile/ios/Databag.xcodeproj/project.pbxproj @@ -516,7 +516,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.10; + MARKETING_VERSION = 1.11; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -549,7 +549,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.10; + MARKETING_VERSION = 1.11; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -571,7 +571,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -643,7 +643,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++14"; + CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; diff --git a/app/mobile/ios/Podfile.lock b/app/mobile/ios/Podfile.lock index 3aa16c90..653f48be 100644 --- a/app/mobile/ios/Podfile.lock +++ b/app/mobile/ios/Podfile.lock @@ -427,6 +427,8 @@ PODS: - React-jsi (= 0.71.3) - React-logger (= 0.71.3) - React-perflogger (= 0.71.3) + - ReactNativeIncallManager (4.0.1): + - React-Core - RNCClipboard (1.11.1): - React-Core - RNDeviceInfo (10.4.0): @@ -528,6 +530,7 @@ DEPENDENCIES: - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - ReactNativeIncallManager (from `../node_modules/react-native-incall-manager`) - "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)" - RNDeviceInfo (from `../node_modules/react-native-device-info`) - "RNFBApp (from `../node_modules/@react-native-firebase/app`)" @@ -637,6 +640,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" ReactCommon: :path: "../node_modules/react-native/ReactCommon" + ReactNativeIncallManager: + :path: "../node_modules/react-native-incall-manager" RNCClipboard: :path: "../node_modules/@react-native-clipboard/clipboard" RNDeviceInfo: @@ -712,6 +717,7 @@ SPEC CHECKSUMS: React-RCTVibration: 5199a180d04873366a83855de55ac33ce60fe4d5 React-runtimeexecutor: 7bf0dafc7b727d93c8cb94eb00a9d3753c446c3e ReactCommon: 5f9a24e64c1c3e2b719014f07cb2acf628983000 + ReactNativeIncallManager: 0d2cf9f4d50359728a30c08549762fe67a2efb81 RNCClipboard: 2834e1c4af68697089cdd455ee4a4cdd198fa7dd RNDeviceInfo: 749f2e049dcd79e2e44f134f66b73a06951b5066 RNFBApp: 4f8ea53443d52c7db793234d2398a357fc6cfbf1 diff --git a/app/mobile/package.json b/app/mobile/package.json index f10a5886..fcba0932 100644 --- a/app/mobile/package.json +++ b/app/mobile/package.json @@ -31,6 +31,7 @@ "react-native-document-picker": "^8.1.3", "react-native-gesture-handler": "^2.9.0", "react-native-image-crop-picker": "^0.39.0", + "react-native-incall-manager": "^4.0.1", "react-native-reanimated": "^2.14.4", "react-native-reanimated-carousel": "^3.3.0", "react-native-rsa-native": "^2.0.5", diff --git a/app/mobile/src/context/useRingContext.hook.js b/app/mobile/src/context/useRingContext.hook.js index c84e58a2..bef665e3 100644 --- a/app/mobile/src/context/useRingContext.hook.js +++ b/app/mobile/src/context/useRingContext.hook.js @@ -6,6 +6,7 @@ import { addCall } from 'api/addCall'; import { keepCall } from 'api/keepCall'; import { removeCall } from 'api/removeCall'; import { removeContactCall } from 'api/removeContactCall'; +import InCallManager from 'react-native-incall-manager'; import { ScreenCapturePickerView, @@ -203,6 +204,7 @@ export function useRingContext() { } if (event.track.kind === 'video') { updateState({ remoteVideo: true }); + InCallManager.setForceSpeakerphoneOn(true); } stream.current.addTrack(event.track, stream.current); } ); @@ -252,6 +254,7 @@ export function useRingContext() { updateState({ callStatus: "connected" }); if (policy === 'polite') { connected.current = true; + InCallManager.start({media: 'audio'}); transmit('polite'); polite(); } @@ -289,6 +292,8 @@ export function useRingContext() { } clearRing(); clearAlive(); + InCallManager.stop(); + connected.current = false; calling.current = null; if (videoTrack.current) { videoTrack.current.stop(); @@ -304,6 +309,7 @@ export function useRingContext() { ws.current.send(JSON.stringify({ AppToken: token })); if (policy === 'impolite') { connected.current = true; + InCallManager.start({media: 'audio'}); transmit('impolite'); impolite(); } @@ -454,7 +460,9 @@ export function useRingContext() { if (track.kind === 'video') { videoTrack.current = track; pc.current.addTrack(track, stream); - updateState({ localVideo: true }); + const localStream = new MediaStream(); + localStream.addTrack(track, localStream); + updateState({ localVideo: true, localStream }); } } } diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx index f42a2db6..430c5037 100644 --- a/app/mobile/src/session/Session.jsx +++ b/app/mobile/src/session/Session.jsx @@ -1,4 +1,4 @@ -import { View, ScrollView, TouchableOpacity, StatusBar, Text, Image, Modal } from 'react-native'; +import { Alert, View, ScrollView, TouchableOpacity, StatusBar, Text, Image, Modal } from 'react-native'; import { useState, useEffect, useContext } from 'react'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; @@ -25,6 +25,7 @@ import { ProfileIcon } from './profileIcon/ProfileIcon'; import { CardsIcon } from './cardsIcon/CardsIcon'; import { Logo } from 'utils/Logo'; import { Call } from './call/Call'; +import { DeviceEventEmitter } from 'react-native'; import splash from 'images/session.png'; const ConversationStack = createStackNavigator(); @@ -326,6 +327,13 @@ export function Session() { setDmChannel({ id }); }; + useEffect(() => { + const listener = DeviceEventEmitter.addListener('Proximity', function (data) { + Alert.alert("proximity"); + }); + return () => { listener.remove() } + }, []); + useEffect(() => { let incoming = []; for (let i = 0; i < state.ringing.length; i++) { diff --git a/app/mobile/yarn.lock b/app/mobile/yarn.lock index 7c1a5cf7..5fbfae5f 100644 --- a/app/mobile/yarn.lock +++ b/app/mobile/yarn.lock @@ -6326,6 +6326,11 @@ react-native-image-crop-picker@^0.39.0: resolved "https://registry.yarnpkg.com/react-native-image-crop-picker/-/react-native-image-crop-picker-0.39.0.tgz#9cb8e8ffb0e8ab06f7b3227cadf077169e225eba" integrity sha512-4aANbQMrmU6zN/4b0rVBA7SbaZ3aa5JESm3Xk751sINybZMt1yz/9h95LkO7U0pbslHDo3ofXjG75PmQRP6a/w== +react-native-incall-manager@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/react-native-incall-manager/-/react-native-incall-manager-4.0.1.tgz#7dae419433383ed31262d811fd549bba7951b2f2" + integrity sha512-Bqq7C+p7vCmCTpM8Xv6l4DJ3UJYzVr60IvkHMw1Ugs0KJswh3veBJrpk+hUPSETPT6J/5oUwxChXlNsymsh7fg== + react-native-reanimated-carousel@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/react-native-reanimated-carousel/-/react-native-reanimated-carousel-3.3.0.tgz#e71e9441ee6aaae401c5a023b27bf48a54565d16"