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

[AND-243] Save attachments on attachment picker dismiss #5554

Merged
merged 7 commits into from
Jan 23, 2025

Conversation

VelikovPetar
Copy link
Contributor

🎯 Goal

Add an additional configuration flag to AttachmentsPickerTheme(compose) and AttachmentsPickerDialogStyle(xml): saveAttachmentsOnDismiss which configures the whether the selected attachments should be 'saved' and added to the composer, if the user dismisses the picker. The idea is to prevent the 'loss' of attachments, if a user accidentally dismisses the picker after selecting one or more attachments. (Defaults to false, to persist the current default behaviour, where the selected attachments are dismissed if the picker is dismissed)

🛠 Implementation details

  • Add saveAttachmentsOnDismiss flag in AttachmentsPickerTheme(compose)
  • Add saveAttachmentsOnDismiss flag in AttachmentsPickerDialogStyle(xml)
  • If the flag is set to false, ensure the selected attachments are propagated to the composer after dismissing the picker

Usage

Compose:

ChatTheme(
        attachmentPickerTheme = AttachmentPickerTheme.defaultTheme(colors).copy(
              saveAttachmentsOnDismiss = true,
        ),
        // ...
) {
      // ...
}

XML:

<io.getstream.chat.android.ui.feature.messages.composer.MessageComposerView
        android:id="@+id/messageComposerView"
        app:streamUiMessageComposerAttachmentsPickerSaveAttachmentsOnDismiss="true"
        />

🎨 UI Changes

Add relevant screenshots

Compose XML
compose.mp4
xml.mp4

🧪 Testing

  1. Apply the provided patch
  2. Run either XML / Compose sample apps
  3. Open a channel
  4. Open attachments picker
  5. Select one or more attachments
  6. Dismiss the picker
  7. The attachments should be visible in the message composer
Patch
Subject: [PATCH] Add saveAttachmentsOnDismiss flag for attachments picker.
---
Index: stream-chat-android-ui-components-sample/src/main/res/layout/fragment_chat.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/stream-chat-android-ui-components-sample/src/main/res/layout/fragment_chat.xml b/stream-chat-android-ui-components-sample/src/main/res/layout/fragment_chat.xml
--- a/stream-chat-android-ui-components-sample/src/main/res/layout/fragment_chat.xml	(revision 668da80266c39373f806aa3f074adf86665de827)
+++ b/stream-chat-android-ui-components-sample/src/main/res/layout/fragment_chat.xml	(date 1736775065148)
@@ -52,6 +52,7 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/messageListView"
+        app:streamUiMessageComposerAttachmentsPickerSaveAttachmentsOnDismiss="true"
         />
 
 </androidx.constraintlayout.widget.ConstraintLayout>
Index: stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/MessagesActivity.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/MessagesActivity.kt b/stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/MessagesActivity.kt
--- a/stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/MessagesActivity.kt	(revision 668da80266c39373f806aa3f074adf86665de827)
+++ b/stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/MessagesActivity.kt	(date 1736776762477)
@@ -179,6 +179,7 @@
                 backgroundOverlay = colors.overlayDark,
                 backgroundSecondary = colors.inputBackground,
                 backgroundPrimary = colors.barsBackground,
+                saveAttachmentsOnDismiss = true,
             ),
             reactionOptionsTheme = ReactionOptionsTheme.defaultTheme(),
             messageOptionsTheme = MessageOptionsTheme.defaultTheme(

Copy link
Contributor

github-actions bot commented Jan 13, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.18 MB 3.18 MB 0.00 MB 🟢
stream-chat-android-offline 3.39 MB 3.39 MB 0.00 MB 🟢
stream-chat-android-ui-components 7.89 MB 7.89 MB 0.00 MB 🟢
stream-chat-android-compose 8.71 MB 8.71 MB 0.00 MB 🟢

@VelikovPetar VelikovPetar marked this pull request as ready for review January 13, 2025 15:05
@VelikovPetar VelikovPetar requested a review from a team as a code owner January 13, 2025 15:05
Copy link
Member

@skydoves skydoves left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@JcMinarro JcMinarro enabled auto-merge (squash) January 23, 2025 00:19
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JcMinarro JcMinarro merged commit 3268d8d into develop Jan 23, 2025
11 of 12 checks passed
@JcMinarro JcMinarro deleted the feature/save-attachments-on-dismiss branch January 23, 2025 10:43
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.

3 participants