Skip to content

Commit

Permalink
Android UI Kit v2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Oct 21, 2020
1 parent c7627fb commit f236088
Show file tree
Hide file tree
Showing 83 changed files with 1,309 additions and 749 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,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.1'
implementation 'com.cometchat:pro-android-chat-sdk:2.1.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import screen.CometChatGroupDetailScreenActivity;
import screen.CometChatUserDetailScreenActivity;
import screen.messagelist.CometChatMessageListActivity;
import utils.CallUtils;
import utils.Utils;

public class CallListViewFragment extends Fragment {
Expand Down Expand Up @@ -109,9 +110,9 @@ public void onSuccess(Call call) {
} else {
user = var.getSender();
}
Utils.startCallIntent(getContext(), user, CometChatConstants.CALL_TYPE_AUDIO, true, call.getSessionId());
CallUtils.startCallIntent(getContext(), user, CometChatConstants.CALL_TYPE_AUDIO, true, call.getSessionId());
} else
Utils.startGroupCallIntent(getContext(),((Group)call.getCallReceiver()),CometChatConstants.CALL_TYPE_AUDIO,true,call.getSessionId());
CallUtils.startGroupCallIntent(getContext(),((Group)call.getCallReceiver()),CometChatConstants.CALL_TYPE_AUDIO,true,call.getSessionId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.cometchat.pro.constants.CometChatConstants;
import com.cometchat.pro.core.CometChat;
import com.cometchat.pro.exceptions.CometChatException;
import com.cometchat.pro.uikit.UIKitSettings;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.snackbar.Snackbar;

Expand Down Expand Up @@ -69,6 +70,7 @@ public void onClick(View view) {
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
}
});

screenGroup = (RadioGroup)findViewById(R.id.screen_selector);
callGroup = findViewById(R.id.call_selector);
audioCallRb = findViewById(R.id.audioCall);
Expand Down
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.1'
compileOnly 'com.cometchat:pro-android-chat-sdk:2.1.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0"
}
repositories {
Expand Down
2 changes: 1 addition & 1 deletion uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature android:name="android.hardware.camera2.full" />
<application
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="true"
Expand Down
Empty file modified uikit/src/main/assets/Roboto-Black.ttf
100644 → 100755
Empty file.
Empty file modified uikit/src/main/assets/Roboto-Bold.ttf
100644 → 100755
Empty file.
Empty file modified uikit/src/main/assets/Roboto-Light.ttf
100644 → 100755
Empty file.
Empty file modified uikit/src/main/assets/Roboto-Medium.ttf
100644 → 100755
Empty file.
Empty file modified uikit/src/main/assets/Roboto-Regular.ttf
100644 → 100755
Empty file.
Empty file modified uikit/src/main/assets/Roboto-Thin.ttf
100644 → 100755
Empty file.
238 changes: 151 additions & 87 deletions uikit/src/main/java/adapter/MessageAdapter.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions uikit/src/main/java/adapter/ThreadAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,14 @@ public void onClick(DialogInterface dialog, int which) {
}
}
}

viewHolder.txtMessage.setText(txtMessage);
String profanityFilter = Extensions.checkProfanityMessage(baseMessage);
viewHolder.txtMessage.setText(profanityFilter);
viewHolder.txtMessage.setTypeface(fontUtils.getTypeFace(FontUtils.robotoRegular));

viewHolder.txtMessage.setTextColor(context.getResources().getColor(R.color.primaryTextColor));

Utils.setHyperLinkSupport(context,viewHolder.txtMessage);
showMessageTime(viewHolder, baseMessage);
if (messageList.get(messageList.size()-1).equals(baseMessage))
{
Expand Down Expand Up @@ -953,7 +953,7 @@ private void setLinkData(LinkMessageViewHolder viewHolder, int i) {
}
}
}

Utils.setHyperLinkSupport(context,viewHolder.message);
showMessageTime(viewHolder, baseMessage);
String finalUrl = url;
viewHolder.linkVisit.setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.cometchat.pro.uikit.ComposeBox;

import android.content.ContentResolver;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputContentInfo;

import androidx.appcompat.widget.AppCompatEditText;
import androidx.core.os.BuildCompat;
import androidx.core.view.inputmethod.EditorInfoCompat;
import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;

import com.cometchat.pro.constants.CometChatConstants;
import com.cometchat.pro.core.CometChat;
import com.cometchat.pro.exceptions.CometChatException;
import com.cometchat.pro.models.MediaMessage;

import java.io.File;

import utils.MediaUtils;
import utils.Utils;

