Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +10 −3 Original line number Diff line number Diff line Loading @@ -1076,8 +1076,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { Bundle b = new Bundle(); b.putParcelable(Helper.ARG_SHARE_URI, imageUri); List<Uri> uris = new ArrayList<>(); uris.add(imageUri); Helper.createAttachmentFromUri(BaseMainActivity.this, uris, attachments -> { b.putSerializable(Helper.ARG_MEDIA_ATTACHMENTS, new ArrayList<>(attachments)); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); }); } else { Toasty.warning(BaseMainActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); } Loading @@ -1087,7 +1091,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt ArrayList<Uri> imageList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (imageList != null) { Bundle b = new Bundle(); b.putParcelableArrayList(Helper.ARG_SHARE_URI_LIST, imageList); Helper.createAttachmentFromUri(BaseMainActivity.this, imageList, attachments -> { b.putSerializable(Helper.ARG_MEDIA_ATTACHMENTS, new ArrayList<>(attachments)); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); }); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); } else { Toasty.warning(BaseMainActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Loading app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +11 −12 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana private ComposeAdapter composeAdapter; private boolean promptSaveDraft; private boolean restoredDraft; private List<Attachment> sharedAttachments; private final BroadcastReceiver imageReceiver = new BroadcastReceiver() { Loading Loading @@ -147,8 +148,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana private app.fedilab.android.client.entities.api.Account accountMention; private String statusReplyId; private app.fedilab.android.client.entities.api.Account mentionBooster; private ArrayList<Uri> sharedUriList = new ArrayList<>(); private Uri sharedUri; private String sharedSubject, sharedContent, sharedTitle, sharedDescription, shareURL, sharedUrlMedia; private String editMessageId; Loading Loading @@ -483,8 +482,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana mentionBooster = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_MENTION_BOOSTER); accountMention = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION); //Shared elements sharedUriList = b.getParcelableArrayList(Helper.ARG_SHARE_URI_LIST); sharedUri = b.getParcelable(Helper.ARG_SHARE_URI); sharedAttachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ATTACHMENTS); sharedUrlMedia = b.getString(Helper.ARG_SHARE_URL_MEDIA); sharedSubject = b.getString(Helper.ARG_SHARE_SUBJECT, null); sharedContent = b.getString(Helper.ARG_SHARE_CONTENT, null); Loading Loading @@ -678,18 +676,19 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana }, 0, 10000); } if (sharedUriList != null && sharedUriList.size() > 0) { List<Uri> uris = new ArrayList<>(sharedUriList); Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> { if (sharedAttachments != null && sharedAttachments.size() > 0) { for (Attachment attachment : sharedAttachments) { composeAdapter.addAttachment(-1, attachment); }); } else if (sharedUri != null && !sharedUri.toString().startsWith("http")) { } } /*else if (sharedUri != null && !sharedUri.toString().startsWith("http")) { List<Uri> uris = new ArrayList<>(); uris.add(sharedUri); Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> { Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachments -> { for(Attachment attachment: attachments) { composeAdapter.addAttachment(-1, attachment); } }); } else if (shareURL != null) { } */ else if (shareURL != null) { Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() { @Override Loading app/src/main/java/app/fedilab/android/helper/CacheHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class CacheHelper { String[] children = dir.list(); assert children != null; for (String aChildren : children) { if (!aChildren.equals("databases") && !aChildren.equals("shared_prefs")) { if (!aChildren.equals("databases") && !aChildren.equals("shared_prefs") && !aChildren.equals(Helper.TEMP_MEDIA_DIRECTORY)) { boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; Loading app/src/main/java/app/fedilab/android/helper/Helper.java +15 −9 Original line number Diff line number Diff line Loading @@ -235,10 +235,8 @@ public class Helper { public static final String ARG_MINIFIED = "ARG_MINIFIED"; public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT"; public static final String ARG_STATUS_MENTION = "ARG_STATUS_MENTION"; public static final String ARG_SHARE_URI = "ARG_SHARE_URI"; public static final String ARG_SHARE_URL_MEDIA = "ARG_SHARE_URL_MEDIA"; public static final String ARG_SHARE_URL = "ARG_SHARE_URL"; public static final String ARG_SHARE_URI_LIST = "ARG_SHARE_URI_LIST"; public static final String ARG_SHARE_TITLE = "ARG_SHARE_TITLE"; public static final String ARG_SHARE_SUBJECT = "ARG_SHARE_SUBJECT"; public static final String ARG_SHARE_DESCRIPTION = "ARG_SHARE_DESCRIPTION"; Loading @@ -258,6 +256,7 @@ public class Helper { public static final String ARG_TAG_TIMELINE = "ARG_TAG_TIMELINE"; public static final String ARG_MEDIA_POSITION = "ARG_MEDIA_POSITION"; public static final String ARG_MEDIA_ATTACHMENT = "ARG_MEDIA_ATTACHMENT"; public static final String ARG_MEDIA_ATTACHMENTS = "ARG_MEDIA_ATTACHMENTS"; public static final String ARG_SHOW_REPLIES = "ARG_SHOW_REPLIES"; public static final String ARG_SHOW_REBLOGS = "ARG_SHOW_REBLOGS"; public static final String ARG_INITIALIZE_VIEW = "ARG_INITIALIZE_VIEW"; Loading Loading @@ -1220,6 +1219,7 @@ public class Helper { public static void createAttachmentFromUri(Context context, List<Uri> uris, OnAttachmentCopied callBack) { new Thread(() -> { List<Attachment> attachments = new ArrayList<>(); for (Uri uri : uris) { Attachment attachment = new Attachment(); attachment.filename = Helper.getFileName(context, uri); Loading Loading @@ -1274,11 +1274,11 @@ public class Helper { e.printStackTrace(); } } attachments.add(attachment); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachment); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachments); mainHandler.post(myRunnable); } }).start(); } Loading Loading @@ -1328,6 +1328,7 @@ public class Helper { public static void createAttachmentFromPAth(String path, OnAttachmentCopied callBack) { new Thread(() -> { List<Attachment> attachmentList = new ArrayList<>(); Attachment attachment = new Attachment(); attachment.mimeType = "image/*"; String extension = "jpg"; Loading @@ -1336,7 +1337,8 @@ public class Helper { Date now = new Date(); attachment.filename = formatter.format(now) + "." + extension; Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachment); attachmentList.add(attachment); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachmentList); mainHandler.post(myRunnable); }).start(); } Loading Loading @@ -1733,7 +1735,11 @@ public class Helper { fileName = FileNameCleaner.cleanFileName(fileName); // opens input stream from the HTTP connection InputStream inputStream = httpURLConnection.getInputStream(); File saveDir = context.getCacheDir(); final File saveDir = new File(context.getCacheDir(), TEMP_MEDIA_DIRECTORY); boolean isCertCacheDirExists = saveDir.exists(); if (!isCertCacheDirExists) { saveDir.mkdirs(); } final String saveFilePath = saveDir + File.separator + fileName; // opens an output stream to save into file FileOutputStream outputStream = new FileOutputStream(saveFilePath); Loading Loading @@ -1979,7 +1985,7 @@ public class Helper { } public interface OnAttachmentCopied { void onAttachmentCopied(Attachment attachment); void onAttachmentCopied(List<Attachment> attachments); } public interface OnFileCopied { Loading app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java +1 −7 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.animation.AnticipateOvershootInterpolator; Loading Loading @@ -179,8 +178,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList } uri = resultUri; } } else { Log.e(Helper.TAG, "onActivityResult...Error CropImage: " + result.getError()); } }); mPhotoEditor.setFilterEffect(PhotoFilter.NONE); Loading Loading @@ -299,7 +296,7 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList int imgHeightInEditor; int imgWidthInEditor; //If the original image has its height greater than width => heights are equals float focusX = -2, focusY = -2; float focusX, focusY; if (imageHeight > imageWidth) { imgHeightInEditor = pHeight; float ratio = (float) pHeight / (float) imageHeight; Loading @@ -325,7 +322,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList intentImage.putExtra("focusY", focusY); } LocalBroadcastManager.getInstance(EditImageActivity.this).sendBroadcast(intentImage); finish(); } Loading Loading @@ -415,8 +411,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList } uri = resultUri; } } else { Log.e(Helper.TAG, "onActivityResult...Error CropImage: " + result.getError()); } }); cropImageContractOptionsActivityResultLauncher.launch(cropImageContractOptions); Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +10 −3 Original line number Diff line number Diff line Loading @@ -1076,8 +1076,12 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { Bundle b = new Bundle(); b.putParcelable(Helper.ARG_SHARE_URI, imageUri); List<Uri> uris = new ArrayList<>(); uris.add(imageUri); Helper.createAttachmentFromUri(BaseMainActivity.this, uris, attachments -> { b.putSerializable(Helper.ARG_MEDIA_ATTACHMENTS, new ArrayList<>(attachments)); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); }); } else { Toasty.warning(BaseMainActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); } Loading @@ -1087,7 +1091,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt ArrayList<Uri> imageList = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (imageList != null) { Bundle b = new Bundle(); b.putParcelableArrayList(Helper.ARG_SHARE_URI_LIST, imageList); Helper.createAttachmentFromUri(BaseMainActivity.this, imageList, attachments -> { b.putSerializable(Helper.ARG_MEDIA_ATTACHMENTS, new ArrayList<>(attachments)); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); }); CrossActionHelper.doCrossShare(BaseMainActivity.this, b); } else { Toasty.warning(BaseMainActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show(); Loading
app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +11 −12 Original line number Diff line number Diff line Loading @@ -109,6 +109,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana private ComposeAdapter composeAdapter; private boolean promptSaveDraft; private boolean restoredDraft; private List<Attachment> sharedAttachments; private final BroadcastReceiver imageReceiver = new BroadcastReceiver() { Loading Loading @@ -147,8 +148,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana private app.fedilab.android.client.entities.api.Account accountMention; private String statusReplyId; private app.fedilab.android.client.entities.api.Account mentionBooster; private ArrayList<Uri> sharedUriList = new ArrayList<>(); private Uri sharedUri; private String sharedSubject, sharedContent, sharedTitle, sharedDescription, shareURL, sharedUrlMedia; private String editMessageId; Loading Loading @@ -483,8 +482,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana mentionBooster = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_MENTION_BOOSTER); accountMention = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION); //Shared elements sharedUriList = b.getParcelableArrayList(Helper.ARG_SHARE_URI_LIST); sharedUri = b.getParcelable(Helper.ARG_SHARE_URI); sharedAttachments = (ArrayList<Attachment>) b.getSerializable(Helper.ARG_MEDIA_ATTACHMENTS); sharedUrlMedia = b.getString(Helper.ARG_SHARE_URL_MEDIA); sharedSubject = b.getString(Helper.ARG_SHARE_SUBJECT, null); sharedContent = b.getString(Helper.ARG_SHARE_CONTENT, null); Loading Loading @@ -678,18 +676,19 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana }, 0, 10000); } if (sharedUriList != null && sharedUriList.size() > 0) { List<Uri> uris = new ArrayList<>(sharedUriList); Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> { if (sharedAttachments != null && sharedAttachments.size() > 0) { for (Attachment attachment : sharedAttachments) { composeAdapter.addAttachment(-1, attachment); }); } else if (sharedUri != null && !sharedUri.toString().startsWith("http")) { } } /*else if (sharedUri != null && !sharedUri.toString().startsWith("http")) { List<Uri> uris = new ArrayList<>(); uris.add(sharedUri); Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachment -> { Helper.createAttachmentFromUri(ComposeActivity.this, uris, attachments -> { for(Attachment attachment: attachments) { composeAdapter.addAttachment(-1, attachment); } }); } else if (shareURL != null) { } */ else if (shareURL != null) { Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() { @Override Loading
app/src/main/java/app/fedilab/android/helper/CacheHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ public class CacheHelper { String[] children = dir.list(); assert children != null; for (String aChildren : children) { if (!aChildren.equals("databases") && !aChildren.equals("shared_prefs")) { if (!aChildren.equals("databases") && !aChildren.equals("shared_prefs") && !aChildren.equals(Helper.TEMP_MEDIA_DIRECTORY)) { boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; Loading
app/src/main/java/app/fedilab/android/helper/Helper.java +15 −9 Original line number Diff line number Diff line Loading @@ -235,10 +235,8 @@ public class Helper { public static final String ARG_MINIFIED = "ARG_MINIFIED"; public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT"; public static final String ARG_STATUS_MENTION = "ARG_STATUS_MENTION"; public static final String ARG_SHARE_URI = "ARG_SHARE_URI"; public static final String ARG_SHARE_URL_MEDIA = "ARG_SHARE_URL_MEDIA"; public static final String ARG_SHARE_URL = "ARG_SHARE_URL"; public static final String ARG_SHARE_URI_LIST = "ARG_SHARE_URI_LIST"; public static final String ARG_SHARE_TITLE = "ARG_SHARE_TITLE"; public static final String ARG_SHARE_SUBJECT = "ARG_SHARE_SUBJECT"; public static final String ARG_SHARE_DESCRIPTION = "ARG_SHARE_DESCRIPTION"; Loading @@ -258,6 +256,7 @@ public class Helper { public static final String ARG_TAG_TIMELINE = "ARG_TAG_TIMELINE"; public static final String ARG_MEDIA_POSITION = "ARG_MEDIA_POSITION"; public static final String ARG_MEDIA_ATTACHMENT = "ARG_MEDIA_ATTACHMENT"; public static final String ARG_MEDIA_ATTACHMENTS = "ARG_MEDIA_ATTACHMENTS"; public static final String ARG_SHOW_REPLIES = "ARG_SHOW_REPLIES"; public static final String ARG_SHOW_REBLOGS = "ARG_SHOW_REBLOGS"; public static final String ARG_INITIALIZE_VIEW = "ARG_INITIALIZE_VIEW"; Loading Loading @@ -1220,6 +1219,7 @@ public class Helper { public static void createAttachmentFromUri(Context context, List<Uri> uris, OnAttachmentCopied callBack) { new Thread(() -> { List<Attachment> attachments = new ArrayList<>(); for (Uri uri : uris) { Attachment attachment = new Attachment(); attachment.filename = Helper.getFileName(context, uri); Loading Loading @@ -1274,11 +1274,11 @@ public class Helper { e.printStackTrace(); } } attachments.add(attachment); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachment); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachments); mainHandler.post(myRunnable); } }).start(); } Loading Loading @@ -1328,6 +1328,7 @@ public class Helper { public static void createAttachmentFromPAth(String path, OnAttachmentCopied callBack) { new Thread(() -> { List<Attachment> attachmentList = new ArrayList<>(); Attachment attachment = new Attachment(); attachment.mimeType = "image/*"; String extension = "jpg"; Loading @@ -1336,7 +1337,8 @@ public class Helper { Date now = new Date(); attachment.filename = formatter.format(now) + "." + extension; Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachment); attachmentList.add(attachment); Runnable myRunnable = () -> callBack.onAttachmentCopied(attachmentList); mainHandler.post(myRunnable); }).start(); } Loading Loading @@ -1733,7 +1735,11 @@ public class Helper { fileName = FileNameCleaner.cleanFileName(fileName); // opens input stream from the HTTP connection InputStream inputStream = httpURLConnection.getInputStream(); File saveDir = context.getCacheDir(); final File saveDir = new File(context.getCacheDir(), TEMP_MEDIA_DIRECTORY); boolean isCertCacheDirExists = saveDir.exists(); if (!isCertCacheDirExists) { saveDir.mkdirs(); } final String saveFilePath = saveDir + File.separator + fileName; // opens an output stream to save into file FileOutputStream outputStream = new FileOutputStream(saveFilePath); Loading Loading @@ -1979,7 +1985,7 @@ public class Helper { } public interface OnAttachmentCopied { void onAttachmentCopied(Attachment attachment); void onAttachmentCopied(List<Attachment> attachments); } public interface OnFileCopied { Loading
app/src/main/java/app/fedilab/android/imageeditor/EditImageActivity.java +1 −7 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ import android.graphics.Typeface; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.animation.AnticipateOvershootInterpolator; Loading Loading @@ -179,8 +178,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList } uri = resultUri; } } else { Log.e(Helper.TAG, "onActivityResult...Error CropImage: " + result.getError()); } }); mPhotoEditor.setFilterEffect(PhotoFilter.NONE); Loading Loading @@ -299,7 +296,7 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList int imgHeightInEditor; int imgWidthInEditor; //If the original image has its height greater than width => heights are equals float focusX = -2, focusY = -2; float focusX, focusY; if (imageHeight > imageWidth) { imgHeightInEditor = pHeight; float ratio = (float) pHeight / (float) imageHeight; Loading @@ -325,7 +322,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList intentImage.putExtra("focusY", focusY); } LocalBroadcastManager.getInstance(EditImageActivity.this).sendBroadcast(intentImage); finish(); } Loading Loading @@ -415,8 +411,6 @@ public class EditImageActivity extends BaseActivity implements OnPhotoEditorList } uri = resultUri; } } else { Log.e(Helper.TAG, "onActivityResult...Error CropImage: " + result.getError()); } }); cropImageContractOptionsActivityResultLauncher.launch(cropImageContractOptions); Loading