Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summary UI android Agent App #565

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kommunicate/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/.idea
/gradle
/src/main/resources/META-INF/io/kommunicate/sdk/kommunicate/verification.properties
/.cxx/
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.applozic.mobicomkit.api.conversation;

import static io.kommunicate.utils.KmConstants.KM_SUMMARY;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
Expand Down Expand Up @@ -345,7 +347,7 @@ public synchronized List<Message> getMessagesForParticularThread(Long startTime,
}


public synchronized List<Message> getMessages(Long startTime, Long endTime, Contact contact, Channel channel, Integer conversationId, boolean isSkipRead, boolean isForSearch) {
public synchronized List<Message> getMessages(Boolean isAgentApp, Long startTime, Long endTime, Contact contact, Channel channel, Integer conversationId, boolean isSkipRead, boolean isForSearch) {
adarshmishra marked this conversation as resolved.
Show resolved Hide resolved
if (isForSearch) {
return getMessagesForParticularThread(startTime, endTime, contact, channel, conversationId, isSkipRead);
}
Expand Down Expand Up @@ -442,8 +444,23 @@ public synchronized List<Message> getMessages(Long startTime, Long endTime, Cont
FileClientService fileClientService = new FileClientService(context);
fileClientService.loadContactsvCard(message);
}
if (Message.MetaDataType.HIDDEN.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue())) || Message.MetaDataType.PUSHNOTIFICATION.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))) {
continue;


if (Message.MetaDataType.HIDDEN.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))
|| Message.MetaDataType.PUSHNOTIFICATION.getValue().equals(message.getMetaDataValueForKey(Message.MetaDataType.KEY.getValue()))
) {
// Check if message is conversation summary.
boolean isKmSummary;
if (message.getMetadata().containsKey(KM_SUMMARY)) {
isKmSummary = Boolean.parseBoolean(message.getMetaDataValueForKey(KM_SUMMARY));
adarshmishra marked this conversation as resolved.
Show resolved Hide resolved
}else {
isKmSummary = false;
}

// Avoid storing message if it is not summary message.
if (!(isAgentApp && isKmSummary)) {
continue;
}
}

