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.widget.TextView;
|
|
|
|
|
2014-04-21 15:40:19 +00:00
|
|
|
import org.whispersystems.libaxolotl.IdentityKey;
|
|
|
|
import org.whispersystems.textsecure.crypto.IdentityKeyParcelable;
|
2012-07-23 20:50:12 +00:00
|
|
|
|
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 {
|
|
|
|
|
2014-04-21 15:40:19 +00:00
|
|
|
public static final String IDENTITY_KEY = "identity_key";
|
|
|
|
public static final String TITLE = "title";
|
|
|
|
|
2013-05-24 01:54:16 +00:00
|
|
|
private TextView identityFingerprint;
|
2011-12-20 18:20:44 +00:00
|
|
|
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);
|
2013-05-24 01:54:16 +00:00
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
2011-12-20 18:20:44 +00:00
|
|
|
setContentView(R.layout.view_identity_activity);
|
2012-07-23 20:50:12 +00:00
|
|
|
|
2013-08-15 17:49:06 +00:00
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void initialize() {
|
2011-12-20 18:20:44 +00:00
|
|
|
initializeResources();
|
|
|
|
initializeFingerprint();
|
|
|
|
}
|
2012-07-23 20:50:12 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void initializeFingerprint() {
|
|
|
|
if (identityKey == null) {
|
2012-09-20 02:56:04 +00:00
|
|
|
identityFingerprint.setText(R.string.ViewIdentityActivity_you_do_not_have_an_identity_key);
|
2011-12-20 18:20:44 +00:00
|
|
|
} else {
|
|
|
|
identityFingerprint.setText(identityKey.getFingerprint());
|
|
|
|
}
|
|
|
|
}
|
2012-07-23 20:50:12 +00:00
|
|
|
|
2011-12-20 18:20:44 +00:00
|
|
|
private void initializeResources() {
|
2014-04-21 15:40:19 +00:00
|
|
|
IdentityKeyParcelable identityKeyParcelable = getIntent().getParcelableExtra(IDENTITY_KEY);
|
|
|
|
|
|
|
|
if (identityKeyParcelable == null) {
|
|
|
|
throw new AssertionError("No identity key!");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.identityKey = identityKeyParcelable.get();
|
2011-12-20 18:20:44 +00:00
|
|
|
this.identityFingerprint = (TextView)findViewById(R.id.identity_fingerprint);
|
2014-04-21 15:40:19 +00:00
|
|
|
String title = getIntent().getStringExtra(TITLE);
|
2012-07-23 20:50:12 +00:00
|
|
|
|
2013-05-24 01:54:16 +00:00
|
|
|
if (title != null) {
|
2014-04-21 15:40:19 +00:00
|
|
|
getSupportActionBar().setTitle(getIntent().getStringExtra(TITLE));
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getScanString() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_scan_to_compare);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getDisplayString() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_get_scanned_to_compare);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected IdentityKey getIdentityKeyToCompare() {
|
|
|
|
return identityKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected IdentityKey getIdentityKeyToDisplay() {
|
|
|
|
return identityKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getNotVerifiedMessage() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_warning_the_scanned_key_does_not_match_exclamation);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getNotVerifiedTitle() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_not_verified_exclamation);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getVerifiedMessage() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_the_scanned_key_matches_exclamation);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String getVerifiedTitle() {
|
2012-09-20 02:56:04 +00:00
|
|
|
return getString(R.string.ViewIdentityActivity_verified_exclamation);
|
2011-12-20 18:20:44 +00:00
|
|
|
}
|
|
|
|
}
|