Skip to content

Commit

Permalink
feat: update v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hiennguyen92 committed Mar 5, 2024
1 parent e893989 commit 65b1d1b
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 26 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
53 changes: 31 additions & 22 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 @@ -152,7 +160,7 @@ Our top sponsors are shown below!
```
* Hide notification call for Android
```
hideCallkitIncoming
hideCallkitIncoming({ id: 'uuid call' })
```

* Started an outgoing call
Expand Down Expand Up @@ -490,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
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 65b1d1b

Please sign in to comment.