Commit 7f48b037 authored by Thomas's avatar Thomas
Browse files

Comment issue #276 - Fix crashes when sharing only text

parent d7bd889d
Loading
Loading
Loading
Loading
+94 −86
Original line number Diff line number Diff line
@@ -308,6 +308,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
                        if (matchStart < matchEnd && sharedText.length() >= matchEnd)
                            url[0] = sharedText.substring(matchStart, matchEnd);
                    }
                    if (url[0] != null) {
                        new Thread(() -> {
                            if (url[0].startsWith("www."))
                                url[0] = "http://" + url[0];
@@ -400,6 +401,13 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt

                            }
                        }).start();
                    } else {
                        Bundle b = new Bundle();
                        b.putString(Helper.ARG_SHARE_TITLE, sharedSubject);
                        b.putString(Helper.ARG_SHARE_DESCRIPTION, sharedText);
                        CrossActionHelper.doCrossShare(BaseMainActivity.this, b);
                    }


                }
            } else if (type.startsWith("image/") || type.startsWith("video/")) {
+2 −0
Original line number Diff line number Diff line
@@ -385,6 +385,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
                }
            });

        } else {
            composeAdapter.addSharing(null, null, sharedDescription, null, sharedContent, null);
        }
    }

+21 −13
Original line number Diff line number Diff line
@@ -411,11 +411,18 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
     */
    public void addSharing(String url, String title, String description, String subject, String content, String saveFilePath) {
        int position = statusList.size() - 1;
        if (title != null || subject != null) {
            statusList.get(position).text = title != null ? title : subject;
            statusList.get(position).text += "\n\n";
        } else {
            statusList.get(position).text = "";
        }
        statusList.get(position).text += description != null ? description : content;
        statusList.get(position).text += "\n\n";
        if (url != null) {
            statusList.get(position).text += url;
        }
        if (saveFilePath != null) {
            Attachment attachment = new Attachment();
            attachment.mimeType = "image/*";
            String extension = "jpg";
@@ -427,6 +434,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                statusList.get(position).media_attachments = new ArrayList<>();
            }
            statusList.get(position).media_attachments.add(attachment);
        }
        notifyItemChanged(position);
    }