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

[Device management] Rename a session (PSG-747) #7189

Merged
merged 19 commits into from
Sep 26, 2022

Conversation

mnaturel
Copy link
Contributor

@mnaturel mnaturel commented Sep 21, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Adding a new screen to rename a given session. It can be reached from the session overview screen using the overflow menu.

Motivation and context

Closes #7158

Screenshots / GIFs

Tests

  • Enable the new device manager feature flag
  • Go to Settings -> Security & Privacy -> Show all sessions (V2, WIP)
  • Press a session entry to go to a session overview
  • Press the overflow menu
  • Press the rename action
  • Check the focus is on the text field and the keaboard is opened when landing on the screen
  • Edit the name
  • Press the "Save" button
  • Check the session name is correctly updated everywhere
  • Press a session entry to go to a session overview
  • Press the overflow menu
  • Press the rename action
  • Edit the name
  • Press the close button
  • Check the session name has not been changed

Tested devices

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

Checklist

@mnaturel mnaturel marked this pull request as ready for review September 21, 2022 09:32
@mnaturel mnaturel requested review from a team and jmartinesp and removed request for a team September 21, 2022 09:32
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.

Minor comment, other than that it LGTM.

Comment on lines 89 to 96
if (renameEditTextInitialized.not()) {
views.renameSessionEditText.setText(state.editedDeviceName)
views.renameSessionEditText.setSelection(views.renameSessionEditText.length())
renameEditTextInitialized = true
}
views.renameSessionSave.isEnabled = state.editedDeviceName.isNotEmpty()
Copy link
Member

Choose a reason for hiding this comment

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

This looks a bit weird. If it's a one time event, shouldn't it be done through a ViewEvent? Or if it needs to be part of the state, could we check the contents of renameSessionEditText before applying these changes instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me it should be in the ViewState. The reason is that we should be able to reconstruct the view at any moment using the ViewState. So for the enable status of the save button, we should use info from the ViewState. Like you said ViewEvent is a one time event and so not persisted, meaning we will lose the enable status of the button.
But I don't understand the last part of your comment:

could we check the contents of renameSessionEditText before applying these changes instead?

Can you add more details about your suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

I was suggesting to either add a RenameSessionViewEvent.Initialized(val deviceName: String) that can be consumed once, or maybe checking if (views.renameSessionEditText.text.isNullOrEmpty()) before applying the state here instead of adding the renameEditTextInitialized variable for that, since it seems like you only want to set the view contents when this data is first loaded, I guess because otherwise keyboard input and state updates would clash on the EditText.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry I got it! I will try to improve. I completely misunderstood your suggestion at first...

Copy link
Contributor Author

@mnaturel mnaturel Sep 22, 2022

Choose a reason for hiding this comment

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

I have done an update: see a8d7723. It adds more complexity to the ViewModel but I think it is more logical this way. Let me know what you think about it.

Base automatically changed from feature/mna/device-manager-verify-other-session to develop September 22, 2022 09:46
@mnaturel mnaturel requested a review from jmartinesp September 22, 2022 13:09
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 the changes. LGTM!

@mnaturel mnaturel force-pushed the feature/mna/device-manager-rename-session branch 2 times, most recently from 55b8a60 to 5399ef6 Compare September 23, 2022 15:07
@ElementBot
Copy link

ElementBot commented Sep 23, 2022

Warnings
⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

vector/src/main/AndroidManifest.xml#L260 - 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#L260 - 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#L269 - Attribute supportsPictureInPicture is only used in API level 24 and higher (current min is 21)

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

⚠️

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

Generated by 🚫 dangerJS against 7a4bf83

@mnaturel mnaturel force-pushed the feature/mna/device-manager-rename-session branch from 5399ef6 to 7a4bf83 Compare September 26, 2022 07:47
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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

67.6% 67.6% Coverage
0.0% 0.0% Duplication

@mnaturel mnaturel merged commit 2231498 into develop Sep 26, 2022
@mnaturel mnaturel deleted the feature/mna/device-manager-rename-session branch September 26, 2022 08:35
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.

[Device management] Rename a session
3 participants