-
Notifications
You must be signed in to change notification settings - Fork 767
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
[Device Manager] Render security recommendations (PSG-681) #6965
[Device Manager] Render security recommendations (PSG-681) #6965
Conversation
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.
LGTM, just small remarks. Did not test the code.
fun execute(lastSeenTs: Long): Boolean { | ||
val lastSeenDate = DateProvider.toLocalDateTime(lastSeenTs) | ||
val currentDate = DateProvider.currentLocalDateTime() | ||
val diffMilliseconds = currentDate.toTimestamp() - lastSeenDate.toTimestamp() |
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 would inject a Clock
in the constructor and just make a diff between lastSeenTs
and clock.epochMillis()
.
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.
Right, easier, done.
<string name="device_manager_unverified_sessions_title">Unverified sessions</string> | ||
<string name="device_manager_unverified_sessions_description">Verify or sign out from unverified sessions.</string> | ||
<string name="device_manager_inactive_sessions_title">Inactive sessions</string> | ||
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (90 days or older) you don’t use anymore.</string> |
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.
Is there a word missing here?
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (90 days or older) you don’t use anymore.</string> | |
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (90 days or older) you don’t use them anymore.</string> |
Also maybe 90 days or more
is better than 90 days or older
.
Disclaimer: I am not a native speaker!
Also 90 is hard-coded here, we could use %d
and use SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
for more flexibility (Element or their forks).
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. I believe the missing word was "that".
@@ -3222,6 +3222,7 @@ | |||
<string name="device_manager_other_sessions_view_all">View All (%1$d)</string> | |||
<string name="device_manager_other_sessions_description_verified">Verified · Last activity %1$s</string> | |||
<string name="device_manager_other_sessions_description_unverified">Unverified · Last activity %1$s</string> | |||
<string name="device_manager_other_sessions_description_inactive">Inactive for %1$d+ days (%2$s)</string> |
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.
ElementBot is right (I did not think about it) please use a plurals
. In English it will not change anything (since I do not think we will use the value 1
, but on some other languages we can have difference.
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.
Fixed in 5791a4d
@@ -3228,6 +3228,6 @@ | |||
<string name="device_manager_unverified_sessions_title">Unverified sessions</string> | |||
<string name="device_manager_unverified_sessions_description">Verify or sign out from unverified sessions.</string> | |||
<string name="device_manager_inactive_sessions_title">Inactive sessions</string> | |||
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (90 days or older) you don’t use anymore.</string> | |||
<string name="device_manager_inactive_sessions_description">Consider signing out from old sessions (%1$d days or more) that you don’t use anymore.</string> |
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.
Please also use a plurals
here. Thanks!
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.
Fixed in 5791a4d
@@ -42,18 +44,26 @@ class OtherSessionsController @Inject constructor( | |||
} else { | |||
data.take(NUMBER_OF_OTHER_DEVICES_TO_RENDER).forEach { device -> | |||
val formattedLastActivityDate = host.dateFormatter.format(device.deviceInfo.lastSeenTs, DateFormatKind.DEFAULT_DATE_AND_TIME) |
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 format the date when inactive, I think we should use DateFormatKind.TIMELINE_DAY_DIVIDER
to only get the date.
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.
Fixed in fbff8d6
views.recommendationShieldImageView.backgroundTintList = ColorStateList.valueOf(backgroundTint) | ||
} | ||
|
||
fun setTitle(title: String) { |
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 would create a dedicated SecurityRecommendationViewState
in a separate file to encapsulate all data used to render the view. Then we would have a unique method render(viewState: SecurityRecommendationViewState)
to be called when needed.
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.
ViewState
added in c53a8f3
@@ -68,6 +72,7 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la | |||
holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel) | |||
holder.otherSessionNameTextView.text = sessionName | |||
holder.otherSessionDescriptionTextView.text = sessionDescription | |||
holder.otherSessionDescriptionTextView.setCompoundDrawablesWithIntrinsicBounds(sessionDescriptionDrawable, null, null, null) |
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 the drawable will have the same tint color as the text. Can you check both in light and dark mode?
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.
Fixed in dc0a36
287c153
to
9dc0a36
Compare
SonarCloud Quality Gate failed. |
Type of change
Content
Implement current session section as in the new layout.
Motivation and context
Closes #6964
Screenshots / GIFs
Tests
Tested devices
Checklist