Skip to content

Commit

Permalink
Android UI Kit v3.0.0-2
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Aug 30, 2021
1 parent 6b83fbc commit 6685dd0
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The UI Kit is developed to keep developers in mind and aims to reduce developmen
[![Platform](https://img.shields.io/badge/Language-Java-yellowgreen.svg)](#)
![GitHub repo size](https://img.shields.io/github/repo-size/cometchat-pro/android-java-chat-ui-kit)
![GitHub contributors](https://img.shields.io/github/contributors/cometchat-pro/android-java-chat-ui-kit)
![Version](https://shields.io/badge/version-v3.0.0--1-orange)
![Version](https://shields.io/badge/version-v3.0.0--2-orange)
![GitHub stars](https://img.shields.io/github/stars/cometchat-pro/android-java-chat-ui-kit?style=social)
![Twitter Follow](https://img.shields.io/twitter/follow/cometchat?style=social)

Expand Down
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ android {
compileSdkVersion 30

defaultConfig {
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand Down
12 changes: 4 additions & 8 deletions uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,11 @@
<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" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/*" />
</intent-filter>
</activity>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
Expand All @@ -46,7 +49,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand Down Expand Up @@ -124,6 +129,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -1758,6 +1764,7 @@ public void onError(CometChatException e) {
if (messageAdapter == null) {
Log.e(TAG, "onError: MessageAdapter is null");
} else {
e.printStackTrace();
textMessage.setSentAt(-1);
messageAdapter.updateChangedMessage(textMessage);
}
Expand Down Expand Up @@ -2225,7 +2232,7 @@ public void onSuccess(Boolean booleanVal) {
@Override
public void onSuccess(Boolean booleanVal) {
if (booleanVal)
tvStatus.setText(typingIndicator.getSender().getName() + getString(R.string.is_typing));
tvStatus.setText(typingIndicator.getSender().getName() +" "+getString(R.string.is_typing));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,17 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
showPermissionSnackBar(view.findViewById(R.id.message_box), getResources().getString(R.string.grant_storage_permission));
break;
case UIKitConstants.RequestCode.LOCATION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { }
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
initLocation();
// locationManager = (LocationManager) Objects.requireNonNull(getContext()).getSystemService(Context.LOCATION_SERVICE);
boolean provider = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!provider) {
turnOnLocation();
}
else {
getLocation();
}
}
else
showPermissionSnackBar(view.findViewById(R.id.message_box), getResources().getString(R.string.grant_location_permission));
break;
Expand Down Expand Up @@ -1715,11 +1725,7 @@ private void scrollToBottom() {
* @param baseMessage is object of BaseMessage.class. It is message which is been marked as read.
*/
private void markMessageAsRead(BaseMessage baseMessage) {
// CometChat.markAsRead(baseMessage);
if (type.equals(CometChatConstants.RECEIVER_TYPE_USER))
CometChat.markAsRead(baseMessage.getId(), baseMessage.getSender().getUid(), baseMessage.getReceiverType());
else
CometChat.markAsRead(baseMessage.getId(), baseMessage.getReceiverUid(), baseMessage.getReceiverType());
CometChat.markAsRead(baseMessage);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public void onBindViewHolder(@NonNull ConversationViewHolder conversationViewHol
name = conversationUser.getName();
avatar = conversationUser.getAvatar();
status = conversationUser.getStatus();
Log.e("Conversation:",conversation.getConversationWith().toString());
if (status.equals(CometChatConstants.USER_STATUS_ONLINE)) {
conversationViewHolder.conversationListRowBinding.userStatus.setVisibility(View.VISIBLE);
conversationViewHolder.conversationListRowBinding.userStatus.setUserStatus(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ public static class IntentStrings {

public static final String INTENT_MEDIA_VIDEO_MESSAGE = "intent_media_video_message";

public static final String INTENT_MEDIA_AUDIO_MESSAGE = "intent_media_audio_message";

public static final String INTENT_MEDIA_FILE_MESSAGE = "intent_media_file_message";

public static final String LINK = "link";

public static final String IS_TITLE_VISIBLE = "IS_TITLE_VISIBLE";

public static final String CREATE_GROUP_VISIBLE = "IS_CREATE_GROUP_VISIBLE";

public static String POLL_QUESTION = "poll_question";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.cometchat.pro.uikit.ui_resources.utils;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ComponentName;
Expand Down Expand Up @@ -33,15 +32,13 @@
import android.widget.Toast;

import androidx.core.content.FileProvider;
import androidx.loader.content.CursorLoader;

import com.cometchat.pro.models.BaseMessage;
import com.cometchat.pro.models.MediaMessage;
import com.cometchat.pro.uikit.BuildConfig;
import com.cometchat.pro.uikit.R;
import com.cometchat.pro.uikit.ui_settings.FeatureRestriction;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
Expand Down Expand Up @@ -161,7 +158,7 @@ public static Intent openCamera(Context context) {
e.printStackTrace();
}

outputFileUri = FileProvider.getUriForFile(context, provider + ".provider", file);
outputFileUri = FileProvider.getUriForFile(context, provider + ".provider", file);

if (Build.VERSION.SDK_INT >= 29) {
ContentResolver resolver = context.getContentResolver();
Expand Down Expand Up @@ -310,14 +307,21 @@ private static File createFileFromBitmap(Bitmap bitmap) {
return f;
}

public static File makeEmptyFileWithTitle(String title) {
String root;
if (Build.VERSION.SDK_INT < 29) {
root = Environment.getExternalStorageDirectory().getAbsolutePath();
} else {
root = Environment.DIRECTORY_DOWNLOADS;
}
return new File(root, title);
}

public static File getRealPath(Context context, Uri fileUri,boolean isThirdParty) {
Log.d("", "getRealPath: " + fileUri.getPath());
String realPath;
if (isGoogleDrive(fileUri)) {
return saveDriveFile(context, fileUri);
}
else if (isThirdParty) {
return downloadImage(context, fileUri);
if (isGoogleDrive(fileUri) || isThirdParty) {
return downloadFile(context, fileUri);
}
// SDK > 19 (Android 4.4) and up
else if (Build.VERSION.SDK_INT < 28){
Expand All @@ -330,12 +334,12 @@ else if (Build.VERSION.SDK_INT < 28){
return new File(realPath);
}

public static File downloadImage(Context context, Uri imageUri) {
public static File downloadFile(Context context, Uri imageUri) {
// Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
File file = null;
try {
if (imageUri != null) {
file = new File(context.getCacheDir(), "image");
file = new File(context.getCacheDir(), getFileName(context,imageUri));
InputStream inputStream = context.getContentResolver().openInputStream(imageUri);
try {

Expand Down Expand Up @@ -402,43 +406,38 @@ private static String getFilePathForN(Uri uri, Context context) {
return file.getPath();
}

public static File saveDriveFile(Context context, Uri uri) {

try {

InputStream inputStream = context.getContentResolver().openInputStream(uri);
int originalSize = inputStream.available();

BufferedInputStream bis = null;
BufferedOutputStream bos = null;
String fileName = getFileName(context, uri);
File file = makeEmptyFileWithTitle(fileName);
bis = new BufferedInputStream(inputStream);
bos = new BufferedOutputStream(new FileOutputStream(
file, false));

byte[] buf = new byte[originalSize];
bis.read(buf);
do {
bos.write(buf);
} while (bis.read(buf) != -1);

bos.flush();
bos.close();
bis.close();

return file;

} catch (IOException e) {
return null;
}

}

public static File makeEmptyFileWithTitle(String title) {
String root = Environment.getExternalStorageDirectory().getAbsolutePath();
return new File(root, title);
}
// public static File saveDriveFile(Context context, Uri uri) {
//
// try {
//
// InputStream inputStream = context.getContentResolver().openInputStream(uri);
// int originalSize = inputStream.available();
//
// BufferedInputStream bis = null;
// BufferedOutputStream bos = null;
// String fileName = getFileName(context, uri);
// File file = makeEmptyFileWithTitle(fileName);
// bis = new BufferedInputStream(inputStream);
// bos = new BufferedOutputStream(new FileOutputStream(
// file, false));
//
// byte[] buf = new byte[originalSize];
// bis.read(buf);
// do {
// bos.write(buf);
// } while (bis.read(buf) != -1);
//
// bos.flush();
// bos.close();
// bis.close();
//
// return file;
//
// } catch (IOException e) {
// return null;
// }
//
// }


/**
Expand Down Expand Up @@ -470,15 +469,15 @@ private static String getRealPathFromURI(final Context context, final Uri uri) {
// DownloadsProvider
else if (isDownloadsDocument(uri)) {

String id = DocumentsContract.getDocumentId(uri);
String id = DocumentsContract.getDocumentId(uri);

if (id != null){
if(id.startsWith("raw:")) {
return id.substring(4);
}
if (id.startsWith("msf:")){
id=id.substring(4);
}
if(id.startsWith("raw:")) {
return id.substring(4);
}
if (id.startsWith("msf:")){
id=id.substring(4);
}
}

String[] contentUriPrefixesToTry = new String[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar
android:layout_width="48dp"
android:id="@+id/caller_av"
app:corner_radius="24dp"
android:layout_margin="16dp"
app:corner_radius="24dp"
android:layout_alignParentEnd="true"
tools:src="@tools:sample/avatars"
android:layout_height="48dp"/>
Expand Down Expand Up @@ -108,11 +108,12 @@
<com.cometchat.pro.uikit.ui_components.shared.cometchatAvatar.CometChatAvatar
app:border_color="@color/textColorWhite"
app:border_width="16dp"
app:corner_radius="100dp"
android:layout_below="@+id/calling_tv"
tools:src="@tools:sample/avatars"
android:layout_width="200dp"
app:corner_radius="100dp"
android:id="@+id/user_av"
app:avatar_shape="circle"
android:layout_centerHorizontal="true"
android:layout_height="200dp"/>
<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
tools:src="@tools:sample/avatars"/>
<com.cometchat.pro.uikit.ui_components.shared.cometchatUserPresence.CometChatUserPresence
android:layout_width="16dp"
android:visibility="gone"
app:cardCornerRadius="8dp"
android:visibility="gone"
android:layout_alignEnd="@+id/av_user"
android:layout_alignBottom="@+id/av_user"
android:id="@+id/user_status"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@
<LinearLayout
android:visibility="gone"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/iv_user"
android:layout_below="@+id/iv_user"
android:background="@drawable/cc_message_bubble_left"
android:background="@drawable/cc_message_bubble_right"
android:orientation="vertical"
android:id="@+id/poll_message"
android:layout_width="250dp"
Expand Down Expand Up @@ -213,17 +211,14 @@
android:id="@+id/whiteboard_vw"
android:visibility="gone"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/iv_user"
android:layout_below="@+id/iv_user"
android:background="@drawable/cc_message_bubble_left"
android:background="@drawable/cc_message_bubble_right"
android:orientation="vertical"
android:layout_width="250dp"
android:layout_height="wrap_content">
<ImageView
android:padding="8dp"
android:id="@+id/whiteboard_icon"
android:background="@drawable/cc_message_bubble_right"
android:backgroundTint="@color/grey_200"
android:tint="@color/textColorWhite"
android:src="@drawable/ic_collaborative_whiteboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Expand Down Expand Up @@ -253,18 +248,15 @@
android:id="@+id/writeboard_vw"
android:visibility="gone"
android:layout_marginStart="10dp"
android:layout_toEndOf="@+id/iv_user"
android:layout_below="@+id/iv_user"
android:background="@drawable/cc_message_bubble_left"
android:background="@drawable/cc_message_bubble_right"
android:orientation="vertical"
android:layout_width="250dp"
android:layout_height="wrap_content">
<ImageView
android:padding="8dp"
android:id="@+id/writeboard_icon"
android:background="@drawable/cc_message_bubble_right"
android:backgroundTint="@color/grey_200"
android:src="@drawable/ic_collaborative_whiteboard"
android:tint="@color/textColorWhite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
Expand Down
Loading

0 comments on commit 6685dd0

Please sign in to comment.