Skip to content

Commit

Permalink
Added v3.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sendbird-sdk-deployment committed Aug 29, 2024
1 parent c2f6aa7 commit 70ebb13
Show file tree
Hide file tree
Showing 43 changed files with 718 additions and 291 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
### v3.20.0 (Aug 29, 2024) with Chat SDK `v4.18.0`
* Added support for EmojiCategory. You can now filter emojis for different messages when adding Reactions to a message.
* New Interfaces
```kotlin
class BaseMessageListAdapter {
fun getEmojiCategories(message: BaseMessage): List<Long>? {
return null
}
}
```
* Note: You need to set your custom EmojiCategory using [Sendbird Platform API](https://sendbird.com/docs/chat/platform-api/v3/message/reactions-and-emojis/reactions-and-emojis-overview) in advance.
### v3.19.0 (Aug 1, 2024) with Chat SDK `v4.17.0`
* Deprecated `authenticateFeed(AuthenticationHandler)` in `SendbirdUIKit`, which is replaced by `authenticate(AuthenticationHandler)`.
* Fixed the crash issue caused by the `bindingAdapterPosition` in the RecyclerView not being returned correctly.
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.19.0
UIKIT_VERSION = 3.20.0
UIKIT_VERSION_CODE = 1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import com.sendbird.uikit.samples.databinding.ActivityWebViewAiChatbotBinding
import com.sendbird.uikit.samples.databinding.DialogWebViewAiChatbotBinding

// Set the Bot ID
private const val BOT_ID = "client_bot"
private const val BOT_ID = "onboarding_bot"
private const val WEB_VIEW_SAMPLE_APP_ID = "C127D74A-67AF-4762-ABF8-09354638B138"

fun showWebViewAiChatBotSample(activity: Activity) {
activity.startActivity(Intent(activity, WebViewAiChatBotActivity::class.java))
Expand Down Expand Up @@ -71,7 +72,7 @@ class WebViewAiChatBotActivity : AppCompatActivity() {
if (url == null) {
loadDataWithBaseURL(
"app://local", // Added baseUrl to preserve chat history when the page reloads, allowing restoration of previous chat sessions
widgetHtmlString(PreferenceUtils.appId, BOT_ID),
widgetHtmlString(WEB_VIEW_SAMPLE_APP_ID, BOT_ID),
"text/html",
"utf-8",
null
Expand Down
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Sendbird
api 'com.sendbird.sdk:sendbird-chat:4.17.0'
api 'com.sendbird.sdk:sendbird-chat:4.18.0'

implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
import com.sendbird.uikit.interfaces.OnIdentifiableItemLongClickListener;
import com.sendbird.uikit.interfaces.OnItemClickListener;
import com.sendbird.uikit.interfaces.OnMessageListUpdateHandler;
import com.sendbird.uikit.internal.contracts.SendbirdUIKitContract;
import com.sendbird.uikit.internal.contracts.SendbirdUIKitImpl;
import com.sendbird.uikit.internal.extensions.MessageExtensionsKt;
import com.sendbird.uikit.internal.interfaces.OnFeedbackRatingClickListener;
import com.sendbird.uikit.internal.singleton.MessageDisplayDataManager;
import com.sendbird.uikit.internal.ui.viewholders.MyUserMessageViewHolder;
import com.sendbird.uikit.internal.ui.viewholders.OtherUserMessageViewHolder;
import com.sendbird.uikit.internal.contracts.SendbirdUIKitImpl;
import com.sendbird.uikit.internal.contracts.SendbirdUIKitContract;
import com.sendbird.uikit.log.Logger;
import com.sendbird.uikit.model.MessageListUIParams;
import com.sendbird.uikit.model.MessageUIConfig;
Expand Down Expand Up @@ -240,7 +241,7 @@ public void onBindViewHolder(@NonNull MessageViewHolder holder, final int positi
if (ChannelConfig.getEnableReactions(messageListUIParams.getChannelConfig(), channel) && holder instanceof EmojiReactionHandler) {
EmojiReactionHandler emojiReactionHandler = (EmojiReactionHandler) holder;
List<Reaction> reactionList = current.getReactions();
emojiReactionHandler.setEmojiReaction(reactionList, (view, reactionPosition, reactionKey) -> {
emojiReactionHandler.setEmojiReaction(reactionList, MessageExtensionsKt.allowedEmojiList(current), (view, reactionPosition, reactionKey) -> {
int messagePosition = holder.getBindingAdapterPosition();
if (messagePosition != NO_POSITION && emojiReactionClickListener != null) {
emojiReactionClickListener.onEmojiReactionClick(
Expand Down Expand Up @@ -358,12 +359,14 @@ public void setItems(@NonNull final GroupChannel channel, @NonNull final List<Ba
if (messageDisplayDataProvider == null || messageDisplayDataProvider.shouldRunOnUIThread()) {
if (messageDisplayDataProvider != null)
MessageDisplayDataManager.checkAndGenerateDisplayData(messageList, messageDisplayDataProvider);
MessageExtensionsKt.updateMessageEmojiCategories(messageList, this::getEmojiCategories);
notifyMessageListChanged(channel, messageList, callback);
return;
}

messageDisplayDataProvider.threadPool().submit(() -> {
MessageDisplayDataManager.checkAndGenerateDisplayData(messageList, messageDisplayDataProvider);
MessageExtensionsKt.updateMessageEmojiCategories(messageList, this::getEmojiCategories);
notifyMessageListChanged(channel, messageList, callback);
});
}
Expand Down Expand Up @@ -627,6 +630,19 @@ public List<BaseMessage> getItems() {
return Collections.unmodifiableList(messageList);
}

/**
* Returns the list of {@link com.sendbird.android.message.EmojiCategory} ids which should be available for the given {@link BaseMessage}.
* If the list is null, all the available emoji categories will be shown.
*
* @param message The {@link BaseMessage} to get the emoji category for.
* @return The list of {@link com.sendbird.android.message.EmojiCategory} ids which is available for the given {@link BaseMessage}.
* @since 3.20.0
*/
@Nullable
public List<Long> getEmojiCategories(@NonNull BaseMessage message) {
return null;
}

@TestOnly
@NonNull
MessageListUIParams getMessageListUIParams() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import androidx.recyclerview.widget.DiffUtil;

import com.sendbird.android.SendbirdChat;
import com.sendbird.android.message.Emoji;
import com.sendbird.android.message.Reaction;
import com.sendbird.uikit.activities.viewholder.BaseViewHolder;
import com.sendbird.uikit.databinding.SbViewEmojiReactionBinding;
import com.sendbird.uikit.interfaces.OnItemClickListener;
import com.sendbird.uikit.interfaces.OnItemLongClickListener;
import com.sendbird.uikit.internal.extensions.EmojiExtensionsKt;
import com.sendbird.uikit.internal.ui.reactions.EmojiReactionView;
import com.sendbird.uikit.internal.ui.viewholders.EmojiReactionMoreViewHolder;
import com.sendbird.uikit.internal.ui.viewholders.EmojiReactionViewHolder;
Expand Down Expand Up @@ -45,6 +47,8 @@ public class EmojiReactionListAdapter extends BaseAdapter<Reaction, BaseViewHold
private boolean useMoreButton = true;
private boolean clickable = true;
private boolean longClickable = true;
@NonNull
private List<Emoji> totalEmojiList = EmojiManager.getAllEmojis();

/**
* Called when RecyclerView needs a new {@link BaseViewHolder<Reaction>} of the given type to represent
Expand Down Expand Up @@ -144,7 +148,7 @@ public void onBindViewHolder(@NonNull BaseViewHolder<Reaction> holder, int posit
*/
@Override
public int getItemCount() {
if (reactionList.size() >= EmojiManager.getAllEmojis().size()) {
if (EmojiExtensionsKt.hasAllEmoji(reactionList, totalEmojiList)) {
return reactionList.size();
} else {
return reactionList.size() + (useMoreButton ? 1 : 0);
Expand Down Expand Up @@ -195,6 +199,16 @@ public int getItemViewType(int position) {
return VIEW_EMOJI_REACTION;
}

/**
* Sets the total emoji list that can be added to the current message.
* This value is used to compare whether `add` button should be displayed from the reactions view.
* @param totalEmojiList The total emoji list that can be added to the current message. Defaults to {@link EmojiManager#getAllEmojis()}.
* @since 3.20.0
*/
public void setTotalEmojiList(@NonNull List<Emoji> totalEmojiList) {
this.totalEmojiList = totalEmojiList;
}

/**
* Sets the {@link List<Reaction>} to be displayed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
return false;
}

if (MessageExtensionsKt.getEmojiCategories(oldMessage) != MessageExtensionsKt.getEmojiCategories(newMessage)) {
return false;
}

// In the case of Bot message stream mode, the `message` is updated, but `updated_at` is not updated.
boolean isBotOld = oldMessage.getSender() != null && oldMessage.getSender().isBot();
boolean isBotNew = newMessage.getSender() != null && newMessage.getSender().isBot();
Expand All @@ -89,7 +93,7 @@ public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
}
}

if (MessageExtensionsKt.getShouldShowSuggestedReplies(oldMessage) != MessageExtensionsKt.getShouldShowSuggestedReplies(newMessage)) {
if (MessageExtensionsKt.isSuggestedRepliesVisible(oldMessage) != MessageExtensionsKt.getShouldShowSuggestedReplies(newMessage)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.sendbird.android.message.Emoji;
import com.sendbird.android.message.Reaction;
import com.sendbird.uikit.interfaces.EmojiReactionHandler;
import com.sendbird.uikit.interfaces.OnItemClickListener;
Expand Down Expand Up @@ -38,4 +39,22 @@ abstract public void setEmojiReaction(@NonNull List<Reaction> reactionList,
@Nullable OnItemClickListener<String> emojiReactionClickListener,
@Nullable OnItemLongClickListener<String> emojiReactionLongClickListener,
@Nullable View.OnClickListener moreButtonClickListener);

/**
* Sets message reaction data with total emoji count allowed for the message.
*
* @param reactionList List of reactions which the message has.
* @param totalEmojiList The total list of emojis allowed for this message. This value is used to compare whether `add` button should be displayed from the reactions view. Defaults to {@link com.sendbird.uikit.model.EmojiManager.getAllEmojis()}.
* @param emojiReactionClickListener The callback to be invoked when the emoji reaction is clicked and held.
* @param emojiReactionLongClickListener The callback to be invoked when the emoji reaction is long clicked and held.
* @param moreButtonClickListener The callback to be invoked when the emoji reaction more button is clicked and held.
* @since 3.20.0
*/
public void setEmojiReaction(@NonNull List<Reaction> reactionList,
@NonNull List<Emoji> totalEmojiList,
@Nullable OnItemClickListener<String> emojiReactionClickListener,
@Nullable OnItemLongClickListener<String> emojiReactionLongClickListener,
@Nullable View.OnClickListener moreButtonClickListener) {
setEmojiReaction(reactionList, emojiReactionClickListener, emojiReactionLongClickListener, moreButtonClickListener);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.ViewGroup
import androidx.annotation.CallSuper
import com.sendbird.android.channel.BaseChannel
import com.sendbird.android.message.BaseMessage
import com.sendbird.android.message.Emoji
import com.sendbird.android.message.Reaction
import com.sendbird.uikit.annotation.MessageViewHolderExperimental
import com.sendbird.uikit.consts.ClickableViewIdentifier
Expand All @@ -14,6 +15,7 @@ import com.sendbird.uikit.interfaces.EmojiReactionHandler
import com.sendbird.uikit.interfaces.OnItemClickListener
import com.sendbird.uikit.interfaces.OnItemLongClickListener
import com.sendbird.uikit.internal.extensions.toComponentListContextThemeWrapper
import com.sendbird.uikit.model.EmojiManager
import com.sendbird.uikit.model.MessageListUIParams

/**
Expand Down Expand Up @@ -62,17 +64,38 @@ open class MyMessageViewHolder(
* @param moreButtonClickListener The callback to be invoked when the emoji reaction more button is clicked and held.
* @since 3.12.0
*/
final override fun setEmojiReaction(
fun setEmojiReaction(
reactionList: List<Reaction>,
emojiReactionClickListener: OnItemClickListener<String>?,
emojiReactionLongClickListener: OnItemLongClickListener<String>?,
moreButtonClickListener: View.OnClickListener?
) {
binding.root.binding.rvEmojiReactionList.apply {
setReactionList(reactionList)
setEmojiReactionClickListener(emojiReactionClickListener)
setEmojiReactionLongClickListener(emojiReactionLongClickListener)
setMoreButtonClickListener(moreButtonClickListener)
setClickListeners(emojiReactionClickListener, emojiReactionLongClickListener, moreButtonClickListener)
}
}

/**
* Sets message reaction data.
*
* @param reactionList List of reactions which the message has.
* @param totalEmojiList The total list of emojis allowed for this message. This value is used to compare whether `add` button should be displayed from the reactions view. Defaults to [EmojiManager.allEmojis].
* @param emojiReactionClickListener The callback to be invoked when the emoji reaction is clicked and held.
* @param emojiReactionLongClickListener The callback to be invoked when the emoji reaction is long clicked and held.
* @param moreButtonClickListener The callback to be invoked when the emoji reaction more button is clicked and held.
* @since 3.20.0
*/
final override fun setEmojiReaction(
reactionList: List<Reaction>,
totalEmojiList: List<Emoji>,
emojiReactionClickListener: OnItemClickListener<String>?,
emojiReactionLongClickListener: OnItemLongClickListener<String>?,
moreButtonClickListener: View.OnClickListener?
) {
binding.root.binding.rvEmojiReactionList.apply {
setReactionList(reactionList, totalEmojiList)
setClickListeners(emojiReactionClickListener, emojiReactionLongClickListener, moreButtonClickListener)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.view.ViewGroup
import androidx.annotation.CallSuper
import com.sendbird.android.channel.BaseChannel
import com.sendbird.android.message.BaseMessage
import com.sendbird.android.message.Emoji
import com.sendbird.android.message.Reaction
import com.sendbird.uikit.annotation.MessageViewHolderExperimental
import com.sendbird.uikit.consts.ClickableViewIdentifier
Expand All @@ -14,6 +15,7 @@ import com.sendbird.uikit.interfaces.EmojiReactionHandler
import com.sendbird.uikit.interfaces.OnItemClickListener
import com.sendbird.uikit.interfaces.OnItemLongClickListener
import com.sendbird.uikit.internal.extensions.toComponentListContextThemeWrapper
import com.sendbird.uikit.model.EmojiManager
import com.sendbird.uikit.model.MessageListUIParams

/**
Expand Down Expand Up @@ -62,17 +64,38 @@ open class OtherMessageViewHolder(
* @param moreButtonClickListener The callback to be invoked when the emoji reaction more button is clicked and held.
* @since 3.12.0
*/
final override fun setEmojiReaction(
fun setEmojiReaction(
reactionList: List<Reaction>,
emojiReactionClickListener: OnItemClickListener<String>?,
emojiReactionLongClickListener: OnItemLongClickListener<String>?,
moreButtonClickListener: View.OnClickListener?
) {
binding.root.binding.rvEmojiReactionList.apply {
setReactionList(reactionList)
setEmojiReactionClickListener(emojiReactionClickListener)
setEmojiReactionLongClickListener(emojiReactionLongClickListener)
setMoreButtonClickListener(moreButtonClickListener)
setClickListeners(emojiReactionClickListener, emojiReactionLongClickListener, moreButtonClickListener)
}
}

/**
* Sets message reaction data.
*
* @param reactionList List of reactions which the message has.
* @param totalEmojiList The total list of emojis allowed for this message. This value is used to compare whether `add` button should be displayed from the reactions view. Defaults to [EmojiManager.allEmojis].
* @param emojiReactionClickListener The callback to be invoked when the emoji reaction is clicked and held.
* @param emojiReactionLongClickListener The callback to be invoked when the emoji reaction is long clicked and held.
* @param moreButtonClickListener The callback to be invoked when the emoji reaction more button is clicked and held.
* @since 3.20.0
*/
final override fun setEmojiReaction(
reactionList: List<Reaction>,
totalEmojiList: List<Emoji>,
emojiReactionClickListener: OnItemClickListener<String>?,
emojiReactionLongClickListener: OnItemLongClickListener<String>?,
moreButtonClickListener: View.OnClickListener?
) {
binding.root.binding.rvEmojiReactionList.apply {
setReactionList(reactionList, totalEmojiList)
setClickListeners(emojiReactionClickListener, emojiReactionLongClickListener, moreButtonClickListener)
}
}
}
1 change: 1 addition & 0 deletions uikit/src/main/java/com/sendbird/uikit/consts/StringSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ object StringSet {

// extras
const val should_show_suggested_replies = "should_show_suggested_replies"
const val is_suggested_replies_visible = "is_suggested_replies_visible"
}
Loading

0 comments on commit 70ebb13

Please sign in to comment.