From 258c7d1b3b7db8e75431116c87751dd694d5af47 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 6 Jun 2018 19:59:30 +0200 Subject: [PATCH] attach editor content as file --- .../siacs/conversations/persistance/FileBackend.java | 11 +---------- .../siacs/conversations/ui/ConversationFragment.java | 9 ++++----- .../eu/siacs/conversations/ui/widget/EditMessage.java | 7 +------ 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 956b1810e..9a01a9dbd 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -199,15 +199,6 @@ public class FileBackend { return context.getPackageName() + FILE_PROVIDER; } - public static Uri getIndexableTakePhotoUri(Uri original) { - if (Config.ONLY_INTERNAL_STORAGE || "file".equals(original.getScheme())) { - return original; - } else { - List segments = original.getPathSegments(); - return Uri.parse("file://" + getTakePhotoPath() + segments.get(segments.size() - 1)); - } - } - private static boolean hasAlpha(final Bitmap bitmap) { for (int x = 0; x < bitmap.getWidth(); ++x) { for (int y = 0; y < bitmap.getWidth(); ++y) { @@ -226,7 +217,7 @@ public class FileBackend { return calcSampleSize(options, size); } - public static int calcSampleSize(BitmapFactory.Options options, int size) { + private static int calcSampleSize(BitmapFactory.Options options, int size) { int height = options.outHeight; int width = options.outWidth; int inSampleSize = 1; diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 9b32a535f..34812e10e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -16,7 +16,6 @@ import android.support.annotation.StringRes; import android.support.v7.app.AlertDialog; import android.app.Fragment; import android.app.PendingIntent; -import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -286,7 +285,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } if (hasPermissions(REQUEST_ADD_EDITOR_CONTENT, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - attachImageToConversation(inputContentInfo.getContentUri()); + attachEditorContentToConversation(inputContentInfo.getContentUri()); } else { mPendingEditorContent = inputContentInfo.getContentUri(); } @@ -649,8 +648,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke }); } - public void attachImageToConversation(Uri uri) { - this.attachImageToConversation(conversation, uri); + public void attachEditorContentToConversation(Uri uri) { + this.attachFileToConversation(conversation, uri, null); } private void attachImageToConversation(Conversation conversation, Uri uri) { @@ -1360,7 +1359,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } } else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) { if (this.mPendingEditorContent != null) { - attachImageToConversation(this.mPendingEditorContent); + attachEditorContentToConversation(this.mPendingEditorContent); } } else { attachFile(requestCode); diff --git a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java index 4efc50def..5b47f88c2 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java @@ -135,12 +135,7 @@ public class EditMessage extends EmojiAppCompatEditText { if (mimeTypes != null && mCommitContentListener != null) { EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes); - return InputConnectionCompat.createWrapper(ic, editorInfo, new InputConnectionCompat.OnCommitContentListener() { - @Override - public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) { - return EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes); - } - }); + return InputConnectionCompat.createWrapper(ic, editorInfo, (inputContentInfo, flags, opts) -> EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes)); } else { return ic; }