Skip to content

Commit

Permalink
Android UI Kit v2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Jan 20, 2021
1 parent 8aa6e62 commit 392e717
Show file tree
Hide file tree
Showing 38 changed files with 758 additions and 77 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ dependencies {
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.1.6'
implementation 'com.cometchat:pro-android-chat-sdk:2.1.7-beta2'
}
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dependencies {
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.6'
compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.7-beta2'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
}
repositories {
Expand Down
1 change: 1 addition & 0 deletions uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_path" />
</provider>

</application>

</manifest>
163 changes: 163 additions & 0 deletions uikit/src/main/java/adapter/MessageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import screen.CometChatReactionInfoScreenActivity;
import screen.messagelist.CometChatMessageListActivity;
import screen.threadconversation.CometChatThreadMessageActivity;
import utils.CallUtils;
import utils.Extensions;
import utils.FontUtils;
import utils.MediaUtils;
Expand Down Expand Up @@ -151,6 +152,10 @@ public class MessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder

private static final int LEFT_POLLS_CUSTOM_MESSAGE = 42;

private static final int LEFT_GROUP_CALL_MESSAGE = 313;

private static final int RIGHT_GROUP_CALL_MESSAGE = 314;

public static double LATITUDE;
public static double LONGITUDE;

Expand Down Expand Up @@ -399,6 +404,17 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
view.setTag(RIGHT_WRITEBOARD_MESSAGE);
return new WriteBoardViewHolder(view);

case RIGHT_GROUP_CALL_MESSAGE:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.message_right_group_call_item, parent, false);
view.setTag(RIGHT_GROUP_CALL_MESSAGE);
return new GroupCallMessageViewHolder(view);

case LEFT_GROUP_CALL_MESSAGE:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.message_left_group_call_item, parent, false);
view.setTag(LEFT_GROUP_CALL_MESSAGE);
return new GroupCallMessageViewHolder(view);


default:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.message_right_text_item, parent, false);
view.setTag(-1);
Expand Down Expand Up @@ -531,6 +547,10 @@ else if(!isNextMessage) {
setWriteBoardData((WriteBoardViewHolder) viewHolder,i);
break;

case LEFT_GROUP_CALL_MESSAGE:
case RIGHT_GROUP_CALL_MESSAGE:
setGroupCallMessageData((GroupCallMessageViewHolder)viewHolder,i);
break;
}
}

Expand Down Expand Up @@ -705,7 +725,108 @@ public boolean onLongClick(View view) {
setReactionSupport(baseMessage,viewHolder.reactionLayout);
}

private void setGroupCallMessageData(GroupCallMessageViewHolder viewHolder, int i) {
BaseMessage baseMessage = messageList.get(i);
if (baseMessage!=null) {
if (!baseMessage.getSender().getUid().equals(loggedInUser.getUid())) {
if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_USER)) {
viewHolder.tvUser.setVisibility(View.GONE);
viewHolder.ivUser.setVisibility(View.GONE);
}
else if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
if (isUserDetailVisible) {
viewHolder.tvUser.setVisibility(View.VISIBLE);
viewHolder.ivUser.setVisibility(View.VISIBLE);
} else
{
viewHolder.tvUser.setVisibility(View.GONE);
viewHolder.ivUser.setVisibility(View.INVISIBLE);
}
setAvatar(viewHolder.ivUser, baseMessage.getSender().getAvatar(), baseMessage.getSender().getName());
viewHolder.tvUser.setText(baseMessage.getSender().getName());
}
viewHolder.groupCallMessage.setText(baseMessage.getSender().getName() + " " +
context.getString(R.string.has_shared_group_call));

} else {
viewHolder.groupCallMessage.setText(context.getString(R.string.you_created_group_call));
}

viewHolder.joinBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (((CustomMessage)baseMessage).getCustomData()!=null) {
CallUtils.startDirectCall(context, Utils.getDirectCallData(baseMessage));
}
}
});

