From 29d0bed38bc61dbd4fb76614d6a17fedf81672dc Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 26 Aug 2019 13:40:47 +0200 Subject: [PATCH] when sharing text from Conversations to Conversations use quotes --- .../eu/siacs/conversations/ui/ConversationsActivity.java | 2 +- .../java/eu/siacs/conversations/ui/ShareWithActivity.java | 4 ++++ .../java/eu/siacs/conversations/ui/util/ShareUtil.java | 7 ++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index 815278420..72d6b3006 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -93,7 +93,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio public static final String ACTION_VIEW_CONVERSATION = "eu.siacs.conversations.action.VIEW"; public static final String EXTRA_CONVERSATION = "conversationUuid"; public static final String EXTRA_DOWNLOAD_UUID = "eu.siacs.conversations.download_uuid"; - public static final String EXTRA_AS_QUOTE = "as_quote"; + public static final String EXTRA_AS_QUOTE = "eu.siacs.conversations.as_quote"; public static final String EXTRA_NICK = "nick"; public static final String EXTRA_IS_PRIVATE_MESSAGE = "pm"; public static final String EXTRA_DO_NOT_APPEND = "do_not_append"; diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 83b0bebcc..0ec7abd9a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -40,6 +40,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer public String account; public String contact; public String text; + public boolean asQuote = false; } private Share share; @@ -132,6 +133,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer if (Intent.ACTION_SEND.equals(action)) { final String text = intent.getStringExtra(Intent.EXTRA_TEXT); final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); + final boolean asQuote = intent.getBooleanExtra(ConversationsActivity.EXTRA_AS_QUOTE, false); if (data != null && "geo".equals(data.getScheme())) { this.share.uris.clear(); @@ -141,6 +143,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer this.share.uris.add(uri); } else { this.share.text = text; + this.share.asQuote = asQuote; } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final ArrayList uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); @@ -195,6 +198,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer } else if (share.text != null) { intent.setAction(ConversationsActivity.ACTION_VIEW_CONVERSATION); intent.putExtra(Intent.EXTRA_TEXT, share.text); + intent.putExtra(ConversationsActivity.EXTRA_AS_QUOTE, share.asQuote); } startActivity(intent); finish(); 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 a48e8d6a2..89dbd0a25 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java +++ b/src/main/java/eu/siacs/conversations/ui/util/ShareUtil.java @@ -30,16 +30,11 @@ package eu.siacs.conversations.ui.util; import android.content.ActivityNotFoundException; -import android.content.Context; import android.content.Intent; -import android.support.v4.content.ContextCompat; -import android.util.Log; import android.widget.Toast; -import java.net.URL; import java.util.regex.Matcher; -import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; @@ -58,9 +53,11 @@ public class ShareUtil { if (message.isGeoUri()) { shareIntent.putExtra(Intent.EXTRA_TEXT, message.getBody()); shareIntent.setType("text/plain"); + shareIntent.putExtra(ConversationsActivity.EXTRA_AS_QUOTE, true); } else if (!message.isFileOrImage()) { shareIntent.putExtra(Intent.EXTRA_TEXT, message.getMergedBody().toString()); shareIntent.setType("text/plain"); + shareIntent.putExtra(ConversationsActivity.EXTRA_AS_QUOTE, true); } else { final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); try {