Skip to content

Commit

Permalink
Android UI Kit v2.4.1-1
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanbhanushali committed Aug 26, 2021
1 parent 5fe2723 commit be62768
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 182 deletions.
4 changes: 2 additions & 2 deletions 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)](#)
<img src="https://img.shields.io/badge/Repo%20Size-9.26%20MB-blue" />
![GitHub contributors](https://img.shields.io/github/contributors/cometchat-pro/android-java-chat-ui-kit)
![Version](https://shields.io/badge/version-v2.4.0--1-orange)
![Version](https://shields.io/badge/version-v2.4.1--1-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 Expand Up @@ -71,7 +71,7 @@ allprojects {

```groovy
dependencies {
implementation 'com.cometchat:pro-android-chat-sdk:2.4.0'
implementation 'com.cometchat:pro-android-chat-sdk:2.4.1'
/** From v2.4+ onwards, Voice & Video Calling functionality has been
moved to a separate library. In case you plan to use the calling
Expand Down
2 changes: 1 addition & 1 deletion uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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.4.0'
compileOnly 'com.cometchat:pro-android-chat-sdk:2.4.1'
compileOnly 'com.cometchat:pro-android-calls-sdk:2.1.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
}
13 changes: 4 additions & 9 deletions uikit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<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-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<queries>
Expand Down Expand Up @@ -67,15 +66,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 @@ -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
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 @@ -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
1 change: 1 addition & 0 deletions uikit/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,5 @@
<string name="search_users">Search Users</string>
<string name="search_groups">Search Groups</string>
<string name="background_location_permission_title">Allow Background Location Permisssion</string>
<string name="forwarded_successful_message">Message Forwarded Successfully</string>
</resources>

0 comments on commit be62768

Please sign in to comment.