Fix view identity key QR code action.

This commit is contained in:
Moxie Marlinspike 2012-07-23 13:50:12 -07:00
parent 78998d0c93
commit a1b077c349
2 changed files with 16 additions and 17 deletions

View file

@ -32,7 +32,7 @@
android:padding="5dip" android:padding="5dip"
android:layout_width="100dip" android:layout_width="100dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Compare" /> android:text="QR Code" />
<Button android:id="@+id/ok_button" <Button android:id="@+id/ok_button"
android:layout_margin="10dip" android:layout_margin="10dip"

View file

@ -1,6 +1,6 @@
/** /**
* Copyright (C) 2011 Whisper Systems * Copyright (C) 2011 Whisper Systems
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
@ -10,22 +10,22 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.thoughtcrime.securesms; package org.thoughtcrime.securesms;
import org.thoughtcrime.securesms.crypto.IdentityKey;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import org.thoughtcrime.securesms.crypto.IdentityKey;
/** /**
* Activity for displaying an identity key. * Activity for displaying an identity key.
* *
* @author Moxie Marlinspike * @author Moxie Marlinspike
*/ */
public class ViewIdentityActivity extends KeyScanningActivity { public class ViewIdentityActivity extends KeyScanningActivity {
@ -34,17 +34,17 @@ public class ViewIdentityActivity extends KeyScanningActivity {
private Button compareButton; private Button compareButton;
private Button okButton; private Button okButton;
private IdentityKey identityKey; private IdentityKey identityKey;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
super.onCreate(state); super.onCreate(state);
setContentView(R.layout.view_identity_activity); setContentView(R.layout.view_identity_activity);
initializeResources(); initializeResources();
initializeListeners(); initializeListeners();
initializeFingerprint(); initializeFingerprint();
} }
private void initializeFingerprint() { private void initializeFingerprint() {
if (identityKey == null) { if (identityKey == null) {
identityFingerprint.setText("You do not have an identity key."); identityFingerprint.setText("You do not have an identity key.");
@ -52,26 +52,25 @@ public class ViewIdentityActivity extends KeyScanningActivity {
identityFingerprint.setText(identityKey.getFingerprint()); identityFingerprint.setText(identityKey.getFingerprint());
} }
} }
private void initializeListeners() { private void initializeListeners() {
this.okButton.setOnClickListener(new OkButtonListener()); this.okButton.setOnClickListener(new OkButtonListener());
this.compareButton.setOnClickListener(new CompareListener()); this.compareButton.setOnClickListener(new CompareListener());
} }
private void initializeResources() { private void initializeResources() {
this.identityKey = (IdentityKey)getIntent().getParcelableExtra("identity_key"); this.identityKey = (IdentityKey)getIntent().getParcelableExtra("identity_key");
this.identityFingerprint = (TextView)findViewById(R.id.identity_fingerprint); this.identityFingerprint = (TextView)findViewById(R.id.identity_fingerprint);
this.okButton = (Button)findViewById(R.id.ok_button); this.okButton = (Button)findViewById(R.id.ok_button);
this.compareButton = (Button)findViewById(R.id.compare_button); this.compareButton = (Button)findViewById(R.id.compare_button);
} }
private class CompareListener implements View.OnClickListener { private class CompareListener implements View.OnClickListener {
public void onClick(View v) { public void onClick(View v) {
registerForContextMenu(compareButton); initiateDisplay();
compareButton.showContextMenu();
} }
} }
private class OkButtonListener implements View.OnClickListener { private class OkButtonListener implements View.OnClickListener {
public void onClick(View v) { public void onClick(View v) {
finish(); finish();