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

[Devices Management] Session overview screen (PSG-691, PSG-693) #7005

Merged
merged 28 commits into from
Sep 8, 2022

Conversation

mnaturel
Copy link
Contributor

@mnaturel mnaturel commented Sep 5, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Adding the new Session overview screen. In this screen, we only see a single view with session info for now. This new screen can be reached from a tap on current session info view (whole card or details button) and from any session item from other sessions list.
  • Mutualizing the SessionInfoView which can be reused for current session or any session.
  • Adding UseCases with tests to compute the trust level of a given Session.

Motivation and context

Closes #6961

Screenshots / GIFs

Tests

  • Enable the feature flag for new device management
  • Go to Settings -> Security&Privacy -> Show all Sessions (V2, WIP)
  • Press the current session view or the details button
  • Check the Session overview screen is opened with the correct info corresponding to the current session
  • Press back
  • Press any session item from the "Other sessions" list
  • Check the Session overview screen is opened with the correct info corresponding to the selected session

Tested devices

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

Checklist

@ElementBot
Copy link

ElementBot commented Sep 5, 2022

Warnings
⚠️

vector/src/main/AndroidManifest.xml#L220 - Consider splitting data tag into multiple tags with individual attributes to avoid confusion

⚠️

vector/src/main/AndroidManifest.xml#L220 - Consider splitting data tag into multiple tags with individual attributes to avoid confusion

⚠️

vector/src/main/AndroidManifest.xml#L223 - Consider splitting data tag into multiple tags with individual attributes to avoid confusion

⚠️

vector/src/main/AndroidManifest.xml#L223 - Consider splitting data tag into multiple tags with individual attributes to avoid confusion

⚠️

vector/src/main/AndroidManifest.xml#L277 - Expecting android:screenOrientation="unspecified" or "fullSensor" for this activity so the user can use the application in any orientation and provide a great experience on Chrome OS devices

⚠️

vector/src/main/AndroidManifest.xml#L277 - Expecting android:screenOrientation="unspecified" or "fullSensor" for this activity so the user can use the application in any orientation and provide a great experience on Chrome OS devices

⚠️

vector/src/main/AndroidManifest.xml#L286 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L286 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L293 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L293 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L299 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L299 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

vector/src/main/AndroidManifest.xml#L415 - Exported receiver does not require permission

⚠️

vector/src/main/AndroidManifest.xml#L415 - Exported receiver does not require permission

⚠️

vector/src/main/res/layout/item_other_session.xml#L7 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

⚠️

vector/src/main/res/layout/item_other_session.xml#L7 - Attribute android:foreground has no effect on API levels lower than 23 (current min is 21)

Generated by 🚫 dangerJS against 669beb1

@mnaturel mnaturel requested review from a team and fedrunov and removed request for a team September 5, 2022 08:32
@mnaturel mnaturel marked this pull request as ready for review September 5, 2022 08:33
@mnaturel
Copy link
Contributor Author

mnaturel commented Sep 5, 2022

Messages
📖 This pull request seems relatively large. Please consider splitting it into multiple smaller ones.

Generated by 🚫 dangerJS against 838064d

This is due to the fact I had to do many small renamings and extract reusable use cases to reduce the existing technical debt on this area. So the PR is large but modifications are not complex. I am not sure how to split it without rewriting the whole history into different branches...

@mnaturel mnaturel force-pushed the feature/mna/session-overview-screen branch from eb59a53 to 682905d Compare September 7, 2022 07:40
Copy link
Contributor

@fedrunov fedrunov left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 7, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

4.2% 4.2% Coverage
0.0% 0.0% Duplication

@mnaturel mnaturel merged commit 6c2bf35 into develop Sep 8, 2022
@mnaturel mnaturel deleted the feature/mna/session-overview-screen branch September 8, 2022 07:18
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Nice work! Some post merge remarks, feel free to handle them in a quick PR or ignore, the goal is also to give you some feedback. Thanks!

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<declare-styleable name="DevicesListHeaderView">
<declare-styleable name="SessionsListHeaderView">
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I renamed it in a following PR 😄


fun getDeviceInfo(deviceId: String, callback: MatrixCallback<DeviceInfo>)
fun getMyDevicesInfoLive(deviceId: String): LiveData<Optional<DeviceInfo>>
Copy link
Member

Choose a reason for hiding this comment

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

a changelog with .sdk extension is required when there are changes in the API (especially SDK Services)

Also in this case, I think the fun should be named getMyDeviceInfoLive (no s on Devices)

fun getDeviceInfo(userId: String, deviceId: String?): CryptoDeviceInfo?
fun getCryptoDeviceInfo(userId: String, deviceId: String?): CryptoDeviceInfo?

fun getCryptoDeviceInfo(deviceId: String, callback: MatrixCallback<DeviceInfo>)
Copy link
Member

Choose a reason for hiding this comment

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

We've got 2 models: CryptoDeviceInfo and DeviceInfo. I think the fun name should match the model. This is not the case here.


fun getLiveCryptoDeviceInfoWithId(deviceId: String): LiveData<Optional<CryptoDeviceInfo>>

fun getLiveCryptoDeviceInfo(userId: String): LiveData<List<CryptoDeviceInfo>>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename to getLiveCryptoDeviceInfos (plurals)


fun getCryptoDeviceInfo(userId: String): List<CryptoDeviceInfo>

fun getLiveCryptoDeviceInfo(): LiveData<List<CryptoDeviceInfo>>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe rename to getLiveCryptoDeviceInfos (plurals), or maybe more English correct getLiveCryptoDevicesInfo

private fun appendLearnMoreToVerificationStatus() {
val status = views.sessionInfoVerificationStatusDetailTextView.text
val learnMore = context.getString(R.string.action_learn_more)
val stringBuilder = StringBuilder()
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Kotlin stdlib provides a handy buildString {} which can be nice to use in such case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know this method. Thanks, I will update.

}
?: run {
views.sessionInfoLastIPAddressTextView.isGone = true
}
Copy link
Member

Choose a reason for hiding this comment

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

Could be rewrite to shorter version using setTextOrHide:

views.sessionInfoLastIPAddressTextView.setTextOrHide(deviceInfo.lastSeenIp?.takeIf { isLastSeenDetailsVisible })

* Display the overview info about a Session.
*/
@AndroidEntryPoint
class SessionOverviewActivity : SimpleFragmentActivity() {
Copy link
Member

Choose a reason for hiding this comment

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

About the naming, the convention in the project would dictate to name this class SessionDetailActivity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will have in a next PR another screen for "Session details" which will be named SessionDetailsActivity. It will be accessed from this "Session overview" screen.


private fun observeSessionInfo(deviceId: String) {
getDeviceFullInfoUseCase.execute(deviceId)
.mapNotNull { it.getOrNull() }
Copy link
Member

Choose a reason for hiding this comment

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

You could replace by .unwrap()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't see there was this extension method. I will use it inside the getDeviceFullInfoUseCase.

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Member

Choose a reason for hiding this comment

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

I would have used a ScrollView here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it might be a good idea for small devices. It will be done in a next PR (session details screen).

@mnaturel
Copy link
Contributor Author

mnaturel commented Sep 8, 2022

Nice work! Some post merge remarks, feel free to handle them in a quick PR or ignore, the goal is also to give you some feedback. Thanks!

Thanks for the feedbacks, I will handle some of them in a dedicated future PR.

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.

[Devices Management] Session overview screen
4 participants