Port v6 XML poll improvements to develop#6468
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
* Add configurable character limits and feature toggles for polls Introduces PollsConfig to control poll feature availability and enforce character limits on questions and options. Poll features (multiple votes, anonymous voting, suggest options, add comments) can now be hidden or preset with default values through ChatUI.pollsConfig or passed directly to CreatePollDialogFragment. * addressing pr comments * 1. Detekt - Fixed the MaxLineLength violation in PollsConfig.kt:23 by breaking the long comment line 2. Spotless - Applied formatting fixes (added license header to PollFeatureConfig.kt) 3. API Check - Regenerated the API dump file * Update stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/PollsConfig.kt Co-authored-by: Gianmarco <47775302+gpunto@users.noreply.github.com> * Apply suggestion from @gpunto --------- Co-authored-by: Gianmarco <47775302+gpunto@users.noreply.github.com>
* Allow voters to suggest poll options in UI Components * Use doAfterTextChanged * Align Compose & XML option name trimming
* Allow voters to add poll comments in UI Components * Add missing KDoc and default params
- Use UiCommonR for stream_ui_poll_action_view_comments plural - Update StateRegistry imports to client.api.state package
WalkthroughThis PR adds comprehensive poll comment and suggestion features to the Stream Chat Android UI, including new dialog fragments for user interactions, configuration types for feature enablement/limits, listener interfaces for click handling, and corresponding view model events and rendering updates across the message list. ChangesPoll Comments & Suggestions Integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
stream-chat-android-ui-components/src/main/res/layout/stream_ui_dialog_add_poll_comment.xml (1)
23-31: ⚡ Quick winConsider adding a hint to improve UX.
The
EditTexthas noandroid:hintattribute. Adding a hint would provide better user guidance about what to enter. However, if the hint is set programmatically in the dialog, this can be skipped.💡 Suggested enhancement
<androidx.appcompat.widget.AppCompatEditText android:id="@+id/answerInput" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" + android:hint="`@string/stream_ui_poll_add_a_comment_label`" android:imeOptions="actionDone" android:inputType="text" android:textAppearance="`@style/StreamUiTextAppearance.Headline`" />🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@stream-chat-android-ui-components/src/main/res/layout/stream_ui_dialog_add_poll_comment.xml` around lines 23 - 31, The EditText with id "answerInput" (androidx.appcompat.widget.AppCompatEditText) has no android:hint, which harms UX; add a descriptive android:hint attribute (e.g., "Enter answer" or localized string resource) to the XML for stream_ui_dialog_add_poll_comment.xml unless the hint is intentionally set in code—if it's set programmatically, verify and leave as-is, otherwise add the hint to the layout and reference a string resource.stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/internal/PollView.kt (1)
153-153: ⚡ Quick winDocument the
LongParameterListsuppression (or remove it via callback grouping).This suppression is currently undocumented; add a brief rationale comment to align with repo Kotlin rules.
As per coding guidelines `**/*.kt`: "Use `@OptIn` annotations explicitly in Kotlin code; avoid suppressions unless documented".Proposed fix
-@Suppress("LongParameterList") +// Suppressed intentionally: constructor wires discrete UI callbacks explicitly. +@Suppress("LongParameterList") private class PollAdapter(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/internal/PollView.kt` at line 153, The `@Suppress`("LongParameterList") on PollView lacks a rationale comment; update the suppression on PollView (the `@Suppress` declaration in PollView.kt) to include a short comment explaining why the long parameter list is acceptable here (e.g., grouping of callback params or UI binding constraints) or remove the suppression by refactoring/grouping callbacks into a single data class or listener to reduce parameters; reference the `@Suppress`("LongParameterList") token and the PollView component when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@stream-chat-android-ui-components/api/stream-chat-android-ui-components.api`:
- Around line 3064-3069: The diff added new abstract getters on the public
interface MessageListListeners (getOnAddPollCommentClickListener,
getOnPollCloseClickListener, getOnPollOptionClickListener,
getOnShowAllPollOptionClickListener, getOnSuggestPollOptionClickListener,
getOnViewPollCommentsClickListener), which is a binary-breaking change; instead
either make each of these methods a default interface method with a safe default
(e.g., return null or a no-op listener) in MessageListListeners so existing
implementers remain compatible, or move these poll-related hooks into a new
interface (e.g., MessageListPollListeners) and keep MessageListListeners
unchanged so implementers can opt-in; update usages to call the default methods
or the new interface without changing the existing abstract surface.
- Around line 3150-3176: PollViewStyle's ABI changed because two new properties
were added to the data class primary constructor (which altered the generated
primary constructor, copy and componentN signatures like
component10/component11); revert ABI break by removing the new properties from
the data class primary constructor and instead declare them as regular
properties with default values inside the class body (keep the original 11
primary-constructor params intact so generated copy/componentN/constructor
signatures remain unchanged), update any internal usage to read the new in-body
vals and keep the existing getter names (getPollAddCommentTextStyle,
getPollViewCommentsTextStyle) so consumers can still access them without ABI
changes.
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/OptionsAdapter.kt`:
- Around line 72-75: The init block in OptionsAdapter applies an
InputFilter.LengthFilter unconditionally when optionTextLimit is non-null, which
breaks input for 0 or negative limits; change the guard to only apply the filter
when optionTextLimit != null && optionTextLimit > 0 (mirror the question limit
check), i.e., update the init logic around binding.option.filters and the
optionTextLimit handling in OptionsAdapter so the LengthFilter is only set for
positive limits.
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/PollsConfig.kt`:
- Around line 39-48: Add validation in the PollsConfig init block to ensure
questionTextLimit and optionTextLimit, when non-null, are positive integers;
update the existing init (which already validates multipleVotes) to also
require(questionTextLimit == null || questionTextLimit > 0) and
require(optionTextLimit == null || optionTextLimit > 0) with clear error
messages referencing questionTextLimit/optionTextLimit so invalid non-positive
limits are rejected at construction.
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/PollViewStyle.kt`:
- Around line 41-43: The new PollViewStyle constructor adds
pollSuggestOptionTextStyle without a default which breaks existing callers; give
pollSuggestOptionTextStyle a default value (e.g., TextStyle()) in the
PollViewStyle declaration so it matches pollAddCommentTextStyle and
pollViewCommentsTextStyle and preserves backward-compatible construction of
PollViewStyle.
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/internal/poll/SuggestPollOptionDialogFragment.kt`:
- Around line 56-57: The dialog currently reads raw input into val text =
binding.optionInput.text?.toString().orEmpty() and later validates using trimmed
text, which allows whitespace-padded options to be submitted and leaves the
confirm button state stale on reopen/restore; update
SuggestPollOptionDialogFragment to always normalize input by using the trimmed
string for both validation and submission (e.g., derive textTrimmed =
binding.optionInput.text?.toString().orEmpty().trim()), replace usages of the
raw text with textTrimmed, and when initializing/restoring the dialog set the
confirm button enabled state from textTrimmed.isNotBlank() so the confirm button
reflects the current input without requiring further edits (apply same change to
the other occurrence around lines 70-75).
---
Nitpick comments:
In
`@stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/internal/PollView.kt`:
- Line 153: The `@Suppress`("LongParameterList") on PollView lacks a rationale
comment; update the suppression on PollView (the `@Suppress` declaration in
PollView.kt) to include a short comment explaining why the long parameter list
is acceptable here (e.g., grouping of callback params or UI binding constraints)
or remove the suppression by refactoring/grouping callbacks into a single data
class or listener to reduce parameters; reference the
`@Suppress`("LongParameterList") token and the PollView component when making the
change.
In
`@stream-chat-android-ui-components/src/main/res/layout/stream_ui_dialog_add_poll_comment.xml`:
- Around line 23-31: The EditText with id "answerInput"
(androidx.appcompat.widget.AppCompatEditText) has no android:hint, which harms
UX; add a descriptive android:hint attribute (e.g., "Enter answer" or localized
string resource) to the XML for stream_ui_dialog_add_poll_comment.xml unless the
hint is intentionally set in code—if it's set programmatically, verify and leave
as-is, otherwise add the hint to the layout and reference a string resource.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: edeb4362-4ae8-4305-90cf-76b289bf08fc
📒 Files selected for processing (34)
stream-chat-android-core/src/testFixtures/kotlin/io/getstream/chat/android/Mother.ktstream-chat-android-ui-common/api/stream-chat-android-ui-common.apistream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListController.ktstream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.ktstream-chat-android-ui-components/api/stream-chat-android-ui-components.apistream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/ChatUI.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/CreatePollDialogFragment.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/CreatePollViewModel.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/OptionsAdapter.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/PollFeatureConfig.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/attachment/picker/poll/PollsConfig.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/MessageListView.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/MessageListListeners.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/MessageListListenersImpl.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/PollViewStyle.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/view/internal/PollView.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/adapter/viewholder/impl/PollViewHolder.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/internal/poll/AddPollCommentDialogFragment.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/internal/poll/PollCommentsDialogFragment.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/internal/poll/SuggestPollOptionDialogFragment.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageListViewModel.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageListViewModelBinding.ktstream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/PollCommentsViewModel.ktstream-chat-android-ui-components/src/main/res/layout/stream_ui_dialog_add_poll_comment.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_dialog_suggest_poll_option.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_fragment_poll_comments.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_item_poll_add_comment.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_item_poll_comment.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_item_poll_suggest_option.xmlstream-chat-android-ui-components/src/main/res/layout/stream_ui_item_poll_view_comments.xmlstream-chat-android-ui-components/src/main/res/values/attrs_poll_view.xmlstream-chat-android-ui-components/src/main/res/values/strings.xmlstream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/viewmodels/messages/MessageListViewModelTest.ktstream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/viewmodels/messages/PollCommentsViewModelTest.kt
|


Goal
Port the recent v6 XML changes over to
develop.Bundles the following v6 PRs:
MessageListViewrotation crash and custommessagesStartnot being appliedoptionTextLimitto the suggest poll option dialoghttps://linear.app/stream/issue/AND-603/xmlpolls-some-features-are-missing
Implementation
develop.MessageListListenerContainer/MessageListListenerContainerImplareMessageListListeners/MessageListListenersImplon develop.CreatePollDialogListener.onCreatePolltakesCreatePollParamsinstead ofPollConfig.StateRegistryand thestate()extension now live underio.getstream.chat.android.client.api.state.stream_ui_poll_action_view_commentsplural lives inui-common, soPollViewreferences it viaUiCommonR.pluralsinstead ofR.plurals.UI Changes
Same as the original PRs.
Testing
allowAnswers = true: an "Add a comment" entry shows up until the current user posts an answer; afterwards a "View N comments" entry replaces it.ChatUI.pollsConfig.optionTextLimitis enforced on the input.PollsConfig: confirm question/option character limits and feature toggles (multiple votes, anonymous voting, suggest options, add comments) behave as configured.Summary by CodeRabbit
New Features