Skip to content

Commit

Permalink
Android UI Kit v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Aug 19, 2020
1 parent 4b2c62e commit afaf89f
Show file tree
Hide file tree
Showing 89 changed files with 7,274 additions and 749 deletions.
7 changes: 5 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
manifestPlaceholders = [file_provider: "com.cometchat.pro.androiduikit"]

ndk {
abiFilters "armeabi-v7a", "x86"
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
dataBinding {
Expand Down Expand Up @@ -55,8 +55,11 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation project(path: ':uikit')

implementation 'androidx.emoji:emoji:1.1.0-rc01'
implementation 'androidx.emoji:emoji-bundled:1.1.0'

implementation 'com.google.android.material:material:1.2.0-alpha05'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
//
implementation 'com.cometchat:pro-android-chat-sdk:2.0.6'
implementation 'com.cometchat:pro-android-chat-sdk:2.0.7'
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void onSuccess(User user) {

@Override
public void onError(CometChatException e) {
progressBar.setVisibility(View.GONE);
createUserBtn.setClickable(true);
Toast.makeText(CreateUserActivity.this,"Failed to create user",Toast.LENGTH_LONG).show();
}
Expand Down Expand Up @@ -111,7 +110,6 @@ public void onSuccess(User user) {

@Override
public void onError(CometChatException e) {
progressBar.setVisibility(View.GONE);
if (uid!=null)
Snackbar.make(uid.getRootView(),"Unable to login",Snackbar.LENGTH_INDEFINITE).setAction("Try Again", new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (CometChat.getLoggedInUser()!=null)
{
startActivity(new Intent(MainActivity.this,SelectActivity.class));
}
loginBtn = findViewById(R.id.login);
superhero1 = findViewById(R.id.superhero1);
superhero2 = findViewById(R.id.superhero2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

import androidx.emoji.bundled.BundledEmojiCompatConfig;
import androidx.emoji.text.EmojiCompat;

import com.cometchat.pro.core.AppSettings;
import com.cometchat.pro.core.CometChat;
import com.cometchat.pro.exceptions.CometChatException;
import com.cometchat.pro.androiduikit.constants.AppConfig;
import com.cometchat.pro.helpers.Logger;

import constant.StringContract;
import listeners.CometChatCallListener;
import utils.PreferenceUtil;

Expand All @@ -27,13 +32,16 @@ public class UIKitApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
AppSettings appSettings = new AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings, new CometChat.CallbackListener<String>() {
EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
EmojiCompat.init(config);
AppSettings appSettings = new AppSettings.AppSettingsBuilder().
subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings,
new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
PreferenceUtil preferenceUtil = PreferenceUtil.getInstance(UIKitApplication.this);
preferenceUtil.saveString("apikey",AppConfig.AppDetails.API_KEY);
CometChat.setSource("ui-kit-sampleapp","android","java");
StringContract.AppInfo.API_KEY = AppConfig.AppDetails.API_KEY;
CometChat.setSource("ui-kit","android","java");
Log.d(TAG, "onSuccess: "+s);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ public class AppConfig {

public class AppDetails {

public static final String APP_ID = "XXXXXXXXXXX";
public static final String APP_ID = "XXXXXXXXXXXXXXXX";

public static final String API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

public static final String REGION = "XX";
}
Expand Down
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ dependencies {
implementation 'com.facebook.shimmer:shimmer:0.4.0'

//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:2.0.6'
compileOnly 'com.cometchat:pro-android-chat-sdk:2.0.7'
}
24 changes: 19 additions & 5 deletions uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
android:usesCleartextTraffic="true"
tools:node="merge"
tools:targetApi="m">
<activity android:name="screen.banmembers.CometChatBanMemberScreenActivity"/>
<activity android:name="screen.threadconversation.CometChatThreadMessageActivity"
android:windowSoftInputMode="adjustResize"/>
<activity android:name="screen.banmembers.CometChatBanMemberScreenActivity" />
<activity
android:name="screen.CometChatCallActivity"
android:screenOrientation="portrait"
Expand All @@ -32,9 +34,10 @@
<activity
android:name="screen.creategroup.CometChatCreateGroupScreenActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"/>
<activity android:name="screen.CometChatMorePrivacyScreenActivity"
android:screenOrientation="portrait"/>
android:windowSoftInputMode="adjustPan" />
<activity
android:name="screen.CometChatMorePrivacyScreenActivity"
android:screenOrientation="portrait" />
<activity
android:name="screen.blockuserlist.CometChatBlockUserListScreenActivity"
android:screenOrientation="portrait" />
Expand All @@ -49,7 +52,18 @@
android:screenOrientation="portrait" />
<activity
android:name="screen.CometChatForwardMessageScreenActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity
android:name="screen.groupmemberlist.CometChatGroupMemberListScreenActivity"
android:screenOrientation="portrait" />
Expand Down
15 changes: 15 additions & 0 deletions uikit/src/main/java/adapter/ConversationListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.List;

import utils.Extensions;
import utils.FontUtils;
import utils.Utils;

Expand Down Expand Up @@ -111,6 +112,7 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol

String avatar;
String name;
String status;
String lastMessageText = null;
BaseMessage baseMessage = conversation.getLastMessage();
conversationViewHolder.conversationListRowBinding.setConversation(conversation);
Expand All @@ -133,16 +135,29 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol
conversationViewHolder.conversationListRowBinding.messageTime.setVisibility(View.GONE);
}
conversationViewHolder.conversationListRowBinding.txtUserMessage.setText(lastMessageText);
if (baseMessage!=null) {
boolean isSentimentNegative = Extensions.checkSentiment(baseMessage);
if (isSentimentNegative && !baseMessage.getSender().getUid().equals(CometChat.getLoggedInUser().getUid())) {
conversationViewHolder.conversationListRowBinding.txtUserMessage.setText(context.getResources().getString(R.string.sentimment_content));
}
}
conversationViewHolder.conversationListRowBinding.txtUserMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
conversationViewHolder.conversationListRowBinding.txtUserName.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));
conversationViewHolder.conversationListRowBinding.messageTime.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));

if (conversation.getConversationType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
name = ((User) conversation.getConversationWith()).getName();
avatar = ((User) conversation.getConversationWith()).getAvatar();
status = ((User)conversation.getConversationWith()).getStatus();
if (status.equals(CometChatConstants.USER_STATUS_ONLINE)) {
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.VISIBLE);
conversationViewHolder.conversationListRowBinding.userStatus.setUserStatus(status);
} else
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.GONE);
} else {
name = ((Group) conversation.getConversationWith()).getName();
avatar = ((Group) conversation.getConversationWith()).getIcon();
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.GONE);
}

conversationViewHolder.conversationListRowBinding.messageCount.setCount(conversation.getUnreadMessageCount());
Expand Down
25 changes: 20 additions & 5 deletions uikit/src/main/java/adapter/GroupListAdapter.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package adapter;

import android.content.Context;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.cometchat.pro.constants.CometChatConstants;
import com.cometchat.pro.uikit.R;
import com.cometchat.pro.uikit.databinding.GroupListRowBinding;
import com.cometchat.pro.models.Group;
Expand Down Expand Up @@ -81,16 +83,28 @@ public GroupViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewTyp
public void onBindViewHolder(@NonNull GroupViewHolder groupViewHolder, int position) {
Group group = groupList.get(position);
groupViewHolder.groupListRowBinding.setGroup(group);
groupViewHolder.groupListRowBinding.executePendingBindings();
groupViewHolder.groupListRowBinding.txtUserMessage.setText("Members: "+group.getMembersCount());

if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PRIVATE))
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_security_24dp,0);
else if (group.getGroupType().equals(CometChatConstants.GROUP_TYPE_PASSWORD))
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_lock_24dp,0);
else
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);

