fix send icon merge botch, encryption icons logic

// FREEBIE
This commit is contained in:
Jake McGinty 2014-04-03 10:47:51 -07:00 committed by Moxie Marlinspike
parent d4ac0c077d
commit 7d5e66eb6e
2 changed files with 18 additions and 15 deletions

View File

@ -103,12 +103,9 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.InvalidMessageException;
import org.whispersystems.textsecure.crypto.MasterCipher;
import org.whispersystems.textsecure.crypto.MasterSecret;
import org.whispersystems.textsecure.directory.Directory;
import org.whispersystems.textsecure.directory.NotInDirectoryException;
import org.whispersystems.textsecure.storage.RecipientDevice;
import org.whispersystems.textsecure.storage.Session;
import org.whispersystems.textsecure.storage.SessionRecordV2;
import org.whispersystems.textsecure.util.InvalidNumberException;
import org.whispersystems.textsecure.util.Util;
import java.io.IOException;
@ -678,25 +675,23 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi
}
private void initializeSecurity() {
TypedArray drawables = obtainStyledAttributes(SEND_ATTRIBUTES);
boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
Recipient primaryRecipient = getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
TypedArray drawables = obtainStyledAttributes(SEND_ATTRIBUTES);
if ((getRecipients() != null && getRecipients().isGroupRecipient()) ||
(isSingleConversation() && Session.hasSession(this, masterSecret, getRecipients().getPrimaryRecipient())))
if (isPushDestination ||
(isSingleConversation() && Session.hasSession(this, masterSecret, primaryRecipient)))
{
this.isEncryptedConversation = true;
this.isAuthenticatedConversation = Session.hasRemoteIdentityKey(this, masterSecret, getRecipients().getPrimaryRecipient());
this.isAuthenticatedConversation = Session.hasRemoteIdentityKey(this, masterSecret, primaryRecipient);
this.characterCalculator = new EncryptedCharacterCalculator();
if (isPushDestination) sendButton.setImageDrawable(drawables.getDrawable(0));
else sendButton.setImageDrawable(drawables.getDrawable(1));
} else {
this.isEncryptedConversation = false;
this.isAuthenticatedConversation = false;
this.characterCalculator = new CharacterCalculator();
}
if (DirectoryHelper.isPushDestination(this, getRecipients())) {
sendButton.setImageDrawable(drawables.getDrawable(0));
} else if (isEncryptedConversation) {
sendButton.setImageDrawable(drawables.getDrawable(1));
} else {
sendButton.setImageDrawable(drawables.getDrawable(2));
}

View File

@ -83,17 +83,25 @@ public class DirectoryHelper {
if (recipients == null) {
return false;
}
if (!TextSecurePreferences.isPushRegistered(context)) {
return false;
}
if (!recipients.isSingleRecipient()) {
return false;
}
if (recipients.isGroupRecipient()) {
return true;
}
final String number = recipients.getPrimaryRecipient().getNumber();
final String number = recipients.getPrimaryRecipient().getNumber();
if (number == null) {
return false;
}
final String e164number = Util.canonicalizeNumber(context, number);
return Directory.getInstance(context).isActiveNumber(e164number);