resizingSize = new Pair<>(DEFAULT_RESIZING_WIDTH_SIZE, DEFAULT_RESIZING_HEIGHT_SIZE);
@NonNull
- private static ReplyType replyType = ReplyType.QUOTE_REPLY;
- @NonNull
- private static ThreadReplySelectType threadReplySelectType = ThreadReplySelectType.THREAD;
- @NonNull
private static UIKitFragmentFactory fragmentFactory = new UIKitFragmentFactory();
- private static volatile boolean useChannelListTypingIndicators = false;
- private static volatile boolean useChannelListMessageReceiptStatus = false;
- private static volatile boolean useMention = false;
- private static volatile boolean useUserIdForNickname = true;
private static UserMentionConfig userMentionConfig = new UserMentionConfig.Builder().build();
- private static volatile boolean useVoiceMessage = false;
static void clearAll() {
SendbirdUIKit.customUserListQueryHandler = null;
@@ -237,7 +239,7 @@ static void clearAll() {
* @param context Context
of Application
.
*/
public synchronized static void init(@NonNull SendbirdUIKitAdapter adapter, @NonNull Context context) {
- init(adapter, context, false);
+ init(new SendbirdChatImpl(), adapter, new UIKitConfigRepository(context, adapter.getAppId()), context, false);
}
/**
@@ -248,11 +250,19 @@ public synchronized static void init(@NonNull SendbirdUIKitAdapter adapter, @Non
* since 2.1.8
*/
public synchronized static void initFromForeground(@NonNull SendbirdUIKitAdapter adapter, @NonNull Context context) {
- init(adapter, context, true);
+ init(new SendbirdChatImpl(), adapter, new UIKitConfigRepository(context, adapter.getAppId()), context, true);
}
- private synchronized static void init(@NonNull SendbirdUIKitAdapter adapter, @NonNull Context context, boolean isForeground) {
+ @VisibleForTesting
+ synchronized static void init(
+ @NonNull SendbirdChatWrapper sendbirdChatWrapper,
+ @NonNull SendbirdUIKitAdapter adapter,
+ @NonNull UIKitConfigRepository uikitConfigRepo,
+ @NonNull Context context,
+ boolean isForeground)
+ {
SendbirdUIKit.adapter = adapter;
+ SendbirdUIKit.uikitConfigRepo = uikitConfigRepo;
final InitResultHandler handler = adapter.getInitResultHandler();
final InitResultHandler initResultHandler = new InitResultHandler() {
@@ -273,7 +283,7 @@ public void onInitFailed(@NonNull SendbirdException e) {
public void onInitSucceed() {
Logger.d(">> onInitSucceed()");
try {
- SendbirdChat.addExtension(StringSet.sb_uikit, BuildConfig.VERSION_NAME);
+ sendbirdChatWrapper.addExtension(StringSet.sb_uikit, BuildConfig.VERSION_NAME);
} catch (Throwable ignored) {
}
@@ -284,226 +294,224 @@ public void onInitSucceed() {
final com.sendbird.android.LogLevel logLevel = BuildConfig.DEBUG ? com.sendbird.android.LogLevel.VERBOSE : com.sendbird.android.LogLevel.WARN;
// useCaching=true is required for UIKit
final InitParams initParams = new InitParams(adapter.getAppId(), context, true, logLevel, isForeground);
- SendbirdChat.init(initParams, initResultHandler);
+ sendbirdChatWrapper.init(initParams, initResultHandler);
FileUtils.removeDeletableDir(context.getApplicationContext());
UIKitPrefs.init(context.getApplicationContext());
NotificationChannelManager.init(context.getApplicationContext());
EmojiManager.getInstance().init();
}
- /**
- * @param level set the displaying log level. {@link LogLevel}
- *
- * since 1.0.2
- */
- public static void setLogLevel(@NonNull LogLevel level) {
- Logger.setLogLevel(level.getLevel());
- }
-
- /**
- * Returns the default theme mode.
- *
- * @see #setDefaultThemeMode(ThemeMode)
- */
- @NonNull
- public static ThemeMode getDefaultThemeMode() {
- return defaultThemeMode;
- }
-
- /**
- * Sets the default theme mode. This is the default value used for all components, but can
- * be overridden locally via the builder of a fragment.
- *
- * Defaults to {@link ThemeMode#Light}.
- *
- * @see #getDefaultThemeMode() ()
- */
- public static void setDefaultThemeMode(@NonNull ThemeMode themeMode) {
- defaultThemeMode = themeMode;
- }
-
- /**
- * Determines whether the theme mode is {@link ThemeMode#Dark}.
- *
- * @return True if the theme mode is the dark, false otherwise.
- */
- public static boolean isDarkMode() {
- return defaultThemeMode == ThemeMode.Dark;
- }
-
- /**
- * Returns the adapter of SendBirdUIKit.
- *
- * @see #init(SendbirdUIKitAdapter, Context)
- */
- @Nullable
- public static SendbirdUIKitAdapter getAdapter() {
- return adapter;
- }
-
- /**
- * Returns the custom user list query handler.
- *
- * @return The callback handler.
- */
- @Nullable
- public static CustomUserListQueryHandler getCustomUserListQueryHandler() {
- return customUserListQueryHandler;
- }
-
- /**
- * Returns the custom params handler.
- *
- * @return The callback handler.
- * since 1.2.2
- */
- @Nullable
- public static CustomParamsHandler getCustomParamsHandler() {
- return customParamsHandler;
- }
-
/**
* Returns set value whether the user profile uses.
+ * since 1.2.2
*
* @return the value whether the user profile uses.
- * since 1.2.2
+ * @deprecated 3.6.0
+ * Use {@link Common#getEnableUsingDefaultUserProfile()} instead.
*/
+ @Deprecated
public static boolean shouldUseDefaultUserProfile() {
- return useDefaultUserProfile;
+ return UIKitConfig.getCommon().getEnableUsingDefaultUserProfile();
}
/**
* Sets whether the user profile uses.
+ * since 1.2.2
*
* @param useDefaultUserProfile If true
the default user profile included the UIKit will be shown, false
other wise.
- * since 1.2.2
+ * @deprecated 3.6.0
+ * Use {@link Common#setEnableUsingDefaultUserProfile(Boolean)} instead.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
public static void setUseDefaultUserProfile(boolean useDefaultUserProfile) {
- SendbirdUIKit.useDefaultUserProfile = useDefaultUserProfile;
+ UIKitConfig.getCommon().setEnableUsingDefaultUserProfile(useDefaultUserProfile);
}
/**
* Sets whether the typing indicator is used on the channel list screen.
+ * since 3.0.0
*
* @param useChannelListTypingIndicators If true
the typing indicator will be shown at the channel list item, false
other wise.
- * since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelListConfig#setEnableTypingIndicator(Boolean)} instead.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
public static void setUseChannelListTypingIndicators(boolean useChannelListTypingIndicators) {
- SendbirdUIKit.useChannelListTypingIndicators = useChannelListTypingIndicators;
+ UIKitConfig.getGroupChannelListConfig().setEnableTypingIndicator(useChannelListTypingIndicators);
}
/**
* Returns set value whether the typing indicator is used on the channel list screen.
+ * since 3.0.0
*
* @return the value whether the typing indicator is used on the channel list screen.
- * since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelListConfig#getEnableTypingIndicator()} instead.
*/
+ @Deprecated
public static boolean isUsingChannelListTypingIndicators() {
- return useChannelListTypingIndicators;
+ return UIKitConfig.getGroupChannelListConfig().getEnableTypingIndicator();
}
/**
* Sets whether the states read-receipt and delivery-receipt are used on the channel list screen.
+ * since 3.0.0
*
* @param useChannelListMessageReceiptStatus If true
the states read-receipt and delivery-receipt will be shown at the channel list item, false
other wise.
- * since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelListConfig#setEnableMessageReceiptStatus(Boolean)} instead.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
public static void setUseChannelListMessageReceiptStatus(boolean useChannelListMessageReceiptStatus) {
- SendbirdUIKit.useChannelListMessageReceiptStatus = useChannelListMessageReceiptStatus;
+ UIKitConfig.getGroupChannelListConfig().setEnableMessageReceiptStatus(useChannelListMessageReceiptStatus);
}
/**
* Returns set value whether the states read-receipt and delivery-receipt are used on the channel list screen.
+ * since 3.0.0
*
* @return the value whether the states read-receipt and delivery-receipt are used on the channel list screen.
- * since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelListConfig#getEnableMessageReceiptStatus()} (Boolean)} instead.
*/
+ @Deprecated
public static boolean isUsingChannelListMessageReceiptStatus() {
- return useChannelListMessageReceiptStatus;
+ return UIKitConfig.getGroupChannelListConfig().getEnableMessageReceiptStatus();
}
/**
* Sets whether the user mention is used on the channel screen.
+ * since 3.0.0
*
* @param useMention If true
the mention will be used at the channel, false
other wise.
- * since 3.0.0
+ * @since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#setEnableMention(Boolean)} instead.
*/
+ @Deprecated
public static void setUseUserMention(boolean useMention) {
- SendbirdUIKit.useMention = useMention;
- }
-
- /**
- * Sets the user mention configuration.
- *
- * @param config The configuration to be applied for the mention
- * @see UserMentionConfig
- * since 3.0.0
- */
- public static void setMentionConfig(@NonNull UserMentionConfig config) {
- SendbirdUIKit.userMentionConfig = config;
+ UIKitConfig.getGroupChannelConfig().setEnableMention(useMention);
}
/**
* Sets whether a nickname uses a user ID when there is no user nickname based on the user ID.
+ * since 3.3.0
*
* @param useUserIdForNickname If true
the user's nickname uses user ID when the nickname is empty, false
other wise.
- * since 3.3.0
*/
public static void setUseUserIdForNickname(boolean useUserIdForNickname) {
SendbirdUIKit.useUserIdForNickname = useUserIdForNickname;
}
- /**
- * Returns the user mention configuration.
- *
- * @return The configuration applied for the user mention
- * since 3.0.0
- */
- @NonNull
- public static UserMentionConfig getUserMentionConfig() {
- return userMentionConfig;
- }
-
/**
* Returns set value whether the user mention is used on the channel screen.
+ * since 3.0.0
*
* @return The value whether the user mention is used on the channel screen.
- * since 3.0.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#setEnableMention(Boolean)} instead.
*/
+ @Deprecated
public static boolean isUsingUserMention() {
- return SendbirdUIKit.useMention;
+ return UIKitConfig.getGroupChannelConfig().getEnableMention();
}
/**
* Returns set value whether a nickname uses a user ID when there is no user nickname based on the user ID.
+ * since 3.3.0
*
* @return The value whether a nickname uses a user ID when there is no user nickname based on the user ID.
- * since 3.3.0
*/
public static boolean isUsingUserIdForNickname() {
- return useUserIdForNickname;
+ return SendbirdUIKit.useUserIdForNickname;
}
/**
* Sets whether the voice message is used on the channel screen and message thread screen.
* The voice message is only active in group channels.
+ * since 3.4.0
*
* @param useVoiceMessage If true
the voice message will be used, false
other wise.
- * since 3.4.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#setEnableVoiceMessage(Boolean)} instead.
*/
+ @SuppressWarnings("DeprecatedIsStillUsed")
+ @Deprecated
public static void setUseVoiceMessage(boolean useVoiceMessage) {
- SendbirdUIKit.useVoiceMessage = useVoiceMessage;
+ UIKitConfig.getGroupChannelConfig().setEnableVoiceMessage(useVoiceMessage);
}
/**
* Returns set value whether the voice message is used on the channel screen and message thread screen.
* The voice message is only active in group channels.
+ * since 3.4.0
*
* @return The value whether the voice message is used on the channel screen, message thread screen.
- * since 3.4.0
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#getEnableVoiceMessage()}.
*/
+ @Deprecated
public static boolean isUsingVoiceMessage() {
- return SendbirdUIKit.useVoiceMessage;
+ return UIKitConfig.getGroupChannelConfig().getEnableVoiceMessage();
+ }
+
+ /**
+ * Sets ReplyType
, which is how replies are displayed in the message list.
+ * since 2.2.0
+ *
+ * @param replyType A type that represents how to display replies in message list
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#setReplyType(ReplyType)} instead.
+ */
+ @Deprecated
+ public static void setReplyType(@NonNull ReplyType replyType) {
+ UIKitConfig.getGroupChannelConfig().setReplyType(replyType);
+ }
+
+ /**
+ * Sets ThreadReplySelectType
, which is how replies are displayed in the message list.
+ * ThreadReplySelectType
can be applied when the reply type is ReplyType.THREAD
.
+ * since 3.3.0
+ *
+ * @param threadReplySelectType A type that represents where to go when selecting a reply
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#setThreadReplySelectType(ThreadReplySelectType)} instead.
+ */
+ @Deprecated
+ public static void setThreadReplySelectType(@NonNull ThreadReplySelectType threadReplySelectType) {
+ UIKitConfig.getGroupChannelConfig().setThreadReplySelectType(threadReplySelectType);
+ }
+
+ /**
+ * Returns ReplyType
, which is how replies are displayed in the message list.
+ * since 2.2.0
+ *
+ * @return The value of ReplyType
.
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#getReplyType()} instead.
+ */
+ @Deprecated
+ @NonNull
+ public static ReplyType getReplyType() {
+ return UIKitConfig.getGroupChannelConfig().getReplyType();
+ }
+
+ /**
+ * Returns ThreadReplySelectType
, which determines where to go when reply is selected.
+ * ThreadReplySelectType
can be applied when the reply type is ReplyType.THREAD
.
+ * since 3.3.0
+ *
+ * @return The value of ThreadReplySelectType
.
+ * @deprecated 3.6.0
+ * Use {@link UIKitConfig#getGroupChannelConfig#getThreadReplySelectType()} instead.
+ */
+ @Deprecated
+ @NonNull
+ public static ThreadReplySelectType getThreadReplySelectType() {
+ return UIKitConfig.getGroupChannelConfig().getThreadReplySelectType();
}
/**
@@ -512,13 +520,20 @@ public static boolean isUsingVoiceMessage() {
* @param handler Callback handler.
*/
public static void connect(@Nullable ConnectHandler handler) {
- TaskQueue.addTask(new JobResultTask>() {
+ connect(new SendbirdChatImpl(), new TaskQueueImpl(), handler);
+ }
+
+ @VisibleForTesting
+ static void connect(@NonNull SendbirdChatWrapper sendbirdChat,
+ @NonNull TaskQueueWrapper taskQueueWrapper,
+ @Nullable ConnectHandler handler) {
+ taskQueueWrapper.addTask(new JobResultTask>() {
@Override
public Pair call() throws Exception {
- final Pair data = connect();
+ final Pair data = connect(sendbirdChat);
final User user = data.first;
final SendbirdException error = data.second;
- if (SendbirdChat.getConnectionState() == ConnectionState.OPEN && user != null) {
+ if (sendbirdChat.getConnectionState() == ConnectionState.OPEN && user != null) {
UserInfo userInfo = adapter.getUserInfo();
String userId = userInfo.getUserId();
String nickname = TextUtils.isEmpty(userInfo.getNickname()) ? user.getNickname() : userInfo.getNickname();
@@ -528,12 +543,12 @@ public Pair call() throws Exception {
final UserUpdateParams params = new UserUpdateParams();
params.setNickname(nickname);
params.setProfileImageUrl(profileUrl);
- updateUserInfoBlocking(params);
+ updateUserInfoBlocking(sendbirdChat, params);
}
Logger.dev("++ user nickname = %s, profileUrl = %s", user.getNickname(), user.getProfileUrl());
- final AppInfo appInfo = SendbirdChat.getAppInfo();
+ final AppInfo appInfo = sendbirdChat.getAppInfo();
if (appInfo != null) {
if (appInfo.getUseReaction() &&
appInfo.needUpdateEmoji(EmojiManager.getInstance().getEmojiHash())) {
@@ -556,6 +571,14 @@ public Pair call() throws Exception {
} catch (Exception ignore) {
}
}
+
+ if (SendbirdUIKit.uikitConfigRepo != null) {
+ try {
+ SendbirdUIKit.uikitConfigRepo.requestConfigurationsBlocking(sendbirdChat, appInfo.getUiKitConfigInfo());
+ } catch (Exception e) {
+ Logger.w(e);
+ }
+ }
}
}
@@ -575,7 +598,7 @@ public void onResultForUiThread(@Nullable Pair data, @N
}
@NonNull
- private static Pair connect() throws InterruptedException {
+ private static Pair connect(@NonNull SendbirdChatWrapper sendbirdChat) throws InterruptedException {
AtomicReference result = new AtomicReference<>();
AtomicReference error = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
@@ -583,7 +606,7 @@ private static Pair connect() throws InterruptedExcepti
String userId = userInfo.getUserId();
String accessToken = adapter.getAccessToken();
- SendbirdChat.connect(userId, accessToken, (user, e) -> {
+ sendbirdChat.connect(userId, accessToken, (user, e) -> {
result.set(user);
if (e != null) {
error.set(e);
@@ -619,10 +642,10 @@ public static void updateUserInfo(@NonNull UserUpdateParams params, @Nullable Co
SendbirdChat.updateCurrentUserInfo(params, handler);
}
- private static void updateUserInfoBlocking(@NonNull UserUpdateParams params) throws SendbirdException, InterruptedException {
+ private static void updateUserInfoBlocking(@NonNull SendbirdChatWrapper sendbirdChatWrapper, @NonNull UserUpdateParams params) throws SendbirdException, InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference error = new AtomicReference<>();
- SendbirdChat.updateCurrentUserInfo(params, e -> {
+ sendbirdChatWrapper.updateCurrentUserInfo(params, e -> {
if (e != null) error.set(e);
latch.countDown();
});
@@ -752,50 +775,111 @@ public static Pair getResizingSize() {
}
/**
- * Sets ReplyType
, which is how replies are displayed in the message list.
+ * Returns the user mention configuration.
*
- * @param replyType A type that represents how to display replies in message list
- * since 2.2.0
+ * @return The configuration applied for the user mention
+ * since 3.0.0
*/
- public static void setReplyType(@NonNull ReplyType replyType) {
- SendbirdUIKit.replyType = replyType;
+ @NonNull
+ public static UserMentionConfig getUserMentionConfig() {
+ return userMentionConfig;
}
/**
- * Sets ThreadReplySelectType
, which is how replies are displayed in the message list.
- * ThreadReplySelectType
can be applied when the reply type is ReplyType.THREAD
.
+ * Sets the user mention configuration.
*
- * @param threadReplySelectType A type that represents where to go when selecting a reply
- * since 3.3.0
+ * @param config The configuration to be applied for the mention
+ * @see UserMentionConfig
+ * since 3.0.0
*/
- public static void setThreadReplySelectType(@NonNull ThreadReplySelectType threadReplySelectType) {
- SendbirdUIKit.threadReplySelectType = threadReplySelectType;
+ public static void setMentionConfig(@NonNull UserMentionConfig config) {
+ SendbirdUIKit.userMentionConfig = config;
}
/**
- * Returns ReplyType
, which is how replies are displayed in the message list.
+ * @param level set the displaying log level. {@link LogLevel}
*
- * @return The value of ReplyType
.
- * since 2.2.0
+ * since 1.0.2
*/
- @NonNull
- public static ReplyType getReplyType() {
- return SendbirdUIKit.replyType;
+ public static void setLogLevel(@NonNull LogLevel level) {
+ Logger.setLogLevel(level.getLevel());
}
/**
- * Returns ThreadReplySelectType
, which determines where to go when reply is selected.
- * ThreadReplySelectType
can be applied when the reply type is ReplyType.THREAD
.
+ * Returns the default theme mode.
*
- * @return The value of ThreadReplySelectType
.
- * since 3.3.0
+ * @see #setDefaultThemeMode(ThemeMode)
*/
@NonNull
- public static ThreadReplySelectType getThreadReplySelectType() {
- return SendbirdUIKit.threadReplySelectType;
+ public static ThemeMode getDefaultThemeMode() {
+ return defaultThemeMode;
+ }
+
+ /**
+ * Sets the default theme mode. This is the default value used for all components, but can
+ * be overridden locally via the builder of a fragment.
+ *
+ * Defaults to {@link ThemeMode#Light}.
+ *
+ * @see #getDefaultThemeMode() ()
+ */
+ public static void setDefaultThemeMode(@NonNull ThemeMode themeMode) {
+ defaultThemeMode = themeMode;
+ }
+
+ /**
+ * Determines whether the theme mode is {@link ThemeMode#Dark}.
+ *
+ * @return True if the theme mode is the dark, false otherwise.
+ */
+ public static boolean isDarkMode() {
+ return defaultThemeMode == ThemeMode.Dark;
+ }
+
+ /**
+ * Returns the adapter of SendBirdUIKit.
+ *
+ * @see #init(SendbirdUIKitAdapter, Context)
+ */
+ @Nullable
+ public static SendbirdUIKitAdapter getAdapter() {
+ return adapter;
}
+ /**
+ * Returns the custom user list query handler.
+ *
+ * @return The callback handler.
+ */
+ @Nullable
+ public static CustomUserListQueryHandler getCustomUserListQueryHandler() {
+ return customUserListQueryHandler;
+ }
+
+ /**
+ * Returns the custom params handler.
+ *
+ * @return The callback handler.
+ * since 1.2.2
+ */
+ @Nullable
+ public static CustomParamsHandler getCustomParamsHandler() {
+ return customParamsHandler;
+ }
+
+ /**
+ * Context switching is performed to the main thread.
+ *
+ * @param runnable The Runnable that will be executed.
+ * since 3.6.0
+ */
public static void runOnUIThread(@NonNull Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
+
+ @TestOnly
+ @Nullable
+ static UIKitConfigRepository getUikitConfigRepo() {
+ return uikitConfigRepo;
+ }
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/BannedUserListActivity.java b/uikit/src/main/java/com/sendbird/uikit/activities/BannedUserListActivity.java
index 025affef..75243754 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/BannedUserListActivity.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/BannedUserListActivity.java
@@ -8,7 +8,6 @@
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/BaseMessageListAdapter.java b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/BaseMessageListAdapter.java
index c5ab7141..beed9e86 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/BaseMessageListAdapter.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/BaseMessageListAdapter.java
@@ -39,7 +39,7 @@
import com.sendbird.uikit.log.Logger;
import com.sendbird.uikit.model.MessageListUIParams;
import com.sendbird.uikit.model.MessageUIConfig;
-import com.sendbird.uikit.utils.ReactionUtils;
+import com.sendbird.uikit.model.configurations.ChannelConfig;
import com.sendbird.uikit.utils.TextUtils;
import org.jetbrains.annotations.TestOnly;
@@ -234,7 +234,7 @@ public void onBindViewHolder(@NonNull MessageViewHolder holder, final int positi
next = getItem(position - 1);
}
- if (ReactionUtils.useReaction(channel) && holder instanceof GroupChannelMessageViewHolder) {
+ if (ChannelConfig.getEnableReactions(messageListUIParams.getChannelConfig(), channel) && holder instanceof GroupChannelMessageViewHolder) {
GroupChannelMessageViewHolder groupChannelHolder = (GroupChannelMessageViewHolder) holder;
List reactionList = current.getReactions();
groupChannelHolder.setEmojiReaction(reactionList, (view, reactionPosition, reactionKey) -> {
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/ChannelListAdapter.java b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/ChannelListAdapter.java
index f4d6c0d6..ec8fab1f 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/ChannelListAdapter.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/ChannelListAdapter.java
@@ -19,13 +19,14 @@
import com.sendbird.android.message.UserMessage;
import com.sendbird.android.user.User;
import com.sendbird.uikit.R;
-import com.sendbird.uikit.SendbirdUIKit;
import com.sendbird.uikit.activities.viewholder.BaseViewHolder;
import com.sendbird.uikit.databinding.SbViewChannelPreviewBinding;
import com.sendbird.uikit.interfaces.MessageDisplayDataProvider;
import com.sendbird.uikit.interfaces.OnItemClickListener;
import com.sendbird.uikit.interfaces.OnItemLongClickListener;
import com.sendbird.uikit.internal.singleton.MessageDisplayDataManager;
+import com.sendbird.uikit.model.ChannelListUIParams;
+import com.sendbird.uikit.model.configurations.UIKitConfig;
import com.sendbird.uikit.utils.ChannelUtils;
import java.util.ArrayList;
@@ -47,12 +48,14 @@ public class ChannelListAdapter extends BaseAdapter longClickListener;
@Nullable
private MessageDisplayDataProvider messageDisplayDataProvider;
+ @NonNull
+ private final ChannelListUIParams params;
/**
* Constructor
*/
public ChannelListAdapter() {
- setHasStableIds(true);
+ this(null);
}
/**
@@ -61,8 +64,14 @@ public ChannelListAdapter() {
* @param listener The listener performing when the {@link ChannelPreviewHolder} is clicked.
*/
public ChannelListAdapter(@Nullable OnItemClickListener listener) {
+ this(listener, new ChannelListUIParams());
+ }
+
+ public ChannelListAdapter(@Nullable OnItemClickListener listener, @NonNull ChannelListUIParams params) {
setHasStableIds(true);
setOnItemClickListener(listener);
+ setOnItemLongClickListener(longClickListener);
+ this.params = params;
}
/**
@@ -83,7 +92,7 @@ public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent
final TypedValue values = new TypedValue();
parent.getContext().getTheme().resolveAttribute(R.attr.sb_component_list, values, true);
final Context contextWrapper = new ContextThemeWrapper(parent.getContext(), values.resourceId);
- return new ChannelPreviewHolder(SbViewChannelPreviewBinding.inflate(LayoutInflater.from(contextWrapper), parent, false));
+ return new ChannelPreviewHolder(SbViewChannelPreviewBinding.inflate(LayoutInflater.from(contextWrapper), parent, false), params);
}
/**
@@ -229,7 +238,7 @@ public void setItems(@NonNull List channelList) {
}
private void notifyChannelListChanged(@NonNull List channelList) {
- final List newChannelInfo = ChannelInfo.toChannelInfoList(channelList);
+ final List newChannelInfo = ChannelInfo.toChannelInfoList(channelList, new ChannelListUIParams());
final ChannelDiffCallback diffCallback = new ChannelDiffCallback(this.cachedChannelList, newChannelInfo);
final DiffUtil.DiffResult diffResult = calculateDiff(diffCallback);
@@ -249,12 +258,12 @@ private static class ChannelPreviewHolder extends BaseViewHolder {
@NonNull
private final SbViewChannelPreviewBinding binding;
- ChannelPreviewHolder(@NonNull SbViewChannelPreviewBinding binding) {
+ ChannelPreviewHolder(@NonNull SbViewChannelPreviewBinding binding, @NonNull ChannelListUIParams params) {
super(binding.getRoot());
this.binding = binding;
- this.binding.channelPreview.setUseTypingIndicator(SendbirdUIKit.isUsingChannelListTypingIndicators());
- this.binding.channelPreview.setUseMessageReceiptStatus(SendbirdUIKit.isUsingChannelListMessageReceiptStatus());
- this.binding.channelPreview.setUseUnreadMentionCount(SendbirdUIKit.isUsingUserMention());
+ this.binding.channelPreview.setUseTypingIndicator(params.getEnableTypingIndicator());
+ this.binding.channelPreview.setUseMessageReceiptStatus(params.getEnableMessageReceiptStatus());
+ this.binding.channelPreview.setUseUnreadMentionCount(UIKitConfig.getGroupChannelConfig().getEnableMention());
}
@Override
@@ -284,8 +293,10 @@ static class ChannelInfo {
private List typingMembers = new ArrayList<>();
private int unReadMemberCount;
private int unDeliveredMemberCount;
+ @NonNull
+ private final ChannelListUIParams params;
- ChannelInfo(@NonNull GroupChannel channel) {
+ ChannelInfo(@NonNull GroupChannel channel, @NonNull ChannelListUIParams params) {
this.channelUrl = channel.getUrl();
this.createdAt = channel.getCreatedAt();
this.memberCount = channel.getMemberCount();
@@ -297,10 +308,11 @@ static class ChannelInfo {
this.unreadMentionCount = channel.getUnreadMentionCount();
this.coverImageHash = toUrlsHash(channel);
this.isFrozen = channel.isFrozen();
- if (SendbirdUIKit.isUsingChannelListTypingIndicators()) {
+ this.params = params;
+ if (params.getEnableTypingIndicator()) {
this.typingMembers = channel.getTypingUsers();
}
- if (SendbirdUIKit.isUsingChannelListMessageReceiptStatus()) {
+ if (params.getEnableMessageReceiptStatus()) {
if (channel.getLastMessage() != null) {
this.unReadMemberCount = channel.getUnreadMemberCount(channel.getLastMessage());
this.unDeliveredMemberCount = channel.getUndeliveredMemberCount(channel.getLastMessage());
@@ -379,7 +391,7 @@ public boolean equals(Object o) {
if (unreadMentionCount != that.unreadMentionCount) return false;
if (isFrozen != that.isFrozen) return false;
- if (SendbirdUIKit.isUsingChannelListMessageReceiptStatus()) {
+ if (params.getEnableMessageReceiptStatus()) {
if (unReadMemberCount != that.unReadMemberCount) return false;
if (unDeliveredMemberCount != that.unDeliveredMemberCount) return false;
}
@@ -402,7 +414,7 @@ public boolean equals(Object o) {
}
}
}
- if (SendbirdUIKit.isUsingChannelListTypingIndicators()) {
+ if (params.getEnableTypingIndicator()) {
return typingMembers.equals(that.typingMembers);
}
return true;
@@ -422,11 +434,11 @@ public int hashCode() {
result = 31 * result + unreadMentionCount;
result = 31 * result + (isFrozen ? 1 : 0);
- if (SendbirdUIKit.isUsingChannelListTypingIndicators()) {
+ if (params.getEnableTypingIndicator()) {
result = 31 * result + typingMembers.hashCode();
}
- if (SendbirdUIKit.isUsingChannelListMessageReceiptStatus()) {
+ if (params.getEnableMessageReceiptStatus()) {
result = 31 * result + unReadMemberCount;
result = 31 * result + unDeliveredMemberCount;
}
@@ -455,10 +467,10 @@ public String toString() {
}
@NonNull
- static List toChannelInfoList(@NonNull List channelList) {
+ static List toChannelInfoList(@NonNull List channelList, @NonNull ChannelListUIParams params) {
List results = new ArrayList<>();
for (GroupChannel channel : channelList) {
- results.add(new ChannelInfo(channel));
+ results.add(new ChannelInfo(channel, params));
}
return results;
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageDiffCallback.java b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageDiffCallback.java
index 9760213a..bd39a9f9 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageDiffCallback.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageDiffCallback.java
@@ -12,7 +12,6 @@
import com.sendbird.android.message.Reaction;
import com.sendbird.android.message.ThreadInfo;
import com.sendbird.android.user.User;
-import com.sendbird.uikit.SendbirdUIKit;
import com.sendbird.uikit.consts.MessageGroupType;
import com.sendbird.uikit.consts.ReplyType;
import com.sendbird.uikit.model.MessageListUIParams;
@@ -129,7 +128,7 @@ public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
}
}
- if (SendbirdUIKit.getReplyType() == ReplyType.THREAD) {
+ if (messageListUIParams.getChannelConfig().getReplyType() == ReplyType.THREAD) {
if (!(oldMessage instanceof CustomizableMessage) && !(newMessage instanceof CustomizableMessage)) {
final ThreadInfo oldThreadInfo = oldMessage.getThreadInfo();
final ThreadInfo newThreadInfo = newMessage.getThreadInfo();
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageListAdapter.java b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageListAdapter.java
index 2aa2ad8c..b8ea3c4d 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageListAdapter.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/MessageListAdapter.java
@@ -23,14 +23,19 @@ public MessageListAdapter(@Nullable GroupChannel channel) {
}
public MessageListAdapter(@Nullable GroupChannel channel, boolean useMessageGroupUI) {
- this(channel, useMessageGroupUI, new SendbirdUIKitImpl());
+ this(channel, new MessageListUIParams.Builder()
+ .setUseMessageGroupUI(useMessageGroupUI)
+ .build());
+ }
+
+ public MessageListAdapter(@Nullable GroupChannel channel, @NonNull MessageListUIParams messageListUIParams) {
+ this(channel, messageListUIParams, new SendbirdUIKitImpl());
}
@VisibleForTesting
- MessageListAdapter(@Nullable GroupChannel channel, boolean useMessageGroupUI, @NonNull SendbirdUIKitWrapper sendbirdUIKit) {
+ MessageListAdapter(@Nullable GroupChannel channel, @NonNull MessageListUIParams messageListUIParams, @NonNull SendbirdUIKitWrapper sendbirdUIKit) {
super(channel,
- new MessageListUIParams.Builder()
- .setUseMessageGroupUI(useMessageGroupUI)
+ new MessageListUIParams.Builder(messageListUIParams)
.setUseQuotedView(true)
.build(),
sendbirdUIKit);
diff --git a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/OpenChannelMessageListAdapter.java b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/OpenChannelMessageListAdapter.java
index c86520da..5128e987 100644
--- a/uikit/src/main/java/com/sendbird/uikit/activities/adapter/OpenChannelMessageListAdapter.java
+++ b/uikit/src/main/java/com/sendbird/uikit/activities/adapter/OpenChannelMessageListAdapter.java
@@ -100,11 +100,22 @@ public OpenChannelMessageListAdapter(@Nullable OpenChannel channel, boolean useM
* since 3.2.2
*/
public OpenChannelMessageListAdapter(@Nullable OpenChannel channel, boolean useMessageGroupUI, boolean useReverseLayout) {
- if (channel != null) this.channel = OpenChannel.clone(channel);
- this.messageListUIParams = new MessageListUIParams.Builder()
+ this(channel, new MessageListUIParams.Builder()
.setUseMessageGroupUI(useMessageGroupUI)
.setUseReverseLayout(useReverseLayout)
- .build();
+ .build());
+ }
+
+ /**
+ * Constructor
+ *
+ * @param channel The {@link OpenChannel} that contains the data needed for this adapter
+ * @param messageListUIParams The {@link MessageListUIParams} that contains the data needed for this adapter
+ * since 3.6.0
+ */
+ public OpenChannelMessageListAdapter(@Nullable OpenChannel channel, @NonNull MessageListUIParams messageListUIParams) {
+ if (channel != null) this.channel = OpenChannel.clone(channel);
+ this.messageListUIParams = messageListUIParams;
setHasStableIds(true);
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/consts/ReplyType.java b/uikit/src/main/java/com/sendbird/uikit/consts/ReplyType.java
index 701e0b02..ac0e2cd9 100644
--- a/uikit/src/main/java/com/sendbird/uikit/consts/ReplyType.java
+++ b/uikit/src/main/java/com/sendbird/uikit/consts/ReplyType.java
@@ -1,5 +1,7 @@
package com.sendbird.uikit.consts;
+import androidx.annotation.NonNull;
+
/**
* Represents how to display replies in message list.
*
@@ -11,17 +13,45 @@ public enum ReplyType {
*
* since 2.2.0
*/
- NONE,
+ NONE(StringSet.none),
/**
* Displays replies linearly in the message list.
*
* since 2.2.0
*/
- QUOTE_REPLY,
+ QUOTE_REPLY(StringSet.quote_reply),
/**
* Displays replies to a parent message on a separate screen.
*
* since 3.3.0
*/
- THREAD
+ THREAD(StringSet.thread);
+
+ private final String value;
+
+ ReplyType(@NonNull String value) {
+ this.value = value;
+ }
+
+ @NonNull
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Convert to ReplyType that matches the given value.
+ *
+ * @param value the text value of the ReplyType.
+ * @return the {@link ReplyType}
+ * since 3.6.0
+ */
+ @NonNull
+ public static ReplyType from(@NonNull String value) {
+ for (ReplyType type : values()) {
+ if (type.value.equals(value)) {
+ return type;
+ }
+ }
+ return NONE;
+ }
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/consts/StringSet.java b/uikit/src/main/java/com/sendbird/uikit/consts/StringSet.java
index 529fc6c4..3f01776d 100644
--- a/uikit/src/main/java/com/sendbird/uikit/consts/StringSet.java
+++ b/uikit/src/main/java/com/sendbird/uikit/consts/StringSet.java
@@ -80,6 +80,10 @@ public class StringSet {
public final static String KEY_USE_REFRESH_LAYOUT = "KEY_USE_REFRESH_LAYOUT";
public final static String KEY_VOICE_MESSAGE_DURATION = "KEY_VOICE_MESSAGE_DURATION";
public final static String KEY_INTERNAL_MESSAGE_TYPE = "KEY_INTERNAL_MESSAGE_TYPE";
+ public final static String KEY_CHANNEL_CONFIG = "KEY_CHANNEL_CONFIG";
+ public final static String KEY_CHANNEL_LIST_CONFIG = "KEY_CHANNEL_LIST_CONFIG";
+ public final static String KEY_CHANNEL_SETTING_CONFIG = "KEY_CHANNEL_SETTING_CONFIG";
+ public final static String KEY_OPEN_CHANNEL_CONFIG = "KEY_OPEN_CHANNEL_CONFIG";
public final static String sb_uikit = "sb_uikit";
public final static String sbu_type = "sbu_type";
@@ -140,4 +144,10 @@ public class StringSet {
public final static String custom = "custom";
public final static String uikit = "uikit";
public final static String delete = "delete";
+
+ // Config
+ public final static String none = "none";
+ public final static String quote_reply = "quote_reply";
+ public final static String thread = "thread";
+ public final static String parent = "parent";
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/consts/ThreadReplySelectType.java b/uikit/src/main/java/com/sendbird/uikit/consts/ThreadReplySelectType.java
index cae3d462..d65cb102 100644
--- a/uikit/src/main/java/com/sendbird/uikit/consts/ThreadReplySelectType.java
+++ b/uikit/src/main/java/com/sendbird/uikit/consts/ThreadReplySelectType.java
@@ -1,5 +1,7 @@
package com.sendbird.uikit.consts;
+import androidx.annotation.NonNull;
+
/**
* Represents where to go when selecting a reply.
* This type is only available for ReplyType.THREAD
type.
@@ -12,11 +14,39 @@ public enum ThreadReplySelectType {
*
* since 3.3.0
*/
- PARENT,
+ PARENT(StringSet.parent),
/**
* Moves to thread page.
*
* since 3.3.0
*/
- THREAD
+ THREAD(StringSet.thread);
+
+ private final String value;
+
+ ThreadReplySelectType(@NonNull String value) {
+ this.value = value;
+ }
+
+ @NonNull
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Convert to ReplyType that matches the given value.
+ *
+ * @param value the text value of the ReplyType.
+ * @return the {@link ReplyType}
+ * since 3.6.0
+ */
+ @NonNull
+ public static ThreadReplySelectType from(@NonNull String value) {
+ for (ThreadReplySelectType type : values()) {
+ if (type.value.equals(value)) {
+ return type;
+ }
+ }
+ return THREAD;
+ }
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/fragments/BannedUserListFragment.java b/uikit/src/main/java/com/sendbird/uikit/fragments/BannedUserListFragment.java
index ba1f7bf6..1bf1dc8e 100644
--- a/uikit/src/main/java/com/sendbird/uikit/fragments/BannedUserListFragment.java
+++ b/uikit/src/main/java/com/sendbird/uikit/fragments/BannedUserListFragment.java
@@ -24,6 +24,7 @@
import com.sendbird.uikit.log.Logger;
import com.sendbird.uikit.model.DialogListItem;
import com.sendbird.uikit.model.ReadyStatus;
+import com.sendbird.uikit.model.configurations.UIKitConfig;
import com.sendbird.uikit.modules.BannedUserListModule;
import com.sendbird.uikit.modules.components.BannedUserListComponent;
import com.sendbird.uikit.modules.components.HeaderComponent;
@@ -178,7 +179,7 @@ protected void onBindStatusComponent(@NonNull StatusComponent statusComponent, @
*/
protected void onProfileClicked(@NonNull View view, int position, @NonNull User user) {
final Bundle args = getArguments();
- final boolean useUserProfile = args == null || args.getBoolean(StringSet.KEY_USE_USER_PROFILE, SendbirdUIKit.shouldUseDefaultUserProfile());
+ final boolean useUserProfile = args == null || args.getBoolean(StringSet.KEY_USE_USER_PROFILE, UIKitConfig.getCommon().getEnableUsingDefaultUserProfile());
if (getContext() == null || SendbirdUIKit.getAdapter() == null || !useUserProfile) return;
boolean useChannelCreateButton = !user.getUserId().equals(SendbirdUIKit.getAdapter().getUserInfo().getUserId());
DialogUtils.showUserProfileDialog(getContext(), user, useChannelCreateButton, null, getModule().getLoadingDialogHandler());
diff --git a/uikit/src/main/java/com/sendbird/uikit/fragments/BaseMessageListFragment.java b/uikit/src/main/java/com/sendbird/uikit/fragments/BaseMessageListFragment.java
index 0552567d..1e7c3db0 100644
--- a/uikit/src/main/java/com/sendbird/uikit/fragments/BaseMessageListFragment.java
+++ b/uikit/src/main/java/com/sendbird/uikit/fragments/BaseMessageListFragment.java
@@ -63,6 +63,8 @@
import com.sendbird.uikit.model.FileInfo;
import com.sendbird.uikit.model.ReadyStatus;
import com.sendbird.uikit.model.VoiceMessageInfo;
+import com.sendbird.uikit.model.configurations.ChannelConfig;
+import com.sendbird.uikit.model.configurations.UIKitConfig;
import com.sendbird.uikit.modules.BaseMessageListModule;
import com.sendbird.uikit.modules.components.BaseMessageListComponent;
import com.sendbird.uikit.utils.ContextUtils;
@@ -102,6 +104,8 @@ abstract public class BaseMessageListFragment<
private LA adapter;
@Nullable
private SuggestedMentionListAdapter suggestedMentionListAdapter;
+ @NonNull
+ protected ChannelConfig channelConfig = UIKitConfig.getGroupChannelConfig();
@Nullable
BaseMessage targetMessage;
@@ -140,6 +144,15 @@ abstract public class BaseMessageListFragment<
}
});
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ final Bundle args = getArguments();
+ if (args != null && args.containsKey(StringSet.KEY_CHANNEL_CONFIG)) {
+ channelConfig = args.getParcelable(StringSet.KEY_CHANNEL_CONFIG);
+ }
+ }
+
@Override
protected void onConfigureParams(@NonNull MT module, @NonNull Bundle args) {
if (loadingDialogHandler != null) module.setOnLoadingDialogHandler(loadingDialogHandler);
@@ -405,7 +418,7 @@ void showEmojiActionsDialog(@NonNull BaseMessage message, @NonNull DialogListIte
private void showUserProfile(@NonNull User sender) {
final Bundle args = getArguments();
- final boolean useUserProfile = args == null || args.getBoolean(StringSet.KEY_USE_USER_PROFILE, SendbirdUIKit.shouldUseDefaultUserProfile());
+ final boolean useUserProfile = args == null || args.getBoolean(StringSet.KEY_USE_USER_PROFILE, UIKitConfig.getCommon().getEnableUsingDefaultUserProfile());
if (getContext() == null || !useUserProfile) return;
hideKeyboard();
DialogUtils.showUserProfileDialog(getContext(), sender, true, null, null);
@@ -485,7 +498,7 @@ void showEmojiListDialog(@NonNull BaseMessage message) {
}
void sendFileMessageInternal(@NonNull FileInfo fileInfo, @NonNull FileMessageCreateParams params) {
- if (targetMessage != null && SendbirdUIKit.getReplyType() != ReplyType.NONE) {
+ if (targetMessage != null && channelConfig.getReplyType() != ReplyType.NONE) {
params.setParentMessageId(targetMessage.getMessageId());
params.setReplyToChannel(true);
}
@@ -525,14 +538,22 @@ public void onResultForUiThread(@Nullable Intent intent, @Nullable SendbirdExcep
*/
protected void showMediaSelectDialog() {
if (getContext() == null) return;
- DialogListItem[] items = {
- new DialogListItem(R.string.sb_text_channel_input_camera, R.drawable.icon_camera),
- new DialogListItem(R.string.sb_text_channel_input_take_video, R.drawable.icon_camera),
- new DialogListItem(R.string.sb_text_channel_input_gallery, R.drawable.icon_photo),
- new DialogListItem(R.string.sb_text_channel_input_document, R.drawable.icon_document)
- };
+ final List items = new ArrayList<>();
+ if (channelConfig.getInput().getCamera().getEnablePhoto()) {
+ items.add(new DialogListItem(R.string.sb_text_channel_input_camera, R.drawable.icon_camera));
+ }
+ if (channelConfig.getInput().getCamera().getEnableVideo()) {
+ items.add(new DialogListItem(R.string.sb_text_channel_input_take_video, R.drawable.icon_camera));
+ }
+ if (channelConfig.getInput().getGallery().getEnablePhoto() || channelConfig.getInput().getGallery().getEnableVideo()) {
+ items.add(new DialogListItem(R.string.sb_text_channel_input_gallery, R.drawable.icon_photo));
+ }
+ if (channelConfig.getInput().getEnableDocument()) {
+ items.add(new DialogListItem(R.string.sb_text_channel_input_document, R.drawable.icon_document));
+ }
+ if (items.isEmpty()) return;
hideKeyboard();
- DialogUtils.showListBottomDialog(requireContext(), items, (view, position, item) -> {
+ DialogUtils.showListBottomDialog(requireContext(), items.toArray(new DialogListItem[0]), (view, position, item) -> {
final int key = item.getKey();
try {
if (key == R.string.sb_text_channel_input_camera) {
@@ -607,11 +628,11 @@ public void takePhoto() {
final String[] permissions = PermissionUtils.GET_CONTENT_PERMISSION;
if (permissions.length > 0) {
requestPermission(permissions, () -> {
- Intent intent = IntentUtils.getGalleryIntent();
+ Intent intent = channelConfig.getInput().getGallery().getGalleryIntent();
getContentLauncher.launch(intent);
});
} else {
- Intent intent = IntentUtils.getGalleryIntent();
+ Intent intent = channelConfig.getInput().getGallery().getGalleryIntent();
getContentLauncher.launch(intent);
}
}
diff --git a/uikit/src/main/java/com/sendbird/uikit/fragments/ChannelFragment.java b/uikit/src/main/java/com/sendbird/uikit/fragments/ChannelFragment.java
index fdb2f7ad..30eb5780 100644
--- a/uikit/src/main/java/com/sendbird/uikit/fragments/ChannelFragment.java
+++ b/uikit/src/main/java/com/sendbird/uikit/fragments/ChannelFragment.java
@@ -55,6 +55,7 @@
import com.sendbird.uikit.model.DialogListItem;
import com.sendbird.uikit.model.ReadyStatus;
import com.sendbird.uikit.model.TextUIConfig;
+import com.sendbird.uikit.model.configurations.ChannelConfig;
import com.sendbird.uikit.modules.ChannelModule;
import com.sendbird.uikit.modules.components.ChannelHeaderComponent;
import com.sendbird.uikit.modules.components.MessageInputComponent;
@@ -63,7 +64,6 @@
import com.sendbird.uikit.utils.ChannelUtils;
import com.sendbird.uikit.utils.DialogUtils;
import com.sendbird.uikit.utils.MessageUtils;
-import com.sendbird.uikit.utils.ReactionUtils;
import com.sendbird.uikit.utils.TextUtils;
import com.sendbird.uikit.vm.ChannelViewModel;
import com.sendbird.uikit.vm.FileDownloader;
@@ -93,6 +93,7 @@ public class ChannelFragment extends BaseMessageListFragment threadInfoClickListener;
@Nullable
private View.OnClickListener replyModeCloseButtonClickListener;
+ @SuppressWarnings("DeprecatedIsStillUsed")
@Nullable
@Deprecated
private View.OnClickListener scrollBottomButtonClickListener;
@@ -151,7 +152,7 @@ protected ChannelModule onCreateModule(@NonNull Bundle args) {
@NonNull
@Override
protected ChannelViewModel onCreateViewModel() {
- return new ViewModelProvider(this, new ViewModelFactory(getChannelUrl(), params)).get(getChannelUrl(), ChannelViewModel.class);
+ return new ViewModelProvider(this, new ViewModelFactory(getChannelUrl(), params, channelConfig)).get(getChannelUrl(), ChannelViewModel.class);
}
@Override
@@ -218,13 +219,15 @@ protected void onBindChannelHeaderComponent(@NonNull ChannelHeaderComponent head
startActivity(intent);
});
- viewModel.getTypingMembers().observe(getViewLifecycleOwner(), typingMembers -> {
- String description = null;
- if (typingMembers != null && getContext() != null) {
- description = ChannelUtils.makeTypingText(getContext(), typingMembers);
- }
- headerComponent.notifyHeaderDescriptionChanged(description);
- });
+ if (channelConfig.getEnableTypingIndicator()) {
+ viewModel.getTypingMembers().observe(getViewLifecycleOwner(), typingMembers -> {
+ String description = null;
+ if (typingMembers != null && getContext() != null) {
+ description = ChannelUtils.makeTypingText(getContext(), typingMembers);
+ }
+ headerComponent.notifyHeaderDescriptionChanged(description);
+ });
+ }
viewModel.onChannelUpdated().observe(getViewLifecycleOwner(), headerComponent::notifyChannelChanged);
}
@@ -402,7 +405,7 @@ protected void onBindMessageInputComponent(@NonNull MessageInputComponent inputC
inputComponent.setOnQuoteReplyModeCloseButtonClickListener(replyModeCloseButtonClickListener != null ? replyModeCloseButtonClickListener : v -> inputComponent.requestInputMode(MessageInputView.Mode.DEFAULT));
inputComponent.setOnVoiceRecorderButtonClickListener((onVoiceRecorderButtonClickListener != null) ? onVoiceRecorderButtonClickListener : v -> takeVoiceRecorder());
- if (SendbirdUIKit.isUsingUserMention()) {
+ if (channelConfig.getEnableMention()) {
inputComponent.bindUserMention(SendbirdUIKit.getUserMentionConfig(), text -> viewModel.loadMemberList(text != null ? text.toString() : null));
// observe suggestion list
@@ -457,8 +460,8 @@ protected void onQuoteReplyMessageClicked(@NonNull View view, int position, @Non
quoteReplyMessageClickListener.onItemClick(view, position, message);
return;
}
- if (SendbirdUIKit.getReplyType() == ReplyType.THREAD &&
- SendbirdUIKit.getThreadReplySelectType() == ThreadReplySelectType.THREAD) {
+ if (channelConfig.getReplyType() == ReplyType.THREAD &&
+ channelConfig.getThreadReplySelectType() == ThreadReplySelectType.THREAD) {
startMessageThreadActivity(message);
} else {
jumpToParentMessage(message);
@@ -504,11 +507,11 @@ private void onInputRightButtonClicked(@NonNull View view) {
if (inputText != null && !TextUtils.isEmpty(inputText.getText())) {
final Editable editableText = inputText.getText();
UserMessageCreateParams params = new UserMessageCreateParams(editableText.toString());
- if (targetMessage != null && SendbirdUIKit.getReplyType() != ReplyType.NONE) {
+ if (targetMessage != null && channelConfig.getReplyType() != ReplyType.NONE) {
params.setParentMessageId(targetMessage.getMessageId());
params.setReplyToChannel(true);
}
- if (SendbirdUIKit.isUsingUserMention()) {
+ if (channelConfig.getEnableMention()) {
if (inputText instanceof MentionEditText) {
final List mentionedUsers = ((MentionEditText) inputText).getMentionedUsers();
final CharSequence mentionedTemplate = ((MentionEditText) inputText).getMentionedTemplate();
@@ -557,14 +560,14 @@ protected List makeMessageContextMenu(@NonNull BaseMessage messa
DialogListItem edit = new DialogListItem(R.string.sb_text_channel_anchor_edit, R.drawable.icon_edit);
DialogListItem save = new DialogListItem(R.string.sb_text_channel_anchor_save, R.drawable.icon_download);
DialogListItem delete = new DialogListItem(R.string.sb_text_channel_anchor_delete, R.drawable.icon_delete, false, MessageUtils.hasThread(message));
- int replyStringRes = SendbirdUIKit.getReplyType() == ReplyType.THREAD ? R.string.sb_text_channel_anchor_reply_in_thread : R.string.sb_text_channel_anchor_reply;
- int replyDrawableRes = SendbirdUIKit.getReplyType() == ReplyType.THREAD ? R.drawable.icon_thread : R.drawable.icon_reply;
+ int replyStringRes = channelConfig.getReplyType() == ReplyType.THREAD ? R.string.sb_text_channel_anchor_reply_in_thread : R.string.sb_text_channel_anchor_reply;
+ int replyDrawableRes = channelConfig.getReplyType() == ReplyType.THREAD ? R.drawable.icon_thread : R.drawable.icon_reply;
DialogListItem reply = new DialogListItem(replyStringRes, replyDrawableRes, false, MessageUtils.hasParentMessage(message));
DialogListItem retry = new DialogListItem(R.string.sb_text_channel_anchor_retry, 0);
DialogListItem deleteFailed = new DialogListItem(R.string.sb_text_channel_anchor_delete, 0);
DialogListItem[] actions = null;
- final ReplyType replyType = SendbirdUIKit.getReplyType();
+ final ReplyType replyType = channelConfig.getReplyType();
switch (type) {
case VIEW_TYPE_USER_MESSAGE_ME:
if (status == SendingStatus.SUCCEEDED) {
@@ -676,7 +679,7 @@ protected boolean onMessageContextMenuItemClicked(@NonNull BaseMessage message,
void showMessageContextMenu(@NonNull View anchorView, @NonNull BaseMessage message, @NonNull List items) {
int size = items.size();
final DialogListItem[] actions = items.toArray(new DialogListItem[size]);
- if (!ReactionUtils.canSendReaction(getViewModel().getChannel())) {
+ if (getViewModel().getChannel() != null && !(ChannelConfig.canSendReactions(channelConfig, getViewModel().getChannel()))) {
final RecyclerView messageListView = getModule().getMessageListComponent().getRecyclerView();
if (getContext() == null || messageListView == null || size <= 0) return;
MessageAnchorDialog messageAnchorDialog = new MessageAnchorDialog.Builder(anchorView, messageListView, actions)
@@ -750,7 +753,7 @@ private void startMessageThreadActivity(@NonNull BaseMessage message) {
}
private void redirectMessageThreadIfNeeded(@Nullable Bundle args) {
- if (args == null || SendbirdUIKit.getReplyType() != ReplyType.THREAD) return;
+ if (args == null || channelConfig.getReplyType() != ReplyType.THREAD) return;
if (args.containsKey(StringSet.KEY_ANCHOR_MESSAGE_ID)) {
long messageId = args.getLong(StringSet.KEY_ANCHOR_MESSAGE_ID);
@@ -932,8 +935,12 @@ public Builder setUseHeaderLeftButton(boolean useHeaderLeftButton) {
* @param useTypingIndicator true
if the typing indicator is used,
* false
otherwise.
* @return This Builder object to allow for chaining of calls to set methods.
+ * @deprecated 3.6.0
+ * Use {@link #setChannelConfig(ChannelConfig)} instead.
+ * @see ChannelConfig#setEnableTypingIndicator(boolean)
*/
@NonNull
+ @Deprecated
public Builder setUseTypingIndicator(boolean useTypingIndicator) {
bundle.putBoolean(StringSet.KEY_USE_TYPING_INDICATOR, useTypingIndicator);
return this;
@@ -1812,6 +1819,19 @@ public Builder setOnMessageMentionClickListener(@NonNull OnItemClickListener