public class CometChatEditText extends AppCompatEditText {

private static final String TAG = "CometChatEditText";

public OnEditTextMediaListener onEditTextMediaListener;

public CometChatEditText(Context context) {
super(context);
}

public CometChatEditText(Context context, AttributeSet attrs) {
super(context, attrs);
}

public CometChatEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
final InputConnection ic = super.onCreateInputConnection(outAttrs);
EditorInfoCompat.setContentMimeTypes(outAttrs,
new String [] {"image/png","image/gif"});


final InputConnectionCompat.OnCommitContentListener callback =
new InputConnectionCompat.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
int flags, Bundle opts) {
// read and display inputContentInfo asynchronously
if (BuildCompat.isAtLeastNMR1() && (flags &
InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
try {
inputContentInfo.requestPermission();
}
catch (Exception e) {
return false; // return false if failed
}
}
ContentResolver cr = getContext().getContentResolver();
String mimeType = cr.getType(inputContentInfo.getLinkUri());

Log.e(TAG, "onCommitContent: "+inputContentInfo.getLinkUri().getPath()
+"\n"+inputContentInfo.getContentUri()+"\n"+
mimeType);
onEditTextMediaListener.OnMediaSelected(inputContentInfo);
// read and display inputContentInfo asynchronously.
// call inputContentInfo.releasePermission() as needed.

return true; // return true if succeeded
}
};
return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
}

public void setMediaSelected(OnEditTextMediaListener onEditTextMediaListener) {
this.onEditTextMediaListener = onEditTextMediaListener;
}

public interface OnEditTextMediaListener {
void OnMediaSelected(InputContentInfoCompat i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
Expand All @@ -19,6 +20,8 @@
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.ImageView;
Expand All @@ -27,6 +30,10 @@
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.os.BuildCompat;
import androidx.core.view.inputmethod.EditorInfoCompat;
import androidx.core.view.inputmethod.InputConnectionCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.fragment.app.FragmentManager;

import com.cometchat.pro.core.CometChat;
Expand All @@ -44,6 +51,8 @@

public class ComposeBox extends RelativeLayout implements View.OnClickListener {

private static final String TAG = ComposeBox.class.getName();

private AudioRecordView audioRecordView;

private MediaRecorder mediaRecorder;
Expand All @@ -68,7 +77,7 @@ public class ComposeBox extends RelativeLayout implements View.OnClickListener {

private Chronometer recordTime;

public EditText etComposeBox;
public CometChatEditText etComposeBox;

private RelativeLayout composeBox;

Expand Down Expand Up @@ -231,6 +240,16 @@ public void afterTextChanged(Editable editable) {
}
}
});
etComposeBox.setMediaSelected(new CometChatEditText.OnEditTextMediaListener() {
@Override
public void OnMediaSelected(InputContentInfoCompat i) {
composeActionListener.onEditTextMediaSelected(i);
}
});
// InputConnection ic = etComposeBox.onCreateInputConnection(new EditorInfo());
// EditorInfoCompat.setContentMimeTypes(new EditorInfo(),
// new String [] {"image/png","image/gif"});


if (Utils.isDarkMode(context)) {
composeBox.setBackgroundColor(getResources().getColor(R.color.darkModeBackground));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cometchat.pro.uikit.SharedMedia;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -22,6 +23,7 @@
import com.google.android.material.snackbar.Snackbar;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import adapter.SharedMediaAdapter;
Expand Down Expand Up @@ -77,14 +79,21 @@ private void fetchMessage() {
if (messagesRequest==null)
{
if (type!=null && type.equals(CometChatConstants.RECEIVER_TYPE_USER))
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_FILE).setUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_FILE))
.setUID(Id).setLimit(30).build();
else
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_FILE).setGUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_FILE))
.setGUID(Id).setLimit(30).build();
}
messagesRequest.fetchPrevious(new CometChat.CallbackListener<List<BaseMessage>>() {
@Override
public void onSuccess(List<BaseMessage> baseMessageList) {
if(baseMessageList.size()!=0)

setAdapter(baseMessageList);
checkMediaVisble();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.android.material.snackbar.Snackbar;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import adapter.SharedMediaAdapter;
Expand Down Expand Up @@ -86,9 +87,15 @@ private void fetchMessage() {
if (messagesRequest==null)
{
if (type!=null && type.equals(CometChatConstants.RECEIVER_TYPE_USER))
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_IMAGE).setUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_IMAGE))
.setUID(Id).setLimit(30).build();
else
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_IMAGE).setGUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_IMAGE))
.setGUID(Id).setLimit(30).build();
}
messagesRequest.fetchPrevious(new CometChat.CallbackListener<List<BaseMessage>>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cometchat.pro.uikit.SharedMedia;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -22,6 +23,7 @@
import com.google.android.material.snackbar.Snackbar;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import adapter.SharedMediaAdapter;
Expand Down Expand Up @@ -69,9 +71,15 @@ private void fetchMessage() {
if (messagesRequest==null)
{
if (type!=null && type.equals(CometChatConstants.RECEIVER_TYPE_USER))
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_VIDEO).setUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_VIDEO))
.setUID(Id).setLimit(30).build();
else
messagesRequest = new MessagesRequest.MessagesRequestBuilder().setType(CometChatConstants.MESSAGE_TYPE_VIDEO).setGUID(Id).setLimit(30).build();
messagesRequest = new MessagesRequest.MessagesRequestBuilder()
.setCategories(Arrays.asList(CometChatConstants.CATEGORY_MESSAGE))
.setTypes(Arrays.asList(CometChatConstants.MESSAGE_TYPE_VIDEO))
.setGUID(Id).setLimit(30).build();
}
messagesRequest.fetchPrevious(new CometChat.CallbackListener<List<BaseMessage>>() {
@Override
Expand Down
Loading

0 comments on commit f236088

Please sign in to comment.