Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +6 −3 Original line number Diff line number Diff line Loading @@ -383,9 +383,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } // If we actually have a URL then make use of it. if (potentialUrl != null && potentialUrl.length() > 0) { Pattern titlePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:title[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern descriptionPattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:description[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern imagePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:image[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern titlePattern = Pattern.compile("<meta [^>]*property=[\"']og:title[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); Pattern descriptionPattern = Pattern.compile("<meta [^>]*property=[\"']og:description[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); Pattern imagePattern = Pattern.compile("<meta [^>]*property=[\"']og:image[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); try { OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) Loading Loading @@ -440,6 +441,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt String finalImage = image; String finalTitle = title; String finalDescription = description; runOnUiThread(() -> { Bundle b = new Bundle(); b.putString(Helper.ARG_SHARE_URL, url[0]); Loading app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -508,7 +508,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana shareURL = b.getString(Helper.ARG_SHARE_URL, null); } if (sharedContent != null && shareURL != null && sharedContent.compareTo(shareURL) == 0) { sharedContent = ""; } if (sharedTitle != null && sharedSubject != null && sharedSubject.length() > sharedTitle.length()) { sharedTitle = sharedSubject; } binding.toolbar.setPopupTheme(Helper.popupStyle()); //Edit a scheduled status from server if (scheduledStatus != null) { Loading Loading @@ -698,6 +703,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() { @Override public void onDownloaded(String saveFilePath, String downloadUrl, Error error) { composeAdapter.addSharing(shareURL, sharedTitle, sharedDescription, sharedSubject, sharedContent, saveFilePath); } Loading app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +16 −17 Original line number Diff line number Diff line Loading @@ -419,26 +419,25 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder * @param content - String content (description) coming from the shared elements */ public void addSharing(String url, String title, String description, String subject, String content, String saveFilePath) { int position = statusList.size() - 1; if (description == null && content == null) { return; } boolean addUrl = true; if (url != null && content != null && content.trim().length() > url.trim().length()) { statusList.get(position).text = content; statusList.get(position).text += "\n\n"; addUrl = false; } else { if (title != null || subject != null) { statusList.get(position).text = title != null ? title : subject; statusList.get(position).text += "\n\n"; } else { statusList.get(position).text = ""; if (title != null && title.trim().length() > 0) { statusList.get(position).text += title + "\n\n"; } else if (subject != null && subject.trim().length() > 0) { statusList.get(position).text += subject + "\n\n"; } if (description != null && description.trim().length() > 0) { statusList.get(position).text += description + "\n\n"; if (!description.contains(url)) { statusList.get(position).text += url; } } else if (content != null && content.trim().length() > 0) { statusList.get(position).text += content + "\n\n"; if (!content.contains(url)) { statusList.get(position).text += url; } statusList.get(position).text += description != null ? description : content; if (url != null && addUrl) { statusList.get(position).text += "\n\n"; } else { statusList.get(position).text += url; } if (saveFilePath != null) { Loading Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +6 −3 Original line number Diff line number Diff line Loading @@ -383,9 +383,10 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } // If we actually have a URL then make use of it. if (potentialUrl != null && potentialUrl.length() > 0) { Pattern titlePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:title[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern descriptionPattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:description[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern imagePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:image[\"']\\s+content=[\"']([^>]*)[\"']"); Pattern titlePattern = Pattern.compile("<meta [^>]*property=[\"']og:title[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); Pattern descriptionPattern = Pattern.compile("<meta [^>]*property=[\"']og:description[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); Pattern imagePattern = Pattern.compile("<meta [^>]*property=[\"']og:image[\"'] [^>]*content=[\"']([^'^\"]+?)[\"'][^>]*>"); try { OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) Loading Loading @@ -440,6 +441,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt String finalImage = image; String finalTitle = title; String finalDescription = description; runOnUiThread(() -> { Bundle b = new Bundle(); b.putString(Helper.ARG_SHARE_URL, url[0]); Loading
app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -508,7 +508,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana shareURL = b.getString(Helper.ARG_SHARE_URL, null); } if (sharedContent != null && shareURL != null && sharedContent.compareTo(shareURL) == 0) { sharedContent = ""; } if (sharedTitle != null && sharedSubject != null && sharedSubject.length() > sharedTitle.length()) { sharedTitle = sharedSubject; } binding.toolbar.setPopupTheme(Helper.popupStyle()); //Edit a scheduled status from server if (scheduledStatus != null) { Loading Loading @@ -698,6 +703,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana Helper.download(ComposeActivity.this, sharedUrlMedia, new OnDownloadInterface() { @Override public void onDownloaded(String saveFilePath, String downloadUrl, Error error) { composeAdapter.addSharing(shareURL, sharedTitle, sharedDescription, sharedSubject, sharedContent, saveFilePath); } Loading
app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +16 −17 Original line number Diff line number Diff line Loading @@ -419,26 +419,25 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder * @param content - String content (description) coming from the shared elements */ public void addSharing(String url, String title, String description, String subject, String content, String saveFilePath) { int position = statusList.size() - 1; if (description == null && content == null) { return; } boolean addUrl = true; if (url != null && content != null && content.trim().length() > url.trim().length()) { statusList.get(position).text = content; statusList.get(position).text += "\n\n"; addUrl = false; } else { if (title != null || subject != null) { statusList.get(position).text = title != null ? title : subject; statusList.get(position).text += "\n\n"; } else { statusList.get(position).text = ""; if (title != null && title.trim().length() > 0) { statusList.get(position).text += title + "\n\n"; } else if (subject != null && subject.trim().length() > 0) { statusList.get(position).text += subject + "\n\n"; } if (description != null && description.trim().length() > 0) { statusList.get(position).text += description + "\n\n"; if (!description.contains(url)) { statusList.get(position).text += url; } } else if (content != null && content.trim().length() > 0) { statusList.get(position).text += content + "\n\n"; if (!content.contains(url)) { statusList.get(position).text += url; } statusList.get(position).text += description != null ? description : content; if (url != null && addUrl) { statusList.get(position).text += "\n\n"; } else { statusList.get(position).text += url; } if (saveFilePath != null) { Loading