rns-nativecall 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,10 +32,16 @@ object NativeCallManager {
|
|
|
32
32
|
PendingIntent.FLAG_UPDATE_CURRENT
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// Prepare Common Bundle
|
|
36
|
+
val extras = Bundle().apply {
|
|
37
|
+
data.forEach { (k, v) -> putString(k, v) }
|
|
38
|
+
putString("EXTRA_CALL_UUID", uuid)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 1. UI Intent (When tapping the notification body)
|
|
36
42
|
val intentToActivity = Intent(context, AcceptCallActivity::class.java).apply {
|
|
37
43
|
action = "ACTION_SHOW_UI_$uuid"
|
|
38
|
-
|
|
44
|
+
putExtras(extras)
|
|
39
45
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
40
46
|
}
|
|
41
47
|
val fullScreenPendingIntent = PendingIntent.getActivity(
|
|
@@ -45,8 +51,7 @@ object NativeCallManager {
|
|
|
45
51
|
// 2. Reject Intent
|
|
46
52
|
val rejectIntent = Intent(context, CallActionReceiver::class.java).apply {
|
|
47
53
|
action = "ACTION_REJECT_$uuid"
|
|
48
|
-
|
|
49
|
-
data.forEach { (key, value) -> putExtra(key, value) }
|
|
54
|
+
putExtras(extras)
|
|
50
55
|
}
|
|
51
56
|
val rejectPendingIntent = PendingIntent.getBroadcast(
|
|
52
57
|
context, uuid.hashCode() + 1, rejectIntent, pendingFlags
|
|
@@ -55,8 +60,7 @@ object NativeCallManager {
|
|
|
55
60
|
// 3. Answer Intent
|
|
56
61
|
val answerIntent = Intent(context, CallActionReceiver::class.java).apply {
|
|
57
62
|
action = "ACTION_ACCEPT_$uuid"
|
|
58
|
-
|
|
59
|
-
data.forEach { (key, value) -> putExtra(key, value) }
|
|
63
|
+
putExtras(extras)
|
|
60
64
|
}
|
|
61
65
|
val answerPendingIntent = PendingIntent.getBroadcast(
|
|
62
66
|
context, uuid.hashCode() + 2, answerIntent, pendingFlags
|
|
@@ -74,34 +78,24 @@ object NativeCallManager {
|
|
|
74
78
|
notificationManager.createNotificationChannel(channel)
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
// FIX: Use IconCompat.createWithResource instead of raw Int
|
|
78
|
-
val caller = Person.Builder()
|
|
79
|
-
.setName(name)
|
|
80
|
-
.setImportant(true)
|
|
81
|
-
.setIcon(IconCompat.createWithResource(context, context.applicationInfo.icon))
|
|
82
|
-
.build()
|
|
83
|
-
|
|
84
81
|
val builder = NotificationCompat.Builder(context, CALL_CHANNEL_ID)
|
|
85
|
-
.setSmallIcon(context.applicationInfo.icon) // Ensure small icon is set
|
|
86
82
|
.setContentTitle("Incoming $callType call")
|
|
87
83
|
.setContentText(name)
|
|
88
84
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
|
89
85
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
90
86
|
.setOngoing(true)
|
|
91
87
|
.setAutoCancel(false)
|
|
92
|
-
.setFullScreenIntent(fullScreenPendingIntent, true)
|
|
88
|
+
.setFullScreenIntent(fullScreenPendingIntent, true) // Essential for waking screen
|
|
93
89
|
.setColor(Color.parseColor("#28a745"))
|
|
94
90
|
.setColorized(true)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
)
|
|
102
|
-
|
|
91
|
+
// ADDING ACTIONS MANUALLY TO CONTROL ORDER
|
|
92
|
+
// First Action added = Leftmost button
|
|
93
|
+
.addAction(0, "Answer", answerPendingIntent)
|
|
94
|
+
.addAction(0, "Decline", rejectPendingIntent)
|
|
95
|
+
|
|
103
96
|
notificationManager.notify(uuid.hashCode(), builder.build())
|
|
104
97
|
|
|
98
|
+
// Start Ringtone
|
|
105
99
|
try {
|
|
106
100
|
val ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
|
|
107
101
|
ringtone = RingtoneManager.getRingtone(context, ringtoneUri)
|
|
@@ -112,13 +106,9 @@ object NativeCallManager {
|
|
|
112
106
|
|
|
113
107
|
fun stopRingtone() {
|
|
114
108
|
try {
|
|
115
|
-
ringtone?.let {
|
|
116
|
-
if (it.isPlaying) it.stop()
|
|
117
|
-
}
|
|
109
|
+
ringtone?.let { if (it.isPlaying) it.stop() }
|
|
118
110
|
ringtone = null
|
|
119
|
-
} catch (e: Exception) {
|
|
120
|
-
e.printStackTrace()
|
|
121
|
-
}
|
|
111
|
+
} catch (e: Exception) { e.printStackTrace() }
|
|
122
112
|
}
|
|
123
113
|
|
|
124
114
|
fun dismissIncomingCall(context: Context, uuid: String?) {
|
package/package.json
CHANGED