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

Open user profile and room with event from permalink #2776

Merged
merged 12 commits into from
May 3, 2024

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Apr 30, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Partially handle #2648 , since it will only work for Android 11 and before. Extra steps are required to make it work on Android 12 and higher. This is handled by https://github.com/element-hq/element.io-website/pull/275.

I have extracted some classes from the roomdetail module in order to be able to render a user profile screen (i.e. without having any room available). So extracting stuff to avoid copy pasting.

To be able to use host like *.element.io, I had to remove the declaration call.element.io from the Manifest about ElementCallActivity. All intent are now handled by the MainActivity, which will eventually start the ElementCallActivity.

Motivation and context

External permalink handling.

Screenshots / GIFs

Tests

matrix.to links

  • Open a matrix.to link from another app installed on the phone (Gmail, etc.) and observe that EXA is opening it and is routing the user to the expected screen.
  • Can also be tested using command line with:
adb shell am start -a android.intent.action.VIEW -d 'https://matrix.to/#/@benoitx:matrix.org'

NOTE Use and Android emulator with Android 11 or lower, else the link will be opened by the browser. When opened in the browser, the user can select Element and then get a link to open the permalink in the Element mobile application ("Continue" button below):

image

It should work on Android 12 and higher.

Edit Actually on mobile, matrix.to website is using a custom scheme (element), so I will add the support for it too:

image

I have added the support here: 181742b, and it's working when triggering with adb, but for some reason, nothing happen when I click on the matrix.to website on open it here:

image

element.io links

Test for instance with

adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE \
   -d "https://app.element.io/#/room/!cuqHozLHNBgupgLMKN:matrix.org/%24LZDOueY3R8OD2ZYf8FLKtu95aF7imLBC3F5TIUj-4cc"

Note: will work on Android 12 and higher only when the element.io website will be deployed.

Tested devices

  • Physical
  • Emulator (Android 10)
  • OS version(s):

Checklist

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 1, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label May 1, 2024
Copy link
Contributor

github-actions bot commented May 1, 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/3MAPh2

Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 64.70588% with 60 lines in your changes are missing coverage. Please review.

Project coverage is 73.41%. Comparing base (682fd45) to head (baf3877).

Files Patch % Lines
...atures/userprofile/shared/UserProfileNodeHelper.kt 0.00% 11 Missing ⚠️
...nt/android/features/call/ui/ElementCallActivity.kt 0.00% 9 Missing ⚠️
...s/userprofile/impl/DefaultUserProfileEntryPoint.kt 0.00% 8 Missing ⚠️
...s/userprofile/shared/blockuser/BlockUserSection.kt 33.33% 5 Missing and 3 partials ⚠️
...c/main/kotlin/io/element/android/x/MainActivity.kt 0.00% 6 Missing ⚠️
...impl/members/details/RoomMemberDetailsPresenter.kt 78.57% 1 Missing and 2 partials ⚠️
...ures/userprofile/impl/root/UserProfilePresenter.kt 92.85% 1 Missing and 2 partials ⚠️
...s/userprofile/shared/blockuser/BlockUserDialogs.kt 57.14% 0 Missing and 3 partials ⚠️
...io/element/android/appnav/intent/IntentResolver.kt 77.77% 0 Missing and 2 partials ⚠️
.../features/userprofile/impl/di/UserProfileModule.kt 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2776      +/-   ##
===========================================
- Coverage    73.45%   73.41%   -0.05%     
===========================================
  Files         1517     1523       +6     
  Lines        36431    36528      +97     
  Branches      7013     7038      +25     
===========================================
+ Hits         26760    26816      +56     
- Misses        6006     6043      +37     
- Partials      3665     3669       +4     

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

@bmarty bmarty force-pushed the feature/bma/externalLinks branch from b2112b3 to 181742b Compare May 2, 2024 16:50
@bmarty bmarty marked this pull request as ready for review May 2, 2024 16:53
@bmarty bmarty requested a review from a team as a code owner May 2, 2024 16:53
@bmarty bmarty requested review from jmartinesp and removed request for a team May 2, 2024 16:53
val userName: String?,
val avatarUrl: String?,
val isBlocked: AsyncData<Boolean>,
val startDmActionState: AsyncAction<RoomId>,
val displayConfirmationDialog: ConfirmationDialog?,
val isCurrentUser: Boolean,
val eventSink: (RoomMemberDetailsEvents) -> Unit
val eventSink: (UserProfileEvents) -> Unit
Copy link
Member Author

