diff --git a/CHANGELOG.md b/CHANGELOG.md index dad9abfd..cfb00032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 0c1b4ead..5e55696b 100644 --- a/README.md +++ b/README.md @@ -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 - ``` - - ... - - - - ``` - 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 + ``` + + ... + + + + + + ... + ... + + + ``` + 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 ``` @@ -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 @@ -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 |
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index fc2f0a8c..0bc478ba 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -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" diff --git a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/Call.kt b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/Call.kt index c9c6530e..cd17cb31 100644 --- a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/Call.kt +++ b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/Call.kt @@ -82,6 +82,9 @@ data class Data(val args: Map) { @JsonProperty("isMuted") var isMuted: Boolean = (args["isMuted"] as? Boolean) ?: false + @JsonProperty("isShowFullLockedScreen") + var isShowFullLockedScreen: Boolean = true + init { var android: Map? = args["android"] as? HashMap? android = android ?: args @@ -97,6 +100,7 @@ data class Data(val args: Map) { incomingCallNotificationChannelName = android["incomingCallNotificationChannelName"] as? String missedCallNotificationChannelName = android["missedCallNotificationChannelName"] as? String + isShowFullLockedScreen = android["isShowFullLockedScreen"] as? Boolean ?: true val missedNotification: Map? = args["missedCallNotification"] as? Map? @@ -206,6 +210,10 @@ data class Data(val args: Map) { CallkitConstants.EXTRA_CALLKIT_MISSED_CALL_NOTIFICATION_CHANNEL_NAME, missedCallNotificationChannelName ) + bundle.putBoolean( + CallkitConstants.EXTRA_CALLKIT_IS_SHOW_FULL_LOCKED_SCREEN, + isShowFullLockedScreen + ) return bundle } @@ -291,6 +299,10 @@ data class Data(val args: Map) { 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 } } diff --git a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitConstants.kt b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitConstants.kt index 4b75137b..2e07d360 100644 --- a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitConstants.kt +++ b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitConstants.kt @@ -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" } diff --git a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitIncomingActivity.kt b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitIncomingActivity.kt index e0a2fd06..cd16b491 100644 --- a/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitIncomingActivity.kt +++ b/android/src/main/kotlin/com/hiennv/flutter_callkit_incoming/CallkitIncomingActivity.kt @@ -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() @@ -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, "") diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 814abde3..5fb579c2 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -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' @@ -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 diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index f6918e55..abf48f61 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -138,8 +138,8 @@ class HomePageState extends State { 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( diff --git a/lib/entities/android_params.dart b/lib/entities/android_params.dart index 93191abc..c4cb2f7f 100644 --- a/lib/entities/android_params.dart +++ b/lib/entities/android_params.dart @@ -17,6 +17,7 @@ class AndroidParams { this.textColor, this.incomingCallNotificationChannelName, this.missedCallNotificationChannelName, + this.isShowFullLockedScreen, }); /// Using custom notifications. @@ -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 json) => _$AndroidParamsFromJson(json); diff --git a/lib/entities/android_params.g.dart b/lib/entities/android_params.g.dart index 66b931af..223e3e52 100644 --- a/lib/entities/android_params.g.dart +++ b/lib/entities/android_params.g.dart @@ -21,6 +21,8 @@ AndroidParams _$AndroidParamsFromJson(Map json) => json['incomingCallNotificationChannelName'] as String?, missedCallNotificationChannelName: json['missedCallNotificationChannelName'] as String?, + isShowFullLockedScreen: + json['isShowFullLockedScreen'] as bool?, ); Map _$AndroidParamsToJson(AndroidParams instance) => @@ -38,4 +40,5 @@ Map _$AndroidParamsToJson(AndroidParams instance) => instance.incomingCallNotificationChannelName, 'missedCallNotificationChannelName': instance.missedCallNotificationChannelName, + 'isShowFullLockedScreen': instance.isShowFullLockedScreen, }; diff --git a/pubspec.yaml b/pubspec.yaml index df7577ee..b4eae47d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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