void sendMedia(File file, String contactId, String type, P pr } public static
void handleCameraImage(Context context, P presenter, Intent data, String contactId) { - File file = null; - Logger.error("uri", String.valueOf(data.getData())); - Bitmap bitmap = (Bitmap) data.getExtras().get("data"); - Uri fileUri = MediaUtils.getImageUri(context, bitmap); - - Logger.error("", "fileUri: " + fileUri); - file = new File(MediaUtils.ImagePath(fileUri, context)); + File file = new File(pictureImagePath); +// if (file.exists()) { - + BitmapFactory.decodeFile(file.getAbsolutePath()); if (presenter instanceof OneToOneActivityPresenter) { ((OneToOneActivityPresenter) presenter).sendMediaMessage(file, contactId, CometChatConstants.MESSAGE_TYPE_IMAGE); } else if (presenter instanceof GroupChatPresenter) { @@ -146,6 +153,26 @@ public static
void handleCameraImage(Context context, P presenter, Intent da } + private static File persistImage(Context context,Bitmap bitmap) { + File filesDir = context.getFilesDir(); + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + File imageFile = new File(filesDir, timeStamp + ".jpg"); + + OutputStream os; + try { + os = new FileOutputStream(imageFile); + bitmap.compress(Bitmap.CompressFormat.PNG, 0, os); + os.flush(); + os.close(); + } catch (Exception e) { + + } + finally { + + return imageFile; + } + } + public static
void handleCameraVideo(Context context, P presenter, Intent data, String contactId) {
String path = MediaUtils.getVideoPath(data.getData(), context);
Logger.debug("handleCameraVideo", " Video Path" + path);
@@ -257,8 +284,23 @@ public static boolean isMediaDocument(Uri uri) {
}
public static void captureImage(Activity activity, int code) {
- Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- activity.startActivityForResult(intent, code);
+
+ try {
+ String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
+ String imageFileName = timeStamp + ".jpg";
+ File storageDir = Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_PICTURES);
+ pictureImagePath = storageDir.getAbsolutePath() + "/" + imageFileName;
+ File file = new File(pictureImagePath);
+ Uri outputFileUri;
+// if ()
+ outputFileUri= Uri.fromFile(file);
+ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
+ activity.startActivityForResult(intent, code);
+ }catch (Exception e){
+ e.printStackTrace();
+ }
}
public static void captureVideo(Activity activity, int code) {
diff --git a/app/src/main/java/com/inscripts/cometchatpulse/demo/Presenters/BlockedUserListActivityPresenter.java b/app/src/main/java/com/inscripts/cometchatpulse/demo/Presenters/BlockedUserListActivityPresenter.java
index afdeab2b..5e902d10 100644
--- a/app/src/main/java/com/inscripts/cometchatpulse/demo/Presenters/BlockedUserListActivityPresenter.java
+++ b/app/src/main/java/com/inscripts/cometchatpulse/demo/Presenters/BlockedUserListActivityPresenter.java
@@ -24,7 +24,7 @@ public class BlockedUserListActivityPresenter extends Presenter>() {
@Override
@@ -42,7 +42,6 @@ public void onSuccess(List
>() {
@Override
public void onSuccess(List
>() {
@Override
public void onSuccess(List