attach editor content as file

This commit is contained in:
Daniel Gultsch 2018-06-06 19:59:30 +02:00
parent 4019593181
commit 258c7d1b3b
3 changed files with 6 additions and 21 deletions

View file

@ -199,15 +199,6 @@ public class FileBackend {
return context.getPackageName() + FILE_PROVIDER; return context.getPackageName() + FILE_PROVIDER;
} }
public static Uri getIndexableTakePhotoUri(Uri original) {
if (Config.ONLY_INTERNAL_STORAGE || "file".equals(original.getScheme())) {
return original;
} else {
List<String> segments = original.getPathSegments();
return Uri.parse("file://" + getTakePhotoPath() + segments.get(segments.size() - 1));
}
}
private static boolean hasAlpha(final Bitmap bitmap) { private static boolean hasAlpha(final Bitmap bitmap) {
for (int x = 0; x < bitmap.getWidth(); ++x) { for (int x = 0; x < bitmap.getWidth(); ++x) {
for (int y = 0; y < bitmap.getWidth(); ++y) { for (int y = 0; y < bitmap.getWidth(); ++y) {
@ -226,7 +217,7 @@ public class FileBackend {
return calcSampleSize(options, size); 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 height = options.outHeight;
int width = options.outWidth; int width = options.outWidth;
int inSampleSize = 1; int inSampleSize = 1;

View file

@ -16,7 +16,6 @@ import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.app.Fragment; import android.app.Fragment;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; 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)) { if (hasPermissions(REQUEST_ADD_EDITOR_CONTENT, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
attachImageToConversation(inputContentInfo.getContentUri()); attachEditorContentToConversation(inputContentInfo.getContentUri());
} else { } else {
mPendingEditorContent = inputContentInfo.getContentUri(); mPendingEditorContent = inputContentInfo.getContentUri();
} }
@ -649,8 +648,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}); });
} }
public void attachImageToConversation(Uri uri) { public void attachEditorContentToConversation(Uri uri) {
this.attachImageToConversation(conversation, uri); this.attachFileToConversation(conversation, uri, null);
} }
private void attachImageToConversation(Conversation conversation, Uri uri) { 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) { } else if (requestCode == REQUEST_ADD_EDITOR_CONTENT) {
if (this.mPendingEditorContent != null) { if (this.mPendingEditorContent != null) {
attachImageToConversation(this.mPendingEditorContent); attachEditorContentToConversation(this.mPendingEditorContent);
} }
} else { } else {
attachFile(requestCode); attachFile(requestCode);

View file

@ -135,12 +135,7 @@ public class EditMessage extends EmojiAppCompatEditText {
if (mimeTypes != null && mCommitContentListener != null) { if (mimeTypes != null && mCommitContentListener != null) {
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes); EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
return InputConnectionCompat.createWrapper(ic, editorInfo, new InputConnectionCompat.OnCommitContentListener() { return InputConnectionCompat.createWrapper(ic, editorInfo, (inputContentInfo, flags, opts) -> EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes));
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
return EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes);
}
});
} else { } else {
return ic; return ic;
} }