session-android/src/org/thoughtcrime/securesms/ViewIdentityActivity.java

120 lines
3.1 KiB
Java
Raw Normal View History

2012-07-23 20:50:12 +00:00
/**
2011-12-20 18:20:44 +00:00
* Copyright (C) 2011 Whisper Systems
2012-07-23 20:50:12 +00:00
*
2011-12-20 18:20:44 +00:00
* 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
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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.
2012-07-23 20:50:12 +00:00
*
2011-12-20 18:20:44 +00:00
* 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.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
2012-07-23 20:50:12 +00:00
import org.thoughtcrime.securesms.crypto.IdentityKey;
2011-12-20 18:20:44 +00:00
/**
* Activity for displaying an identity key.
2012-07-23 20:50:12 +00:00
*
2011-12-20 18:20:44 +00:00
* @author Moxie Marlinspike
*/
public class ViewIdentityActivity extends KeyScanningActivity {
private TextView identityFingerprint;
private Button compareButton;
private Button okButton;
private IdentityKey identityKey;
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.view_identity_activity);
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
initializeResources();
initializeListeners();
initializeFingerprint();
}
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
private void initializeFingerprint() {
if (identityKey == null) {
identityFingerprint.setText("You do not have an identity key.");
} else {
identityFingerprint.setText(identityKey.getFingerprint());
}
}
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
private void initializeListeners() {
this.okButton.setOnClickListener(new OkButtonListener());
this.compareButton.setOnClickListener(new CompareListener());
}
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
private void initializeResources() {
this.identityKey = (IdentityKey)getIntent().getParcelableExtra("identity_key");
this.identityFingerprint = (TextView)findViewById(R.id.identity_fingerprint);
2012-07-23 20:50:12 +00:00
this.okButton = (Button)findViewById(R.id.ok_button);
2011-12-20 18:20:44 +00:00
this.compareButton = (Button)findViewById(R.id.compare_button);
}
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
private class CompareListener implements View.OnClickListener {
public void onClick(View v) {
2012-07-23 20:50:12 +00:00
initiateDisplay();
2011-12-20 18:20:44 +00:00
}
}
2012-07-23 20:50:12 +00:00
2011-12-20 18:20:44 +00:00
private class OkButtonListener implements View.OnClickListener {
public void onClick(View v) {
finish();
}
}
@Override
protected String getScanString() {
return "Scan to compare";
}
@Override
protected String getDisplayString() {
return "Get scanned to compare";
}
@Override
protected IdentityKey getIdentityKeyToCompare() {
return identityKey;
}
@Override
protected IdentityKey getIdentityKeyToDisplay() {
return identityKey;
}
@Override
protected String getNotVerifiedMessage() {
return "WARNING, the scanned key DOES NOT match!";
}
@Override
protected String getNotVerifiedTitle() {
return "NOT Verified!";
}
@Override
protected String getVerifiedMessage() {
return "The scanned key matches!";
}
@Override
protected String getVerifiedTitle() {
return "Verified!";
}
}