From 5ac0e9267d8ff98dcb6a28d1837e81b4572e8b03 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 3 Oct 2016 21:04:10 +0200 Subject: [PATCH] fixed omemo shown as unavailable in 1:1 chats --- .../siacs/conversations/crypto/axolotl/AxolotlService.java | 3 ++- .../java/eu/siacs/conversations/persistance/FileBackend.java | 4 +++- .../java/eu/siacs/conversations/ui/ConversationActivity.java | 5 +++-- .../eu/siacs/conversations/ui/adapter/MessageAdapter.java | 3 ++- src/main/res/values/strings.xml | 2 ++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index ddfe2d8e3..508168c83 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -660,7 +660,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { } public Pair isConversationAxolotlCapableDetailed(Conversation conversation) { - if (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous()) { + if (conversation.getMode() == Conversation.MODE_SINGLE + || (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous())) { final List jids = getCryptoTargets(conversation); for(Jid jid : jids) { if (!hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty())) { diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 32d38c1fb..bc919788d 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -59,6 +59,8 @@ import eu.siacs.conversations.xmpp.pep.Avatar; public class FileBackend { private static final SimpleDateFormat IMAGE_DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US); + public static final String CONVERSATIONS_FILE_PROVIDER = "eu.siacs.conversations.files"; + private XmppConnectionService mXmppConnectionService; public FileBackend(XmppConnectionService service) { @@ -439,7 +441,7 @@ public class FileBackend { File file = new File(getTakePhotoPath()+"IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); file.getParentFile().mkdirs(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return FileProvider.getUriForFile(mXmppConnectionService, "eu.siacs.conversations.files", file); + return FileProvider.getUriForFile(mXmppConnectionService, CONVERSATIONS_FILE_PROVIDER, file); } else { return Uri.fromFile(file); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index b45d9d707..82b59dfcc 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -451,14 +451,15 @@ public class ConversationActivity extends XmppActivity private boolean quickOmemoDebugger(Conversation c) { if (c != null) { + boolean single = c.getMode() == Conversation.MODE_SINGLE; AxolotlService axolotlService = c.getAccount().getAxolotlService(); Pair capabilityJidPair = axolotlService.isConversationAxolotlCapableDetailed(c); switch (capabilityJidPair.first) { case MISSING_PRESENCE: - Toast.makeText(ConversationActivity.this,getString(R.string.missing_presence_subscription_with_x,capabilityJidPair.second.toBareJid().toString()),Toast.LENGTH_SHORT).show(); + Toast.makeText(ConversationActivity.this,single ? getString(R.string.missing_presence_subscription) : getString(R.string.missing_presence_subscription_with_x,capabilityJidPair.second.toBareJid().toString()),Toast.LENGTH_SHORT).show(); return true; case MISSING_KEYS: - Toast.makeText(ConversationActivity.this,getString(R.string.missing_keys_from_x,capabilityJidPair.second.toBareJid().toString()),Toast.LENGTH_SHORT).show(); + Toast.makeText(ConversationActivity.this,single ? getString(R.string.missing_omemo_keys) : getString(R.string.missing_keys_from_x,capabilityJidPair.second.toBareJid().toString()),Toast.LENGTH_SHORT).show(); return true; case WRONG_CONFIGURATION: Toast.makeText(ConversationActivity.this,R.string.wrong_conference_configuration, Toast.LENGTH_SHORT).show(); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 9e2b3ba7d..496d8ab58 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -51,6 +51,7 @@ import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message.FileParams; import eu.siacs.conversations.entities.Transferable; +import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.widget.ClickableMovementMethod; import eu.siacs.conversations.utils.CryptoHelper; @@ -698,7 +699,7 @@ public class MessageAdapter extends ArrayAdapter { Uri uri; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { try { - uri = FileProvider.getUriForFile(activity, "eu.siacs.conversations.files", file); + uri = FileProvider.getUriForFile(activity, FileBackend.CONVERSATIONS_FILE_PROVIDER, file); } catch (IllegalArgumentException e) { Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); return; diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 45bbd7ef0..79da0a2fb 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -284,6 +284,7 @@ Conference requires password Enter password Missing presence updates from contact + Missing presence subscription Please request presence updates from your contact first.\n\nThis will be used to determine what client(s) your contact is using. Request now Delete Fingerprint @@ -684,6 +685,7 @@ Unable to update account Missing presence subscription with %s. Missing OMEMO keys from %s. + Missing OMEMO keys This is not a private, non-anonymous conference. There are no members in this conference. Report this JID as sending unwanted messages.