groupViewHolder.groupListRowBinding.executePendingBindings();
groupViewHolder.groupListRowBinding.avGroup.setBackgroundColor(context.getResources().getColor(R.color.colorPrimary));
groupViewHolder.groupListRowBinding.getRoot().setTag(R.string.group, group);
groupViewHolder.groupListRowBinding.txtUserMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));
groupViewHolder.groupListRowBinding.txtUserName.setTypeface(fontUtils.getTypeFace(FontUtils.robotoMedium));

if(Utils.isDarkMode(context)) {
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawableTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.grey)));
groupViewHolder.groupListRowBinding.txtUserName.setTextColor(context.getResources().getColor(R.color.textColorWhite));
groupViewHolder.groupListRowBinding.tvSeprator.setBackgroundColor(context.getResources().getColor(R.color.grey));
} else {
groupViewHolder.groupListRowBinding.txtUserName.setCompoundDrawableTintList(ColorStateList.valueOf(context.getResources().getColor(R.color.message_bubble_grey)));
groupViewHolder.groupListRowBinding.txtUserName.setTextColor(context.getResources().getColor(R.color.primaryTextColor));
groupViewHolder.groupListRowBinding.tvSeprator.setBackgroundColor(context.getResources().getColor(R.color.light_grey));
}
Expand All @@ -103,7 +117,7 @@ public void onBindViewHolder(@NonNull GroupViewHolder groupViewHolder, int posit
public void updateGroupList(List<Group> groupList) {

for (int i = 0; i <groupList.size() ; i++) {
updateGroup(groupList.get(i));
updateGroup(groupList.get(i),i);
}
}

Expand All @@ -112,12 +126,12 @@ public void updateGroupList(List<Group> groupList) {
*
* @param group is an object of Group. It will be updated with previous group in a list.
*/
public void updateGroup(Group group) {
public void updateGroup(Group group,int i) {
if (group != null) {
if (groupList.contains(group)) {
int index = groupList.indexOf(group);
int index = groupList.indexOf(groupList.get(i));
groupList.remove(index);
groupList.add(group);
groupList.add(index,group);
notifyItemChanged(index);
} else {
groupList.add(group);
Expand Down Expand Up @@ -172,7 +186,8 @@ public void searchGroup(List<Group> groups) {
*/
public void add(Group group) {
if (group != null) {
updateGroup(group);
groupList.add(group);
notifyItemInserted(getItemCount()-1);
}
}

Expand Down
Loading

0 comments on commit afaf89f

Please sign in to comment.