From 72aa10b53660fdb6e32f74a103ff1e349232a816 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 14 Apr 2016 21:12:44 +0200 Subject: [PATCH] add setting for quick sharing --- .../conversations/ui/ShareWithActivity.java | 27 +++++++++++++- src/main/res/values/strings.xml | 4 ++ src/main/res/xml/preferences.xml | 37 +++++++++++-------- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 8cd017bf6..4ed015f4b 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 97ba18afc..aadf81d7a 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 e4b29856b..d1ba6b7f3 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"/> - - - + + + + +