Skip to content

Commit

Permalink
Added 3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-shin committed Mar 14, 2023
1 parent 4af87e4 commit 1a286e9
Show file tree
Hide file tree
Showing 100 changed files with 6,857 additions and 82 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
### v3.5.0 (Mar 14, 2023) with Chat SDK `v4.6.0`
We’re excited to announce the launch of Sendbird Notifications v1.0! It’s a powerful solutions that makes it easier for brands to send marketing, transactional, and operational messages to their users. We’ve introduced a new type of channel called the notification channel that’s specifically designed for these kinds of messages. Just a heads up, you’ll need to use notification channels with Sendbird Notifications, otherwise things might not work properly.
* Support Notification Channel
* Added FeedNotificationChannelActivity` and `FeedNotificationChannelFragment`
* Added ChatNotificationChannelActivity` and `ChatNotificationChannelFragment`

### v3.4.0 (Feb 23, 2023) with Chat SDK `v4.4.0`
* Support voice message in GroupChannel
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.7.10'

dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ org.gradle.jvmargs=-Xmx1536m
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

UIKIT_VERSION = 3.4.0
UIKIT_VERSION = 3.5.0
UIKIT_VERSION_CODE = 1
1 change: 1 addition & 0 deletions uikit-custom-sample/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@

<string name="text_tab_channels">채널</string>
<string name="text_tab_settings">설정</string>
<string name="text_tab_notifications">알림채널</string>
<string name="text_tab_badge_max_count">99+</string>

<string name="text_create_community">커뮤니티 만들기</string>
Expand Down
4 changes: 3 additions & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlinx-serialization'
}

version = UIKIT_VERSION
Expand Down Expand Up @@ -65,7 +66,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Sendbird
api 'com.sendbird.sdk:sendbird-chat:4.4.0'
api 'com.sendbird.sdk:sendbird-chat:4.6.0'

implementation 'com.github.bumptech.glide:glide:4.13.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
Expand All @@ -79,6 +80,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2"



Expand Down
48 changes: 47 additions & 1 deletion uikit/consumer-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,50 @@
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}
}

