Skip to content

Commit

Permalink
Merge pull request #46 from sendbird/release/3.22.0
Browse files Browse the repository at this point in the history
3.22.0
  • Loading branch information
sendbird-sdk-deployment authored Dec 16, 2024
2 parents 7c7849f + 6737fde commit f4e815d
Show file tree
Hide file tree
Showing 56 changed files with 756 additions and 2,303 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
### v3.22.0 (Dec 16, 2024) with Chat SDK `v4.21.1`
* Templated-related code has been moved to a separate module.
### v3.21.1 (Nov 12, 2024) with Chat SDK `v4.20.0`
* Fixed thumbs up reaction not working in chat messages.
### v3.21.0 (Sep 12, 2024) with Chat SDK `v4.19.0`
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.enableR8.fullMode=false

UIKIT_VERSION = 3.21.1
UIKIT_VERSION = 3.22.0
UIKIT_VERSION_CODE = 1
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ dependencyResolutionManagement {
}

include ':uikit'
rootProject.name='sendbird-uikit-android-sources'
include ':uikit-samples'
rootProject.name='sendbird-uikit-android-sources'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Sendbird
api 'com.sendbird.sdk:sendbird-chat:4.20.0'
api 'com.sendbird.sdk:sendbird-chat:4.21.1'
implementation "com.sendbird.sdk:message-template:1.0.0"

implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
Expand Down
1 change: 1 addition & 0 deletions uikit/internal.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
androidTestImplementation "androidx.arch.core:core-testing:2.2.0"
androidTestImplementation 'io.kotest:kotest-assertions-core:5.3.0'

testImplementation 'com.google.code.gson:gson:2.9.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.robolectric:robolectric:4.10'
testImplementation 'androidx.test:core:1.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public Builder withArguments(@NonNull Bundle args) {

