From 0ac9e037c3a4906bec829962a0904d8f36aada2b Mon Sep 17 00:00:00 2001 From: kosyak Date: Sat, 18 May 2024 13:29:19 +0200 Subject: [PATCH] get rid of old bug reports system --- .../java/eu/siacs/conversations/Config.java | 1 - .../conversations/entities/Conversation.java | 3 -- .../siacs/conversations/entities/Message.java | 3 +- .../services/XmppConnectionService.java | 13 ++------ .../conversations/ui/util/ShareUtil.java | 30 +++++++++++++++++++ .../conversations/utils/ExceptionHelper.java | 9 ++---- 6 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index a19710688..a4a58fd6a 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -43,7 +43,6 @@ public final class Config { public static final boolean QUICK_LOG = false; - public static final Jid BUG_REPORTS = Jid.of("bugs@conversations.im"); public static final Uri HELP = Uri.parse("https://help.conversations.im"); diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 6f31d4f6a..8ab8b1769 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -255,9 +255,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } private static boolean suitableForOmemoByDefault(final Conversation conversation) { - if (conversation.getJid().asBareJid().equals(Config.BUG_REPORTS)) { - return false; - } if (conversation.getContact().isOwnServer()) { return false; } diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index 863141338..abf2bda06 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -789,8 +789,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable !message.bodyIsOnlyEmojis() && ((this.axolotlFingerprint == null && message.axolotlFingerprint == null) || this.axolotlFingerprint.equals(message.getFingerprint())) && UIHelper.sameDay(message.getTimeSent(), this.getTimeSent()) && - this.getReadByMarkers().equals(message.getReadByMarkers()) && - !this.conversation.getJid().asBareJid().equals(Config.BUG_REPORTS) + this.getReadByMarkers().equals(message.getReadByMarkers()) ); } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index f66e29a96..85aef0a38 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -136,6 +136,7 @@ import eu.siacs.conversations.ui.UiCallback; import eu.siacs.conversations.ui.interfaces.OnAvatarPublication; import eu.siacs.conversations.ui.interfaces.OnMediaLoaded; import eu.siacs.conversations.ui.interfaces.OnSearchResultsAvailable; +import eu.siacs.conversations.ui.util.ShareUtil; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.Compatibility; import eu.siacs.conversations.utils.ConversationsFileObserver; @@ -923,17 +924,7 @@ public class XmppConnectionService extends Service { if (Strings.isNullOrEmpty(message)) { return; } - final Account account = AccountUtils.getFirstEnabled(this); - if (account == null) { - return; - } - final Conversation conversation = - findOrCreateConversation(account, Config.BUG_REPORTS, null, false, false, true, null); - final Message report = new Message(conversation, message, Message.ENCRYPTION_NONE); - report.setStatus(Message.STATUS_RECEIVED); - conversation.add(report); - databaseBackend.createMessage(report); - updateConversationUi(); + ShareUtil.share(getApplication(), message); } private void manageAccountConnectionStatesInternal() { diff --git a/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java b/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java index 05198bf6e..c7bf7999c 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java +++ b/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java @@ -29,6 +29,7 @@ package eu.siacs.conversations.ui.util; +import android.app.Application; import android.content.ActivityNotFoundException; import android.content.ClipData; import android.content.ClipboardManager; @@ -87,6 +88,35 @@ public class ShareUtil { } } + public static void share(XmppActivity activity, String text) { + Intent shareIntent = new Intent(); + shareIntent.setAction(Intent.ACTION_SEND); + + shareIntent.putExtra(Intent.EXTRA_TEXT, text); + shareIntent.setType("text/plain"); + try { + activity.startActivity(Intent.createChooser(shareIntent, activity.getText(R.string.share_with))); + } catch (ActivityNotFoundException e) { + //This should happen only on faulty androids because normally chooser is always available + Toast.makeText(activity, R.string.no_application_found_to_open_file, Toast.LENGTH_SHORT).show(); + } + } + + public static void share(Application application, String text) { + Intent shareIntent = new Intent(); + shareIntent.setAction(Intent.ACTION_SEND); + + shareIntent.putExtra(Intent.EXTRA_TEXT, text); + shareIntent.setType("text/plain"); + + try { + application.startActivity(Intent.createChooser(shareIntent, application.getText(R.string.share_with))); + } catch (ActivityNotFoundException e) { + //This should happen only on faulty androids because normally chooser is always available + Toast.makeText(application, R.string.no_application_found_to_open_file, Toast.LENGTH_SHORT).show(); + } + } + public static void share(XmppActivity activity, List messages) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java index 3416943a1..434e6b164 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java @@ -26,6 +26,7 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.XmppActivity; +import eu.siacs.conversations.ui.util.ShareUtil; public class ExceptionHelper { @@ -47,7 +48,7 @@ public class ExceptionHelper { } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); boolean neverSend = preferences.getBoolean("never_send", false); - if (neverSend || Config.BUG_REPORTS == null) { + if (neverSend) { return false; } final Account account = AccountUtils.getFirstEnabled(service); @@ -87,11 +88,7 @@ public class ExceptionHelper { builder.setTitle(activity.getString(R.string.crash_report_title, activity.getString(R.string.app_name))); builder.setMessage(activity.getString(R.string.crash_report_message, activity.getString(R.string.app_name))); builder.setPositiveButton(activity.getText(R.string.send_now), (dialog, which) -> { - - Log.d(Config.LOGTAG, "using account=" + account.getJid().asBareJid() + " to send in stack trace"); - Conversation conversation = service.findOrCreateConversation(account, Config.BUG_REPORTS, null, false, false, true, null); - Message message = new Message(conversation, report.toString(), Message.ENCRYPTION_NONE); - service.sendMessage(message); + ShareUtil.share(activity, report.toString()); }); builder.setNegativeButton(activity.getText(R.string.send_never), (dialog, which) -> preferences.edit().putBoolean("never_send", true).apply()); builder.create().show();