Skip to content
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

Use new functions exposed by Element Call about PiP #3334

Merged
merged 7 commits into from
Aug 26, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Aug 23, 2024

Content

  • Communicate with Element Call about PiP status.
  • Also only use eventSink to communicate with the Presenter, instead of having public methods.
  • Change WeakReference to an Activity to a listener and update tests.

Motivation and context

Closes #3326

Screenshots / GIFs

Tests

  • Change Element Call url to https://pr2573--element-call.netlify.app/
  • Start a call and play with the Pip mode
  • Note that if the call is in error, the pip mode will not start, but the call will be terminated. This can be tested when entering pip mode just after starting the call (and this is maybe a thing to fix on Element Call side. The call is not in error, but not fully started yet CC @robintown )

Note: using regular (so not deployed) Element Call should not be impacted by this change.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

bmarty and others added 2 commits August 23, 2024 16:19
Also only use eventSink to communicate with the Presenter, instead of having public methods.
Change WeakReference to an Activity to a listener and update tests.
@bmarty bmarty requested a review from a team as a code owner August 23, 2024 14:28
@bmarty bmarty requested review from jmartinesp and removed request for a team August 23, 2024 14:28
@bmarty bmarty changed the title Use new functions expose by Element Call about PiP Use new functions exposed by Element Call about PiP Aug 23, 2024
Copy link
Contributor

github-actions bot commented Aug 23, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/gEe6Pw

@bmarty bmarty added the PR-Change For updates to an existing feature label Aug 23, 2024
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 45.58824% with 37 lines in your changes missing coverage. Please review.

Project coverage is 82.69%. Comparing base (1b7c0db) to head (7f4b846).
Report is 12 commits behind head on develop.

Files Patch % Lines
...droid/features/call/impl/ui/ElementCallActivity.kt 0.00% 28 Missing ⚠️
...d/features/call/impl/utils/WebViewPipController.kt 28.57% 5 Missing ⚠️
...eatures/call/impl/pip/PictureInPicturePresenter.kt 84.61% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3334      +/-   ##
===========================================
- Coverage    82.75%   82.69%   -0.07%     
===========================================
  Files         1680     1681       +1     
  Lines        39382    39415      +33     
  Branches      4777     4787      +10     
===========================================
+ Hits         32591    32594       +3     
- Misses        5117     5146      +29     
- Partials      1674     1675       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty requested review from ganfra and removed request for jmartinesp August 26, 2024 08:14
Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some remarks, let me know what you think


package io.element.android.features.call.impl.utils

interface WebPipApi {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the naming a bit weird, especially with the default implementation being WebViewWebPipApi.
I'd have call it PipController maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done


package io.element.android.features.call.impl.pip

interface PipActivity {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the fact we leak the fact it's an Activity, can we just try to find another name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PipView maybe?

@@ -66,6 +74,7 @@ class ElementCallActivity : AppCompatActivity(), CallScreenNavigator {
private val webViewTarget = mutableStateOf<CallType?>(null)

private var eventSink: ((CallScreenEvents) -> Unit)? = null
private var pipEventSink: ((PictureInPictureEvents) -> Unit)? = null
Copy link
Member

@ganfra ganfra Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of keeping a reference to the eventSink in a seperate value, I'd instead keep everything alive inside the content block :

setContent {
            val pipState = pictureInPicturePresenter.present()
            val pipEventSink by rememberUpdatedState(pipState.eventSink)
            DisposableEffect(Unit) {
                val onUserLeaveHintListener = Runnable {
                    pipEventSink(PictureInPictureEvents.EnterPictureInPicture)
                }
                val onPictureInPictureModeChangedListener = Consumer { value: PictureInPictureModeChangedInfo ->
                    pipEventSink(PictureInPictureEvents.OnPictureInPictureModeChanged(value.isInPictureInPictureMode))
                }
                addOnPictureInPictureModeChangedListener(onPictureInPictureModeChangedListener)
                addOnUserLeaveHintListener(onUserLeaveHintListener)
                onDispose {
                    removeOnPictureInPictureModeChangedListener(onPictureInPictureModeChangedListener)
                    removeOnUserLeaveHintListener(onUserLeaveHintListener)
                }
            }
            [...]
}

Copy link

sonarcloud bot commented Aug 26, 2024

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 26, 2024
@bmarty bmarty enabled auto-merge August 26, 2024 15:40
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Aug 26, 2024
@bmarty bmarty merged commit 1a43aa3 into develop Aug 26, 2024
27 of 29 checks passed
@bmarty bmarty deleted the feature/bma/pipCallApi branch August 26, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Change For updates to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PiP] Use new functions expose by Element Call about PiP
2 participants