/**
* Sets the click listener on the message template view clicked.
* Sets the click listener when the view component that has {@link com.sendbird.uikit.model.Action} is clicked
* Sets the click listener when the view component that has {@link Action} is clicked
*
* @param handler The callback that will run.
* @return This Builder object to allow for chaining of calls to set methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public Builder withArguments(@NonNull Bundle args) {

/**
* Sets the click listener on the message template view clicked.
* Sets the click listener when the view component that has {@link com.sendbird.uikit.model.Action} is clicked
* Sets the click listener when the view component that has {@link Action} is clicked
*
* @param handler The callback that will run.
* @return This Builder object to allow for chaining of calls to set methods.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import com.sendbird.android.message.Emoji
import com.sendbird.android.message.FileMessage
import com.sendbird.android.message.MessageFormItem
import com.sendbird.android.message.MultipleFilesMessage
import com.sendbird.android.shadow.com.google.gson.JsonParser
import com.sendbird.uikit.R
import com.sendbird.uikit.activities.adapter.MessageFormViewType
import com.sendbird.uikit.consts.StringSet
import com.sendbird.uikit.internal.singleton.MessageDisplayDataManager
import com.sendbird.uikit.model.MessageList
import com.sendbird.uikit.log.Logger
import com.sendbird.uikit.model.EmojiManager
import com.sendbird.uikit.model.MessageList
import com.sendbird.uikit.model.UserMessageDisplayData
import com.sendbird.uikit.utils.MessageUtils
import org.json.JSONObject

internal fun BaseMessage.hasParentMessage() = parentMessageId != 0L

Expand Down Expand Up @@ -165,7 +165,7 @@ internal val BaseMessage.isStreamMessage: Boolean
return false
}
return try {
JsonParser.parseString(data).asJsonObject[StringSet.stream].asBoolean
JSONObject(data).getBoolean(StringSet.stream)
} catch (e: Exception) {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ package com.sendbird.uikit.internal.extensions

import com.sendbird.android.annotation.AIChatBotExperimental
import com.sendbird.android.channel.TemplateMessageData
import com.sendbird.android.exception.SendbirdException
import com.sendbird.android.message.BaseMessage
import com.sendbird.message.template.consts.MessageTemplateError
import com.sendbird.message.template.consts.TemplateTheme
import com.sendbird.message.template.model.TemplateParams
import com.sendbird.uikit.SendbirdUIKit
import com.sendbird.uikit.SendbirdUIKit.ThemeMode
import com.sendbird.uikit.consts.StringSet
import com.sendbird.uikit.internal.model.template_messages.Params
import com.sendbird.uikit.internal.model.notifications.NotificationThemeMode
import com.sendbird.uikit.internal.model.templates.MessageTemplateStatus
import com.sendbird.uikit.internal.singleton.MessageTemplateManager
import com.sendbird.uikit.internal.singleton.MessageTemplateParser

internal fun BaseMessage.isTemplateMessage(): Boolean {
return this.templateMessageData != null
Expand All @@ -25,22 +30,16 @@ internal fun TemplateMessageData?.isValid(): Boolean {
internal fun BaseMessage.saveParamsFromTemplate() {
val templateMessageData = this.templateMessageData ?: return
val key = templateMessageData.key
val template = MessageTemplateManager.getTemplate(key)
if (template != null) {
val syntax = template.getTemplateSyntax(
templateMessageData.variables,
templateMessageData.viewVariables
)

try {
val params = MessageTemplateParser.parse(syntax)
this.messageTemplateStatus = MessageTemplateStatus.CACHED
this.messageTemplateParams = params
} catch (e: Exception) {
this.messageTemplateStatus = MessageTemplateStatus.FAILED_TO_PARSE
try {
val params = MessageTemplateManager.parseTemplate(key, templateMessageData.variables, templateMessageData.viewVariables)
this.messageTemplateStatus = MessageTemplateStatus.CACHED
this.messageTemplateParams = params
} catch (e: SendbirdException) {
when (e.code) {
MessageTemplateError.ERROR_TEMPLATE_NOT_EXIST -> this.messageTemplateStatus = MessageTemplateStatus.FAILED_TO_FETCH
MessageTemplateError.ERROR_TEMPLATE_PARSE_FAILED -> this.messageTemplateStatus = MessageTemplateStatus.FAILED_TO_PARSE
}
} else {
this.messageTemplateStatus = MessageTemplateStatus.FAILED_TO_FETCH
}
}

Expand All @@ -67,8 +66,8 @@ internal var BaseMessage.messageTemplateStatus: MessageTemplateStatus?
}

@OptIn(AIChatBotExperimental::class)
internal var BaseMessage.messageTemplateParams: Params?
get() = extras[StringSet.message_template_params] as? Params
internal var BaseMessage.messageTemplateParams: TemplateParams?
get() = extras[StringSet.message_template_params] as? TemplateParams
set(value) {
if (value == null) {
extras.remove(StringSet.message_template_params)
Expand All @@ -77,6 +76,21 @@ internal var BaseMessage.messageTemplateParams: Params?
}
}

internal fun ThemeMode.toTemplateTheme(): TemplateTheme {
return when (this) {
ThemeMode.Light -> TemplateTheme.Light
ThemeMode.Dark -> TemplateTheme.Dark
}
}

internal fun NotificationThemeMode.toTemplateTheme(): TemplateTheme {
return when (this) {
NotificationThemeMode.Light -> TemplateTheme.Light
NotificationThemeMode.Dark -> TemplateTheme.Dark
NotificationThemeMode.Default -> SendbirdUIKit.getDefaultThemeMode().toTemplateTheme()
}
}

internal enum class MessageTemplateContainerType {
UNKNOWN, DEFAULT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ package com.sendbird.uikit.internal.extensions
import android.annotation.SuppressLint
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.RippleDrawable
import android.os.Build
import android.util.TypedValue
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ProgressBar
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
Expand All @@ -30,11 +25,6 @@ import com.sendbird.android.message.FeedbackRating
import com.sendbird.uikit.R
import com.sendbird.uikit.consts.StringSet
import com.sendbird.uikit.internal.interfaces.OnFeedbackRatingClickListener
import com.sendbird.uikit.internal.model.notifications.NotificationThemeMode
import com.sendbird.uikit.internal.model.template_messages.Params
import com.sendbird.uikit.internal.model.template_messages.TemplateParamsCreator
import com.sendbird.uikit.internal.model.template_messages.TemplateViewGenerator.spinnerColor
import com.sendbird.uikit.utils.DrawableUtils
import com.sendbird.uikit.widgets.FeedbackView

@Suppress("DEPRECATION")
Expand Down Expand Up @@ -155,45 +145,3 @@ internal fun FeedbackView.drawFeedback(message: BaseMessage, listener: OnFeedbac
listener?.onFeedbackClicked(message, feedbackRating)
}
}

internal fun Context.createTemplateMessageLoadingView(): View {
val height = resources.getDimensionPixelSize(R.dimen.sb_template_message_loading_view_height)
return FrameLayout(this).apply {
layoutParams = FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height)
setBackgroundColor(Color.TRANSPARENT)
addView(
ProgressBar(context).apply {
val size = resources.intToDp(42)
layoutParams = FrameLayout.LayoutParams(
size, size, Gravity.CENTER
)
val loading = DrawableUtils.setTintList(
context,
R.drawable.sb_progress,
ColorStateList.valueOf(NotificationThemeMode.Default.spinnerColor)
)
this.indeterminateDrawable = loading
}
)
}
}

internal fun Context.createFallbackViewParams(message: BaseMessage): Params {
return createFallbackViewParams(message.message)
}

internal fun Context.createFallbackViewParams(message: String): Params {
return TemplateParamsCreator.createMessageTemplateDefaultViewParam(
message,
this.getString(R.string.sb_text_template_message_fallback_title),
this.getString(R.string.sb_text_template_message_fallback_description),
)
}

internal fun TextView.applyTextAlignment(gravity: Int) {
if ((gravity and Gravity.START) == Gravity.START) {
textAlignment = View.TEXT_ALIGNMENT_VIEW_START
} else if ((gravity and Gravity.END) == Gravity.END) {
textAlignment = View.TEXT_ALIGNMENT_VIEW_END
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.sendbird.uikit.internal.interfaces

import com.sendbird.android.exception.SendbirdException
import com.sendbird.message.template.model.TemplateParams

internal interface GetTemplateResultHandler {
fun onResult(templateKey: String, jsonTemplate: String?, isDataTemplate: Boolean, e: SendbirdException?)
internal fun interface GetTemplateResultHandler {
fun onResult(templateKey: String, templateParams: TemplateParams?, e: SendbirdException?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.sendbird.uikit.internal.model

import androidx.recyclerview.widget.DiffUtil
import com.sendbird.android.message.BaseMessage
import com.sendbird.uikit.internal.extensions.messageTemplateStatus

internal class NotificationDiffCallback(
private val oldMessageList: List<BaseMessage>,
Expand Down Expand Up @@ -75,6 +76,10 @@ internal class NotificationDiffCallback(
return false
}

if (oldMessage.messageTemplateStatus != newMessage.messageTemplateStatus) {
return false
}

val prevIsNew: Boolean = oldMessage.createdAt > oldLastSeenAt
val currentIsNew: Boolean = newMessage.createdAt > newLastSeenAt
if (prevIsNew != currentIsNew) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

package com.sendbird.uikit.internal.model.notifications

import com.sendbird.message.template.consts.Weight
import com.sendbird.uikit.internal.model.serializer.CSVColorIntAsStringSerializer
import com.sendbird.uikit.internal.model.template_messages.KeySet
import com.sendbird.uikit.internal.model.template_messages.Weight
import com.sendbird.uikit.internal.singleton.JsonParser
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Loading

0 comments on commit f4e815d

Please sign in to comment.