Skip to content

Commit

Permalink
Merge pull request #60 from GetStream/upgrade-stream-v6
Browse files Browse the repository at this point in the history
Upgrade stream v6
  • Loading branch information
skydoves authored Oct 19, 2023
2 parents 3ebe160 + c7a5b0d commit 42960e0
Show file tree
Hide file tree
Showing 54 changed files with 517 additions and 330 deletions.
4 changes: 3 additions & 1 deletion compose-custom-attachments/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ android {

dependencies {
// Stream SDK
implementation "io.getstream:stream-chat-android-compose:5.17.0"
implementation "io.getstream:stream-chat-android-compose:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-state:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-offline:6.0.0-beta2"

implementation libs.androidxCoreKtx
implementation libs.androidxAppCompat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ package io.getstream.chat.android.compose.customattachments
import android.app.Application
import io.getstream.chat.android.client.ChatClient
import io.getstream.chat.android.client.logger.ChatLogLevel
import io.getstream.chat.android.client.models.User
import io.getstream.chat.android.offline.model.message.attachments.UploadAttachmentsNetworkType
import io.getstream.chat.android.offline.plugin.configuration.Config
import io.getstream.chat.android.models.UploadAttachmentsNetworkType
import io.getstream.chat.android.models.User
import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
import io.getstream.chat.android.state.plugin.config.StatePluginConfig
import io.getstream.chat.android.state.plugin.factory.StreamStatePluginFactory

class CustomAttachmentsApp : Application() {
override fun onCreate() {
Expand All @@ -40,18 +41,18 @@ class CustomAttachmentsApp : Application() {
}

private fun setupStreamSdk() {
val offlinePluginFactory = StreamOfflinePluginFactory(
config = Config(
val offlinePluginFactory = StreamOfflinePluginFactory(appContext = applicationContext)
val statePluginFactory = StreamStatePluginFactory(
config = StatePluginConfig(
backgroundSyncEnabled = true,
userPresence = true,
persistenceEnabled = true,
uploadAttachmentsNetworkType = UploadAttachmentsNetworkType.NOT_ROAMING
),
appContext = applicationContext
appContext = applicationContext,
)
ChatClient.Builder("qx5us2v6xvmh", applicationContext)
.logLevel(ChatLogLevel.ALL)
.withPlugin(offlinePluginFactory)
.uploadAttachmentsNetworkType(UploadAttachmentsNetworkType.NOT_ROAMING)
.withPlugins(offlinePluginFactory, statePluginFactory)
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.android.material.datepicker.MaterialDatePicker
import io.getstream.chat.android.client.models.Attachment
import io.getstream.chat.android.common.state.MessageMode
import io.getstream.chat.android.common.state.Reply
import io.getstream.chat.android.compose.customattachments.R
import io.getstream.chat.android.compose.ui.messages.MessagesScreen
import io.getstream.chat.android.compose.ui.messages.composer.MessageComposer
Expand All @@ -58,6 +55,9 @@ import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.compose.viewmodel.messages.MessageComposerViewModel
import io.getstream.chat.android.compose.viewmodel.messages.MessageListViewModel
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.chat.android.models.Attachment
import io.getstream.chat.android.ui.common.state.messages.MessageMode
import io.getstream.chat.android.ui.common.state.messages.Reply
import java.text.DateFormat
import java.util.Date

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import io.getstream.chat.android.client.models.Attachment
import io.getstream.chat.android.compose.customattachments.R
import io.getstream.chat.android.compose.state.messages.attachments.AttachmentState
import io.getstream.chat.android.compose.ui.attachments.AttachmentFactory
import io.getstream.chat.android.compose.ui.components.CancelIcon
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.models.Attachment

/**
* A custom [AttachmentFactory] that adds support for date attachments.
Expand Down
4 changes: 3 additions & 1 deletion custom-attachments-message-composer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ android {

dependencies {
// Stream SDK dependency
implementation "io.getstream:stream-chat-android-ui-components:5.17.0"
implementation "io.getstream:stream-chat-android-ui-components:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-state:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-offline:6.0.0-beta2"

implementation libs.androidxCoreKtx
implementation libs.androidxActivityKtx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ package io.getstream.chat.android.customattachments
import android.app.Application
import io.getstream.chat.android.client.ChatClient
import io.getstream.chat.android.client.logger.ChatLogLevel
import io.getstream.chat.android.client.models.User
import io.getstream.chat.android.customattachments.factory.DateAttachmentFactory
import io.getstream.chat.android.customattachments.factory.DateAttachmentPreviewFactory
import io.getstream.chat.android.customattachments.factory.QuotedDateAttachmentFactory
import io.getstream.chat.android.offline.plugin.configuration.Config
import io.getstream.chat.android.models.User
import io.getstream.chat.android.offline.plugin.factory.StreamOfflinePluginFactory
import io.getstream.chat.android.state.plugin.config.StatePluginConfig
import io.getstream.chat.android.state.plugin.factory.StreamStatePluginFactory
import io.getstream.chat.android.ui.ChatUI
import io.getstream.chat.android.ui.message.composer.attachment.AttachmentPreviewFactoryManager
import io.getstream.chat.android.ui.message.composer.attachment.factory.FileAttachmentPreviewFactory
import io.getstream.chat.android.ui.message.composer.attachment.factory.ImageAttachmentPreviewFactory
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.AttachmentFactoryManager
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.DefaultQuotedAttachmentMessageFactory
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.QuotedAttachmentFactoryManager
import io.getstream.chat.android.ui.feature.messages.composer.attachment.preview.AttachmentPreviewFactoryManager
import io.getstream.chat.android.ui.feature.messages.composer.attachment.preview.factory.FileAttachmentPreviewFactory
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.AttachmentFactoryManager
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.DefaultQuotedAttachmentMessageFactory
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.QuotedAttachmentFactoryManager

class App : Application() {
override fun onCreate() {
Expand All @@ -49,28 +49,33 @@ class App : Application() {
}

private fun setupStreamSdk() {
val offlinePluginFactory = StreamOfflinePluginFactory(
config = Config(),
appContext = applicationContext
val offlinePluginFactory = StreamOfflinePluginFactory(appContext = applicationContext)
val statePluginFactory = StreamStatePluginFactory(
config = StatePluginConfig(),
appContext = applicationContext,
)
ChatClient.Builder("qx5us2v6xvmh", applicationContext)
.logLevel(ChatLogLevel.ALL)
.withPlugin(offlinePluginFactory)
.withPlugins(offlinePluginFactory, statePluginFactory)
.build()

ChatUI.attachmentFactoryManager = AttachmentFactoryManager(listOf(DateAttachmentFactory()))
ChatUI.attachmentFactoryManager = AttachmentFactoryManager(
attachmentFactories = listOf(
DateAttachmentFactory()
)
)

ChatUI.attachmentPreviewFactoryManager = AttachmentPreviewFactoryManager(
listOf(
DateAttachmentPreviewFactory(),
ImageAttachmentPreviewFactory(),
FileAttachmentPreviewFactory()
)
)

ChatUI.quotedAttachmentFactoryManager = QuotedAttachmentFactoryManager(
listOf(
quotedAttachmentFactories = listOf(
QuotedDateAttachmentFactory(),
// The default factory
DefaultQuotedAttachmentMessageFactory()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

package io.getstream.chat.android.customattachments.activity

import io.getstream.chat.android.client.models.Channel
import io.getstream.chat.android.ui.channel.ChannelListActivity
import io.getstream.chat.android.ui.channel.ChannelListFragment
import io.getstream.chat.android.models.Channel
import io.getstream.chat.android.ui.feature.channels.ChannelListActivity
import io.getstream.chat.android.ui.feature.channels.ChannelListFragment

class ChannelsActivity : ChannelListActivity(), ChannelListFragment.ChannelListItemClickListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,27 @@ import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel
import com.google.android.material.datepicker.MaterialDatePicker
import io.getstream.chat.android.client.models.Attachment
import io.getstream.chat.android.client.models.ChannelCapabilities
import io.getstream.chat.android.common.composer.MessageComposerState
import io.getstream.chat.android.common.state.Edit
import io.getstream.chat.android.common.state.MessageMode
import io.getstream.chat.android.common.state.Reply
import io.getstream.chat.android.core.ExperimentalStreamChatApi
import io.getstream.chat.android.customattachments.databinding.ActivityMessagesBinding
import io.getstream.chat.android.customattachments.databinding.CustomMessageComposerLeadingContentBinding
import io.getstream.chat.android.ui.message.composer.MessageComposerContext
import io.getstream.chat.android.ui.message.composer.MessageComposerViewStyle
import io.getstream.chat.android.ui.message.composer.content.MessageComposerContent
import io.getstream.chat.android.ui.message.composer.viewmodel.MessageComposerViewModel
import io.getstream.chat.android.ui.message.composer.viewmodel.bindView
import io.getstream.chat.android.ui.message.list.header.viewmodel.MessageListHeaderViewModel
import io.getstream.chat.android.ui.message.list.header.viewmodel.bindView
import io.getstream.chat.android.ui.message.list.viewmodel.bindView
import io.getstream.chat.android.ui.message.list.viewmodel.factory.MessageListViewModelFactory
import io.getstream.chat.android.models.Attachment
import io.getstream.chat.android.models.ChannelCapabilities
import io.getstream.chat.android.ui.common.state.messages.Edit
import io.getstream.chat.android.ui.common.state.messages.MessageMode
import io.getstream.chat.android.ui.common.state.messages.Reply
import io.getstream.chat.android.ui.common.state.messages.composer.MessageComposerState
import io.getstream.chat.android.ui.feature.messages.composer.MessageComposerContext
import io.getstream.chat.android.ui.feature.messages.composer.MessageComposerViewStyle
import io.getstream.chat.android.ui.feature.messages.composer.content.MessageComposerContent
import io.getstream.chat.android.ui.viewmodel.messages.MessageComposerViewModel
import io.getstream.chat.android.ui.viewmodel.messages.MessageListHeaderViewModel
import io.getstream.chat.android.ui.viewmodel.messages.MessageListViewModel
import io.getstream.chat.android.ui.viewmodel.messages.MessageListViewModelFactory
import io.getstream.chat.android.ui.viewmodel.messages.bindView
import java.text.DateFormat
import java.util.Date

@OptIn(ExperimentalStreamChatApi::class)
class MessagesActivity : AppCompatActivity() {
private lateinit var binding: ActivityMessagesBinding

Expand All @@ -80,11 +77,11 @@ class MessagesActivity : AppCompatActivity() {

messageListViewModel.mode.observe(this) {
when (it) {
is MessageListViewModel.Mode.Thread -> {
is MessageMode.MessageThread -> {
messageListHeaderViewModel.setActiveThread(it.parentMessage)
messageComposerViewModel.setMessageMode(MessageMode.MessageThread(it.parentMessage))
}
is MessageListViewModel.Mode.Normal -> {
is MessageMode.Normal -> {
messageListHeaderViewModel.resetThread()
messageComposerViewModel.leaveThread()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ package io.getstream.chat.android.customattachments.factory

import android.view.LayoutInflater
import android.view.ViewGroup
import io.getstream.chat.android.client.models.Message
import io.getstream.chat.android.customattachments.databinding.ItemDateAttachmentBinding
import io.getstream.chat.android.ui.message.list.adapter.MessageListListenerContainer
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.AttachmentFactory
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.InnerAttachmentViewHolder
import io.getstream.chat.android.models.Message
import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListenerContainer
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.AttachmentFactory
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.InnerAttachmentViewHolder

class DateAttachmentFactory : AttachmentFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ package io.getstream.chat.android.customattachments.factory

import android.view.LayoutInflater
import android.view.ViewGroup
import io.getstream.chat.android.client.models.Attachment
import io.getstream.chat.android.customattachments.databinding.ItemDateAttachmentPreviewBinding
import io.getstream.chat.android.ui.message.composer.attachment.AttachmentPreviewViewHolder
import io.getstream.chat.android.ui.message.composer.attachment.factory.AttachmentPreviewFactory
import io.getstream.chat.android.models.Attachment
import io.getstream.chat.android.ui.feature.messages.composer.MessageComposerViewStyle
import io.getstream.chat.android.ui.feature.messages.composer.attachment.preview.AttachmentPreviewViewHolder
import io.getstream.chat.android.ui.feature.messages.composer.attachment.preview.factory.AttachmentPreviewFactory

class DateAttachmentPreviewFactory : AttachmentPreviewFactory {

Expand All @@ -39,7 +40,8 @@ class DateAttachmentPreviewFactory : AttachmentPreviewFactory {

override fun onCreateViewHolder(
parentView: ViewGroup,
attachmentRemovalListener: (Attachment) -> Unit
attachmentRemovalListener: (Attachment) -> Unit,
style: MessageComposerViewStyle?
): AttachmentPreviewViewHolder {
return ItemDateAttachmentPreviewBinding
.inflate(LayoutInflater.from(parentView.context), parentView, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import io.getstream.chat.android.client.models.Attachment
import io.getstream.chat.android.client.models.Message
import io.getstream.chat.android.customattachments.databinding.ViewQuotedDateAttachmentBinding
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.QuotedAttachmentFactory
import io.getstream.chat.android.models.Attachment
import io.getstream.chat.android.models.Message
import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.QuotedAttachmentFactory
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<io.getstream.chat.android.ui.message.list.header.MessageListHeaderView
<io.getstream.chat.android.ui.feature.messages.header.MessageListHeaderView
android:id="@+id/messageListHeaderView"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<io.getstream.chat.android.ui.message.list.MessageListView
<io.getstream.chat.android.ui.feature.messages.list.MessageListView
android:id="@+id/messageListView"
android:layout_width="0dp"
android:layout_height="0dp"
Expand All @@ -44,7 +44,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/messageListHeaderView" />

<io.getstream.chat.android.ui.message.composer.MessageComposerView
<io.getstream.chat.android.ui.feature.messages.composer.MessageComposerView
android:id="@+id/messageComposerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,4 @@
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>

<style name="CustomStreamUiTheme" parent="@style/StreamUiTheme">
<item name="streamUiMessageInputViewStyle">@style/CustomMessageInputViewStyle</item>
</style>

<style name="CustomMessageInputViewStyle">
<item name="streamUiAttachButtonIcon">@drawable/ic_calendar</item>
</style>
</resources>
4 changes: 3 additions & 1 deletion custom-attachments-message-input/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ android {

dependencies {
// Stream SDK dependency
implementation "io.getstream:stream-chat-android-ui-components:5.17.0"
implementation "io.getstream:stream-chat-android-ui-components:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-state:6.0.0-beta2"
implementation "io.getstream:stream-chat-android-offline:6.0.0-beta2"

implementation libs.androidxCoreKtx
implementation libs.androidxActivityKtx
Expand Down
Loading

0 comments on commit 42960e0

Please sign in to comment.