@qusaieilouti99/call-manager 0.1.97 → 0.1.98
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.
|
@@ -4,6 +4,7 @@ package com.margelo.nitro.qusaieilouti99.callmanager
|
|
|
4
4
|
import android.app.Activity
|
|
5
5
|
import android.app.KeyguardManager
|
|
6
6
|
import android.content.Context
|
|
7
|
+
import android.graphics.BitmapFactory
|
|
7
8
|
import android.graphics.Color
|
|
8
9
|
import android.graphics.RenderEffect
|
|
9
10
|
import android.graphics.Shader
|
|
@@ -24,9 +25,11 @@ import android.widget.ImageView
|
|
|
24
25
|
import android.widget.LinearLayout
|
|
25
26
|
import android.widget.TextView
|
|
26
27
|
import androidx.core.content.ContextCompat
|
|
27
|
-
import
|
|
28
|
+
import java.net.HttpURLConnection
|
|
29
|
+
import java.net.URL
|
|
28
30
|
|
|
29
31
|
class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
32
|
+
|
|
30
33
|
private enum class FinishReason { ANSWER, DECLINE, TIMEOUT,
|
|
31
34
|
MANUAL_DISMISS, EXTERNAL_END }
|
|
32
35
|
private var finishReason: FinishReason? = null
|
|
@@ -50,15 +53,15 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
50
53
|
setupLockScreenBypass(isSamsungBypass)
|
|
51
54
|
|
|
52
55
|
// Read params
|
|
53
|
-
callId
|
|
54
|
-
callType
|
|
56
|
+
callId = intent.getStringExtra("callId") ?: ""
|
|
57
|
+
callType = intent.getStringExtra("callType") ?: "Audio"
|
|
55
58
|
val callerName = intent.getStringExtra("callerName") ?: "Unknown"
|
|
56
59
|
val avatarUrl = intent.getStringExtra("callerAvatar")
|
|
57
60
|
|
|
58
61
|
CallEngine.registerCallEndListener(this)
|
|
59
62
|
buildUi(callerName, avatarUrl)
|
|
60
63
|
handler.postDelayed(timeoutRunnable, timeoutMs)
|
|
61
|
-
Log.d(TAG, "CallActivity setup complete for
|
|
64
|
+
Log.d(TAG, "CallActivity setup complete for callId=$callId")
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
private fun buildUi(name: String, avatarUrl: String?) {
|
|
@@ -69,25 +72,24 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
69
72
|
)
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
// 1) Background
|
|
75
|
+
// 1) Background ImageView + optional blur
|
|
73
76
|
val bg = ImageView(this).apply {
|
|
74
77
|
layoutParams = FrameLayout.LayoutParams(
|
|
75
78
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
76
79
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
77
80
|
)
|
|
78
81
|
scaleType = ImageView.ScaleType.CENTER_CROP
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
RenderEffect.createBlurEffect(25f, 25f, Shader.TileMode.CLAMP)
|
|
88
|
-
)
|
|
82
|
+
// apply RenderEffect blur on API31+
|
|
83
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
84
|
+
setRenderEffect(
|
|
85
|
+
RenderEffect.createBlurEffect(
|
|
86
|
+
25f, 25f, Shader.TileMode.CLAMP
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
}
|
|
89
90
|
}
|
|
90
91
|
root.addView(bg)
|
|
92
|
+
loadAndBlurBackground(bg, avatarUrl)
|
|
91
93
|
|
|
92
94
|
// 2) Dark scrim
|
|
93
95
|
root.addView(View(this).apply {
|
|
@@ -129,6 +131,7 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
129
131
|
topMargin = dp(20)
|
|
130
132
|
}
|
|
131
133
|
}
|
|
134
|
+
|
|
132
135
|
// Profile circle
|
|
133
136
|
val profile = ImageView(this).apply {
|
|
134
137
|
val sz = dp(140)
|
|
@@ -138,12 +141,11 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
138
141
|
shape = GradientDrawable.OVAL
|
|
139
142
|
setColor(Color.LTGRAY)
|
|
140
143
|
}
|
|
144
|
+
// enable clipping to our oval background
|
|
141
145
|
clipToOutline = true
|
|
142
146
|
}
|
|
143
|
-
if (!avatarUrl.isNullOrEmpty()) {
|
|
144
|
-
Glide.with(this).load(avatarUrl).circleCrop().into(profile)
|
|
145
|
-
}
|
|
146
147
|
centerCol.addView(profile)
|
|
148
|
+
loadAvatar(profile, avatarUrl)
|
|
147
149
|
|
|
148
150
|
// Caller name
|
|
149
151
|
centerCol.addView(TextView(this).apply {
|
|
@@ -193,13 +195,39 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
193
195
|
setContentView(root)
|
|
194
196
|
}
|
|
195
197
|
|
|
198
|
+
// Plain HTTP loader + setImageBitmap
|
|
199
|
+
private fun loadAvatar(iv: ImageView, url: String?) {
|
|
200
|
+
if (url.isNullOrEmpty()) return
|
|
201
|
+
Thread {
|
|
202
|
+
try {
|
|
203
|
+
val conn = URL(url).openConnection() as HttpURLConnection
|
|
204
|
+
conn.doInput = true; conn.connect()
|
|
205
|
+
val bmp = BitmapFactory.decodeStream(conn.inputStream)
|
|
206
|
+
runOnUiThread { iv.setImageBitmap(bmp) }
|
|
207
|
+
} catch (_: Exception) { /* ignore */ }
|
|
208
|
+
}.start()
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Same loader for background
|
|
212
|
+
private fun loadAndBlurBackground(iv: ImageView, url: String?) {
|
|
213
|
+
if (url.isNullOrEmpty()) return
|
|
214
|
+
Thread {
|
|
215
|
+
try {
|
|
216
|
+
val conn = URL(url).openConnection() as HttpURLConnection
|
|
217
|
+
conn.doInput = true; conn.connect()
|
|
218
|
+
val bmp = BitmapFactory.decodeStream(conn.inputStream)
|
|
219
|
+
runOnUiThread { iv.setImageBitmap(bmp) }
|
|
220
|
+
} catch (_: Exception) { /* ignore */ }
|
|
221
|
+
}.start()
|
|
222
|
+
}
|
|
223
|
+
|
|
196
224
|
private fun createCircleButton(iconRes: Int, bgColor: Int): FrameLayout {
|
|
197
225
|
val size = dp(70)
|
|
198
226
|
return FrameLayout(this).apply {
|
|
199
227
|
layoutParams = LinearLayout.LayoutParams(size, size)
|
|
200
228
|
isClickable = true; isFocusable = true
|
|
201
229
|
foreground = getRipple()
|
|
202
|
-
// circle
|
|
230
|
+
// colored circle
|
|
203
231
|
addView(View(context).apply {
|
|
204
232
|
layoutParams = FrameLayout.LayoutParams(
|
|
205
233
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
@@ -271,7 +299,7 @@ class CallActivity : Activity(), CallEngine.CallEndListener {
|
|
|
271
299
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
272
300
|
km.requestDismissKeyguard(this,
|
|
273
301
|
object : KeyguardManager.KeyguardDismissCallback() {
|
|
274
|
-
override fun onDismissSucceeded()
|
|
302
|
+
override fun onDismissSucceeded() {
|
|
275
303
|
Log.d(TAG, "Samsung keyguard dismissed")
|
|
276
304
|
}
|
|
277
305
|
override fun onDismissError() {
|