add setting for quick sharing

This commit is contained in:
Daniel Gultsch 2016-04-14 21:12:44 +02:00
parent 39e717ed94
commit 72aa10b536
3 changed files with 51 additions and 17 deletions

View File

@ -32,6 +32,8 @@ import eu.siacs.conversations.xmpp.jid.Jid;
public class ShareWithActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate { public class ShareWithActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate {
private boolean mReturnToPrevious = false;
@Override @Override
public void onConversationUpdate() { public void onConversationUpdate() {
refreshUi(); refreshUi();
@ -80,7 +82,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
resId = R.string.shared_file_with_x; resId = R.string.shared_file_with_x;
} }
replaceToast(getString(resId, message.getConversation().getName())); replaceToast(getString(resId, message.getConversation().getName()));
if (share.uuid != null) { if (mReturnToPrevious) {
finish(); finish();
} else { } else {
switchToConversation(message.getConversation()); switchToConversation(message.getConversation());
@ -181,6 +183,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
if (intent == null) { if (intent == null) {
return; return;
} }
this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", false);
final String type = intent.getType(); final String type = intent.getType();
final String action = intent.getAction(); final String action = intent.getAction();
Log.d(Config.LOGTAG, "action: "+action+ ", type:"+type); Log.d(Config.LOGTAG, "action: "+action+ ", type:"+type);
@ -304,9 +307,29 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
} else { } else {
selectPresence(conversation, callback); selectPresence(conversation, callback);
} }
} else {
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 { } else {
switchToConversation(conversation, this.share.text, true); switchToConversation(conversation, this.share.text, true);
} }
}
} }

View File

@ -104,6 +104,9 @@
<string name="pref_xmpp_resource_summary">The name this client identifies itself with</string> <string name="pref_xmpp_resource_summary">The name this client identifies itself with</string>
<string name="pref_accept_files">Accept files</string> <string name="pref_accept_files">Accept files</string>
<string name="pref_accept_files_summary">Automatically accept files smaller than…</string> <string name="pref_accept_files_summary">Automatically accept files smaller than…</string>
<string name="pref_attachments">Attachments</string>
<string name="pref_return_to_previous">Quick Sharing</string>
<string name="pref_return_to_previous_summary">Immediately return to previous activity instead of opening the conversation after sharing something</string>
<string name="pref_notification_settings">Notification</string> <string name="pref_notification_settings">Notification</string>
<string name="pref_notifications">Notifications</string> <string name="pref_notifications">Notifications</string>
<string name="pref_notifications_summary">Notify when a new message arrives</string> <string name="pref_notifications_summary">Notify when a new message arrives</string>
@ -580,6 +583,7 @@
<string name="shared_file_with_x">Shared file with %s</string> <string name="shared_file_with_x">Shared file with %s</string>
<string name="shared_image_with_x">Shared image with %s</string> <string name="shared_image_with_x">Shared image with %s</string>
<string name="shared_images_with_x">Shared images with %s</string> <string name="shared_images_with_x">Shared images with %s</string>
<string name="shared_text_with_x">Shared text with %s</string>
<string name="no_storage_permission">Conversations need access to external storage</string> <string name="no_storage_permission">Conversations need access to external storage</string>
<string name="sync_with_contacts">Synchronize with contacts</string> <string name="sync_with_contacts">Synchronize with contacts</string>
<string name="sync_with_contacts_long">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.</string> <string name="sync_with_contacts_long">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.</string>

View File

@ -15,20 +15,6 @@
android:key="resource" android:key="resource"
android:summary="@string/pref_xmpp_resource_summary" android:summary="@string/pref_xmpp_resource_summary"
android:title="@string/pref_xmpp_resource"/> android:title="@string/pref_xmpp_resource"/>
<ListPreference
android:defaultValue="524288"
android:entries="@array/filesizes"
android:entryValues="@array/filesizes_values"
android:key="auto_accept_file_size"
android:summary="@string/pref_accept_files_summary"
android:title="@string/pref_accept_files"/>
<ListPreference
android:defaultValue="auto"
android:entries="@array/picture_compression_entries"
android:entryValues="@array/picture_compression_values"
android:key="picture_compression"
android:summary="@string/pref_picture_compression_summary"
android:title="@string/pref_picture_compression"/>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="confirm_messages" android:key="confirm_messages"
@ -92,7 +78,28 @@
android:ringtoneType="notification" android:ringtoneType="notification"
android:summary="@string/pref_sound_summary" android:summary="@string/pref_sound_summary"
android:title="@string/pref_sound"/> android:title="@string/pref_sound"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_attachments">
<ListPreference
android:defaultValue="524288"
android:entries="@array/filesizes"
android:entryValues="@array/filesizes_values"
android:key="auto_accept_file_size"
android:summary="@string/pref_accept_files_summary"
android:title="@string/pref_accept_files"/>
<ListPreference
android:defaultValue="auto"
android:entries="@array/picture_compression_entries"
android:entryValues="@array/picture_compression_values"
android:key="picture_compression"
android:summary="@string/pref_picture_compression_summary"
android:title="@string/pref_picture_compression"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="return_to_previous"
android:title="@string/pref_return_to_previous"
android:summary="@string/pref_return_to_previous_summary"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_ui_options"> <PreferenceCategory android:title="@string/pref_ui_options">
<CheckBoxPreference <CheckBoxPreference