fixed omemo shown as unavailable in 1:1 chats

This commit is contained in:
Daniel Gultsch 2016-10-03 21:04:10 +02:00
parent cea52b0722
commit 5ac0e9267d
5 changed files with 12 additions and 5 deletions

View File

@ -660,7 +660,8 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
} }
public Pair<AxolotlCapability,Jid> isConversationAxolotlCapableDetailed(Conversation conversation) { public Pair<AxolotlCapability,Jid> isConversationAxolotlCapableDetailed(Conversation conversation) {
if (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous()) { if (conversation.getMode() == Conversation.MODE_SINGLE
|| (conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous())) {
final List<Jid> jids = getCryptoTargets(conversation); final List<Jid> jids = getCryptoTargets(conversation);
for(Jid jid : jids) { for(Jid jid : jids) {
if (!hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty())) { if (!hasAny(jid) && (!deviceIds.containsKey(jid) || deviceIds.get(jid).isEmpty())) {

View File

@ -59,6 +59,8 @@ import eu.siacs.conversations.xmpp.pep.Avatar;
public class FileBackend { public class FileBackend {
private static final SimpleDateFormat IMAGE_DATE_FORMAT = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US); 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; private XmppConnectionService mXmppConnectionService;
public FileBackend(XmppConnectionService service) { 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 file = new File(getTakePhotoPath()+"IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg");
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 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 { } else {
return Uri.fromFile(file); return Uri.fromFile(file);
} }

View File

@ -451,14 +451,15 @@ public class ConversationActivity extends XmppActivity
private boolean quickOmemoDebugger(Conversation c) { private boolean quickOmemoDebugger(Conversation c) {
if (c != null) { if (c != null) {
boolean single = c.getMode() == Conversation.MODE_SINGLE;
AxolotlService axolotlService = c.getAccount().getAxolotlService(); AxolotlService axolotlService = c.getAccount().getAxolotlService();
Pair<AxolotlService.AxolotlCapability,Jid> capabilityJidPair = axolotlService.isConversationAxolotlCapableDetailed(c); Pair<AxolotlService.AxolotlCapability,Jid> capabilityJidPair = axolotlService.isConversationAxolotlCapableDetailed(c);
switch (capabilityJidPair.first) { switch (capabilityJidPair.first) {
case MISSING_PRESENCE: 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; return true;
case MISSING_KEYS: 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; return true;
case WRONG_CONFIGURATION: case WRONG_CONFIGURATION:
Toast.makeText(ConversationActivity.this,R.string.wrong_conference_configuration, Toast.LENGTH_SHORT).show(); Toast.makeText(ConversationActivity.this,R.string.wrong_conference_configuration, Toast.LENGTH_SHORT).show();

View File

@ -51,6 +51,7 @@ import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Message.FileParams; import eu.siacs.conversations.entities.Message.FileParams;
import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.ui.widget.ClickableMovementMethod; import eu.siacs.conversations.ui.widget.ClickableMovementMethod;
import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.CryptoHelper;
@ -698,7 +699,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
Uri uri; Uri uri;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try { try {
uri = FileProvider.getUriForFile(activity, "eu.siacs.conversations.files", file); uri = FileProvider.getUriForFile(activity, FileBackend.CONVERSATIONS_FILE_PROVIDER, file);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show(); Toast.makeText(activity,activity.getString(R.string.no_permission_to_access_x,file.getAbsolutePath()), Toast.LENGTH_SHORT).show();
return; return;

View File

@ -284,6 +284,7 @@
<string name="conference_requires_password">Conference requires password</string> <string name="conference_requires_password">Conference requires password</string>
<string name="enter_password">Enter password</string> <string name="enter_password">Enter password</string>
<string name="missing_presence_updates">Missing presence updates from contact</string> <string name="missing_presence_updates">Missing presence updates from contact</string>
<string name="missing_presence_subscription">Missing presence subscription</string>
<string name="request_presence_updates">Please request presence updates from your contact first.\n\n<small>This will be used to determine what client(s) your contact is using.</small></string> <string name="request_presence_updates">Please request presence updates from your contact first.\n\n<small>This will be used to determine what client(s) your contact is using.</small></string>
<string name="request_now">Request now</string> <string name="request_now">Request now</string>
<string name="delete_fingerprint">Delete Fingerprint</string> <string name="delete_fingerprint">Delete Fingerprint</string>
@ -684,6 +685,7 @@
<string name="unable_to_update_account">Unable to update account</string> <string name="unable_to_update_account">Unable to update account</string>
<string name="missing_presence_subscription_with_x">Missing presence subscription with %s.</string> <string name="missing_presence_subscription_with_x">Missing presence subscription with %s.</string>
<string name="missing_keys_from_x">Missing OMEMO keys from %s.</string> <string name="missing_keys_from_x">Missing OMEMO keys from %s.</string>
<string name="missing_omemo_keys">Missing OMEMO keys</string>
<string name="wrong_conference_configuration">This is not a private, non-anonymous conference.</string> <string name="wrong_conference_configuration">This is not a private, non-anonymous conference.</string>
<string name="this_conference_has_no_members">There are no members in this conference.</string> <string name="this_conference_has_no_members">There are no members in this conference.</string>
<string name="report_jid_as_spammer">Report this JID as sending unwanted messages.</string> <string name="report_jid_as_spammer">Report this JID as sending unwanted messages.</string>