Choose a reason for hiding this comment

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

Room member detail and User profile now have the same actions and rendering, so the state is common, but at some point we may want to add extra data here, like a RoomId?, and extra action like Jump to Read Receipt, only if a room is there.

@jmartinesp
Copy link
Member

I just tested it and the matrix.to, element.io and call.element. links are intercepted as expected on Android < 12.

call.element. and element.io links work on Android 12+.

However, on Android 12+ after the matrix.to website is loaded and I tap on the open action, it does nothing. Could it be because it's using the element: scheme and we only registered the elementx: one instead for EX?

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

I have some comments, nothing major. I'll review the code again once the new changes arrive. Thanks!

}
}

private suspend fun navigateTo(permalinkData: PermalinkData) {
Timber.d("Navigating to $permalinkData")
attachSession(null)
Copy link
Member

Choose a reason for hiding this comment

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

I know it's not new, but this duplicate attachSession is quite confusing until you look at the underlying returned types. Maybe we should think about renaming them in the future.

Copy link
Member Author

@bmarty bmarty May 3, 2024

Choose a reason for hiding this comment

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

Yes, that's not clear, you're right (and it's due to the new intermediate LoggedInAppScopeFlowNode).
I have made it clearer in fb59776 hopefully.

Copy link
Member

Choose a reason for hiding this comment

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

Are those commits uploaded? GH doesn't seem to auto-detect them and I can't find them in the commit list view.

Copy link
Member

Choose a reason for hiding this comment

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

Should we add some more tests for permalinks here?

Copy link
Member Author

@bmarty bmarty May 3, 2024

Choose a reason for hiding this comment

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

Yes, good point, added in f48cc81.

@@ -63,6 +66,26 @@ class ElementCallActivity : NodeComponentActivity(), CallScreenNavigator {
}
context.startActivity(intent)
}

/**
* Eventually start the ElementCallActivity, and return true if it's the case.
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit vague. Maybe 'Start the ElementCallActivity' if the intent contains a valid URL, return true` if it's the case'?

Copy link
Member Author

@bmarty bmarty May 3, 2024

Choose a reason for hiding this comment

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

Yes, thanks fa4ad4a.

@ElementBot
Copy link
Collaborator

ElementBot commented May 3, 2024

Warnings
⚠️

features/roomdetails/impl/src/main/res/values-cs/translations.xml#L64 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

features/roomdetails/impl/src/main/res/values-ro/translations.xml#L30 - For locale "ro" (Romanian) the following quantity should also be defined: few (e.g. "2 zile")

⚠️

features/roomdetails/impl/src/main/res/values-sk/translations.xml#L64 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L4 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L22 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L152 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L176 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

Generated by 🚫 dangerJS against baf3877

@bmarty
Copy link
Member Author

bmarty commented May 3, 2024

However, on Android 12+ after the matrix.to website is loaded and I tap on the open action, it does nothing. Could it be because it's using the element: scheme and we only registered the elementx: one instead for EX?

Fixed in 181742b, and it's working when triggering with adb, but for some reason, nothing happen when I click on the matrix.to website on open it here:

image

Actually hide the attachment of LoggedInAppScopeFlowNode.
@jmartinesp
Copy link
Member

However, on Android 12+ after the matrix.to website is loaded and I tap on the open action, it does nothing. Could it be because it's using the element: scheme and we only registered the elementx: one instead for EX?

Fixed in 181742b, and it's working when triggering with adb, but for some reason, nothing happen when I click on the matrix.to website on open it here:

image

Same here. The intent-filter for the element scheme doesn't seem to be triggered.

@jmartinesp
Copy link
Member

@bmarty I got it to work with:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="element" />
    <data android:host="user" />
    <data android:host="room" />
</intent-filter>

@bmarty
Copy link
Member Author

bmarty commented May 3, 2024

OK, everything is fine, I think I have handled all your remark @jmartinesp (and thanks for the fix about matrix.to website link).

Let me know if there is anything else!

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

Thanks for all the changes! LGTM!

Copy link

sonarcloud bot commented May 3, 2024

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 3, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 3, 2024
@bmarty bmarty merged commit e9c262e into develop May 3, 2024
17 of 19 checks passed
@bmarty bmarty deleted the feature/bma/externalLinks branch May 3, 2024 12:03
@bmarty bmarty mentioned this pull request May 6, 2024
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants