Skip to content

Commit 94454fc

Browse files
maxkahanclaude
andcommitted
chore: bump Stream Chat Android to 7.13.0
Move every sample from Stream Chat Android 6.1.1 to 7.13.0 and update the toolchain v7 needs: Kotlin 2.2.21, AGP 8.13.2, Gradle 8.13, compileSdk 36 and navigation 2.8.4. The Compose sample now uses the Kotlin Compose compiler plugin instead of composeOptions. The Gradle heap goes to 4g because D8 ran out of memory at 2g with the larger v7 dependency graph. API moves, following the v6 to v7 migration guide: - The offline and state artifacts are gone. Clients are configured with ChatClientConfig(offlineEnabled = true, userPresence = true) instead of withPlugins(...). - XML: MessageListViewModelFactory -> ChannelViewModelFactory, MessageListHeaderView/ViewModel -> ChannelHeaderView/ViewModel (layout attrs streamUiMessageListHeader* -> streamUiChannelHeader*), MessageListActivity/Fragment -> ChannelActivity/Fragment, MessageListListenerContainer -> MessageListListeners, addSelectedAttachments -> addAttachments, and bindData now takes a non-null MessageListItemPayloadDiff. - Compose: AttachmentFactory and the attachmentFactories ChatTheme params are gone, so the date attachment rendering moves into a ChatComponentFactory (CustomAttachmentContent, MessageComposerAttachments, MessageQuotedContent, MessageComposerQuotedMessage, MessageComposerLeadingContent). MessagesViewModelFactory -> ChannelViewModelFactory, MessageListHeader -> ChannelHeader, the composer integrations slot -> onAttachmentsClick, ChannelsScreen onItemClick -> onChannelClick, CancelIcon -> ComposerCancelIcon, and theme tokens move to StreamDesign names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 595a427 commit 94454fc

31 files changed

Lines changed: 272 additions & 248 deletions

File tree