if (baseMessage.getReplyCount()!=0) {
viewHolder.tvThreadReplyCount.setVisibility(View.VISIBLE);
viewHolder.tvThreadReplyCount.setText(baseMessage.getReplyCount()+" Replies");
} else {
viewHolder.tvThreadReplyCount.setVisibility(View.GONE);
}
viewHolder.tvThreadReplyCount.setOnClickListener(view -> {
Intent intent = new Intent(context, CometChatThreadMessageActivity.class);
intent.putExtra(StringContract.IntentStrings.NAME,baseMessage.getSender().getName());
intent.putExtra(StringContract.IntentStrings.AVATAR,baseMessage.getSender().getAvatar());
intent.putExtra(StringContract.IntentStrings.REPLY_COUNT,baseMessage.getReplyCount());
intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getSender().getName());
intent.putExtra(StringContract.IntentStrings.PARENT_ID,baseMessage.getId());
intent.putExtra(StringContract.IntentStrings.MESSAGE_TYPE,baseMessage.getType());
intent.putExtra(StringContract.IntentStrings.REACTION_INFO,Extensions.getReactionsOnMessage(baseMessage));
intent.putExtra(StringContract.IntentStrings.SENTAT,baseMessage.getSentAt());

intent.putExtra(StringContract.IntentStrings.TEXTMESSAGE,Extensions.getWriteBoardUrl(baseMessage));

intent.putExtra(StringContract.IntentStrings.MESSAGE_CATEGORY,baseMessage.getCategory());
intent.putExtra(StringContract.IntentStrings.TYPE,baseMessage.getReceiverType());
if (baseMessage.getReceiverType().equals(CometChatConstants.RECEIVER_TYPE_GROUP)) {
intent.putExtra(StringContract.IntentStrings.GUID,baseMessage.getReceiverUid());
}
else {
if (baseMessage.getReceiverUid().equals(loggedInUser.getUid()))
intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getSender().getUid());
else
intent.putExtra(StringContract.IntentStrings.UID,baseMessage.getReceiverUid());
}
context.startActivity(intent);
});

showMessageTime(viewHolder, baseMessage);
viewHolder.txtTime.setVisibility(View.VISIBLE);
setColorFilter(baseMessage,viewHolder.messageContainer);
viewHolder.rlMessageBubble.setOnClickListener(view -> {

if (baseMessage.getSender().getUid().equals(loggedInUser.getUid())){
if (isLongClickEnabled && !isImageMessageClick) {
setLongClickSelectedItem(baseMessage);
messageLongClick.setLongMessageClick(longselectedItemList);
} else {
setSelectedMessage(baseMessage.getId());
}
notifyDataSetChanged();
}

});

viewHolder.rlMessageBubble.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {

if (!isImageMessageClick && !isTextMessageClick) {
isLongClickEnabled = true;
setLongClickSelectedItem(baseMessage);
messageLongClick.setLongMessageClick(longselectedItemList);
notifyDataSetChanged();
}
return true;
}
});
setReactionSupport(baseMessage,viewHolder.reactionLayout);
}
}


private void setWriteBoardData(WriteBoardViewHolder viewHolder,int i) {
Expand Down Expand Up @@ -1828,6 +1949,8 @@ private void showMessageTime(RecyclerView.ViewHolder viewHolder, BaseMessage bas
setStatusIcon((((WhiteBoardViewHolder) viewHolder).txtTime),baseMessage);
} else if (viewHolder instanceof WriteBoardViewHolder) {
setStatusIcon((((WriteBoardViewHolder) viewHolder).txtTime),baseMessage);
} else if (viewHolder instanceof GroupCallMessageViewHolder) {
setStatusIcon((((GroupCallMessageViewHolder) viewHolder).txtTime),baseMessage);
}

}
Expand Down Expand Up @@ -2570,6 +2693,8 @@ else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.WHI
return RIGHT_WHITEBOARD_MESSAGE;
else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.WRITEBOARD))
return RIGHT_WRITEBOARD_MESSAGE;
else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.GROUP_CALL))
return RIGHT_GROUP_CALL_MESSAGE;
else
return RIGHT_CUSTOM_MESSAGE;
}
Expand All @@ -2584,6 +2709,8 @@ else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.WHI
return LEFT_WHITEBOARD_MESSAGE;
else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.WRITEBOARD))
return LEFT_WRITEBOARD_MESSAGE;
else if (baseMessage.getType().equalsIgnoreCase(StringContract.IntentStrings.GROUP_CALL))
return LEFT_GROUP_CALL_MESSAGE;
else
return LEFT_CUSTOM_MESSAGE;
}
Expand Down Expand Up @@ -3015,6 +3142,42 @@ public PollMessageViewHolder(View itemView) {
}
}


public class GroupCallMessageViewHolder extends RecyclerView.ViewHolder {

private TextView tvThreadReplyCount;
private RelativeLayout messageContainer;
private View view;
public TextView txtTime;
public TextView tvUser;
private int type;
private Avatar ivUser;
private RelativeLayout rlMessageBubble;
private ChipGroup reactionLayout;

private ImageView icon;
private TextView groupCallMessage;
private MaterialButton joinBtn;

GroupCallMessageViewHolder(@NonNull View view) {
super(view);

type = (int) view.getTag();
tvUser = view.findViewById(R.id.tv_user);
icon = view.findViewById(R.id.icon);
messageContainer = view.findViewById(R.id.cv_message_container);
txtTime = view.findViewById(R.id.txt_time);
ivUser = view.findViewById(R.id.iv_user);
rlMessageBubble = view.findViewById(R.id.rl_message);
tvThreadReplyCount = view.findViewById(R.id.thread_reply_count);
reactionLayout = view.findViewById(R.id.reactions_layout);
groupCallMessage = view.findViewById(R.id.group_call_message);
joinBtn = view.findViewById(R.id.join_call);
this.view = view;

}
}

