diff --git a/FastChat/src/main/java/com/fastchat/Core/UiConfig.java b/FastChat/src/main/java/com/fastchat/Core/UiConfig.java index d8e8feb..feb8df7 100644 --- a/FastChat/src/main/java/com/fastchat/Core/UiConfig.java +++ b/FastChat/src/main/java/com/fastchat/Core/UiConfig.java @@ -1,5 +1,7 @@ package com.fastchat.Core; +import android.view.View; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -151,6 +153,9 @@ interface OnChatListener { void onVoice(User user, BaseMessage baseMessage); + + void info(View view); + } diff --git a/FastChat/src/main/java/com/fastchat/Ui/Chat/fragmentChat.java b/FastChat/src/main/java/com/fastchat/Ui/Chat/fragmentChat.java index 8eebc19..b466f24 100644 --- a/FastChat/src/main/java/com/fastchat/Ui/Chat/fragmentChat.java +++ b/FastChat/src/main/java/com/fastchat/Ui/Chat/fragmentChat.java @@ -203,9 +203,52 @@ public void onClick(View v) { getActivity().finish(); } }); + info.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (FastChat.getUiConfig().getOnChatListener() != null) { + FastChat.getUiConfig().getOnChatListener().info(v); + } + + } + }); video_call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + if (Utils.hasPermissions(getActivity(), new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA})) { + FastChat.getFastChat().getChatInteract().sendMessageCall(groupId, FastChatConstants.MESSAGE_TYPE_VIDEO, receiverId, userId, new Chat.CallbackListener() { + @Override + public void onSuccess(BaseMessage textMessage) { + MediaUtils.playSendSound(getActivity(), R.raw.outgoing_message); + SendNotification(receiverId, (Call) textMessage); + DatabaseReference databaseReference = FastChat.getFastChat().getChatInteract().getUser(receiverId); + ValueEventListener valueEventListener = new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + User user1 = snapshot.getValue(User.class); + if ((user1 != null ? user1.getUserName() : null) != null) { + if (FastChat.getUiConfig().getOnChatListener() != null) { + FastChat.getUiConfig().getOnChatListener().onVideo(user1, (Call) textMessage); + } + + } + } + @Override + public void onCancelled(@NonNull DatabaseError error) { + + } + }; + databaseReference.addListenerForSingleValueEvent(valueEventListener); + } + }); + + + }else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + ( getActivity()).requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.CAMERA}, + 30); + } + } // FastPermissions.with(getActivity()) // .request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA) // .ifNecessary() @@ -250,6 +293,41 @@ public void onClick(View v) { voice_call.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + + if (Utils.hasPermissions(getActivity(), new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE})) { + FastChat.getFastChat().getChatInteract().sendMessageCall(groupId, FastChatConstants.MESSAGE_TYPE_VIDEO, receiverId, userId, new Chat.CallbackListener() { + @Override + public void onSuccess(BaseMessage textMessage) { + MediaUtils.playSendSound(getActivity(), R.raw.outgoing_message); + SendNotification(receiverId, (Call) textMessage); + DatabaseReference databaseReference = FastChat.getFastChat().getChatInteract().getUser(receiverId); + ValueEventListener valueEventListener = new ValueEventListener() { + @Override + public void onDataChange(@NonNull DataSnapshot snapshot) { + User user1 = snapshot.getValue(User.class); + if ((user1 != null ? user1.getUserName() : null) != null) { + if (FastChat.getUiConfig().getOnChatListener() != null) { + FastChat.getUiConfig().getOnChatListener().onVoice(user1, (Call) textMessage); + } + + } + } + @Override + public void onCancelled(@NonNull DatabaseError error) { + + } + }; + databaseReference.addListenerForSingleValueEvent(valueEventListener); + } + }); + + + }else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + ( getActivity()).requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE}, + 30); + } + } // FastPermissions.with(getActivity()) // .request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA) // .ifNecessary() diff --git a/FastChat/src/main/res/layout/conversation_list_row.xml b/FastChat/src/main/res/layout/conversation_list_row.xml index 5015af6..f591919 100644 --- a/FastChat/src/main/res/layout/conversation_list_row.xml +++ b/FastChat/src/main/res/layout/conversation_list_row.xml @@ -41,6 +41,7 @@ android:layout_toEndOf="@id/av_user" android:layout_height="wrap_content" tools:text="@tools:sample/full_names" + android:textColor="@color/textColorBlack" android:layout_marginEnd="16dp" android:textSize="@dimen/name" android:maxLines="1" @@ -57,6 +58,7 @@ android:layout_below="@id/txt_user_name" android:layout_toEndOf="@id/av_user" android:maxLines="1" + android:textColor="@color/secondaryTextColor" android:layout_marginRight="8dp" android:layout_toStartOf="@+id/messageTime" tools:text="online" @@ -81,6 +83,7 @@ android:textSize="12sp" android:layout_alignTop="@id/txt_user_name" tools:text="11:50" + android:textColor="@color/secondaryTextColor" android:layout_width="wrap_content" android:layout_height="wrap_content"/>