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;
}
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) {
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;

View File

@ -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);

View File

@ -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;
}