public class WhiteBoardViewHolder extends RecyclerView.ViewHolder {

private TextView tvThreadReplyCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class ComposeBox extends RelativeLayout implements View.OnClickListener {

public boolean isGalleryVisible = true,isAudioVisible = true,isCameraVisible = true,
isFileVisible = true,isLocationVisible = true,isPollVisible = true,isStickerVisible = true,
isWhiteBoardVisible = true, isWriteBoardVisible = true;
isWhiteBoardVisible = true, isWriteBoardVisible = true, isGroupCallVisible = true;

public ComposeBox(Context context) {
super(context);
Expand All @@ -113,16 +113,6 @@ public ComposeBox(Context context, AttributeSet attrs, int defStyleAttr) {
initViewComponent(context,attrs,defStyleAttr,-1);
}

public void setAudioButtonVisible(boolean result) { isAudioVisible = result; }

public void setGalleryButtonVisible(boolean result) { isGalleryVisible = result; }

public void setCameraButtonVisible(boolean result) { isCameraVisible = result; }

public void setFileButtonVisible(boolean result) { isFileVisible = result; }

public void setLocationButtonVisible(boolean result) { isLocationVisible = result; }

private void initViewComponent(Context context,AttributeSet attributeSet,int defStyleAttr,int defStyleRes){

View view =View.inflate(context, R.layout.layout_compose_box,null);
Expand Down Expand Up @@ -228,6 +218,11 @@ public void onWhiteBoardClick() {
public void onWriteBoardClick() {
composeActionListener.onWriteboardClicked();
}

@Override
public void onVideoMeetingClick() {
composeActionListener.onVideoMeetingClicked();
}
});
etComposeBox.addTextChangedListener(new TextWatcher() {
@Override
Expand Down Expand Up @@ -299,12 +294,15 @@ public void OnMediaSelected(InputContentInfoCompat i) {
isStickerVisible = UISettings.isStickerVisible();
isWhiteBoardVisible = UISettings.isWhiteBoardVisible();
isWriteBoardVisible = UISettings.isWriteBoardVisible();
isGroupCallVisible = UISettings.isEnableVideoCalling();

if (UISettings.isSendVoiceNotes()) {
ivMic.setVisibility(View.VISIBLE);
} else {
ivMic.setVisibility(GONE);
}
if (!UISettings.isSendPolls() &&
if (!UISettings.isEnableVideoCalling() &&
!UISettings.isSendPolls() &&
!UISettings.isSendFiles() &&
!UISettings.isSendPhotosVideo() &&
!UISettings.isSendVoiceNotes() &&
Expand Down Expand Up @@ -396,6 +394,7 @@ public void onClick(View view) {
bundle.putBoolean("isFileVisible",isFileVisible);
bundle.putBoolean("isAudioVisible",isAudioVisible);
bundle.putBoolean("isLocationVisible",isLocationVisible);
bundle.putBoolean("isGroupCallVisible",isGroupCallVisible);
if (CometChat.isExtensionEnabled("document"))
bundle.putBoolean("isWriteBoardVisible",isWriteBoardVisible);
if (CometChat.isExtensionEnabled("whiteboard"))
Expand Down Expand Up @@ -587,4 +586,49 @@ private void stopRecording(boolean isCancel) {
e.printStackTrace();
}
}

public void setAudioButtonVisible(boolean result) { isAudioVisible = result; }

public void setGalleryButtonVisible(boolean result) { isGalleryVisible = result; }

public void setCameraButtonVisible(boolean result) { isCameraVisible = result; }

public void setFileButtonVisible(boolean result) { isFileVisible = result; }

public void setLocationButtonVisible(boolean result) { isLocationVisible = result; }

public void hideGroupCallOption(boolean b) {
isGroupCallVisible = !b;
}

public void hidePollOption(boolean b) {
isPollVisible = !b;
}

public void hideStickerOption(boolean b) {
isStickerVisible = !b;
}

public void hideWriteBoardOption(boolean b) {
isWriteBoardVisible = !b;
}

public void hideWhiteBoardOption(boolean b) {
isWhiteBoardVisible = !b;
}

public void hideRecordOption(boolean b) {
if (b) {
ivMic.setVisibility(GONE);
} else {
ivMic.setVisibility(VISIBLE);
}
}

public void hideSendButton(boolean b) {
if (b) {
ivSend.setVisibility(GONE);
} else
ivSend.setVisibility(VISIBLE);
}
}
Loading

0 comments on commit 392e717

Please sign in to comment.