Skip to content

Commit

Permalink
Update to 1.3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
sf-tyler-jeong committed Sep 23, 2020
1 parent 7e1b425 commit 15840ba
Show file tree
Hide file tree
Showing 24 changed files with 340 additions and 203 deletions.
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Sendbird Calls for Android Quickstart

![Platform](https://img.shields.io/badge/platform-ANDROID-orange.svg)
![Languages](https://img.shields.io/badge/language-JAVA-orange.svg)

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

## Introduction

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.
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.

### More about Sendbird Calls for Android

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

### Requirements

The minimum requirements for Calls SDK for Android sample are:
The minimum requirements for Calls SDK for Android sample are:

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

## Getting started

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

### Create a Sendbird application

Expand Down Expand Up @@ -65,9 +66,9 @@ public class BaseApplication extends Application {

### Build and run the sample app

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

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

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

<br />

### Sound Effects

You can use different sound effects to enhance the user experience for events that take place while using Sendbird Calls.

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.

```java
// Play on a caller’s side when making a call.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.DIALING, R.raw.dialing);
// Play on a callee’s side when receiving a call.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RINGING, R.raw.ringing);
// Play when a connection is lost, but the SDK immediately attempts to reconnect.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTING, R.raw.reconnecting);
// Play when the connection is re-established.
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTED, R.raw.reconnected);
```

<br />

## Reference

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).
22 changes: 12 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ android {
applicationId "com.sendbird.calls.quickstart"
minSdkVersion 16 // [Calls]
targetSdkVersion 29
versionCode 7
versionName "1.2.0"
versionCode 8
versionName "1.3.0"
multiDexEnabled true // multidex
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -27,13 +28,14 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.multidex:multidex:2.0.1' // multidex

implementation 'com.sendbird.sdk:sendbird-calls:1.2.0' // [Calls]
implementation 'com.google.firebase:firebase-core:17.4.4' // [Calls] FCM
implementation 'com.google.firebase:firebase-messaging:20.2.3' // [Calls] FCM
implementation 'com.sendbird.sdk:sendbird-calls:1.3.0' // [Calls]
implementation 'com.google.firebase:firebase-core:17.5.0' // [Calls] FCM
implementation 'com.google.firebase:firebase-messaging:20.2.4' // [Calls] FCM
implementation 'com.github.bumptech.glide:glide:4.11.0'

//+ [QRCode]
Expand All @@ -42,8 +44,8 @@ dependencies {
//- [QRCode]

testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

apply plugin: 'com.google.gms.google-services' // [Calls] FCM
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "sendbird://” -->
<data android:scheme="sendbird" />
</intent-filter>
</activity>

<activity android:name=".AuthenticateActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.sendbird.calls.quickstart;


import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import androidx.multidex.MultiDexApplication;

import com.sendbird.calls.DirectCall;
import com.sendbird.calls.SendBirdCall;
import com.sendbird.calls.handler.DirectCallListener;
Expand All @@ -16,9 +17,9 @@

import java.util.UUID;

public class BaseApplication extends Application {
public class BaseApplication extends MultiDexApplication { // multidex

public static final String VERSION = "1.2.0";
public static final String VERSION = "1.3.0";

public static final String TAG = "SendBirdCalls";

Expand Down Expand Up @@ -75,6 +76,11 @@ public void onEnded(DirectCall call) {
CallService.onRinging(context, call);
}
});

SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.DIALING, R.raw.dialing);
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RINGING, R.raw.ringing);
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTING, R.raw.reconnecting);
SendBirdCall.Options.addDirectCallSound(SendBirdCall.SoundType.RECONNECTED, R.raw.reconnected);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.sendbird.calls.quickstart;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

import com.sendbird.calls.quickstart.utils.ActivityUtils;
import com.sendbird.calls.quickstart.utils.AuthenticationUtils;
import com.sendbird.calls.quickstart.utils.ToastUtils;

import java.util.Timer;
import java.util.TimerTask;
Expand All @@ -19,6 +23,7 @@ public class SplashActivity extends AppCompatActivity {
private Context mContext;
private Timer mTimer;
private Boolean mAutoAuthenticateResult;
private String mEncodedAuthInfo;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -28,7 +33,30 @@ protected void onCreate(Bundle savedInstanceState) {
mContext = this;

setTimer();
autoAuthenticate();

if (!hasDeepLink()) {
autoAuthenticate();
}
}

private boolean hasDeepLink() {
boolean result = false;

Intent intent = getIntent();
if (intent != null) {
Uri data = intent.getData();
if (data != null) {
String scheme = data.getScheme();
if (scheme != null && scheme.equals("sendbird")) {
Log.i(BaseApplication.TAG, "[SplashActivity] deep link: " + data.toString());
mEncodedAuthInfo = data.getHost();
if (!TextUtils.isEmpty(mEncodedAuthInfo)) {
result = true;
}
}
}
}
return result;
}

private void setTimer() {
Expand All @@ -38,6 +66,23 @@ private void setTimer() {
public void run() {
runOnUiThread(() -> {
mTimer = null;

if (!TextUtils.isEmpty(mEncodedAuthInfo)) {
AuthenticationUtils.authenticateWithEncodedAuthInfo(SplashActivity.this, mEncodedAuthInfo, (isSuccess, hasInvalidValue) -> {
if (isSuccess) {
ActivityUtils.startMainActivityAndFinish(SplashActivity.this);
} else {
if (hasInvalidValue) {
ToastUtils.showToast(SplashActivity.this, getString(R.string.calls_invalid_deep_link));
} else {
ToastUtils.showToast(SplashActivity.this, getString(R.string.calls_deep_linking_to_authenticate_failed));
}
finish();
}
});
return;
}

if (mAutoAuthenticateResult != null) {
if (mAutoAuthenticateResult) {
ActivityUtils.startMainActivityAndFinish(SplashActivity.this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.sendbird.calls.quickstart.R;
import com.sendbird.calls.quickstart.utils.AuthenticationUtils;
import com.sendbird.calls.quickstart.utils.BroadcastUtils;
import com.sendbird.calls.quickstart.utils.EndResultUtils;
import com.sendbird.calls.quickstart.utils.UserInfoUtils;

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

String status = getEndResultString(call);
String status = "";
if (call != null) {
status = EndResultUtils.getEndResultString(mContext, call.getEndResult());
}
setInfo(call, status);
finishWithEnding(status);
break;
Expand Down Expand Up @@ -409,47 +413,6 @@ private void setRemoteMuteInfo(DirectCall call) {
}
}

private String getEndResultString(DirectCall call) {
String endResultString = "";
if (call != null) {
switch (call.getEndResult()) {
case NONE:
break;
case NO_ANSWER:
endResultString = getString(R.string.calls_end_result_no_answer);
break;
case CANCELED:
endResultString = getString(R.string.calls_end_result_canceled);
break;
case DECLINED:
endResultString = getString(R.string.calls_end_result_declined);
break;
case COMPLETED:
endResultString = getString(R.string.calls_end_result_completed);
break;
case TIMED_OUT:
endResultString = getString(R.string.calls_end_result_timed_out);
break;
case CONNECTION_LOST:
endResultString = getString(R.string.calls_end_result_connection_lost);
break;
case UNKNOWN:
endResultString = getString(R.string.calls_end_result_unknown);
break;
case DIAL_FAILED:
endResultString = getString(R.string.calls_end_result_dial_failed);
break;
case ACCEPT_FAILED:
endResultString = getString(R.string.calls_end_result_accept_failed);
break;
case OTHER_DEVICE_ACCEPTED:
endResultString = getString(R.string.calls_end_result_other_device_accepted);
break;
}
}
return endResultString;
}

@Override
public void onBackPressed() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.sendbird.calls.SendBirdCall;
import com.sendbird.calls.quickstart.BaseApplication;
import com.sendbird.calls.quickstart.R;
import com.sendbird.calls.quickstart.utils.ToastUtils;
import com.sendbird.calls.quickstart.utils.UserInfoUtils;

public class CallService extends Service {
Expand Down Expand Up @@ -64,10 +65,6 @@ static class ServiceData {
ServiceData() {
}

ServiceData(ServiceData serviceData) {
set(serviceData);
}

void set(ServiceData serviceData) {
this.isHeadsUpNotification = serviceData.isHeadsUpNotification;
this.remoteNicknameOrUserId = serviceData.remoteNicknameOrUserId;
Expand Down Expand Up @@ -199,6 +196,12 @@ private Notification getNotification(@NonNull ServiceData serviceData) {
}

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

Log.i(BaseApplication.TAG, "[CallService] dial()");

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

ServiceData serviceData = new ServiceData();
serviceData.isHeadsUpNotification = true;
serviceData.remoteNicknameOrUserId = UserInfoUtils.getNicknameOrUserId(call.getCallee());
serviceData.remoteNicknameOrUserId = UserInfoUtils.getNicknameOrUserId(call.getRemoteUser());
serviceData.callState = CallActivity.STATE.STATE_ACCEPTING;
serviceData.callId = call.getCallId();
serviceData.isVideoCall = call.isVideoCall();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ protected void startCall(boolean amICallee) {
Log.i(BaseApplication.TAG, "[VideoCallActivity] dial() => OK");
updateCallService();
});

setListener(mDirectCall);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ protected void startCall(boolean amICallee) {
Log.i(BaseApplication.TAG, "[VoiceCallActivity] dial() => OK");
updateCallService();
});

setListener(mDirectCall);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.sendbird.calls.DirectCallUserRole;
import com.sendbird.calls.quickstart.R;
import com.sendbird.calls.quickstart.call.CallService;
import com.sendbird.calls.quickstart.utils.EndResultUtils;
import com.sendbird.calls.quickstart.utils.ImageUtils;
import com.sendbird.calls.quickstart.utils.TimeUtils;
import com.sendbird.calls.quickstart.utils.UserInfoUtils;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void onBindViewHolder(@NonNull HistoryViewHolder holder, int position) {

String endResult = "";
if (callLog.getEndResult() != null) {
endResult = callLog.getEndResult().toString().toUpperCase();
endResult = EndResultUtils.getEndResultString(mContext, callLog.getEndResult());
}
String endResultAndDuration = endResult + mContext.getString(R.string.calls_and_character) + TimeUtils.getTimeStringForHistory(callLog.getDuration());
holder.textViewEndResultAndDuration.setText(endResultAndDuration);
Expand Down
Loading

0 comments on commit 15840ba

Please sign in to comment.