Skip to content

Commit 15840ba

Browse files
Update to 1.3.0.
1 parent 7e1b425 commit 15840ba

24 files changed

+340
-203
lines changed

README.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Sendbird Calls for Android Quickstart
2+
23
![Platform](https://img.shields.io/badge/platform-ANDROID-orange.svg)
34
![Languages](https://img.shields.io/badge/language-JAVA-orange.svg)
45

@@ -7,7 +8,7 @@ Google Play](https://lh3.googleusercontent.com/cjsqrWQKJQp9RFO7-hJ9AfpKzbUb_Y84v
78

89
## Introduction
910

10-
Sendbird Calls SDK for Android is used to initialize, configure, and build voice and video calling functionality into your Android client app. In this repository, you will find the steps you need to take before implementing the Calls SDK into a project, and a sample app which contains the code for implementing voice and video call.
11+
Sendbird Calls SDK for Android is used to initialize, configure, and build voice and video calling functionality into your Android client app. In this repository, you will find the steps you need to take before implementing the Calls SDK into a project, and a sample app which contains the code for implementing voice and video call.
1112

1213
### More about Sendbird Calls for Android
1314

@@ -21,7 +22,7 @@ This section shows you the prerequisites you need for testing Sendbird Calls for
2122

2223
### Requirements
2324

24-
The minimum requirements for Calls SDK for Android sample are:
25+
The minimum requirements for Calls SDK for Android sample are:
2526

2627
- Android 4.1 (API level 16) or higher
2728
- Java 8 or higher
@@ -34,7 +35,7 @@ For more details on **installing and configuring the Calls SDK for Android**, re
3435

3536
## Getting started
3637

37-
If you would like to try the sample app specifically fit to your usage, you can do so by following the steps below.
38+
If you would like to try the sample app specifically fit to your usage, you can do so by following the steps below.
3839

3940
### Create a Sendbird application
4041

@@ -65,9 +66,9 @@ public class BaseApplication extends Application {
6566

6667
### Build and run the sample app
6768

68-
1. Build and run the sample app on your Android device.
69-
2. Install the application onto at least two separate devices for each test user you created earlier.
70-
3. If there are no two devices available, you can use an emulator to run the application instead.
69+
1. Build and run the sample app on your Android device.
70+
2. Install the application onto at least two separate devices for each test user you created earlier.
71+
3. If there are no two devices available, you can use an emulator to run the application instead.
7172

7273
For more detail on how to build and run an Android application, refer to [Android Documentation](https://developer.android.com/studio/run).
7374

@@ -146,6 +147,25 @@ protected void onCreate(Bundle savedInstanceState) {
146147

147148
<br />
148149

150+
### Sound Effects
151+
152+
You can use different sound effects to enhance the user experience for events that take place while using Sendbird Calls.
153+
154+
To add sound effects, use the `SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType soundType, int resId)` method for the following events: dialing, ringing, reconnecting, and reconnected. Remember to set sound effects before the mentioned events occur. To remove sound effects, use the `SendBirdCall.Options.removeDirectCallSound(SendBirdCall.SoundType soundType)` method.
155+
156+
```java
157+
// Play on a caller’s side when making a call.
158+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.DIALING, R.raw.dialing);
159+
// Play on a callee’s side when receiving a call.
160+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RINGING, R.raw.ringing);
161+
// Play when a connection is lost, but the SDK immediately attempts to reconnect.
162+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTING, R.raw.reconnecting);
163+
// Play when the connection is re-established.
164+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTED, R.raw.reconnected);
165+
```
166+
167+
<br />
168+
149169
## Reference
150170

151171
For further detail on Sendbird Calls for Android, refer to [Sendbird Calls SDK for Android README](https://github.com/sendbird/sendbird-calls-android/blob/master/README.md).

app/build.gradle

+12-10
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ android {
77
applicationId "com.sendbird.calls.quickstart"
88
minSdkVersion 16 // [Calls]
99
targetSdkVersion 29
10-
versionCode 7
11-
versionName "1.2.0"
10+
versionCode 8
11+
versionName "1.3.0"
12+
multiDexEnabled true // multidex
1213
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1314
}
1415
buildTypes {
@@ -27,13 +28,14 @@ android {
2728

2829
dependencies {
2930
implementation fileTree(dir: 'libs', include: ['*.aar'])
30-
implementation 'androidx.appcompat:appcompat:1.1.0'
31-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32-
implementation 'com.google.android.material:material:1.1.0'
31+
implementation 'androidx.appcompat:appcompat:1.2.0'
32+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
33+
implementation 'com.google.android.material:material:1.2.1'
34+
implementation 'androidx.multidex:multidex:2.0.1' // multidex
3335

34-
implementation 'com.sendbird.sdk:sendbird-calls:1.2.0' // [Calls]
35-
implementation 'com.google.firebase:firebase-core:17.4.4' // [Calls] FCM
36-
implementation 'com.google.firebase:firebase-messaging:20.2.3' // [Calls] FCM
36+
implementation 'com.sendbird.sdk:sendbird-calls:1.3.0' // [Calls]
37+
implementation 'com.google.firebase:firebase-core:17.5.0' // [Calls] FCM
38+
implementation 'com.google.firebase:firebase-messaging:20.2.4' // [Calls] FCM
3739
implementation 'com.github.bumptech.glide:glide:4.11.0'
3840

3941
//+ [QRCode]
@@ -42,8 +44,8 @@ dependencies {
4244
//- [QRCode]
4345

4446
testImplementation 'junit:junit:4.13'
45-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
46-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
47+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
48+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4749
}
4850

4951
apply plugin: 'com.google.gms.google-services' // [Calls] FCM

app/src/main/AndroidManifest.xml

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
<action android:name="android.intent.action.MAIN" />
2424
<category android:name="android.intent.category.LAUNCHER" />
2525
</intent-filter>
26+
<intent-filter>
27+
<action android:name="android.intent.action.VIEW" />
28+
<category android:name="android.intent.category.DEFAULT" />
29+
<category android:name="android.intent.category.BROWSABLE" />
30+
<!-- Accepts URIs that begin with "sendbird://” -->
31+
<data android:scheme="sendbird" />
32+
</intent-filter>
2633
</activity>
2734

2835
<activity android:name=".AuthenticateActivity"

app/src/main/java/com/sendbird/calls/quickstart/BaseApplication.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.sendbird.calls.quickstart;
22

33

4-
import android.app.Application;
54
import android.content.Context;
65
import android.text.TextUtils;
76
import android.util.Log;
87

8+
import androidx.multidex.MultiDexApplication;
9+
910
import com.sendbird.calls.DirectCall;
1011
import com.sendbird.calls.SendBirdCall;
1112
import com.sendbird.calls.handler.DirectCallListener;
@@ -16,9 +17,9 @@
1617

1718
import java.util.UUID;
1819

19-
public class BaseApplication extends Application {
20+
public class BaseApplication extends MultiDexApplication { // multidex
2021

21-
public static final String VERSION = "1.2.0";
22+
public static final String VERSION = "1.3.0";
2223

2324
public static final String TAG = "SendBirdCalls";
2425

@@ -75,6 +76,11 @@ public void onEnded(DirectCall call) {
7576
CallService.onRinging(context, call);
7677
}
7778
});
79+
80+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.DIALING, R.raw.dialing);
81+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RINGING, R.raw.ringing);
82+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTING, R.raw.reconnecting);
83+
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTED, R.raw.reconnected);
7884
return true;
7985
}
8086
return false;

app/src/main/java/com/sendbird/calls/quickstart/SplashActivity.java

+46-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.sendbird.calls.quickstart;
22

33
import android.content.Context;
4+
import android.content.Intent;
5+
import android.net.Uri;
46
import android.os.Bundle;
57
import android.text.TextUtils;
8+
import android.util.Log;
69

710
import androidx.appcompat.app.AppCompatActivity;
811

912
import com.sendbird.calls.quickstart.utils.ActivityUtils;
1013
import com.sendbird.calls.quickstart.utils.AuthenticationUtils;
14+
import com.sendbird.calls.quickstart.utils.ToastUtils;
1115

1216
import java.util.Timer;
1317
import java.util.TimerTask;
@@ -19,6 +23,7 @@ public class SplashActivity extends AppCompatActivity {
1923
private Context mContext;
2024
private Timer mTimer;
2125
private Boolean mAutoAuthenticateResult;
26+
private String mEncodedAuthInfo;
2227

2328
@Override
2429
protected void onCreate(Bundle savedInstanceState) {
@@ -28,7 +33,30 @@ protected void onCreate(Bundle savedInstanceState) {
2833
mContext = this;
2934

3035
setTimer();
31-
autoAuthenticate();
36+
37+
if (!hasDeepLink()) {
38+
autoAuthenticate();
39+
}
40+
}
41+
42+
private boolean hasDeepLink() {
43+
boolean result = false;
44+
45+
Intent intent = getIntent();
46+
if (intent != null) {
47+
Uri data = intent.getData();
48+
if (data != null) {
49+
String scheme = data.getScheme();
50+
if (scheme != null && scheme.equals("sendbird")) {
51+
Log.i(BaseApplication.TAG, "[SplashActivity] deep link: " + data.toString());
52+
mEncodedAuthInfo = data.getHost();
53+
if (!TextUtils.isEmpty(mEncodedAuthInfo)) {
54+
result = true;
55+
}
56+
}
57+
}
58+
}
59+
return result;
3260
}
3361

3462
private void setTimer() {
@@ -38,6 +66,23 @@ private void setTimer() {
3866
public void run() {
3967
runOnUiThread(() -> {
4068
mTimer = null;
69+
70+
if (!TextUtils.isEmpty(mEncodedAuthInfo)) {
71+
AuthenticationUtils.authenticateWithEncodedAuthInfo(SplashActivity.this, mEncodedAuthInfo, (isSuccess, hasInvalidValue) -> {
72+
if (isSuccess) {
73+
ActivityUtils.startMainActivityAndFinish(SplashActivity.this);
74+
} else {
75+
if (hasInvalidValue) {
76+
ToastUtils.showToast(SplashActivity.this, getString(R.string.calls_invalid_deep_link));
77+
} else {
78+
ToastUtils.showToast(SplashActivity.this, getString(R.string.calls_deep_linking_to_authenticate_failed));
79+
}
80+
finish();
81+
}
82+
});
83+
return;
84+
}
85+
4186
if (mAutoAuthenticateResult != null) {
4287
if (mAutoAuthenticateResult) {
4388
ActivityUtils.startMainActivityAndFinish(SplashActivity.this);

app/src/main/java/com/sendbird/calls/quickstart/call/CallActivity.java

+5-42
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.sendbird.calls.quickstart.R;
2828
import com.sendbird.calls.quickstart.utils.AuthenticationUtils;
2929
import com.sendbird.calls.quickstart.utils.BroadcastUtils;
30+
import com.sendbird.calls.quickstart.utils.EndResultUtils;
3031
import com.sendbird.calls.quickstart.utils.UserInfoUtils;
3132

3233
import java.util.Set;
@@ -370,7 +371,10 @@ protected boolean setState(STATE state, DirectCall call) {
370371
mRelativeLayoutRingingButtons.setVisibility(View.GONE);
371372
mLinearLayoutConnectingButtons.setVisibility(View.GONE);
372373

373-
String status = getEndResultString(call);
374+
String status = "";
375+
if (call != null) {
376+
status = EndResultUtils.getEndResultString(mContext, call.getEndResult());
377+
}
374378
setInfo(call, status);
375379
finishWithEnding(status);
376380
break;
@@ -409,47 +413,6 @@ private void setRemoteMuteInfo(DirectCall call) {
409413
}
410414
}
411415

412-
private String getEndResultString(DirectCall call) {
413-
String endResultString = "";
414-
if (call != null) {
415-
switch (call.getEndResult()) {
416-
case NONE:
417-
break;
418-
case NO_ANSWER:
419-
endResultString = getString(R.string.calls_end_result_no_answer);
420-
break;
421-
case CANCELED:
422-
endResultString = getString(R.string.calls_end_result_canceled);
423-
break;
424-
case DECLINED:
425-
endResultString = getString(R.string.calls_end_result_declined);
426-
break;
427-
case COMPLETED:
428-
endResultString = getString(R.string.calls_end_result_completed);
429-
break;
430-
case TIMED_OUT:
431-
endResultString = getString(R.string.calls_end_result_timed_out);
432-
break;
433-
case CONNECTION_LOST:
434-
endResultString = getString(R.string.calls_end_result_connection_lost);
435-
break;
436-
case UNKNOWN:
437-
endResultString = getString(R.string.calls_end_result_unknown);
438-
break;
439-
case DIAL_FAILED:
440-
endResultString = getString(R.string.calls_end_result_dial_failed);
441-
break;
442-
case ACCEPT_FAILED:
443-
endResultString = getString(R.string.calls_end_result_accept_failed);
444-
break;
445-
case OTHER_DEVICE_ACCEPTED:
446-
endResultString = getString(R.string.calls_end_result_other_device_accepted);
447-
break;
448-
}
449-
}
450-
return endResultString;
451-
}
452-
453416
@Override
454417
public void onBackPressed() {
455418
}

app/src/main/java/com/sendbird/calls/quickstart/call/CallService.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.sendbird.calls.SendBirdCall;
2222
import com.sendbird.calls.quickstart.BaseApplication;
2323
import com.sendbird.calls.quickstart.R;
24+
import com.sendbird.calls.quickstart.utils.ToastUtils;
2425
import com.sendbird.calls.quickstart.utils.UserInfoUtils;
2526

2627
public class CallService extends Service {
@@ -64,10 +65,6 @@ static class ServiceData {
6465
ServiceData() {
6566
}
6667

67-
ServiceData(ServiceData serviceData) {
68-
set(serviceData);
69-
}
70-
7168
void set(ServiceData serviceData) {
7269
this.isHeadsUpNotification = serviceData.isHeadsUpNotification;
7370
this.remoteNicknameOrUserId = serviceData.remoteNicknameOrUserId;
@@ -199,6 +196,12 @@ private Notification getNotification(@NonNull ServiceData serviceData) {
199196
}
200197

201198
public static void dial(Context context, String doDialWithCalleeId, boolean isVideoCall) {
199+
if (SendBirdCall.getOngoingCallCount() > 0) {
200+
ToastUtils.showToast(context, "Ringing.");
201+
Log.i(BaseApplication.TAG, "[CallService] dial() => SendBirdCall.getOngoingCallCount(): " + SendBirdCall.getOngoingCallCount());
202+
return;
203+
}
204+
202205
Log.i(BaseApplication.TAG, "[CallService] dial()");
203206

204207
ServiceData serviceData = new ServiceData();
@@ -222,7 +225,7 @@ public static void onRinging(Context context, @NonNull DirectCall call) {
222225

223226
ServiceData serviceData = new ServiceData();
224227
serviceData.isHeadsUpNotification = true;
225-
serviceData.remoteNicknameOrUserId = UserInfoUtils.getNicknameOrUserId(call.getCallee());
228+
serviceData.remoteNicknameOrUserId = UserInfoUtils.getNicknameOrUserId(call.getRemoteUser());
226229
serviceData.callState = CallActivity.STATE.STATE_ACCEPTING;
227230
serviceData.callId = call.getCallId();
228231
serviceData.isVideoCall = call.isVideoCall();

app/src/main/java/com/sendbird/calls/quickstart/call/VideoCallActivity.java

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ protected void startCall(boolean amICallee) {
182182
Log.i(BaseApplication.TAG, "[VideoCallActivity] dial() => OK");
183183
updateCallService();
184184
});
185-
186185
setListener(mDirectCall);
187186
}
188187
}

app/src/main/java/com/sendbird/calls/quickstart/call/VoiceCallActivity.java

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ protected void startCall(boolean amICallee) {
137137
Log.i(BaseApplication.TAG, "[VoiceCallActivity] dial() => OK");
138138
updateCallService();
139139
});
140-
141140
setListener(mDirectCall);
142141
}
143142
}

app/src/main/java/com/sendbird/calls/quickstart/main/HistoryRecyclerViewAdapter.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.sendbird.calls.DirectCallUserRole;
1616
import com.sendbird.calls.quickstart.R;
1717
import com.sendbird.calls.quickstart.call.CallService;
18+
import com.sendbird.calls.quickstart.utils.EndResultUtils;
1819
import com.sendbird.calls.quickstart.utils.ImageUtils;
1920
import com.sendbird.calls.quickstart.utils.TimeUtils;
2021
import com.sendbird.calls.quickstart.utils.UserInfoUtils;
@@ -81,7 +82,7 @@ public void onBindViewHolder(@NonNull HistoryViewHolder holder, int position) {
8182

8283
String endResult = "";
8384
if (callLog.getEndResult() != null) {
84-
endResult = callLog.getEndResult().toString().toUpperCase();
85+
endResult = EndResultUtils.getEndResultString(mContext, callLog.getEndResult());
8586
}
8687
String endResultAndDuration = endResult + mContext.getString(R.string.calls_and_character) + TimeUtils.getTimeStringForHistory(callLog.getDuration());
8788
holder.textViewEndResultAndDuration.setText(endResultAndDuration);

0 commit comments

Comments
 (0)