Skip to content

Commit b1d2b7f

Browse files
Update to 1.1.3.
1 parent 889d803 commit b1d2b7f

File tree

100 files changed

+941
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+941
-214
lines changed

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.sendbird.calls.quickstart"
88
minSdkVersion 16 // [Calls]
99
targetSdkVersion 29
10-
versionCode 4
11-
versionName "1.0.2"
10+
versionCode 6
11+
versionName "1.1.3"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
}
1414
buildTypes {
@@ -31,9 +31,9 @@ dependencies {
3131
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
3232
implementation 'com.google.android.material:material:1.1.0'
3333

34-
implementation 'com.sendbird.sdk:sendbird-calls:1.0.2' // [Calls]
35-
implementation 'com.google.firebase:firebase-core:17.4.0' // [Calls] FCM
36-
implementation 'com.google.firebase:firebase-messaging:20.1.6' // [Calls] FCM
34+
implementation 'com.sendbird.sdk:sendbird-calls:1.1.3' // [Calls]
35+
implementation 'com.google.firebase:firebase-core:17.4.3' // [Calls] FCM
36+
implementation 'com.google.firebase:firebase-messaging:20.2.0' // [Calls] FCM
3737
implementation 'com.github.bumptech.glide:glide:4.11.0'
3838

3939
//+ [QRCode]

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.sendbird.calls.quickstart">
55

6-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- https://developer.android.com/guide/components/activities/background-starts -->
76
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" /> <!-- [QRCode] -->
7+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
88

99
<application
1010
android:name=".BaseApplication"
@@ -50,6 +50,8 @@
5050
android:theme="@style/CallTheme"
5151
android:screenOrientation="portrait"
5252
tools:ignore="LockedOrientationActivity" />
53+
<service android:name=".call.CallService"
54+
android:stopWithTask="false" />
5355

5456
<!-- [Calls] FCM -->
5557
<service

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88

99
import com.sendbird.calls.DirectCall;
1010
import com.sendbird.calls.SendBirdCall;
11+
import com.sendbird.calls.handler.DirectCallListener;
1112
import com.sendbird.calls.handler.SendBirdCallListener;
1213
import com.sendbird.calls.quickstart.call.CallActivity;
13-
import com.sendbird.calls.quickstart.utils.ActivityUtils;
14+
import com.sendbird.calls.quickstart.call.CallService;
1415
import com.sendbird.calls.quickstart.utils.PrefUtils;
1516

1617
import java.util.UUID;
1718

1819
public class BaseApplication extends Application {
1920

20-
public static final String VERSION = "1.0.2";
21+
public static final String VERSION = "1.1.3";
2122

2223
private static final String TAG = "BaseApplication";
2324

@@ -50,7 +51,21 @@ public void onRinging(DirectCall call) {
5051
call.end();
5152
return;
5253
}
53-
ActivityUtils.startCallActivityAsCallee(context, call);
54+
55+
call.setListener(new DirectCallListener() {
56+
@Override
57+
public void onConnected(DirectCall call) {
58+
}
59+
60+
@Override
61+
public void onEnded(DirectCall call) {
62+
if (!CallActivity.sIsRunning) {
63+
CallService.stopService(context);
64+
}
65+
}
66+
});
67+
68+
CallService.startService(context, call, true);
5469
}
5570
});
5671
return true;

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

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import com.sendbird.calls.SendBirdCall;
2424
import com.sendbird.calls.handler.DirectCallListener;
2525
import com.sendbird.calls.quickstart.R;
26-
import com.sendbird.calls.quickstart.utils.ActivityUtils;
2726
import com.sendbird.calls.quickstart.utils.AuthenticationUtils;
27+
import com.sendbird.calls.quickstart.utils.BroadcastUtils;
2828
import com.sendbird.calls.quickstart.utils.UserInfoUtils;
2929

