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

Add new UI for selecting an attachment type #7429

Merged
merged 10 commits into from
Oct 25, 2022
Merged

Add new UI for selecting an attachment type #7429

merged 10 commits into from
Oct 25, 2022

Conversation

jonnyandrew
Copy link
Contributor

@jonnyandrew jonnyandrew commented Oct 21, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Add new UI for selecting an attachment type for users of the new rich text editor.
  • Also: add rounded corners to bottom sheets as per designs (note this currently only applies when bottom sheets are not in the fully expanded state - see open issues 1, 2).

Motivation and context

PSU-919

Screenshots / GIFs

Before After
image Screenshot_20221021_123106
image Screenshot_20221021_123155

Tests

New attachment UI

  • Enable the rich text editor via labs
  • Enter a room
  • Tap the plus icon to start adding an attachment
  • Observe the new attachment screen
  • Tap an item to add an attachment
  • Observe the attachment flow starts

Old attachment UI

  • Disable the rich text editor via labs
  • Enter a room
  • Tap the plus icon to start adding an attachment
  • Observe the existing inline attachment UI

Tested devices

  • Physical
  • Emulator
  • OS version(s): 21, 33

Checklist

@jonnyandrew jonnyandrew marked this pull request as ready for review October 21, 2022 12:56
@jonnyandrew jonnyandrew requested review from a team and fedrunov and removed request for a team and fedrunov October 21, 2022 13:00
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, thanks!
Just a few minor remarks.

@@ -14,6 +14,7 @@
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/element_content_primary_light</item>
<item name="android:textColorLink">@color/element_link_light</item>
<item name="bottomSheetStyle">@style/BottomSheetStyle</item>
Copy link
Member

Choose a reason for hiding this comment

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

This change impacts all the BottomSheet of the app, did you check it does not break the other ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

2938112

I think it might be better to update the global bottom sheet style in a separate PR. Given this change hasn't even fully met the design requirements (only affects the non-expanded state), it's not a big loss to remove for now.

override fun setOnClickListener(l: OnClickListener?) {
super.setOnClickListener(l)
views.bottomSheetActionClickableZone.setOnClickListener(l)
}
Copy link
Member

Choose a reason for hiding this comment

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

I understand this is to fix the click effect?
I think this is not necessary to call super.setOnClickListener(l).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not just for the click effect - for some reason setOnClickListener was not working unless we set it to the child view.

9da575b

private val viewModel: AttachmentTypeSelectorViewModel by fragmentViewModel()
private val timelineViewModel: TimelineViewModel by parentFragmentViewModel()
private val sharedActionViewModel: AttachmentTypeSelectorSharedActionViewModel by viewModels(
ownerProducer = { requireParentFragment() }
Copy link
Member

Choose a reason for hiding this comment

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

TIL


override fun invalidate() = withState(viewModel, timelineViewModel) { viewState, timelineState ->
super.invalidate()
views.location.visibility = if (viewState.isLocationVisible) View.VISIBLE else View.GONE
Copy link
Member

Choose a reason for hiding this comment

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

You can you this handy extension which have the same effect

views.location.isVisible = viewState.isLocationVisible

The code will be much clearer.

FTR isGone and isInvisible also exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for letting me know about this!

74591f5

class AttachmentTypeSelectorSharedActionViewModel @Inject constructor() :
VectorSharedActionViewModel<AttachmentTypeSelectorSharedAction>()

sealed class AttachmentTypeSelectorSharedAction : VectorSharedAction {
Copy link
Member

Choose a reason for hiding this comment

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

We now prefer using sealed interface, but the whole codebase has not been migrated yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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


init {
setState {
this.copy(
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 not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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.

This LinearLayout seems useless, can you remove it please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<string name="attachment_type_selector_location">Location</string>
<string name="attachment_type_selector_camera">Camera</string>
<string name="attachment_type_selector_contact">Contact</string>
<string name="attachment_type_selector_text_formatting">Text formatting</string>
Copy link
Member

Choose a reason for hiding this comment

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

Lint is complaining that this is not used. If this is for future usage, you can ignore the error here, so that the string can get translated. Else please remove the string.

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've removed it for now so that we don't forget to remove any lint ignore rule later

0650b6a

@jonnyandrew jonnyandrew requested review from bmarty and a team October 24, 2022 08:44
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.

Thanks for the update!
You can merge the PR when you want.

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.

2 participants