‎build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ buildscript {
99
dependencies {
1010
classpath libs.androidGradlePlugin
1111
classpath libs.kotlinGradlePlugin
12+
classpath libs.composeCompilerGradlePlugin
1213
classpath libs.navigationSafeArgsGradlePlugin
1314
classpath libs.spotlessPlugin
1415
}

‎compose-custom-attachments/build.gradle‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
plugins {
22
id 'com.android.application'
33
id 'kotlin-android'
4+
id 'org.jetbrains.kotlin.plugin.compose'
45
}
56

67
android {
7-
compileSdk 34
8+
compileSdk 36
89

910
defaultConfig {
1011
applicationId "io.getstream.chat.android.compose.customattachments"
@@ -24,9 +25,6 @@ android {
2425
buildFeatures {
2526
compose true
2627
}
27-
composeOptions {
28-
kotlinCompilerExtensionVersion libs.versions.composeCompiler.get()
29-
}
3028
compileOptions {
3129
sourceCompatibility = JavaVersion.VERSION_17
3230
targetCompatibility = JavaVersion.VERSION_17
@@ -35,16 +33,13 @@ android {
3533

3634
dependencies {
3735
// Stream SDK
38-
implementation "io.getstream:stream-chat-android-compose:6.1.1"
39-
implementation "io.getstream:stream-chat-android-state:6.1.1"
40-
implementation "io.getstream:stream-chat-android-offline:6.1.1"
36+
implementation "io.getstream:stream-chat-android-compose:7.13.0"
4137

4238
implementation libs.androidxCoreKtx
4339
implementation libs.androidxAppCompat
4440
implementation libs.materialComponents
4541

4642
// Compose
47-
implementation libs.composeCompiler
4843
implementation libs.composeUi
4944
implementation libs.composeUiTooling
5045
implementation libs.composeFoundation

‎compose-custom-attachments/src/main/java/io/getstream/chat/android/compose/customattachments/CustomAttachmentsApp.kt‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ package io.getstream.chat.android.compose.customattachments
2626

2727
import android.app.Application
2828
import io.getstream.chat.android.client.ChatClient
29+
import io.getstream.chat.android.client.api.ChatClientConfig
2930
import io.getstream.chat.android.client.logger.ChatLogLevel
3031
import io.getstream.chat.android.models.UploadAttachmentsNetworkType
3132
import io.getstream.chat.android.models.User
32-
import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
33-
import io.getstream.chat.android.state.plugin.config.StatePluginConfig
34-
import io.getstream.chat.android.state.plugin.factory.StreamStatePluginFactory
3533

3634
class CustomAttachmentsApp : Application() {
3735
override fun onCreate() {
@@ -41,18 +39,10 @@ class CustomAttachmentsApp : Application() {
4139
}
4240

4341
private fun setupStreamSdk() {
44-
val offlinePluginFactory = StreamOfflinePluginFactory(appContext = applicationContext)
45-
val statePluginFactory = StreamStatePluginFactory(
46-
config = StatePluginConfig(
47-
backgroundSyncEnabled = true,
48-
userPresence = true,
49-
),
50-
appContext = applicationContext,
51-
)
5242
ChatClient.Builder("qx5us2v6xvmh", applicationContext)
5343
.logLevel(ChatLogLevel.ALL)
5444
.uploadAttachmentsNetworkType(UploadAttachmentsNetworkType.NOT_ROAMING)
55-
.withPlugins(offlinePluginFactory, statePluginFactory)
45+
.config(ChatClientConfig(offlineEnabled = true, userPresence = true))
5646
.build()
5747
}
5848

‎compose-custom-attachments/src/main/java/io/getstream/chat/android/compose/customattachments/activity/ChannelsActivity.kt‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ package io.getstream.chat.android.compose.customattachments.activity
2727
import android.os.Bundle
2828
import androidx.activity.compose.setContent
2929
import androidx.appcompat.app.AppCompatActivity
30-
import io.getstream.chat.android.compose.customattachments.ui.dateAttachmentFactory
31-
import io.getstream.chat.android.compose.ui.attachments.StreamAttachmentFactories
30+
import io.getstream.chat.android.compose.customattachments.ui.CustomChatComponentFactory
3231
import io.getstream.chat.android.compose.ui.channels.ChannelsScreen
3332
import io.getstream.chat.android.compose.ui.theme.ChatTheme
3433

@@ -37,13 +36,10 @@ class ChannelsActivity : AppCompatActivity() {
3736
override fun onCreate(savedInstanceState: Bundle?) {
3837
super.onCreate(savedInstanceState)
3938

40-
val customFactories = listOf(dateAttachmentFactory)
41-
val defaultFactories = StreamAttachmentFactories.defaultFactories()
42-
4339
setContent {
44-
ChatTheme(attachmentFactories = customFactories + defaultFactories) {
40+
ChatTheme(componentFactory = CustomChatComponentFactory) {
4541
ChannelsScreen(
46-
onItemClick = { channel ->
42+
onChannelClick = { channel ->
4743
startActivity(MessagesActivity.getIntent(this, channel.cid))
4844
},
4945
onBackPressed = { finish() }

‎compose-custom-attachments/src/main/java/io/getstream/chat/android/compose/customattachments/activity/MessagesActivity.kt‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ import android.content.Intent
2929
import android.os.Bundle
3030
import androidx.activity.compose.setContent
3131
import androidx.appcompat.app.AppCompatActivity
32+
import io.getstream.chat.android.compose.customattachments.ui.CustomChatComponentFactory
3233
import io.getstream.chat.android.compose.customattachments.ui.CustomMessagesScreen
33-
import io.getstream.chat.android.compose.customattachments.ui.dateAttachmentFactory
34-
import io.getstream.chat.android.compose.customattachments.ui.quotedDateAttachmentFactory
35-
import io.getstream.chat.android.compose.ui.attachments.StreamAttachmentFactories
3634
import io.getstream.chat.android.compose.ui.theme.ChatTheme
3735

3836
class MessagesActivity : AppCompatActivity() {
@@ -41,17 +39,8 @@ class MessagesActivity : AppCompatActivity() {
4139
super.onCreate(savedInstanceState)
4240
val channelId = requireNotNull(intent.getStringExtra(KEY_CHANNEL_ID))
4341

44-
val customFactories = listOf(dateAttachmentFactory)
45-
val defaultFactories = StreamAttachmentFactories.defaultFactories()
46-
47-
val customQuotedFactories = listOf(quotedDateAttachmentFactory)
48-
val defaultQuotedFactories = StreamAttachmentFactories.defaultQuotedFactories()
49-
5042
setContent {
51-
ChatTheme(
52-
attachmentFactories = customFactories + defaultFactories,
53-
quotedAttachmentFactories = customQuotedFactories + defaultQuotedFactories
54-
) {
43+
ChatTheme(componentFactory = CustomChatComponentFactory) {
5544
CustomMessagesScreen(
5645
channelId = channelId,
5746
onBackPressed = { finish() }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright 2022 Stream.IO, Inc. All Rights Reserved.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package io.getstream.chat.android.compose.customattachments.ui
26+
27+
import androidx.compose.foundation.layout.Box
28+
import androidx.compose.foundation.layout.Column
29+
import androidx.compose.foundation.layout.fillMaxWidth
30+
import androidx.compose.foundation.layout.offset
31+
import androidx.compose.foundation.layout.padding
32+
import androidx.compose.foundation.layout.size
33+
import androidx.compose.foundation.layout.wrapContentHeight
34+
import androidx.compose.material.Icon
35+
import androidx.compose.material.IconButton
36+
import androidx.compose.runtime.Composable
37+
import androidx.compose.ui.Alignment
38+
import androidx.compose.ui.Modifier
39+
import androidx.compose.ui.res.painterResource
40+
import androidx.compose.ui.unit.dp
41+
import io.getstream.chat.android.compose.customattachments.R
42+
import io.getstream.chat.android.compose.ui.components.ComposerCancelIcon
43+
import io.getstream.chat.android.compose.ui.theme.ChatComponentFactory
44+
import io.getstream.chat.android.compose.ui.theme.ChatTheme
45+
import io.getstream.chat.android.compose.ui.theme.CustomAttachmentContentParams
46+
import io.getstream.chat.android.compose.ui.theme.MessageComposerAttachmentsParams
47+
import io.getstream.chat.android.compose.ui.theme.MessageComposerLeadingContentParams
48+
import io.getstream.chat.android.compose.ui.theme.MessageComposerQuotedMessageParams
49+
import io.getstream.chat.android.compose.ui.theme.MessageQuotedContentParams
50+
51+
/**
52+
* A custom [ChatComponentFactory] that adds support for date attachments.
53+
*
54+
* It renders date attachments in the message list, in the composer preview and in quoted
55+
* messages, and replaces the composer's leading button with a calendar button.
56+
*/
57+
object CustomChatComponentFactory : ChatComponentFactory {
58+
59+
@Composable
60+
override fun CustomAttachmentContent(params: CustomAttachmentContentParams) {
61+
if (params.state.message.attachments.any { it.type == "date" }) {
62+
DateAttachmentContent(
63+
modifier = params.modifier,
64+
attachmentState = params.state
65+
)
66+
}
67+
}
68+
69+
@Composable
70+
override fun MessageComposerAttachments(params: MessageComposerAttachmentsParams) {
71+
val (dateAttachments, otherAttachments) = params.attachments.partition { it.type == "date" }
72+
73+
Column(modifier = params.modifier) {
74+
if (dateAttachments.isNotEmpty()) {
75+
DateAttachmentPreviewContent(
76+
modifier = Modifier
77+
.fillMaxWidth()
78+
.wrapContentHeight(),
79+
attachments = dateAttachments,
80+
onAttachmentRemoved = params.onAttachmentRemoved
81+
)
82+
}
83+
if (otherAttachments.isNotEmpty()) {
84+
super.MessageComposerAttachments(
85+
params = params.copy(
86+
modifier = Modifier
87+
.fillMaxWidth()
88+
.wrapContentHeight(),
89+
attachments = otherAttachments
90+
)
91+
)
92+
}
93+
}
94+
}
95+
96+
@Composable
97+
override fun MessageQuotedContent(params: MessageQuotedContentParams) {
98+
if (params.message.attachments.any { it.type == "date" }) {
99+
QuotedDateAttachmentContent(
100+
modifier = params.modifier,
101+
message = params.message
102+
)
103+
} else {
104+
super.MessageQuotedContent(params)
105+
}
106+
}
107+
108+
@Composable
109+
override fun MessageComposerQuotedMessage(params: MessageComposerQuotedMessageParams) {
110+
if (params.quotedMessage.attachments.any { it.type == "date" }) {
111+
Box(modifier = params.modifier.padding(horizontal = 8.dp)) {
112+
QuotedDateAttachmentContent(message = params.quotedMessage)
113+
114+
ComposerCancelIcon(
115+
modifier = Modifier
116+
.align(Alignment.TopEnd)
117+
.offset(x = 4.dp, y = (-4).dp),
118+
onClick = params.onCancelClick
119+
)
120+
}
121+
} else {
122+
super.MessageComposerQuotedMessage(params)
123+
}
124+
}
125+
126+
@Composable
127+
override fun MessageComposerLeadingContent(params: MessageComposerLeadingContentParams) {
128+
IconButton(
129+
modifier = params.modifier
130+
.size(48.dp)
131+
.padding(12.dp),
132+
content = {
133+
Icon(
134+
painter = painterResource(id = R.drawable.ic_calendar),
135+
contentDescription = null,
136+
tint = ChatTheme.colors.textSecondary
137+
)
138+
},
139+
onClick = params.onAttachmentsClick
140+
)
141+
}
142+
}

0 commit comments

Comments
 (0)