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

Automatically show keyboard after learn more bottom sheet is dismissed (PSG-1105) #7790

Merged
merged 5 commits into from Dec 19, 2022

Conversation

onurays
Copy link
Contributor

@onurays onurays commented Dec 15, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

For a better UX, if an EditText is focused and the keyboard is already shown after showing and hiding a bottom sheet then the expected behavior is to show the keyboard by default.

Motivation and context

UX review remarks.

Screenshots / GIFs

show_keyboard_after_bottomsheet.mp4

Tests

  • Enable new session manager from Labs settings
  • Navigate to Settings > Security & Privacy -> Show all sessions
  • Test as seen in attached video

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@onurays onurays requested review from a team and mnaturel and removed request for a team December 15, 2022 13:01
@ElementBot
Copy link

Warnings
⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against 6d40bd1

@onurays onurays changed the title Automatically show keyboard after learn more bottom sheet is dismissed (PSG-1105) Automatically show keyboard after learn more bottom sheet is dismissed (PSG-1105, PSG-1109) Dec 15, 2022
@onurays onurays changed the title Automatically show keyboard after learn more bottom sheet is dismissed (PSG-1105, PSG-1109) Automatically show keyboard after learn more bottom sheet is dismissed (PSG-1105) Dec 15, 2022
SessionLearnMoreBottomSheet.show(childFragmentManager, args)
SessionLearnMoreBottomSheet
.show(childFragmentManager, args)
.apply {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in general in the project, we try to avoid using apply to avoid bugs on the scope of objects. Maybe it will be better to write it this way:

SessionLearnMoreBottomSheet
                .show(childFragmentManager, args)
                .onDismiss = { showKeyboard() }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

views.renameSessionEditText.doOnTextChanged { text, _, _, _ ->
viewModel.handle(RenameSessionAction.EditLocally(text.toString()))
}
}

private fun showKeyboard() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private fun showKeyboard() {
private fun showKeyboard() {
val focusChangeListener = object : ViewTreeObserver.OnWindowFocusChangeListener {
override fun onWindowFocusChanged(hasFocus: Boolean) {
if (hasFocus) {
views.renameSessionEditText.showKeyboard(andRequestFocus = true)
}
views.renameSessionEditText.viewTreeObserver.removeOnWindowFocusChangeListener(this)
}
}
views.renameSessionEditText.viewTreeObserver.addOnWindowFocusChangeListener(focusChangeListener)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove the listener once done (see my suggestion above). Otherwise it will keep adding a listener each time and every listeners will be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, done.

Copy link
Contributor

@mnaturel mnaturel 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 fix! I think we need to remove listeners on the EditText after adding one. See my related comment.

@sonarcloud
Copy link

sonarcloud bot commented Dec 19, 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 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@mnaturel mnaturel 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 updates! LGTM.

@onurays onurays merged commit 9fd6fe3 into develop Dec 19, 2022
@onurays onurays deleted the feature/ons/fix_rename_session_keyboard_visibility branch December 19, 2022 13:21
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.

None yet

3 participants