# Kotlin Serialization
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class com.sendbird.uikit.** {
static *** Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class com.sendbird.uikit.** {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class com.sendbird.uikit.** {
public static com.sendbird.uikit.** INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

-keepclassmembers class * {
*** writeReplace();
}

# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.
# If you have any, uncomment and replace classes with those containing named companion objects.
#-keepattributes InnerClasses # Needed for `getDeclaredClasses`.
#-if @kotlinx.serialization.Serializable class
#com.example.myapplication.HasNamedCompanion, # <-- List serializable classes with named companions.
#com.example.myapplication.HasNamedCompanion2
#{
# static **$* *;
#}
#-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
# static <1>$$serializer INSTANCE;
#}

10 changes: 10 additions & 0 deletions uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@
android:name=".activities.OpenChannelActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".activities.FeedNotificationChannelActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />

<activity
android:name=".activities.ChatNotificationChannelActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
/>

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
32 changes: 27 additions & 5 deletions uikit/src/main/java/com/sendbird/uikit/SendbirdUIKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.sendbird.android.AppInfo;
import com.sendbird.android.ConnectionState;
import com.sendbird.android.NotificationInfo;
import com.sendbird.android.SendbirdChat;
import com.sendbird.android.exception.SendbirdException;
import com.sendbird.android.handler.CompletionHandler;
Expand All @@ -33,6 +34,7 @@
import com.sendbird.uikit.interfaces.CustomParamsHandler;
import com.sendbird.uikit.interfaces.CustomUserListQueryHandler;
import com.sendbird.uikit.interfaces.UserInfo;
import com.sendbird.uikit.internal.singleton.NotificationChannelManager;
import com.sendbird.uikit.internal.tasks.JobResultTask;
import com.sendbird.uikit.internal.tasks.TaskQueue;
import com.sendbird.uikit.log.Logger;
Expand Down Expand Up @@ -223,6 +225,7 @@ static void clearAll() {
SendbirdUIKit.customUserListQueryHandler = null;
defaultThemeMode = ThemeMode.Light;
UIKitPrefs.clearAll();
NotificationChannelManager.dispose();
}

/**
Expand Down Expand Up @@ -269,6 +272,7 @@ public void onInitSucceed() {
Logger.d(">> onInitSucceed()");
FileUtils.removeDeletableDir(context.getApplicationContext());
UIKitPrefs.init(context.getApplicationContext());
NotificationChannelManager.init(context.getApplicationContext());
EmojiManager.getInstance().init();

try {
Expand Down Expand Up @@ -528,11 +532,29 @@ public Pair<User, SendbirdException> call() throws Exception {

Logger.dev("++ user nickname = %s, profileUrl = %s", user.getNickname(), user.getProfileUrl());

AppInfo appInfo = SendbirdChat.getAppInfo();
if (appInfo != null &&
appInfo.getUseReaction() &&
appInfo.needUpdateEmoji(EmojiManager.getInstance().getEmojiHash())) {
updateEmojiList();
final AppInfo appInfo = SendbirdChat.getAppInfo();
if (appInfo != null) {
if (appInfo.getUseReaction() &&
appInfo.needUpdateEmoji(EmojiManager.getInstance().getEmojiHash())) {
updateEmojiList();
}

final NotificationInfo notificationInfo = appInfo.getNotificationInfo();
if (notificationInfo != null && notificationInfo.isEnabled()) {
// Even if the request fails, it should not affect the result of the connection request.
try {
// if the cache exists or no need to update, blocking is released right away
final String latestToken = notificationInfo.getTemplateListToken();
NotificationChannelManager.requestTemplateListBlocking(latestToken);
} catch (Exception ignore) {
}
try {
// if the cache exists or no need to update, blocking is released right away
final long settingsUpdatedAt = notificationInfo.getSettingsUpdatedAt();
NotificationChannelManager.requestNotificationChannelSettingBlocking(settingsUpdatedAt);
} catch (Exception ignore) {
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.sendbird.uikit.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.sendbird.uikit.R;
import com.sendbird.uikit.SendbirdUIKit;
import com.sendbird.uikit.consts.StringSet;
import com.sendbird.uikit.utils.ContextUtils;
import com.sendbird.uikit.utils.TextUtils;

/**
* Activity displays notifications of a channel by user.
*/
public class ChatNotificationChannelActivity extends AppCompatActivity {

/**
* Create an intent for a {@link ChatNotificationChannelActivity}.
*
* @param context A Context of the application package implementing this class.
* @param channelUrl the url of the channel will be implemented.
* @return ChatNotificationChannelActivity Intent.
* @since 3.5.0
*/
@NonNull
public static Intent newIntent(@NonNull Context context, @NonNull String channelUrl) {
return newIntentFromCustomActivity(context, ChatNotificationChannelActivity.class, channelUrl);
}

/**
* Create an intent for a custom activity. The custom activity must inherit {@link ChatNotificationChannelActivity}.
*
* @param context A Context of the application package implementing this class.
* @param cls The activity class that is to be used for the intent.
* @param channelUrl the url of the channel will be implemented.
* @return Returns a newly created Intent that can be used to launch the activity.
* @since 3.5.0
*/
@NonNull
public static Intent newIntentFromCustomActivity(@NonNull Context context, @NonNull Class<? extends ChatNotificationChannelActivity> cls, @NonNull String channelUrl) {
Intent intent = new Intent(context, cls);
intent.putExtra(StringSet.KEY_CHANNEL_URL, channelUrl);
return intent;
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(SendbirdUIKit.isDarkMode() ? R.style.AppTheme_Dark_Sendbird : R.style.AppTheme_Sendbird);
setContentView(R.layout.sb_activity);

String url = getIntent().getStringExtra(StringSet.KEY_CHANNEL_URL);
if (TextUtils.isEmpty(url)) {
ContextUtils.toastError(this, R.string.sb_text_error_get_channel);
} else {
Fragment fragment = createFragment();
FragmentManager manager = getSupportFragmentManager();
manager.popBackStack();
manager.beginTransaction()
.replace(R.id.sb_fragment_container, fragment)
.commit();
}
}

/**
* It will be called when the {@link ChatNotificationChannelActivity} is being created.
* The data contained in Intent is delivered to Fragment's Bundle.
*
* @return {@link com.sendbird.uikit.fragments.ChatNotificationChannelFragment}
* @since 3.5.0
*/
@NonNull
protected Fragment createFragment() {
final Bundle args = getIntent() != null && getIntent().getExtras() != null ? getIntent().getExtras() : new Bundle();
return SendbirdUIKit.getFragmentFactory().newChatNotificationChannelFragment(args.getString(StringSet.KEY_CHANNEL_URL, ""), args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.sendbird.uikit.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.sendbird.uikit.R;
import com.sendbird.uikit.SendbirdUIKit;
import com.sendbird.uikit.consts.StringSet;
import com.sendbird.uikit.utils.ContextUtils;
import com.sendbird.uikit.utils.TextUtils;

/**
* Activity displays notifications of a channel by user.
*/
public class FeedNotificationChannelActivity extends AppCompatActivity {

/**
* Create an intent for a {@link FeedNotificationChannelActivity}.
*
* @param context A Context of the application package implementing this class.
* @param channelUrl the url of the channel will be implemented.
* @return FeedNotificationChannelActivity Intent.
* @since 3.5.0
*/
@NonNull
public static Intent newIntent(@NonNull Context context, @NonNull String channelUrl) {
return newIntentFromCustomActivity(context, FeedNotificationChannelActivity.class, channelUrl);
}

/**
* Create an intent for a custom activity. The custom activity must inherit {@link FeedNotificationChannelActivity}.
*
* @param context A Context of the application package implementing this class.
* @param cls The activity class that is to be used for the intent.
* @param channelUrl the url of the channel will be implemented.
* @return Returns a newly created Intent that can be used to launch the activity.
* @since 3.5.0
*/
@NonNull
public static Intent newIntentFromCustomActivity(@NonNull Context context, @NonNull Class<? extends FeedNotificationChannelActivity> cls, @NonNull String channelUrl) {
Intent intent = new Intent(context, cls);
intent.putExtra(StringSet.KEY_CHANNEL_URL, channelUrl);
return intent;
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(SendbirdUIKit.isDarkMode() ? R.style.AppTheme_Dark_Sendbird : R.style.AppTheme_Sendbird);
setContentView(R.layout.sb_activity);

String url = getIntent().getStringExtra(StringSet.KEY_CHANNEL_URL);
if (TextUtils.isEmpty(url)) {
ContextUtils.toastError(this, R.string.sb_text_error_get_channel);
} else {
Fragment fragment = createFragment();
FragmentManager manager = getSupportFragmentManager();
manager.popBackStack();
manager.beginTransaction()
.replace(R.id.sb_fragment_container, fragment)
.commit();
}
}

/**
* It will be called when the {@link FeedNotificationChannelActivity} is being created.
* The data contained in Intent is delivered to Fragment's Bundle.
*
* @return {@link com.sendbird.uikit.fragments.FeedNotificationChannelFragment}
* @since 3.5.0
*/
@NonNull
protected Fragment createFragment() {
final Bundle args = getIntent() != null && getIntent().getExtras() != null ? getIntent().getExtras() : new Bundle();
return SendbirdUIKit.getFragmentFactory().newFeedNotificationChannelFragment(args.getString(StringSet.KEY_CHANNEL_URL, ""), args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

import androidx.recyclerview.widget.RecyclerView;

import com.sendbird.uikit.activities.viewholder.MessageViewHolder;

import java.util.List;

/**
* BaseMessageAdapter provides a binding from an app-specific data set to views that are displayed within a RecyclerView.
*
* @param <T> A class of data's type.
* @param <VH> A class that extends MessageViewHolder that will be used by the adapter.
* @param <VH> A class that extends RecyclerView.ViewHolder that will be used by the adapter.
*/
abstract class BaseMessageAdapter<T, VH extends MessageViewHolder> extends RecyclerView.Adapter<VH> {
abstract class BaseMessageAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
/**
* Returns item that located given position.
*
Expand Down
Loading

0 comments on commit 1a286e9

Please sign in to comment.