-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support element call widget (PSG-627) #6616
Conversation
Signed-off-by: Johannes Marbach <[email protected]>
@@ -28,7 +28,8 @@ private val DEFINED_TYPES by lazy { | |||
WidgetType.StickerPicker, | |||
WidgetType.Grafana, | |||
WidgetType.Custom, | |||
WidgetType.IntegrationManager | |||
WidgetType.IntegrationManager, | |||
WidgetType.ElementCall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a trailing comma for the last item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, done.
* @param request WebView permission request of onPermissionRequest function | ||
* @return true if WebView permissions are already granted, false otherwise | ||
*/ | ||
fun checkWebViewPermissions(activity: Activity, request: PermissionRequest): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could extract this method into a dedicated use case such as CheckWebViewPermissionsUseCase
? This way, it may be possible to inject the ApplicationContext
instead of passing the activity as an argument.
We could also add unit tests on it as bonus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.
@@ -26,4 +26,5 @@ sealed class WidgetAction : VectorViewModelAction { | |||
object DeleteWidget : WidgetAction() | |||
object RevokeWidget : WidgetAction() | |||
object OnTermsReviewed : WidgetAction() | |||
object HangupElementCall : WidgetAction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename the action CloseWidget
to avoid introducing too specific action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
override fun onUserLeaveHint() { | ||
super.onUserLeaveHint() | ||
val widgetArgs: WidgetArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG) | ||
if (widgetArgs?.kind == WidgetKind.ELEMENT_CALL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should move if (widgetArgs?.kind == WidgetKind.ELEMENT_CALL)
inside the enterPictureInPicture
. Like this:
override fun onUserLeaveHint() {
super.onUserLeaveHint()
enterPictureInPicture()
}
private fun enterPictureInPicture() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val widgetArgs: WidgetArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG)
val params = when(widgetArgs?.kind) {
WidgetKind.ELEMENT_CALL -> createElementCallPipParams()
else -> null
}
params?.let {
enterPictureInPictureMode(it)
}
}
}
This way we could easily add picture in picture for other widget in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I have just added some suggestions. I have just one question about the picture in picture mode. Should/can we do something to have a better UI in this mode? Now, it looks like a reduced version of the current larger UI.
I have also seen there is one security hotspot to be reviewed in the Sonar analysis. It is about registering a broadcast receiver. I think it is worth checking if everything is okay. |
|
||
@Before | ||
fun setup() { | ||
MockKAnnotations.init(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is needed. MockKAnnotations.init()
is useful when we use the annotations for mockking objects like @MockK
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I started with using @Mockk
then forgot to remove it. Done.
|
||
@Test | ||
fun `given an audio permission is granted when the web client requests audio permission then use case returns true`() { | ||
val permissionRequest = givenAPermissionRequest(arrayOf(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To ease the reading in tests, we should separate them in 3 blocks (given, when, then). We would have something like:
val permissionRequest = givenAPermissionRequest(arrayOf(PermissionRequest.RESOURCE_AUDIO_CAPTURE))
every { checkSelfPermission(activity.applicationContext, any()) } returns PackageManager.PERMISSION_GRANTED
val result = checkWebViewPermissionsUseCase.execute(activity, permissionRequest)
result shouldBe true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
every { checkSelfPermission(activity.applicationContext, any()) } returns PackageManager.PERMISSION_GRANTED | ||
|
||
checkWebViewPermissionsUseCase.execute(activity, permissionRequest) shouldBe true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could add a verify bloc on the call to checkSelfPermission
in the tests. For this test for example:
PERMISSIONS_FOR_AUDIO_IP_CALL.forEach { permission ->
every { checkSelfPermission(activity.applicationContext, permission) }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.
Web team made a CSS trick to show the mic in the middle of the PIP screen but I think it is not in production yet. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
SonarCloud Quality Gate failed. |
Type of change
Content
We implement Element Call as a widget with some extra functionalities.
Motivation and context
Since this is a call widget we need to make it run in the background, provide a picture-in-picture mode and also preserve the current native WebRTC call implementation for rooms which does not have an active Element Call widget.
This PR is a cherry-pick version of PR #6464 which additionally implements a Bluetooth connection with push-to-talk devices. Since it is an experimental PR with a hardcoded device name and service address without a good UX, we wanted to create this PR to be able to merge into develop.
Screenshots / GIFs
element_call_widget.mp4
Tests
Tested devices
Checklist