Skip to content

Commit 5d48e68

Browse files
Merge pull request #118 from ConnectyCube/development
Release 2.4.0
2 parents 4e62f10 + e286f5b commit 5d48e68

25 files changed

+461
-199
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.4.0
2+
- (Android) Add the Call photo to the Call notification and the Incoming call screen;
3+
- (Android) Add different icons to the Accept buttons depending on the call type;
4+
- (Android) Add the possibility for setting the Notification icon depending on the call type;
5+
16
## 2.3.0
27
- (iOS) Add a method for notifying the CallKit about muting/unmuting the call;
38
- (iOS) Improvements for audio after accepting the call from the background or killed state;

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ getting token and displaying the Incoming call screen.
2222
- some customizations according to your app needs (ringtone, icon, accent color(for Android))
2323

2424

25-
<kbd><img alt="Flutter P2P Calls code sample, incoming call in background Android" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_android.png" height="440" /></kbd> <kbd><img alt="Flutter P2P Calls code sample, incoming call locked Android" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_android_locked.png" height="440" /></kbd> <kbd><img alt="Flutter P2P Calls code sample, incoming call in background iOS" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_ios.PNG" height="440" /></kbd>
25+
<kbd><img alt="Flutter P2P Calls code sample, incoming call in background Android" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_android.png" height="440" /></kbd>
26+
<kbd><img alt="Flutter P2P Calls code sample, incoming call locked Android" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_android_locked.png" height="440" /></kbd>
27+
<kbd><img alt="Flutter P2P Calls code sample, incoming call in background iOS" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_ios.PNG" height="440" /></kbd>
2628
<kbd><img alt="Flutter P2P Calls code sample, incoming call locked iOS" src="https://developers.connectycube.com/docs/_images/code_samples/flutter/background_call_ios_locked.PNG" height="440" /></kbd>
2729

2830
## Configure your project
@@ -82,11 +84,30 @@ and notification accent color (Android only). Use the next method for it:
8284
```dart
8385
ConnectycubeFlutterCallKit.instance.updateConfig(
8486
ringtone: 'custom_ringtone',
85-
icon: 'app_icon',
86-
notificationIcon: 'ic_notification',
87+
icon: Platform.isAndroid ? 'default_avatar' : 'CallKitIcon', // is used as an avatar placeholder for Android and as the app icon for iOS
8788
color: '#07711e');
8889
```
8990

91+
#### [Android only] Notification icon customisation
92+
You can set different icons for Audion and Video calls, add suitable resources to your
93+
`android/app/src/main/AndroidManifest.xml` to the `application` section for it:
94+
```xml
95+
<meta-data
96+
android:name="com.connectycube.flutter.connectycube_flutter_call_kit.audio_call_notification_icon"
97+
android:resource="@drawable/ic_notification_audio_call" />
98+
99+
<meta-data
100+
android:name="com.connectycube.flutter.connectycube_flutter_call_kit.video_call_notification_icon"
101+
android:resource="@drawable/ic_notification_video_call" />
102+
```
103+
104+
If you don't need it, add only the default notification icon:
105+
```xml
106+
<meta-data
107+
android:name="com.connectycube.flutter.connectycube_flutter_call_kit.app_notification_icon"
108+
android:resource="@drawable/ic_notification" />
109+
```
110+
90111
### Show Incoming call notification
91112

92113
```dart
@@ -98,6 +119,7 @@ CallEvent callEvent = CallEvent(
98119
callerId: incomingCall.callerId,
99120
callerName: 'Caller Name',
100121
opponentsIds: incomingCall.opponentsIds,
122+
callPhoto: 'https://i.imgur.com/KwrDil8b.jpg',
101123
userInfo: {'customParameter1': 'value1'});
102124
ConnectycubeFlutterCallKit.showCallNotification(callEvent);
103125
```
@@ -221,6 +243,7 @@ params.parameters = {
221243
'caller_id': currentCall.callerId,
222244
'caller_name': callerName,
223245
'call_opponents': currentCall.opponentsIds.join(','),
246+
'photo_url': 'https://i.imgur.com/KwrDil8b.jpg'
224247
'signal_type': 'startCall',
225248
'ios_voip': 1,
226249
};

