@poolse/native 0.0.0-stage → 3.0.0
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.
- package/CHANGELOG.md +25 -0
- package/LICENSE +206 -0
- package/README.md +148 -2
- package/android/build.gradle +58 -0
- package/android/consumer-rules.pro +11 -0
- package/android/src/main/AndroidManifest.xml +46 -0
- package/android/src/main/java/dev/poolse/callcore/CallCoreRuntime.kt +540 -0
- package/android/src/main/java/dev/poolse/callcore/CallMachine.kt +492 -0
- package/android/src/main/java/dev/poolse/callcore/Ports.kt +132 -0
- package/android/src/main/java/dev/poolse/callcore/android/AndroidRingSurface.kt +383 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallActionReceiver.kt +45 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallCore.kt +578 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallForegroundService.kt +294 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallHttpClient.kt +207 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallMessagingService.kt +161 -0
- package/android/src/main/java/dev/poolse/callcore/android/CallVideo.kt +36 -0
- package/android/src/main/java/dev/poolse/callcore/android/HandlerTimerPort.kt +42 -0
- package/android/src/main/java/dev/poolse/callcore/android/IncomingCallActivity.kt +314 -0
- package/android/src/main/java/dev/poolse/callcore/android/MessageNotifications.kt +353 -0
- package/android/src/main/java/dev/poolse/callcore/android/MissedCallNotification.kt +103 -0
- package/android/src/main/java/dev/poolse/callcore/android/RingBundle.kt +42 -0
- package/android/src/main/java/dev/poolse/callcore/android/SnapshotJson.kt +99 -0
- package/android/src/main/java/expo/modules/poolsecalls/CallLockscreen.kt +42 -0
- package/android/src/main/java/expo/modules/poolsecalls/CallPictureInPicture.kt +92 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallVideoView.kt +64 -0
- package/android/src/main/java/expo/modules/poolsecalls/PoolseCallsModule.kt +205 -0
- package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitMediaPort.kt +594 -0
- package/android/src/main/livekit/java/dev/poolse/callcore/livekit/LiveKitVideoSurface.kt +107 -0
- package/android/src/test/java/dev/poolse/callcore/android/CallHttpClientTest.kt +61 -0
- package/app.plugin.js +5 -0
- package/dist/index.cjs +197 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +313 -0
- package/dist/index.d.ts +313 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/expo-module.config.json +11 -0
- package/ios/Core/CallCoreRuntime.swift +543 -0
- package/ios/Core/CallHttpClient.swift +213 -0
- package/ios/Core/CallMachine.swift +394 -0
- package/ios/Core/PORTS_READY.md +93 -0
- package/ios/Core/Ports.swift +238 -0
- package/ios/Core/SnapshotEncoding.swift +122 -0
- package/ios/Module/PoolseCallVideoView.swift +70 -0
- package/ios/Module/PoolseCallsAppDelegateSubscriber.swift +16 -0
- package/ios/Module/PoolseCallsModule.swift +150 -0
- package/ios/Platform/CallCore.swift +623 -0
- package/ios/Platform/CallKitController.swift +326 -0
- package/ios/Platform/CallPictureInPicture.swift +145 -0
- package/ios/Platform/LiveKitMediaPort.swift +798 -0
- package/ios/Platform/LiveKitVideoSurface.swift +68 -0
- package/ios/Platform/MessageNotifications.swift +163 -0
- package/ios/Platform/Ringback.swift +61 -0
- package/ios/Platform/VoipPush.swift +174 -0
- package/ios/PoolseCalls.podspec +68 -0
- package/package.json +53 -4
- package/plugin/index.js +42 -0
- package/plugin/package.json +1 -0
- package/plugin/withCallDelegate.js +35 -0
- package/plugin/withLockscreenCalls.js +84 -0
- package/plugin/withNativeCallMedia.js +19 -0
- package/plugin/withPictureInPicture.js +28 -0
- package/plugin/withRingback.js +86 -0
- package/src/expo-modules-core.d.ts +16 -0
- package/src/index.ts +564 -0
- package/src/react-shims.d.ts +22 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package dev.poolse.callcore.android
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.view.View
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Video rendering, kept SFU-agnostic: a [dev.poolse.callcore.MediaPort]
|
|
8
|
+
* that can render video ALSO implements this; the bridge's view asks
|
|
9
|
+
* [CallCore.createVideoSurface] and never sees the SFU's types. A port
|
|
10
|
+
* without video (the signalling-only fallback) simply doesn't implement
|
|
11
|
+
* it, and the view stays empty.
|
|
12
|
+
*
|
|
13
|
+
* Main thread only — surfaces live in the view hierarchy, and the media
|
|
14
|
+
* adapter keeps its room on main.
|
|
15
|
+
*/
|
|
16
|
+
interface CallVideoSource {
|
|
17
|
+
fun createVideoSurface(context: Context): CallVideoSurface
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** One on-screen video slot, bound to a participant's camera. */
|
|
21
|
+
interface CallVideoSurface {
|
|
22
|
+
/** The Android view to host; it fills its parent. */
|
|
23
|
+
val view: View
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* What to show. [participantId] is the remote's userId (SFU
|
|
27
|
+
* identity); [local] shows the self view instead. [mirror] null =
|
|
28
|
+
* the default (mirrored for the local front camera only). [fit] is
|
|
29
|
+
* `cover` or `contain`. Rebinds immediately and again whenever the
|
|
30
|
+
* underlying track appears, disappears, mutes or the room is replaced.
|
|
31
|
+
*/
|
|
32
|
+
fun configure(participantId: String?, local: Boolean, mirror: Boolean?, fit: String)
|
|
33
|
+
|
|
34
|
+
/** Detach from any track and free the renderer. Idempotent. */
|
|
35
|
+
fun release()
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package dev.poolse.callcore.android
|
|
2
|
+
|
|
3
|
+
import android.os.Handler
|
|
4
|
+
import android.os.Looper
|
|
5
|
+
import dev.poolse.callcore.TimerPort
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The real [TimerPort]: a single main-looper Handler keyed by token, so
|
|
9
|
+
* the runtime's timers (ring deadline, ended-linger, reconnect budget)
|
|
10
|
+
* fire on one predictable thread and rescheduling a key cleanly
|
|
11
|
+
* replaces its pending callback.
|
|
12
|
+
*
|
|
13
|
+
* [nowMs] is wall-clock epoch, because the one value it is compared
|
|
14
|
+
* against — the push's `ring_deadline` — is epoch, minted by the
|
|
15
|
+
* server (CALL_CONTRACT.md §5.1). The actual scheduling delay is handed to
|
|
16
|
+
* [Handler.postDelayed], which counts down monotonically regardless of
|
|
17
|
+
* clock changes, so a mid-ring NTP correction shifts the deadline by at
|
|
18
|
+
* most the drift, never breaks it.
|
|
19
|
+
*/
|
|
20
|
+
internal class HandlerTimerPort(
|
|
21
|
+
private val handler: Handler = Handler(Looper.getMainLooper()),
|
|
22
|
+
) : TimerPort {
|
|
23
|
+
|
|
24
|
+
private val pending = mutableMapOf<String, Runnable>()
|
|
25
|
+
|
|
26
|
+
override fun nowMs(): Long = System.currentTimeMillis()
|
|
27
|
+
|
|
28
|
+
override fun schedule(key: String, delayMs: Long, fire: () -> Unit) {
|
|
29
|
+
cancel(key)
|
|
30
|
+
val runnable = Runnable {
|
|
31
|
+
synchronized(pending) { pending.remove(key) }
|
|
32
|
+
fire()
|
|
33
|
+
}
|
|
34
|
+
synchronized(pending) { pending[key] = runnable }
|
|
35
|
+
handler.postDelayed(runnable, delayMs.coerceAtLeast(0))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun cancel(key: String) {
|
|
39
|
+
val runnable = synchronized(pending) { pending.remove(key) } ?: return
|
|
40
|
+
handler.removeCallbacks(runnable)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
package dev.poolse.callcore.android
|
|
2
|
+
|
|
3
|
+
import android.animation.ValueAnimator
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.BroadcastReceiver
|
|
6
|
+
import android.content.Context
|
|
7
|
+
import android.content.Intent
|
|
8
|
+
import android.content.IntentFilter
|
|
9
|
+
import android.graphics.Color
|
|
10
|
+
import android.graphics.Typeface
|
|
11
|
+
import android.graphics.drawable.GradientDrawable
|
|
12
|
+
import android.os.Build
|
|
13
|
+
import android.os.Bundle
|
|
14
|
+
import android.os.Handler
|
|
15
|
+
import android.os.Looper
|
|
16
|
+
import android.view.Gravity
|
|
17
|
+
import android.view.View
|
|
18
|
+
import android.view.WindowManager
|
|
19
|
+
import android.view.animation.LinearInterpolator
|
|
20
|
+
import android.widget.FrameLayout
|
|
21
|
+
import android.widget.LinearLayout
|
|
22
|
+
import android.widget.TextView
|
|
23
|
+
import androidx.core.content.ContextCompat
|
|
24
|
+
import dev.poolse.callcore.RingContext
|
|
25
|
+
import dev.poolse.callcore.android.AndroidRingSurface.Companion.ACTION_RING_CLOSED
|
|
26
|
+
import dev.poolse.callcore.android.AndroidRingSurface.Companion.EXTRA_CALL_ID
|
|
27
|
+
import dev.poolse.callcore.android.AndroidRingSurface.Companion.EXTRA_RING
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The full-screen ring a locked phone shows. Native and dependency-free
|
|
31
|
+
* so it is on screen within the OS's full-screen-intent budget, long
|
|
32
|
+
* before any JS could load — carrying the call scene's look (dark
|
|
33
|
+
* ground, brand glow, a breathing ring) in plain views. The buttons
|
|
34
|
+
* resolve into [CallCore], the same entry point every other surface
|
|
35
|
+
* uses; answering brings the app forward over the keyguard.
|
|
36
|
+
*
|
|
37
|
+
* It closes itself when the ring ends anywhere else (caller cancelled,
|
|
38
|
+
* answered on another device, deadline) via the package-local
|
|
39
|
+
* [ACTION_RING_CLOSED] broadcast — before, a remotely-ended ring left
|
|
40
|
+
* this screen up with dead buttons.
|
|
41
|
+
*/
|
|
42
|
+
class IncomingCallActivity : Activity() {
|
|
43
|
+
|
|
44
|
+
private var pulse: ValueAnimator? = null
|
|
45
|
+
private val density by lazy { resources.displayMetrics.density }
|
|
46
|
+
private fun px(v: Int): Int = (v * density).toInt()
|
|
47
|
+
private val main = Handler(Looper.getMainLooper())
|
|
48
|
+
|
|
49
|
+
/** The ring on screen. */
|
|
50
|
+
private var ring: RingContext? = null
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Answered: we are only waiting for the app to come forward over us.
|
|
54
|
+
* Our own DISMISS_RING broadcast must not close us before it does —
|
|
55
|
+
* finishing first left the app behind the keyguard.
|
|
56
|
+
*/
|
|
57
|
+
private var awaitingForward = false
|
|
58
|
+
|
|
59
|
+
private val ringClosed = object : BroadcastReceiver() {
|
|
60
|
+
override fun onReceive(context: Context, intent: Intent) {
|
|
61
|
+
val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: return
|
|
62
|
+
if (callId == ring?.callId && !awaitingForward) finish()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
67
|
+
super.onCreate(savedInstanceState)
|
|
68
|
+
showOverKeyguard()
|
|
69
|
+
ContextCompat.registerReceiver(
|
|
70
|
+
this,
|
|
71
|
+
ringClosed,
|
|
72
|
+
IntentFilter(ACTION_RING_CLOSED),
|
|
73
|
+
ContextCompat.RECEIVER_NOT_EXPORTED,
|
|
74
|
+
)
|
|
75
|
+
handle(intent)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** singleInstance: a new ring (or the answer action) arrives here, not in onCreate. */
|
|
79
|
+
override fun onNewIntent(intent: Intent) {
|
|
80
|
+
super.onNewIntent(intent)
|
|
81
|
+
setIntent(intent)
|
|
82
|
+
handle(intent)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private fun handle(intent: Intent) {
|
|
86
|
+
val next = intent.getBundleExtra(EXTRA_RING)?.toRingContext()
|
|
87
|
+
if (next == null) { if (ring == null) finish(); return }
|
|
88
|
+
val core = CallCore.getOrNull(this)
|
|
89
|
+
if (core == null) { finish(); return }
|
|
90
|
+
|
|
91
|
+
// Answered from the notification: this activity exists only to be the
|
|
92
|
+
// foreground context that is ALLOWED to bring the app up (a
|
|
93
|
+
// background receiver is not).
|
|
94
|
+
if (intent.getBooleanExtra(AndroidRingSurface.EXTRA_AUTO_ANSWER, false)) {
|
|
95
|
+
ring = next
|
|
96
|
+
answerAndForward { core.onUserAnswer(next, this) }
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
// End & answer on a call-waiting heads-up: the same, for the call
|
|
100
|
+
// waiting beside the current one.
|
|
101
|
+
if (intent.getBooleanExtra(AndroidRingSurface.EXTRA_WAITING_ANSWER, false)) {
|
|
102
|
+
ring = next
|
|
103
|
+
answerAndForward { core.onUserAnswerWaiting(next, this) }
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// A stale tap (the ring resolved, or the process restarted after it
|
|
108
|
+
// ended): there is nothing to answer.
|
|
109
|
+
if (!core.isRingLive(next)) {
|
|
110
|
+
if (ring == null || ring?.callId == next.callId) finish()
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
ring = next
|
|
114
|
+
awaitingForward = false
|
|
115
|
+
pulse?.cancel()
|
|
116
|
+
val title = next.conversationName ?: next.callerName ?: "Incoming call"
|
|
117
|
+
val body = if (next.media == "video") "Incoming video call" else "Incoming call"
|
|
118
|
+
setContentView(buildScene(title, body, next))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Answer, then bring the app forward FROM THIS ACTIVITY, and stay
|
|
123
|
+
* (as a plain dark window) until the app is in front — finishing at
|
|
124
|
+
* once dropped the start on some OEMs and left the call audible
|
|
125
|
+
* behind the lock screen. onStop (we got covered) finishes us; a
|
|
126
|
+
* timer is the fallback.
|
|
127
|
+
*/
|
|
128
|
+
private fun answerAndForward(answer: () -> Boolean) {
|
|
129
|
+
awaitingForward = true
|
|
130
|
+
pulse?.cancel()
|
|
131
|
+
pulse = null
|
|
132
|
+
setContentView(View(this).apply { setBackgroundColor(Color.parseColor("#0B0B14")) })
|
|
133
|
+
val launched = answer()
|
|
134
|
+
if (!launched) { finish(); return }
|
|
135
|
+
main.postDelayed({ if (!isFinishing) finish() }, FORWARD_FALLBACK_MS)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
override fun onStop() {
|
|
139
|
+
super.onStop()
|
|
140
|
+
if (awaitingForward && !isFinishing) finish()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override fun onDestroy() {
|
|
144
|
+
main.removeCallbacksAndMessages(null)
|
|
145
|
+
runCatching { unregisterReceiver(ringClosed) }
|
|
146
|
+
pulse?.cancel()
|
|
147
|
+
pulse = null
|
|
148
|
+
super.onDestroy()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private companion object {
|
|
152
|
+
const val FORWARD_FALLBACK_MS = 4_000L
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private fun showOverKeyguard() {
|
|
156
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
157
|
+
setShowWhenLocked(true)
|
|
158
|
+
setTurnScreenOn(true)
|
|
159
|
+
} else {
|
|
160
|
+
@Suppress("DEPRECATION")
|
|
161
|
+
window.addFlags(
|
|
162
|
+
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
163
|
+
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private fun buildScene(title: String, body: String, ring: RingContext): View {
|
|
170
|
+
val root = FrameLayout(this).apply { setBackgroundColor(Color.parseColor("#0B0B14")) }
|
|
171
|
+
|
|
172
|
+
root.addView(
|
|
173
|
+
View(this).apply {
|
|
174
|
+
background = GradientDrawable(
|
|
175
|
+
GradientDrawable.Orientation.TOP_BOTTOM,
|
|
176
|
+
intArrayOf(Color.parseColor("#875B54E8"), Color.parseColor("#000B0B14")),
|
|
177
|
+
).apply {
|
|
178
|
+
gradientType = GradientDrawable.RADIAL_GRADIENT
|
|
179
|
+
gradientRadius = 560 * density
|
|
180
|
+
setGradientCenter(0.5f, 0.3f)
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
val column = LinearLayout(this).apply {
|
|
187
|
+
orientation = LinearLayout.VERTICAL
|
|
188
|
+
gravity = Gravity.CENTER_HORIZONTAL
|
|
189
|
+
setPadding(px(32), px(110), px(32), px(72))
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
val stage = FrameLayout(this).apply {
|
|
193
|
+
layoutParams = LinearLayout.LayoutParams(px(176), px(176)).apply { bottomMargin = px(30) }
|
|
194
|
+
}
|
|
195
|
+
val ringView = View(this).apply {
|
|
196
|
+
background = GradientDrawable().apply {
|
|
197
|
+
shape = GradientDrawable.OVAL
|
|
198
|
+
setColor(Color.TRANSPARENT)
|
|
199
|
+
setStroke(px(2), Color.parseColor("#805B54E8"))
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
stage.addView(ringView, FrameLayout.LayoutParams(px(176), px(176), Gravity.CENTER))
|
|
203
|
+
stage.addView(
|
|
204
|
+
TextView(this).apply {
|
|
205
|
+
text = title.trim().take(1).uppercase()
|
|
206
|
+
textSize = 48f
|
|
207
|
+
setTextColor(Color.WHITE)
|
|
208
|
+
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
|
|
209
|
+
gravity = Gravity.CENTER
|
|
210
|
+
background = GradientDrawable(
|
|
211
|
+
GradientDrawable.Orientation.TL_BR,
|
|
212
|
+
intArrayOf(Color.parseColor("#7D76FF"), Color.parseColor("#5B54E8")),
|
|
213
|
+
).apply { shape = GradientDrawable.OVAL }
|
|
214
|
+
},
|
|
215
|
+
FrameLayout.LayoutParams(px(124), px(124), Gravity.CENTER),
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
val name = TextView(this).apply {
|
|
219
|
+
text = title
|
|
220
|
+
textSize = 32f
|
|
221
|
+
setTextColor(Color.WHITE)
|
|
222
|
+
typeface = Typeface.create(Typeface.DEFAULT, Typeface.BOLD)
|
|
223
|
+
gravity = Gravity.CENTER
|
|
224
|
+
}
|
|
225
|
+
val sub = TextView(this).apply {
|
|
226
|
+
text = body
|
|
227
|
+
textSize = 15f
|
|
228
|
+
setTextColor(Color.parseColor("#B8B8C6"))
|
|
229
|
+
gravity = Gravity.CENTER
|
|
230
|
+
background = GradientDrawable().apply {
|
|
231
|
+
cornerRadius = 999f
|
|
232
|
+
setColor(Color.parseColor("#14FFFFFF"))
|
|
233
|
+
}
|
|
234
|
+
setPadding(px(16), px(8), px(16), px(8))
|
|
235
|
+
layoutParams = LinearLayout.LayoutParams(wrap(), wrap()).apply { topMargin = px(12) }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
val buttons = LinearLayout(this).apply {
|
|
239
|
+
orientation = LinearLayout.HORIZONTAL
|
|
240
|
+
gravity = Gravity.CENTER
|
|
241
|
+
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, wrap())
|
|
242
|
+
}
|
|
243
|
+
val decline = actionButton("Decline", "✕", "#EF4444") {
|
|
244
|
+
CallCore.getOrNull(this)?.onUserDecline(ring); finish()
|
|
245
|
+
}
|
|
246
|
+
val accept = actionButton("Answer", "✓", "#22C55E") {
|
|
247
|
+
val core = CallCore.getOrNull(this)
|
|
248
|
+
if (core == null) finish() else answerAndForward { core.onUserAnswer(ring, this) }
|
|
249
|
+
}
|
|
250
|
+
buttons.addView(decline, LinearLayout.LayoutParams(wrap(), wrap()).apply { rightMargin = px(52) })
|
|
251
|
+
buttons.addView(accept, LinearLayout.LayoutParams(wrap(), wrap()).apply { leftMargin = px(52) })
|
|
252
|
+
|
|
253
|
+
column.addView(stage)
|
|
254
|
+
column.addView(name)
|
|
255
|
+
column.addView(sub)
|
|
256
|
+
column.addView(View(this).apply { layoutParams = LinearLayout.LayoutParams(0, 0, 1f) })
|
|
257
|
+
column.addView(buttons)
|
|
258
|
+
root.addView(
|
|
259
|
+
column,
|
|
260
|
+
FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT),
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
pulse = ValueAnimator.ofFloat(0f, 1f).apply {
|
|
264
|
+
duration = 1800
|
|
265
|
+
repeatCount = ValueAnimator.INFINITE
|
|
266
|
+
interpolator = LinearInterpolator()
|
|
267
|
+
addUpdateListener {
|
|
268
|
+
val t = it.animatedValue as Float
|
|
269
|
+
ringView.scaleX = 1f + 0.28f * t
|
|
270
|
+
ringView.scaleY = 1f + 0.28f * t
|
|
271
|
+
ringView.alpha = 1f - t
|
|
272
|
+
}
|
|
273
|
+
start()
|
|
274
|
+
}
|
|
275
|
+
return root
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private fun actionButton(
|
|
279
|
+
label: String,
|
|
280
|
+
glyph: String,
|
|
281
|
+
color: String,
|
|
282
|
+
onClick: () -> Unit,
|
|
283
|
+
): LinearLayout = LinearLayout(this).apply {
|
|
284
|
+
orientation = LinearLayout.VERTICAL
|
|
285
|
+
gravity = Gravity.CENTER_HORIZONTAL
|
|
286
|
+
addView(
|
|
287
|
+
TextView(this@IncomingCallActivity).apply {
|
|
288
|
+
text = glyph
|
|
289
|
+
textSize = 30f
|
|
290
|
+
setTextColor(Color.WHITE)
|
|
291
|
+
gravity = Gravity.CENTER
|
|
292
|
+
background = GradientDrawable().apply {
|
|
293
|
+
shape = GradientDrawable.OVAL
|
|
294
|
+
setColor(Color.parseColor(color))
|
|
295
|
+
}
|
|
296
|
+
layoutParams = LinearLayout.LayoutParams(px(82), px(82))
|
|
297
|
+
isClickable = true
|
|
298
|
+
isFocusable = true
|
|
299
|
+
setOnClickListener { onClick() }
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
addView(
|
|
303
|
+
TextView(this@IncomingCallActivity).apply {
|
|
304
|
+
text = label
|
|
305
|
+
textSize = 14f
|
|
306
|
+
setTextColor(Color.parseColor("#B8B8C6"))
|
|
307
|
+
gravity = Gravity.CENTER
|
|
308
|
+
layoutParams = LinearLayout.LayoutParams(wrap(), wrap()).apply { topMargin = px(10) }
|
|
309
|
+
},
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private fun wrap() = LinearLayout.LayoutParams.WRAP_CONTENT
|
|
314
|
+
}
|