message.setHidden((isHideActionMessage && message.isActionMessage()) || (message.isActionMessage() && TextUtils.isEmpty(message.getMessage())));
Expand All @@ -460,10 +477,10 @@ public synchronized List<Message> getMessages(Long startTime, Long endTime, Cont
if (message.getGroupId() != null) {
Channel newChannel = ChannelService.getInstance(context).getChannelByChannelKey(message.getGroupId());
if (newChannel != null) {
getMessages(null, null, null, newChannel, null, true, isForSearch);
getMessages(isAgentApp, null, null, null, newChannel, null, true, isForSearch);
}
} else {
getMessages(null, null, new Contact(message.getContactIds()), null, null, true, isForSearch);
getMessages(isAgentApp, null, null, new Contact(message.getContactIds()), null, null, true, isForSearch);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public class KmConstants {
public static final String HIDDEN = "hidden";
public static final String PSEUDONAME = "pseudoName";
public static final String KM_PSEUDO_USER = "KM_PSEUDO_USER";
public static final String KM_SUMMARY = "KM_SUMMARY";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -30,13 +31,15 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
Expand All @@ -47,6 +50,7 @@

import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.FragmentActivity;
Expand Down Expand Up @@ -116,6 +120,7 @@
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

import androidx.vectordrawable.graphics.drawable.AnimatorInflaterCompat;

Expand All @@ -125,8 +130,10 @@
import io.kommunicate.utils.KmUtils;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static androidx.core.content.ContextCompat.startActivity;
import static com.applozic.mobicomkit.api.conversation.stat.SourceUrl.SOURCE_URL;
import static io.kommunicate.utils.KmConstants.KM_SUMMARY;

/**
* Created by adarsh on 4/7/15.
Expand Down Expand Up @@ -396,10 +403,29 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
} else if (type == 3) {
MyViewHolder3 myViewHolder3 = (MyViewHolder3) holder;
myViewHolder3.customContentTextView.setText(message.getMessage());
myViewHolder3.customContentTextView.setVisibility(View.VISIBLE);
myViewHolder3.customContentTextView.setVisibility(VISIBLE);
return;
} else if (type == 4) {
MyViewHolder4 myViewHolder4 = (MyViewHolder4) holder;

if (message.getMetadata().containsKey(KM_SUMMARY)
&& Objects.equals(message.getMetadata().get(KM_SUMMARY), "true")
) {
myViewHolder4.normalTextLayout.setVisibility(GONE);

if (alCustomizationSettings.isAgentApp()) {
// Show summary UI
myViewHolder4.summaryCardView.setVisibility(VISIBLE);
myViewHolder4.summaryMessage.setText(message.getMessage());
myViewHolder4.summaryReadMore.setOnClickListener(view -> {
// Open Dialog...
createCustomDialog(message.getMessage());
});
}

return;
}

if (alCustomizationSettings.isAgentApp()) {
GradientDrawable bgGradientDrawable = (GradientDrawable) myViewHolder4.channelMessageTextView.getBackground();
bgGradientDrawable.setColor(Color.parseColor(isDarkModeEnabled ? alCustomizationSettings.getChannelCustomMessageBgColor().get(1) :
Expand All @@ -413,7 +439,6 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
myViewHolder4.channelMessageStaticText.setTextColor(Color.parseColor(isDarkModeEnabled ? alCustomizationSettings.getChannelCustomMessageTextColor().get(1) : alCustomizationSettings.getChannelCustomMessageTextColor().get(0)));
myViewHolder4.channelMessageLeftBg.setBackgroundColor(Color.parseColor(isDarkModeEnabled ? alCustomizationSettings.getChannelCustomMessageBgColor().get(1) : alCustomizationSettings.getChannelCustomMessageBgColor().get(0)));
myViewHolder4.channelMessageRightBg.setBackgroundColor(Color.parseColor(isDarkModeEnabled ? alCustomizationSettings.getChannelCustomMessageBgColor().get(1) : alCustomizationSettings.getChannelCustomMessageBgColor().get(0)));

}
return;
} else if (type == 5) {
Expand Down Expand Up @@ -523,6 +548,26 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
}
}

private void createCustomDialog(String message) {
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.custom_dialog_layout);
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawableResource(android.R.color.transparent);
}

TextView dialogMessage = dialog.findViewById(R.id.dialog_message);
dialogMessage.setText(message);

ImageButton btnClose = dialog.findViewById(R.id.dialog_close);
btnClose.setOnClickListener( view -> {
dialog.dismiss();
});

dialog.show();
}

protected void bindMessageView(RecyclerView.ViewHolder holder, final Message message, final int position) {
final MyViewHolder myHolder = (MyViewHolder) holder;
if (message != null) {
Expand Down Expand Up @@ -1957,17 +2002,25 @@ static class MyViewHolder4 extends RecyclerView.ViewHolder {
TextView channelMessageStaticText;
View channelMessageLeftBg;
View channelMessageRightBg;
CardView summaryCardView;
TextView summaryMessage;
Button summaryReadMore;
LinearLayout normalTextLayout;

public MyViewHolder4(View itemView, boolean isAgentApp) {
super(itemView);
if (isAgentApp) {
channelMessageTextView = (TextView) itemView.findViewById(R.id.channel_message);
summaryCardView = (CardView) itemView.findViewById(R.id.conversation_summary);
summaryMessage = (TextView) itemView.findViewById(R.id.summary_message);
summaryReadMore = (Button) itemView.findViewById(R.id.summary_read_more);
} else {
channelMessageTextView = (TextView) itemView.findViewById(R.id.km_transferred_to);
channelMessageStaticText = (TextView) itemView.findViewById(R.id.km_transferred_text);
channelMessageLeftBg = (View) itemView.findViewById(R.id.km_transferred_to_left_bg);
channelMessageRightBg = (View) itemView.findViewById(R.id.km_transferred_to_right_bg);
}
normalTextLayout = (LinearLayout) itemView.findViewById(R.id.normal_text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4217,7 +4217,7 @@ protected Long doInBackground(Void... voids) {
}


nextMessageList = conversationService.getMessages(lastConversationloadTime + 1L, null, contact, channel, conversationId, false, !TextUtils.isEmpty(messageSearchString));
nextMessageList = conversationService.getMessages(alCustomizationSettings.isAgentApp(), lastConversationloadTime + 1L, null, contact, channel, conversationId, false, !TextUtils.isEmpty(messageSearchString));
isNewConversation = isNewConversation(nextMessageList);
} else if (firstVisibleItem == 1 && loadMore && !messageList.isEmpty()) {
loadMore = false;
Expand All @@ -4229,7 +4229,7 @@ protected Long doInBackground(Void... voids) {
endTime = messageList.get(!TextUtils.isEmpty(alCustomizationSettings.getStaticTopMessage()) ? 1 : 0).getCreatedAtTime();
break;
}
nextMessageList = conversationService.getMessages(null, endTime, contact, channel, conversationId, false, !TextUtils.isEmpty(messageSearchString));
nextMessageList = conversationService.getMessages(alCustomizationSettings.isAgentApp(), null, endTime, contact, channel, conversationId, false, !TextUtils.isEmpty(messageSearchString));
isNewConversation = isNewConversation(nextMessageList);
}
if (BroadcastService.isContextBasedChatEnabled()) {
Expand Down
5 changes: 5 additions & 0 deletions kommunicateui/src/main/res/drawable/dialog_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="20dp" />
</shape>
9 changes: 9 additions & 0 deletions kommunicateui/src/main/res/drawable/ic_cancel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="14"
android:viewportHeight="14">
<path
android:pathData="M14,1.41L12.59,0L7,5.59L1.41,0L0,1.41L5.59,7L0,12.59L1.41,14L7,8.41L12.59,14L14,12.59L8.41,7L14,1.41Z"
android:fillColor="#1C1C1C"/>
</vector>
62 changes: 62 additions & 0 deletions kommunicateui/src/main/res/layout/custom_dialog_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="450dp"
android:orientation="vertical"
android:layout_margin="16dp"
android:background="@drawable/dialog_background">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">

<TextView
android:id="@+id/dialogTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/summary"
android:textStyle="bold"
android:textColor="@color/black"
android:gravity="center" />

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />

<ImageButton
android:id="@+id/dialog_close"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="center"
android:src="@drawable/ic_cancel"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/cancel"
android:padding="12dp" />
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#EFEFEF" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="15dp">
<TextView
android:id="@+id/dialog_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textColor="#313131"
android:gravity="start" />
</ScrollView>
</LinearLayout>
</FrameLayout>
Loading