-
Notifications
You must be signed in to change notification settings - Fork 731
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
Add new UI for selecting an attachment type #7429
Conversation
Note these are currently only visible in the collapsed state. - [Google issue](https://issuetracker.google.com/issues/144859239) - [Rejected PR](material-components/material-components-android#437) - [Github issue](material-components/material-components-android#1278)
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.
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> |
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.
This change impacts all the BottomSheet of the app, did you check it does not break the other ones?
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 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) | ||
} |
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 understand this is to fix the click effect?
I think this is not necessary to call super.setOnClickListener(l)
.
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.
Not just for the click effect - for some reason setOnClickListener
was not working unless we set it to the child view.
private val viewModel: AttachmentTypeSelectorViewModel by fragmentViewModel() | ||
private val timelineViewModel: TimelineViewModel by parentFragmentViewModel() | ||
private val sharedActionViewModel: AttachmentTypeSelectorSharedActionViewModel by viewModels( | ||
ownerProducer = { requireParentFragment() } |
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.
TIL
|
||
override fun invalidate() = withState(viewModel, timelineViewModel) { viewState, timelineState -> | ||
super.invalidate() | ||
views.location.visibility = if (viewState.isLocationVisible) View.VISIBLE else View.GONE |
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.
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.
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.
Thanks for letting me know about this!
class AttachmentTypeSelectorSharedActionViewModel @Inject constructor() : | ||
VectorSharedActionViewModel<AttachmentTypeSelectorSharedAction>() | ||
|
||
sealed class AttachmentTypeSelectorSharedAction : VectorSharedAction { |
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.
We now prefer using sealed interface
, but the whole codebase has not been migrated yet.
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.
|
||
init { | ||
setState { | ||
this.copy( |
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.
this.
is not necessary.
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.
@@ -0,0 +1,91 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
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.
This LinearLayout
seems useless, can you remove it please?
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.
<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> |
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.
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.
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've removed it for now so that we don't forget to remove any lint ignore rule later
This reverts commit 17c43c9.
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.
Thanks for the update!
You can merge the PR when you want.
Type of change
Content
Motivation and context
PSU-919
Screenshots / GIFs
Tests
New attachment UI
Old attachment UI
Tested devices
Checklist