Skip to content

Commit 5677bc0

Browse files
committed
Add new canMakeMultipleCalls method
1 parent c257086 commit 5677bc0

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ Eg: When your used log out (or the connection to your server is broken, etc..),
124124
RNCallKeep.setAvailable(true);
125125
```
126126

127+
### canMakeMultipleCalls
128+
_This feature is available only on Android._
129+
130+
Disable the "Add call" button in ConnectionService UI.
131+
132+
```js
133+
RNCallKeep.canMakeMultipleCalls(false); // Enabled by default
134+
```
135+
127136
- `active`: boolean
128137
- Tell whether the app is ready or not
129138

android/src/main/java/io/wazo/callkeep/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ public class Constants {
1616
public static final String EXTRA_CALL_NUMBER = "EXTRA_CALL_NUMBER";
1717
public static final String EXTRA_CALL_UUID = "EXTRA_CALL_UUID";
1818
public static final String EXTRA_CALLER_NAME = "EXTRA_CALLER_NAME";
19+
// Can't use telecom.EXTRA_DISABLE_ADD_CALL ...
20+
public static final String EXTRA_DISABLE_ADD_CALL = "android.telecom.extra.DISABLE_ADD_CALL";
1921
}

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ public void setAvailable(Boolean active) {
386386
VoiceConnectionService.setAvailable(active);
387387
}
388388

389+
@ReactMethod
390+
public void canMakeMultipleCalls(Boolean allow) {
391+
VoiceConnectionService.setCanMakeMultipleCalls(allow);
392+
}
393+
389394
@ReactMethod
390395
public void setReachable() {
391396
VoiceConnectionService.setReachable();

android/src/main/java/io/wazo/callkeep/VoiceConnectionService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@
5858
import static io.wazo.callkeep.Constants.EXTRA_CALLER_NAME;
5959
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
6060
import static io.wazo.callkeep.Constants.EXTRA_CALL_UUID;
61+
import static io.wazo.callkeep.Constants.EXTRA_DISABLE_ADD_CALL;
6162

6263
// @see https://github.com/kbagchiGWC/voice-quickstart-android/blob/9a2aff7fbe0d0a5ae9457b48e9ad408740dfb968/exampleConnectionService/src/main/java/com/twilio/voice/examples/connectionservice/VoiceConnectionService.java
6364
@TargetApi(Build.VERSION_CODES.M)
6465
public class VoiceConnectionService extends ConnectionService {
6566
private static Boolean isAvailable;
6667
private static Boolean isInitialized;
6768
private static Boolean isReachable;
69+
private static Boolean canMakeMultipleCalls = true;
6870
private static String notReachableCallUuid;
6971
private static ConnectionRequest currentConnectionRequest;
7072
private static PhoneAccountHandle phoneAccountHandle;
@@ -103,6 +105,10 @@ public static void setAvailable(Boolean value) {
103105
isAvailable = value;
104106
}
105107

108+
public static void setCanMakeMultipleCalls(Boolean allow) {
109+
VoiceConnectionService.canMakeMultipleCalls = allow;
110+
}
111+
106112
public static void setReachable() {
107113
Log.d(TAG, "setReachable");
108114
isReachable = true;
@@ -170,6 +176,10 @@ private Connection makeOutgoingCall(ConnectionRequest request, String uuid, Bool
170176
extras.putString(EXTRA_CALL_NUMBER, number);
171177
}
172178

179+
if (!canMakeMultipleCalls) {
180+
extras.putBoolean(EXTRA_DISABLE_ADD_CALL, true);
181+
}
182+
173183
outgoingCallConnection = createConnection(request);
174184
outgoingCallConnection.setDialing();
175185
outgoingCallConnection.setAudioModeIsVoip(true);

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ declare module 'react-native-callkeep' {
136136
*/
137137
static setAvailable(active: boolean): void
138138

139+
static canMakeMultipleCalls(allow: boolean): void
140+
139141
static setCurrentCallActive(callUUID: string): void
140142

141143
static backToForeground(): void

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ class RNCallKeep {
184184
RNCallKeepModule.setAvailable(state);
185185
};
186186

187+
canMakeMultipleCalls = (state) => {
188+
if (isIOS) {
189+
return;
190+
}
191+
192+
RNCallKeepModule.canMakeMultipleCalls(state);
193+
};
194+
187195
setCurrentCallActive = (callUUID) => {
188196
if (isIOS) {
189197
return;

0 commit comments

Comments
 (0)