rns-nativecall 0.5.1 → 0.5.3
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,25 @@ 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)
|
|
82
|
+
.setSmallIcon(context.applicationInfo.icon)
|
|
86
83
|
.setContentTitle("Incoming $callType call")
|
|
87
84
|
.setContentText(name)
|
|
88
85
|
.setPriority(NotificationCompat.PRIORITY_MAX)
|
|
89
86
|
.setCategory(NotificationCompat.CATEGORY_CALL)
|
|
90
87
|
.setOngoing(true)
|
|
91
88
|
.setAutoCancel(false)
|
|
92
|
-
.setFullScreenIntent(fullScreenPendingIntent, true)
|
|
89
|
+
.setFullScreenIntent(fullScreenPendingIntent, true) // Essential for waking screen
|
|
93
90
|
.setColor(Color.parseColor("#28a745"))
|
|
94
91
|
.setColorized(true)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
)
|
|
102
|
-
|
|
92
|
+
// ADDING ACTIONS MANUALLY TO CONTROL ORDER
|
|
93
|
+
// First Action added = Leftmost button
|
|
94
|
+
.addAction(0, "Answer", answerPendingIntent)
|
|
95
|
+
.addAction(0, "Decline", rejectPendingIntent)
|
|
96
|
+
|
|
103
97
|
notificationManager.notify(uuid.hashCode(), builder.build())
|
|
104
98
|
|
|
99
|
+
// Start Ringtone
|
|
105
100
|
try {
|
|
106
101
|
val ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)
|
|
107
102
|
ringtone = RingtoneManager.getRingtone(context, ringtoneUri)
|
|
@@ -112,13 +107,9 @@ object NativeCallManager {
|
|
|
112
107
|
|
|
113
108
|
fun stopRingtone() {
|
|
114
109
|
try {
|
|
115
|
-
ringtone?.let {
|
|
116
|
-
if (it.isPlaying) it.stop()
|
|
117
|
-
}
|
|
110
|
+
ringtone?.let { if (it.isPlaying) it.stop() }
|
|
118
111
|
ringtone = null
|
|
119
|
-
} catch (e: Exception) {
|
|
120
|
-
e.printStackTrace()
|
|
121
|
-
}
|
|
112
|
+
} catch (e: Exception) { e.printStackTrace() }
|
|
122
113
|
}
|
|
123
114
|
|
|
124
115
|
fun dismissIncomingCall(context: Context, uuid: String?) {
|
package/package.json
CHANGED