Skip to content

Commit

Permalink
Merge pull request #470 from hiennguyen92/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hiennguyen92 authored Mar 5, 2024
2 parents bdaea1b + 65b1d1b commit 9aab413
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.2
* Add func `hideCallkitIncoming` clear the incoming notification/ring (after accept/decline/timeout)
* Add props `isShowFullLockedScreen` on Android
* Fixed example/Fixed update android 14

## 2.0.1+2
* Add Action for onDecline
* Add Action for onEnd
Expand Down
55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,35 @@ Our top sponsors are shown below!
```console
flutter pub add flutter_callkit_incoming
```
* Add pubspec.yaml:
```console
dependencies:
flutter_callkit_incoming: any
```
2. Configure Project
* Android
* AndroidManifest.xml
```
<manifest...>
...
<!--
Using for load image from internet
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
```
The following rule needs to be added in the proguard-rules.pro to avoid obfuscated keys.
```
-keep class com.hiennv.flutter_callkit_incoming.** { *; }
```
* Add pubspec.yaml:
```console
dependencies:
flutter_callkit_incoming: any
```
2. Configure Project
* Android
* AndroidManifest.xml
```
<manifest...>
...
<!--
Using for load image from internet
-->
<uses-permission android:name="android.permission.INTERNET"/>

<application ...>
<activity ...
android:name=".MainActivity"
android:launchMode="singleInstance">
...
...
</manifest>
```
The following rule needs to be added in the proguard-rules.pro to avoid obfuscated keys.
```
-keep class com.hiennv.flutter_callkit_incoming.** { *; }
```
* iOS
* Info.plist
```
Expand Down Expand Up @@ -150,6 +158,10 @@ Our top sponsors are shown below!
);
await FlutterCallkitIncoming.showMissCallNotification(params);
```
* Hide notification call for Android
```
hideCallkitIncoming({ id: 'uuid call' })
```

* Started an outgoing call
```dart
Expand Down Expand Up @@ -486,6 +498,7 @@ Our top sponsors are shown below!
| **`incomingCallNotificationChannelName`** | Notification channel name of incoming call. | `Incoming call` |
| **`missedCallNotificationChannelName`** | Notification channel name of missed call. | `Missed call` |
| **`isShowCallID`** | Show call id app inside full screen/notification. | false |
| **`isShowFullLockedScreen`** | Show full screen on Locked Screen. | true |

<br>

Expand Down
1 change: 0 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
android:taskAffinity="com.hiennv.flutter_callkit_incoming.INCOMING_CALL_AFFINITY"
android:excludeFromRecents="true"
android:noHistory="true"
android:showOnLockScreen="true"
android:turnScreenOn="true"
android:configChanges="orientation"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ data class Data(val args: Map<String, Any?>) {
@JsonProperty("isMuted")
var isMuted: Boolean = (args["isMuted"] as? Boolean) ?: false

@JsonProperty("isShowFullLockedScreen")
var isShowFullLockedScreen: Boolean = true

init {
var android: Map<String, Any?>? = args["android"] as? HashMap<String, Any?>?
android = android ?: args
Expand All @@ -97,6 +100,7 @@ data class Data(val args: Map<String, Any?>) {
incomingCallNotificationChannelName =
android["incomingCallNotificationChannelName"] as? String
missedCallNotificationChannelName = android["missedCallNotificationChannelName"] as? String
isShowFullLockedScreen = android["isShowFullLockedScreen"] as? Boolean ?: true

val missedNotification: Map<String, Any?>? =
args["missedCallNotification"] as? Map<String, Any?>?
Expand Down Expand Up @@ -206,6 +210,10 @@ data class Data(val args: Map<String, Any?>) {
CallkitConstants.EXTRA_CALLKIT_MISSED_CALL_NOTIFICATION_CHANNEL_NAME,
missedCallNotificationChannelName
)
bundle.putBoolean(
CallkitConstants.EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN,
isShowFullLockedScreen
)
return bundle
}

Expand Down Expand Up @@ -291,6 +299,10 @@ data class Data(val args: Map<String, Any?>) {
data.missedCallNotificationChannelName = bundle.getString(
CallkitConstants.EXTRA_CALLKIT_MISSED_CALL_NOTIFICATION_CHANNEL_NAME
)
data.isShowFullLockedScreen = bundle.getBoolean(
CallkitConstants.EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN,
true
)
return data
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ object CallkitConstants {
"EXTRA_CALLKIT_MISSED_CALL_NOTIFICATION_CHANNEL_NAME"

const val EXTRA_CALLKIT_ACTION_FROM = "EXTRA_CALLKIT_ACTION_FROM"

const val EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN = "EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN"
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@ class CallkitIncomingActivity : Activity() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
setTurnScreenOn(true)
setShowWhenLocked(true)
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD)
}
transparentStatusAndNavigation()
Expand Down Expand Up @@ -166,6 +164,15 @@ class CallkitIncomingActivity : Activity() {
val data = intent.extras?.getBundle(CallkitConstants.EXTRA_CALLKIT_INCOMING_DATA)
if (data == null) finish()

val isShowFullLockedScreen = data?.getBoolean(CallkitConstants.EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN, true)
if(isShowFullLockedScreen == true) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true)
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED)
}
}

val textColor = data?.getString(CallkitConstants.EXTRA_CALLKIT_TEXT_COLOR, "#ffffff")
val isShowCallID = data?.getBoolean(CallkitConstants.EXTRA_CALLKIT_IS_SHOW_CALL_ID, false)
tvNameCaller.text = data?.getString(CallkitConstants.EXTRA_CALLKIT_NAME_CALLER, "")
Expand Down
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdk 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -36,8 +36,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.hiennv.testing"
minSdkVersion 19
targetSdkVersion 33
minSdk 19
targetSdk 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
Expand Down
4 changes: 2 additions & 2 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class HomePageState extends State<HomePage> {
appName: 'Callkit',
avatar: 'https://i.pravatar.cc/100',
handle: '0123456789',
type: 1,
duration: 10000,
type: 0,
duration: 30000,
textAccept: 'Accept',
textDecline: 'Decline',
missedCallNotification: const NotificationParams(
Expand Down
4 changes: 4 additions & 0 deletions lib/entities/android_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AndroidParams {
this.textColor,
this.incomingCallNotificationChannelName,
this.missedCallNotificationChannelName,
this.isShowFullLockedScreen,
});

/// Using custom notifications.
Expand Down Expand Up @@ -52,6 +53,9 @@ class AndroidParams {
/// Notification channel name of missed call.
final String? missedCallNotificationChannelName;

/// Show full locked screen.
final bool? isShowFullLockedScreen;

factory AndroidParams.fromJson(Map<String, dynamic> json) =>
_$AndroidParamsFromJson(json);

Expand Down
3 changes: 3 additions & 0 deletions lib/entities/android_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_callkit_incoming
description: Flutter Callkit Incoming to show callkit screen in your Flutter app.
version: 2.0.1+2
version: 2.0.2
homepage: https://github.com/hiennguyen92/flutter_callkit_incoming
repository: https://github.com/hiennguyen92/flutter_callkit_incoming
issue_tracker: https://github.com/hiennguyen92/flutter_callkit_incoming/issues
Expand Down

0 comments on commit 9aab413

Please sign in to comment.