mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-20 10:43:22 +00:00
Clean up key/identity verification Activites.
1) Get ride of the crazy button situation. 2) Actionbar-ify and abstract out the common actions. 3) Switch to full activities from dialog themes.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -10,62 +10,68 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
import com.google.zxing.integration.android.IntentResult;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.SerializableKey;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.util.Dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.zxing.integration.android.IntentIntegrator;
|
||||
import com.google.zxing.integration.android.IntentResult;
|
||||
|
||||
/**
|
||||
* Activity for initiating/receiving key QR code scans.
|
||||
*
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public abstract class KeyScanningActivity extends Activity {
|
||||
|
||||
private static final int MENU_ITEM_SCAN = 1;
|
||||
private static final int MENU_ITEM_GET_SCANNED = 2;
|
||||
public abstract class KeyScanningActivity extends SherlockActivity {
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
menu.add(0, MENU_ITEM_SCAN, Menu.NONE, getScanString());
|
||||
menu.add(0, MENU_ITEM_GET_SCANNED, Menu.NONE, getDisplayString());
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = this.getSupportMenuInflater();
|
||||
menu.clear();
|
||||
|
||||
inflater.inflate(R.menu.key_scanning, menu);
|
||||
|
||||
menu.findItem(R.id.menu_scan).setTitle(getScanString());
|
||||
menu.findItem(R.id.menu_get_scanned).setTitle(getDisplayString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
|
||||
switch(item.getItemId()) {
|
||||
case MENU_ITEM_SCAN: initiateScan(); return true;
|
||||
case MENU_ITEM_GET_SCANNED: initiateDisplay(); return true;
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_scan: initiateScan(); return true;
|
||||
case R.id.menu_get_scanned: initiateDisplay(); return true;
|
||||
case android.R.id.home: finish(); return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
|
||||
if ((scanResult != null) && (scanResult.getContents() != null)) {
|
||||
String data = scanResult.getContents();
|
||||
|
||||
|
||||
if (data.equals(Base64.encodeBytes(getIdentityKeyToCompare().serialize()))) {
|
||||
Dialogs.displayAlert(this, getVerifiedTitle(), getVerifiedMessage(), android.R.drawable.ic_dialog_info);
|
||||
} else {
|
||||
@@ -75,11 +81,11 @@ public abstract class KeyScanningActivity extends Activity {
|
||||
Toast.makeText(this, "No scanned key found!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void initiateScan() {
|
||||
IntentIntegrator.initiateScan(this);
|
||||
}
|
||||
|
||||
|
||||
protected void initiateDisplay() {
|
||||
IntentIntegrator.shareText(this, Base64.encodeBytes(getIdentityKeyToDisplay().serialize()));
|
||||
}
|
||||
@@ -92,8 +98,8 @@ public abstract class KeyScanningActivity extends Activity {
|
||||
|
||||
protected abstract SerializableKey getIdentityKeyToCompare();
|
||||
protected abstract SerializableKey getIdentityKeyToDisplay();
|
||||
|
||||
|
||||
protected abstract String getVerifiedTitle();
|
||||
protected abstract String getVerifiedMessage();
|
||||
|
||||
|
||||
}
|
||||
|
40
src/org/thoughtcrime/securesms/KeyVerifyingActivity.java
Normal file
40
src/org/thoughtcrime/securesms/KeyVerifyingActivity.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
public abstract class KeyVerifyingActivity extends KeyScanningActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
MenuInflater inflater = this.getSupportMenuInflater();
|
||||
inflater.inflate(R.menu.verify_keys, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_session_verified: handleVerified(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void handleVerified();
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -10,170 +10,116 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKey;
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.KeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.SessionRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Activity for verifying identity keys.
|
||||
*
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
|
||||
public class VerifyIdentityActivity extends KeyVerifyingActivity {
|
||||
|
||||
private Recipient recipient;
|
||||
private MasterSecret masterSecret;
|
||||
|
||||
|
||||
private TextView localIdentityFingerprint;
|
||||
private TextView remoteIdentityFingerprint;
|
||||
|
||||
private Button verifiedButton;
|
||||
private Button abortButton;
|
||||
private Button cancelButton;
|
||||
private Button compareButton;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.verify_identity_activity);
|
||||
|
||||
|
||||
initializeResources();
|
||||
initializeFingerprints();
|
||||
initializeListeners();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MemoryCleaner.clean(masterSecret);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleVerified() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
builder.setTitle("Mark Identity Verified?");
|
||||
builder.setMessage("Are you sure you have validated the recipients' identity fingerprint " +
|
||||
"and would like to mark it as verified?");
|
||||
|
||||
builder.setPositiveButton("Mark Verified", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SessionRecord sessionRecord = new SessionRecord(VerifyIdentityActivity.this,
|
||||
masterSecret, recipient);
|
||||
IdentityKey identityKey = sessionRecord.getIdentityKey();
|
||||
String recipientName = recipient.getName();
|
||||
|
||||
Intent intent = new Intent(VerifyIdentityActivity.this,
|
||||
SaveIdentityActivity.class);
|
||||
|
||||
intent.putExtra("name_suggestion", recipientName);
|
||||
intent.putExtra("master_secret", masterSecret);
|
||||
intent.putExtra("identity_key", identityKey);
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void initializeLocalIdentityKey() {
|
||||
if (!IdentityKeyUtil.hasIdentityKey(this)) {
|
||||
localIdentityFingerprint.setText("You do not have an identity key.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
localIdentityFingerprint.setText(IdentityKeyUtil.getFingerprint(this));
|
||||
}
|
||||
|
||||
private void initializeRemoteIdentityKey() {
|
||||
SessionRecord sessionRecord = new SessionRecord(this, masterSecret, recipient);
|
||||
IdentityKey identityKey = sessionRecord.getIdentityKey();
|
||||
|
||||
|
||||
if (identityKey == null) {
|
||||
remoteIdentityFingerprint.setText("Recipient has no identity key.");
|
||||
verifiedButton.setEnabled(false);
|
||||
} else {
|
||||
remoteIdentityFingerprint.setText(identityKey.getFingerprint());
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeListeners() {
|
||||
verifiedButton.setOnClickListener(new VerifiedButtonListener());
|
||||
cancelButton.setOnClickListener(new CancelButtonListener());
|
||||
abortButton.setOnClickListener(new AbortButtonListener());
|
||||
compareButton.setOnClickListener(new CompareButtonListener());
|
||||
}
|
||||
|
||||
|
||||
private void initializeFingerprints() {
|
||||
initializeLocalIdentityKey();
|
||||
initializeRemoteIdentityKey();
|
||||
}
|
||||
|
||||
|
||||
private void initializeResources() {
|
||||
localIdentityFingerprint = (TextView)findViewById(R.id.you_read);
|
||||
remoteIdentityFingerprint = (TextView)findViewById(R.id.friend_reads);
|
||||
recipient = (Recipient)this.getIntent().getParcelableExtra("recipient");
|
||||
masterSecret = (MasterSecret)this.getIntent().getParcelableExtra("master_secret");
|
||||
verifiedButton = (Button)findViewById(R.id.verified_button);
|
||||
abortButton = (Button)findViewById(R.id.abort_button);
|
||||
cancelButton = (Button)findViewById(R.id.cancel_button);
|
||||
compareButton = (Button)findViewById(R.id.compare_button);
|
||||
}
|
||||
|
||||
private void abortSession() {
|
||||
KeyUtil.abortSessionFor(this, recipient);
|
||||
}
|
||||
|
||||
private void saveRemoteIdentity() {
|
||||
SessionRecord sessionRecord = new SessionRecord(this, masterSecret, recipient);
|
||||
IdentityKey identityKey = sessionRecord.getIdentityKey();
|
||||
String recipientName = recipient.getName();
|
||||
Intent intent = new Intent(this, SaveIdentityActivity.class);
|
||||
intent.putExtra("name_suggestion", recipientName);
|
||||
intent.putExtra("master_secret", masterSecret);
|
||||
intent.putExtra("identity_key", identityKey);
|
||||
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private class CancelButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class CompareButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
registerForContextMenu(compareButton);
|
||||
compareButton.showContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private class AbortButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(VerifyIdentityActivity.this);
|
||||
dialogBuilder.setTitle("Abort Session?");
|
||||
dialogBuilder.setIcon(android.R.drawable.ic_dialog_info);
|
||||
dialogBuilder.setMessage("Are you sure that you would like to abort this secure session?");
|
||||
dialogBuilder.setCancelable(true);
|
||||
dialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
abortSession();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.no, null);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private class VerifiedButtonListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(VerifyIdentityActivity.this);
|
||||
dialogBuilder.setTitle("Save Identity Key?");
|
||||
dialogBuilder.setIcon(android.R.drawable.ic_dialog_info);
|
||||
dialogBuilder.setMessage("Are you sure that you would like to mark this as a valid identity key for all future correspondence with this recipient? You should only do this if you have actually verified the fingerprint.");
|
||||
dialogBuilder.setCancelable(true);
|
||||
dialogBuilder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
saveRemoteIdentity();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
dialogBuilder.setNegativeButton(R.string.no, null);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,22 +128,22 @@ public class VerifyIdentityActivity extends KeyScanningActivity {
|
||||
Toast.makeText(this, "You don't have an identity key!", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.initiateDisplay();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initiateScan() {
|
||||
SessionRecord sessionRecord = new SessionRecord(this, masterSecret, recipient);
|
||||
IdentityKey identityKey = sessionRecord.getIdentityKey();
|
||||
|
||||
|
||||
if (identityKey == null) {
|
||||
Toast.makeText(this, "Recipient has no identity key!", Toast.LENGTH_LONG);
|
||||
} else {
|
||||
super.initiateScan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getScanString() {
|
||||
return "Scan their key to compare";
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (C) 2011 Whisper Systems
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@@ -10,13 +10,17 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.KeyUtil;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.SerializableKey;
|
||||
import org.thoughtcrime.securesms.database.SessionRecord;
|
||||
@@ -24,131 +28,88 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Hex;
|
||||
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Activity for verifying session keys.
|
||||
*
|
||||
*
|
||||
* @author Moxie Marlinspike
|
||||
*
|
||||
*/
|
||||
public class VerifyKeysActivity extends KeyScanningActivity {
|
||||
public class VerifyKeysActivity extends KeyVerifyingActivity {
|
||||
|
||||
private byte[] yourFingerprintBytes;
|
||||
private byte[] theirFingerprintBytes;
|
||||
|
||||
|
||||
private TextView yourFingerprint;
|
||||
private TextView theirFingerprint;
|
||||
private Button verifiedButton;
|
||||
private Button abortButton;
|
||||
private Button cancelButton;
|
||||
private Button compareButton;
|
||||
|
||||
private Recipient recipient;
|
||||
private MasterSecret masterSecret;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.verify_keys_activity);
|
||||
|
||||
|
||||
initializeResources();
|
||||
initializeFingerprints();
|
||||
initializeCallbacks();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MemoryCleaner.clean(masterSecret);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initializeCallbacks() {
|
||||
this.verifiedButton.setOnClickListener(new VerifiedListener());
|
||||
this.abortButton.setOnClickListener(new AbortListener());
|
||||
this.cancelButton.setOnClickListener(new CancelListener());
|
||||
this.compareButton.setOnClickListener(new CompareListener());
|
||||
|
||||
@Override
|
||||
protected void handleVerified() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
builder.setTitle("Mark Session Verified?");
|
||||
builder.setMessage("Are you sure that you have validated these fingerprints and " +
|
||||
"would like to mark this session as verified?");
|
||||
builder.setPositiveButton("Mark Verified", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SessionRecord sessionRecord = new SessionRecord(VerifyKeysActivity.this, masterSecret,
|
||||
recipient);
|
||||
sessionRecord.setVerifiedSessionKey(true);
|
||||
sessionRecord.save();
|
||||
VerifyKeysActivity.this.finish();
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
||||
private void initializeResources() {
|
||||
this.recipient = (Recipient)this.getIntent().getParcelableExtra("recipient");
|
||||
this.masterSecret = (MasterSecret)this.getIntent().getParcelableExtra("master_secret");
|
||||
this.yourFingerprint = (TextView)findViewById(R.id.you_read);
|
||||
this.theirFingerprint = (TextView)findViewById(R.id.friend_reads);
|
||||
this.verifiedButton = (Button)findViewById(R.id.verified_button);
|
||||
this.abortButton = (Button)findViewById(R.id.abort_button);
|
||||
this.cancelButton = (Button)findViewById(R.id.cancel_button);
|
||||
this.compareButton = (Button)findViewById(R.id.compare_button);
|
||||
}
|
||||
|
||||
|
||||
private void initializeFingerprints() {
|
||||
SessionRecord session = new SessionRecord(this, masterSecret, recipient);
|
||||
this.yourFingerprintBytes = session.getLocalFingerprint();
|
||||
this.theirFingerprintBytes = session.getRemoteFingerprint();
|
||||
|
||||
|
||||
this.yourFingerprint.setText(Hex.toString(yourFingerprintBytes));
|
||||
this.theirFingerprint.setText(Hex.toString(theirFingerprintBytes));
|
||||
}
|
||||
|
||||
private class VerifiedListener implements OnClickListener {
|
||||
public void onClick(View v) {
|
||||
SessionRecord sessionRecord = new SessionRecord(VerifyKeysActivity.this, masterSecret, recipient);
|
||||
sessionRecord.setVerifiedSessionKey(true);
|
||||
sessionRecord.save();
|
||||
VerifyKeysActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class CancelListener implements OnClickListener {
|
||||
public void onClick(View v) {
|
||||
VerifyKeysActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private class CompareListener implements View.OnClickListener {
|
||||
public void onClick(View v) {
|
||||
registerForContextMenu(compareButton);
|
||||
compareButton.showContextMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private class AbortListener implements OnClickListener {
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(VerifyKeysActivity.this);
|
||||
builder.setTitle("Abort Secure Session Confirmation");
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
builder.setCancelable(true);
|
||||
builder.setMessage("Are you sure that you want to abort this secure session?");
|
||||
builder.setPositiveButton(R.string.yes, new AbortConfirmListener());
|
||||
builder.setNegativeButton(R.string.no, null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private class AbortConfirmListener implements DialogInterface.OnClickListener {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
KeyUtil.abortSessionFor(VerifyKeysActivity.this, recipient);
|
||||
VerifyKeysActivity.this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDisplayString() {
|
||||
return "Get my fingerprint scanned";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getScanString() {
|
||||
return "Scan their fingerprint";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SerializableKey getIdentityKeyToCompare() {
|
||||
protected SerializableKey getIdentityKeyToCompare() {
|
||||
return new FingerprintKey(theirFingerprintBytes);
|
||||
}
|
||||
|
||||
@@ -176,14 +137,14 @@ public class VerifyKeysActivity extends KeyScanningActivity {
|
||||
protected String getVerifiedTitle() {
|
||||
return "Verified!";
|
||||
}
|
||||
|
||||
|
||||
private class FingerprintKey implements SerializableKey {
|
||||
private final byte[] fingerprint;
|
||||
|
||||
|
||||
public FingerprintKey(byte[] fingerprint) {
|
||||
this.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
|
||||
public byte[] serialize() {
|
||||
return fingerprint;
|
||||
}
|
||||
|
Reference in New Issue
Block a user