3030
import java.util.ArrayList;
@@ -52,6 +52,7 @@ enum STATE {
5252

5353
Context mContext;
5454
private String mIncomingCallId;
55+
private boolean mIsEnd;
5556
private Timer mEndingTimer;
5657

5758
STATE mState;
@@ -103,23 +104,45 @@ protected void onCreate(Bundle savedInstanceState) {
103104
initViews();
104105
setViews();
105106

106-
mIncomingCallId = getIntent().getStringExtra(ActivityUtils.EXTRA_INCOMING_CALL_ID);
107+
init(getIntent());
108+
}
109+
110+
private void init(Intent intent) {
111+
mIncomingCallId = intent.getStringExtra(CallService.EXTRA_CALL_ID);
112+
mIsEnd = intent.getBooleanExtra(CallService.EXTRA_IS_END, false);
113+
114+
if (mIsEnd) {
115+
CallService.stopService(mContext);
116+
}
117+
107118
if (mIncomingCallId != null) { // as callee
108119
mDirectCall = SendBirdCall.getCall(mIncomingCallId);
109120
mCalleeId = mDirectCall.getCallee().getUserId();
110121
mIsVideoCall = mDirectCall.isVideoCall();
111122

112123
setListener(mDirectCall);
113124
} else { // as caller
114-
mCalleeId = getIntent().getStringExtra(ActivityUtils.EXTRA_CALLEE_ID);
115-
mIsVideoCall = getIntent().getBooleanExtra(ActivityUtils.EXTRA_IS_VIDEO_CALL, false);
125+
mCalleeId = intent.getStringExtra(CallService.EXTRA_CALLEE_ID);
126+
mIsVideoCall = intent.getBooleanExtra(CallService.EXTRA_IS_VIDEO_CALL, false);
116127
}
117128

118129
if (setInitialState()) {
119130
checkAuthenticate();
120131
}
121132
}
122133

134+
@Override
135+
protected void onNewIntent(Intent intent) {
136+
super.onNewIntent(intent);
137+
Log.d(TAG, "onNewIntent()");
138+
139+
mIsEnd = intent.getBooleanExtra(CallService.EXTRA_IS_END, false);
140+
if (mIsEnd) {
141+
CallService.stopService(mContext);
142+
end(mDirectCall);
143+
}
144+
}
145+
123146
protected void initViews() {
124147
mLinearLayoutInfo = findViewById(R.id.linear_layout_info);
125148
mImageViewProfile = findViewById(R.id.image_view_profile);
@@ -141,9 +164,7 @@ protected void initViews() {
141164

142165
protected void setViews() {
143166
mImageViewDecline.setOnClickListener(view -> {
144-
if (mDirectCall != null) {
145-
end(mDirectCall);
146-
}
167+
end(mDirectCall);
147168
});
148169

149170
mImageViewAccept.setOnClickListener(view -> {
@@ -152,7 +173,7 @@ protected void setViews() {
152173
return;
153174
}
154175

155-
if (mState == STATE.STATE_ENDING) {
176+
if (mState == STATE.STATE_ENDING || mState == STATE.STATE_ENDED) {
156177
Log.d(TAG, "mImageViewAccept clicked => Already ending call.");
157178
return;
158179
}
@@ -163,7 +184,6 @@ protected void setViews() {
163184
}
164185

165186
setState(STATE.STATE_ACCEPTING, mDirectCall);
166-
startCall(true);
167187
});
168188

169189
if (mIsAudioEnabled) {
@@ -188,9 +208,7 @@ protected void setViews() {
188208
});
189209

190210
mImageViewEnd.setOnClickListener(view -> {
191-
if (mDirectCall != null) {
192-
end(mDirectCall);
193-
}
211+
end(mDirectCall);
194212
});
195213
}
196214

@@ -208,6 +226,8 @@ public void onConnected(DirectCall call) {
208226
public void onEnded(DirectCall call) {
209227
Log.d(TAG, "onEnded()");
210228
setState(STATE.STATE_ENDED, call);
229+
230+
BroadcastUtils.sendCallLogBroadcast(mContext, call.getCallLog());
211231
}
212232

213233
@Override
@@ -229,18 +249,6 @@ public void onAudioDeviceChanged(DirectCall call, AudioDevice currentAudioDevice
229249
});
230250
}
231251

232-
@Override
233-
protected void onNewIntent(Intent intent) {
234-
super.onNewIntent(intent);
235-
Log.d(TAG, "onNewIntent()");
236-
237-
String incomingCallId = intent.getStringExtra(ActivityUtils.EXTRA_INCOMING_CALL_ID);
238-
if (incomingCallId != null) {
239-
DirectCall call = SendBirdCall.getCall(incomingCallId);
240-
call.end();
241-
}
242-
}
243-
244252
@TargetApi(19)
245253
private static int getSystemUiVisibility() {
246254
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
@@ -260,6 +268,8 @@ private boolean setInitialState() {
260268
return false;
261269
}
262270

271+
CallService.startService(mContext, mDirectCall, false);
272+
263273
setState(STATE.STATE_INCOMING, mDirectCall);
264274
} else {
265275
setState(STATE.STATE_OUTGOING, mDirectCall);
@@ -318,8 +328,15 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
318328
}
319329

320330
private void ready() {
331+
if (mIsEnd) {
332+
end(mDirectCall);
333+
return;
334+
}
335+
321336
if (mState == STATE.STATE_OUTGOING) {
322337
startCall(false);
338+
} else if (mState == STATE.STATE_INCOMING) {
339+
setState(STATE.STATE_ACCEPTING, mDirectCall);
323340
}
324341
}
325342

@@ -348,6 +365,7 @@ protected boolean setState(STATE state, DirectCall call) {
348365
}
349366

350367
case STATE_ACCEPTING: {
368+
startCall(true);
351369
setInfo(call, getString(R.string.calls_connecting_call));
352370
break;
353371
}
@@ -406,7 +424,7 @@ protected void setInfo(DirectCall call, String status) {
406424
DirectCallUser remoteUser = (call != null ? call.getRemoteUser() : null);
407425
if (remoteUser != null) {
408426
UserInfoUtils.setProfileImage(mContext, remoteUser, mImageViewProfile);
409-
UserInfoUtils.setUserId(remoteUser, mTextViewUserId);
427+
UserInfoUtils.setNicknameOrUserId(remoteUser, mTextViewUserId);
410428
} else {
411429
mTextViewUserId.setText(mCalleeId);
412430
}
@@ -476,7 +494,7 @@ protected void end(DirectCall call) {
476494
if (call != null) {
477495
Log.d(TAG, "end(callId: " + call.getCallId() + ")");
478496

479-
if (mState == STATE.STATE_ENDING) {
497+
if (mState == STATE.STATE_ENDING || mState == STATE.STATE_ENDED) {
480498
Log.d(TAG, "Already ending call.");
481499
return;
482500
}
@@ -497,6 +515,7 @@ public void run() {
497515
runOnUiThread(() -> {
498516
Log.d(TAG, "finish()");
499517
finish();
518+
CallService.stopService(mContext);
500519
});
501520
}
502521
}, ENDING_TIME_MS);
@@ -506,6 +525,7 @@ public void run() {
506525
@Override
507526
protected void onDestroy() {
508527
super.onDestroy();
528+
Log.d(TAG, "onDestroy()");
509529
sIsRunning = false;
510530
}
511531
}

0 commit comments

Comments
 (0)