diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 8cd017bf683a3b8326b20df2977afbbcdfd7d79d..4ed015f4b9a2f7b078b56cd8224bb3eafc5f82cd 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -32,6 +32,8 @@ import eu.siacs.conversations.xmpp.jid.Jid; public class ShareWithActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate { + private boolean mReturnToPrevious = false; + @Override public void onConversationUpdate() { refreshUi(); @@ -80,7 +82,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer resId = R.string.shared_file_with_x; } replaceToast(getString(resId, message.getConversation().getName())); - if (share.uuid != null) { + if (mReturnToPrevious) { finish(); } else { switchToConversation(message.getConversation()); @@ -181,6 +183,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer if (intent == null) { return; } + this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", false); final String type = intent.getType(); final String action = intent.getAction(); Log.d(Config.LOGTAG, "action: "+action+ ", type:"+type); @@ -305,7 +308,27 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer selectPresence(conversation, callback); } } else { - switchToConversation(conversation, this.share.text, true); + if (mReturnToPrevious && this.share.text != null && !this.share.text.isEmpty() ) { + final OnPresenceSelected callback = new OnPresenceSelected() { + @Override + public void onPresenceSelected() { + Message message = new Message(conversation,share.text, conversation.getNextEncryption()); + if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) { + message.setCounterpart(conversation.getNextCounterpart()); + } + xmppConnectionService.sendMessage(message); + replaceToast(getString(R.string.shared_text_with_x, conversation.getName())); + finish(); + } + }; + if (conversation.getNextEncryption() == Message.ENCRYPTION_OTR) { + selectPresence(conversation, callback); + } else { + callback.onPresenceSelected(); + } + } else { + switchToConversation(conversation, this.share.text, true); + } } } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 97ba18afc343b70475ab46e0b42b44ad32cbc5f9..aadf81d7ac5ccbefd0038770e20d31f3080adc44 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -104,6 +104,9 @@ The name this client identifies itself with Accept files Automatically accept files smaller than… + Attachments + Quick Sharing + Immediately return to previous activity instead of opening the conversation after sharing something Notification Notifications Notify when a new message arrives @@ -580,6 +583,7 @@ Shared file with %s Shared image with %s Shared images with %s + Shared text with %s Conversations need access to external storage Synchronize with contacts Conversations wants to match your XMPP roster with your contacts to show their full names and avatars.\n\nConversations will only read your contacts and match them locally without uploading them to your server.\n\nYou will now be asked to grant permission to access your contacts. diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index e4b29856b3f8b80c4a1a7c773af1259cd7dd3305..d1ba6b7f39c4a3caa0a97c772b112bf0dc27d2b0 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -15,20 +15,6 @@ android:key="resource" android:summary="@string/pref_xmpp_resource_summary" android:title="@string/pref_xmpp_resource"/> - - - + + + + +