Fix for scanning provided identity

Fixes #4028
// FREEBIE
master
Moxie Marlinspike 2015-09-06 11:45:19 -07:00
parent 797513b372
commit d4718c373a
1 changed files with 17 additions and 28 deletions

View File

@ -19,6 +19,7 @@ package org.thoughtcrime.securesms;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.TextView;
import android.widget.Toast;
@ -51,39 +52,32 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
protected void onCreate(Bundle state, @NonNull MasterSecret masterSecret) {
this.masterSecret = masterSecret;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_identity);
setContentView(R.layout.verify_identity_activity);
initializeResources();
initializeFingerprints();
this.localIdentityFingerprint = (TextView)findViewById(R.id.you_read);
this.remoteIdentityFingerprint = (TextView)findViewById(R.id.friend_reads);
}
@Override
public void onResume() {
super.onResume();
getSupportActionBar().setTitle(R.string.AndroidManifest__verify_identity);
this.recipient = RecipientFactory.getRecipientForId(this, this.getIntent().getLongExtra("recipient", -1), true);
initializeFingerprints();
}
private void initializeLocalIdentityKey() {
private void initializeFingerprints() {
if (!IdentityKeyUtil.hasIdentityKey(this)) {
localIdentityFingerprint.setText(R.string.VerifyIdentityActivity_you_do_not_have_an_identity_key);
return;
}
localIdentityFingerprint.setText(IdentityKeyUtil.getIdentityKey(this).getFingerprint());
}
private void initializeRemoteIdentityKey() {
IdentityKeyParcelable identityKeyParcelable = getIntent().getParcelableExtra("remote_identity");
IdentityKey identityKey = null;
if (identityKeyParcelable != null) {
identityKey = identityKeyParcelable.get();
}
if (identityKey == null) {
identityKey = getRemoteIdentityKey(masterSecret, recipient);
}
IdentityKey identityKey = getRemoteIdentityKey(masterSecret, recipient);
if (identityKey == null) {
remoteIdentityFingerprint.setText(R.string.VerifyIdentityActivity_recipient_has_no_identity_key);
@ -92,17 +86,6 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
}
}
private void initializeFingerprints() {
initializeLocalIdentityKey();
initializeRemoteIdentityKey();
}
private void initializeResources() {
this.localIdentityFingerprint = (TextView)findViewById(R.id.you_read);
this.remoteIdentityFingerprint = (TextView)findViewById(R.id.friend_reads);
this.recipient = RecipientFactory.getRecipientForId(this, this.getIntent().getLongExtra("recipient", -1), true);
}
@Override
protected void initiateDisplay() {
if (!IdentityKeyUtil.hasIdentityKey(this)) {
@ -167,7 +150,13 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
return getString(R.string.VerifyIdentityActivity_verified_exclamation);
}
private IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
private @Nullable IdentityKey getRemoteIdentityKey(MasterSecret masterSecret, Recipient recipient) {
IdentityKeyParcelable identityKeyParcelable = getIntent().getParcelableExtra("remote_identity");
if (identityKeyParcelable != null) {
return identityKeyParcelable.get();
}
SessionStore sessionStore = new TextSecureSessionStore(this, masterSecret);
AxolotlAddress axolotlAddress = new AxolotlAddress(recipient.getNumber(), TextSecureAddress.DEFAULT_DEVICE_ID);
SessionRecord record = sessionStore.loadSession(axolotlAddress);