android/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ group 'com.connectycube.flutter.connectycube_flutter_call_kit'
22
version '2.3.0'
33

44
buildscript {
5-
ext.kotlin_version = '1.6.21'
5+
ext.kotlin_version = '1.9.10'
66
repositories {
77
google()
88
mavenCentral()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:4.0.2'
12+
classpath 'com.android.tools.build:gradle:7.4.2'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
classpath 'com.google.gms:google-services:4.3.10'
1515
}
@@ -26,7 +26,7 @@ apply plugin: 'com.android.library'
2626
apply plugin: 'kotlin-android'
2727

2828
android {
29-
compileSdkVersion 29
29+
compileSdkVersion 34
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -42,6 +42,11 @@ android {
4242
dependencies {
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4444
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
45+
implementation 'androidx.core:core-ktx:1.12.0'
46+
implementation 'com.google.android.material:material:1.10.0'
47+
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
48+
implementation 'com.github.bumptech.glide:glide:4.14.2'
49+
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
4550

4651
implementation platform('com.google.firebase:firebase-bom:29.0.3')
4752
implementation 'com.google.firebase:firebase-messaging-ktx'

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip

android/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.connectycube.flutter.connectycube_flutter_call_kit">
33

4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
46
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
57

68
<application>
79
<receiver android:name=".EventReceiver" />
810
<activity
911
android:name=".IncomingCallActivity"
1012
android:excludeFromRecents="true"
13+
android:inheritShowWhenLocked="true"
1114
android:noHistory="true"
1215
android:screenOrientation="sensorPortrait"
16+
android:showForAllUsers="true"
1317
android:showOnLockScreen="true"
1418
android:showWhenLocked="true"
1519
android:taskAffinity="com.connectycube.flutter.connectycube_flutter_call_kit.INCOMING_CALL_AFFINITY"
16-
android:theme="@android:style/Theme.Holo.NoActionBar"
20+
android:theme="@style/CallkitIncomingTheme"
1721
android:turnScreenOn="true" />
1822

1923
<service

android/src/main/kotlin/com/connectycube/flutter/connectycube_flutter_call_kit/ConnectycubeFCMReceiver.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ class ConnectycubeFCMReceiver : BroadcastReceiver() {
6767
val callType = data["call_type"]?.toInt()
6868
val callInitiatorId = data["caller_id"]?.toInt()
6969
val callInitiatorName = data["caller_name"]
70+
val callPhoto = data["photo_url"]
7071
val callOpponentsString = data["call_opponents"]
7172
var callOpponents = ArrayList<Int>()
7273
if (callOpponentsString != null) {
7374
callOpponents = ArrayList(callOpponentsString.split(',').map { it.toInt() })
7475
}
75-
7676
val userInfo = data["user_info"] ?: JSONObject(emptyMap<String, String>()).toString()
7777

7878
if (callType == null || callInitiatorId == null || callInitiatorName == null || callOpponents.isEmpty()) {
@@ -86,6 +86,7 @@ class ConnectycubeFCMReceiver : BroadcastReceiver() {
8686
callInitiatorId,
8787
callInitiatorName,
8888
callOpponents,
89+
callPhoto,
8990
userInfo
9091
)
9192

android/src/main/kotlin/com/connectycube/flutter/connectycube_flutter_call_kit/ConnectycubeFlutterCallKitPlugin.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class ConnectycubeFlutterCallKitPlugin : FlutterPlugin, MethodCallHandler,
147147
val callOpponents = ArrayList((arguments["call_opponents"] as String)
148148
.split(',')
149149
.map { it.toInt() })
150+
val callPhoto = arguments["photo_url"] as String?
150151
val userInfo = arguments["user_info"] as String
151152

152153
showCallNotification(
@@ -156,6 +157,7 @@ class ConnectycubeFlutterCallKitPlugin : FlutterPlugin, MethodCallHandler,
156157
callInitiatorId,
157158
callInitiatorName,
158159
callOpponents,
160+
callPhoto,
159161
userInfo
160162
)
161163

@@ -293,7 +295,7 @@ class ConnectycubeFlutterCallKitPlugin : FlutterPlugin, MethodCallHandler,
293295
}
294296

295297
"muteCall" -> {
296-
result.success(null)
298+
result.success(null)
297299
}
298300

299301
else ->
@@ -532,6 +534,7 @@ class CallStreamHandler(private var context: Context) : EventChannel.StreamHandl
532534
callEventMap["caller_name"] = intent.getStringExtra(EXTRA_CALL_INITIATOR_NAME)
533535
callEventMap["call_opponents"] =
534536
intent.getIntegerArrayListExtra(EXTRA_CALL_OPPONENTS)?.joinToString(separator = ",")
537+
callEventMap["photo_url"] = intent.getStringExtra(EXTRA_CALL_PHOTO)
535538
callEventMap["user_info"] = intent.getStringExtra(EXTRA_CALL_USER_INFO)
536539

537540
Log.d("ConnectycubeFlutterCallKitPlugin", "callEventMap: $callEventMap")

android/src/main/kotlin/com/connectycube/flutter/connectycube_flutter_call_kit/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const val EXTRA_CALL_INITIATOR_NAME = "extra_call_initiator_name"
77
const val EXTRA_CALL_OPPONENTS = "extra_call_opponents"
88
const val EXTRA_CALL_USER_INFO = "extra_call_user_info"
99
const val EXTRA_PUSH_TOKEN = "extra_push_token"
10+
const val EXTRA_CALL_PHOTO = "photo_url"
1011

1112
const val ACTION_CALL_ACCEPT = "action_call_accept"
1213
const val ACTION_CALL_REJECT = "action_call_reject"

android/src/main/kotlin/com/connectycube/flutter/connectycube_flutter_call_kit/EventReceiver.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class EventReceiver : BroadcastReceiver() {
2626
val callInitiatorId = extras?.getInt(EXTRA_CALL_INITIATOR_ID)
2727
val callInitiatorName = extras?.getString(EXTRA_CALL_INITIATOR_NAME)
2828
val callOpponents = extras?.getIntegerArrayList(EXTRA_CALL_OPPONENTS)
29+
val callPhoto = extras?.getString(EXTRA_CALL_PHOTO)
2930
val userInfo = extras?.getString(EXTRA_CALL_USER_INFO)
3031
Log.i(TAG, "NotificationReceiver onReceive Call REJECT, callId: $callId")
3132

@@ -36,6 +37,7 @@ class EventReceiver : BroadcastReceiver() {
3637
bundle.putInt(EXTRA_CALL_INITIATOR_ID, callInitiatorId!!)
3738
bundle.putString(EXTRA_CALL_INITIATOR_NAME, callInitiatorName)
3839
bundle.putIntegerArrayList(EXTRA_CALL_OPPONENTS, callOpponents)
40+
bundle.putString(EXTRA_CALL_PHOTO, callPhoto)
3941
bundle.putString(EXTRA_CALL_USER_INFO, userInfo)
4042
broadcastIntent.putExtras(bundle)
4143

@@ -62,6 +64,7 @@ class EventReceiver : BroadcastReceiver() {
6264
val callInitiatorId = extras?.getInt(EXTRA_CALL_INITIATOR_ID)
6365
val callInitiatorName = extras?.getString(EXTRA_CALL_INITIATOR_NAME)
6466
val callOpponents = extras?.getIntegerArrayList(EXTRA_CALL_OPPONENTS)
67+
val callPhoto = extras?.getString(EXTRA_CALL_PHOTO)
6568
val userInfo = extras?.getString(EXTRA_CALL_USER_INFO)
6669
Log.i(TAG, "NotificationReceiver onReceive Call ACCEPT, callId: $callId")
6770

@@ -72,6 +75,7 @@ class EventReceiver : BroadcastReceiver() {
7275
bundle.putInt(EXTRA_CALL_INITIATOR_ID, callInitiatorId!!)
7376
bundle.putString(EXTRA_CALL_INITIATOR_NAME, callInitiatorName)
7477
bundle.putIntegerArrayList(EXTRA_CALL_OPPONENTS, callOpponents)
78+
bundle.putString(EXTRA_CALL_PHOTO, callPhoto)
7579
bundle.putString(EXTRA_CALL_USER_INFO, userInfo)
7680
broadcastIntent.putExtras(bundle)
7781

@@ -101,6 +105,7 @@ class EventReceiver : BroadcastReceiver() {
101105
val callType = extras?.getInt(EXTRA_CALL_TYPE)
102106
val callInitiatorId = extras?.getInt(EXTRA_CALL_INITIATOR_ID)
103107
val callInitiatorName = extras?.getString(EXTRA_CALL_INITIATOR_NAME)
108+
val callPhoto = extras?.getString(EXTRA_CALL_PHOTO)
104109
val userInfo = extras?.getString(EXTRA_CALL_USER_INFO)
105110
Log.i(
106111
TAG,

android/src/main/kotlin/com/connectycube/flutter/connectycube_flutter_call_kit/IncomingCallActivity.kt

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ import android.widget.ImageView
1515
import android.widget.TextView
1616
import androidx.annotation.Nullable
1717
import androidx.localbroadcastmanager.content.LocalBroadcastManager
18+
import com.bumptech.glide.Glide
19+
import com.connectycube.flutter.connectycube_flutter_call_kit.utils.getPhotoPlaceholderResId
20+
import com.google.android.material.imageview.ShapeableImageView
21+
import com.skyfishjy.library.RippleBackground
1822

1923

2024
fun createStartIncomingScreenIntent(
2125
context: Context, callId: String, callType: Int, callInitiatorId: Int,
22-
callInitiatorName: String, opponents: ArrayList<Int>, userInfo: String
26+
callInitiatorName: String, opponents: ArrayList<Int>, callPhoto: String?, userInfo: String
2327
): Intent {
2428
val intent = Intent(context, IncomingCallActivity::class.java)
2529
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
@@ -28,6 +32,7 @@ fun createStartIncomingScreenIntent(
2832
intent.putExtra(EXTRA_CALL_INITIATOR_ID, callInitiatorId)
2933
intent.putExtra(EXTRA_CALL_INITIATOR_NAME, callInitiatorName)
3034
intent.putIntegerArrayListExtra(EXTRA_CALL_OPPONENTS, opponents)
35+
intent.putExtra(EXTRA_CALL_PHOTO, callPhoto)
3136
intent.putExtra(EXTRA_CALL_USER_INFO, userInfo)
3237
return intent
3338
}
@@ -41,6 +46,7 @@ class IncomingCallActivity : Activity() {
4146
private var callInitiatorId = -1
4247
private var callInitiatorName: String? = null
4348
private var callOpponents: ArrayList<Int>? = ArrayList()
49+
private var callPhoto: String? = null
4450
private var callUserInfo: String? = null
4551

4652

@@ -59,6 +65,10 @@ class IncomingCallActivity : Activity() {
5965
)
6066
}
6167

68+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q){
69+
setInheritShowWhenLocked(true)
70+
}
71+
6272
processIncomingData(intent)
6373
initUi()
6474
initCallStateReceiver()
@@ -80,6 +90,7 @@ class IncomingCallActivity : Activity() {
8090
ACTION_CALL_NOTIFICATION_CANCELED, ACTION_CALL_REJECT, ACTION_CALL_ENDED -> {
8191
finishAndRemoveTask()
8292
}
93+
8394
ACTION_CALL_ACCEPT -> finishDelayed()
8495
}
8596
}
@@ -116,6 +127,7 @@ class IncomingCallActivity : Activity() {
116127
callInitiatorId = intent.getIntExtra(EXTRA_CALL_INITIATOR_ID, -1)
117128
callInitiatorName = intent.getStringExtra(EXTRA_CALL_INITIATOR_NAME)
118129
callOpponents = intent.getIntegerArrayListExtra(EXTRA_CALL_OPPONENTS)
130+
callPhoto = intent.getStringExtra(EXTRA_CALL_PHOTO)
119131
callUserInfo = intent.getStringExtra(EXTRA_CALL_USER_INFO)
120132
}
121133

@@ -127,21 +139,40 @@ class IncomingCallActivity : Activity() {
127139
findViewById(resources.getIdentifier("call_type_txt", "id", packageName))
128140
callSubTitleTxt.text =
129141
String.format(CALL_TYPE_PLACEHOLDER, if (callType == 1) "Video" else "Audio")
130-
val avatarImg: ImageView =
142+
143+
val callAcceptButton: ImageView =
144+
findViewById(resources.getIdentifier("start_call_btn", "id", packageName))
145+
val acceptButtonIconName = if (callType == 1) "ic_video_call_start" else "ic_call_start"
146+
callAcceptButton.setImageResource(
147+
resources.getIdentifier(
148+
acceptButtonIconName,
149+
"drawable",
150+
packageName
151+
)
152+
)
153+
154+
val avatarImg: ShapeableImageView =
131155
findViewById(resources.getIdentifier("avatar_img", "id", packageName))
132156

133-
val defaultImgResId = resources.getIdentifier("connectycube_place_holder", "drawable", packageName)
134-
val customAvatarResName = com.connectycube.flutter.connectycube_flutter_call_kit.utils.getString(this, "icon")
135-
if (TextUtils.isEmpty(customAvatarResName)){
136-
avatarImg.setImageResource(defaultImgResId)
157+
val defaultPhotoResId = getPhotoPlaceholderResId(applicationContext)
158+
159+
if (!TextUtils.isEmpty(callPhoto)) {
160+
Glide.with(applicationContext)
161+
.load(callPhoto)
162+
.error(defaultPhotoResId)
163+
.placeholder(defaultPhotoResId)
164+
.into(avatarImg)
137165
} else {
138-
val imgResourceId = resources.getIdentifier(customAvatarResName, "drawable", packageName)
139-
if (imgResourceId != 0){
140-
avatarImg.setImageResource(imgResourceId)
141-
} else {
142-
avatarImg.setImageResource(defaultImgResId)
143-
}
166+
avatarImg.setImageResource(defaultPhotoResId)
144167
}
168+
169+
val acceptButtonAnimation: RippleBackground =
170+
findViewById(resources.getIdentifier("accept_button_animation", "id", packageName))
171+
acceptButtonAnimation.startRippleAnimation()
172+
173+
val rejectButtonAnimation: RippleBackground =
174+
findViewById(resources.getIdentifier("reject_button_animation", "id", packageName))
175+
rejectButtonAnimation.startRippleAnimation()
145176
}
146177

147178
// calls from layout file
@@ -152,6 +183,7 @@ class IncomingCallActivity : Activity() {
152183
bundle.putInt(EXTRA_CALL_INITIATOR_ID, callInitiatorId)
153184
bundle.putString(EXTRA_CALL_INITIATOR_NAME, callInitiatorName)
154185
bundle.putIntegerArrayList(EXTRA_CALL_OPPONENTS, callOpponents)
186+
bundle.putString(EXTRA_CALL_PHOTO, callPhoto)
155187
bundle.putString(EXTRA_CALL_USER_INFO, callUserInfo)
156188

157189
val endCallIntent = Intent(this, EventReceiver::class.java)
@@ -168,6 +200,7 @@ class IncomingCallActivity : Activity() {
168200
bundle.putInt(EXTRA_CALL_INITIATOR_ID, callInitiatorId)
169201
bundle.putString(EXTRA_CALL_INITIATOR_NAME, callInitiatorName)
170202
bundle.putIntegerArrayList(EXTRA_CALL_OPPONENTS, callOpponents)
203+
bundle.putString(EXTRA_CALL_PHOTO, callPhoto)
171204
bundle.putString(EXTRA_CALL_USER_INFO, callUserInfo)
172205

173206
val startCallIntent = Intent(this, EventReceiver::class.java)

0 commit comments

Comments
 (0)