Clean up identity key view activity

This commit is contained in:
Moxie Marlinspike
2013-05-23 18:54:16 -07:00
parent 95eb62190a
commit 8c1ca6c9e0
7 changed files with 36 additions and 84 deletions

View File

@@ -118,7 +118,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
@Override
public void onDestroy() {
MemoryCleaner.clean((MasterSecret)getIntent().getParcelableExtra("master_secret"));
MemoryCleaner.clean((MasterSecret) getIntent().getParcelableExtra("master_secret"));
super.onDestroy();
}
@@ -157,7 +157,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
preference.setSummary(newValue == null ? "Not set" : ((String)newValue));
preference.setSummary(newValue == null ? "Not set" : ((String) newValue));
return true;
}
});
@@ -218,6 +218,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr
public boolean onPreferenceClick(Preference preference) {
Intent viewIdentityIntent = new Intent(ApplicationPreferencesActivity.this, ViewIdentityActivity.class);
viewIdentityIntent.putExtra("identity_key", IdentityKeyUtil.getIdentityKey(ApplicationPreferencesActivity.this));
viewIdentityIntent.putExtra("title", getString(R.string.ApplicationPreferencesActivity_my) + " " +
getString(R.string.ViewIdentityActivity_identity_fingerprint));
startActivity(viewIdentityIntent);
return true;

View File

@@ -92,6 +92,10 @@ public class IdentityKeyView extends RelativeLayout
return this.identityKey;
}
public Recipient getRecipient() {
return this.recipients.getPrimaryRecipient();
}
private boolean isBadgeEnabled() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
}

View File

@@ -41,6 +41,8 @@ public class ReviewIdentitiesFragment extends SherlockListFragment
public void onListItemClick(ListView listView, View view, int position, long id) {
Intent viewIntent = new Intent(getActivity(), ViewIdentityActivity.class);
viewIntent.putExtra("identity_key", ((IdentityKeyView)view).getIdentityKey());
viewIntent.putExtra("title", ((IdentityKeyView)view).getRecipient().toShortString() + " " +
getString(R.string.ViewIdentityActivity_identity_fingerprint));
startActivity(viewIntent);
}

View File

@@ -17,8 +17,6 @@
package org.thoughtcrime.securesms;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.thoughtcrime.securesms.crypto.IdentityKey;
@@ -30,18 +28,16 @@ import org.thoughtcrime.securesms.crypto.IdentityKey;
*/
public class ViewIdentityActivity extends KeyScanningActivity {
private TextView identityFingerprint;
private Button compareButton;
private Button okButton;
private TextView identityFingerprint;
private IdentityKey identityKey;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.view_identity_activity);
initializeResources();
initializeListeners();
initializeFingerprint();
}
@@ -53,27 +49,13 @@ public class ViewIdentityActivity extends KeyScanningActivity {
}
}
private void initializeListeners() {
this.okButton.setOnClickListener(new OkButtonListener());
this.compareButton.setOnClickListener(new CompareListener());
}
private void initializeResources() {
this.identityKey = (IdentityKey)getIntent().getParcelableExtra("identity_key");
this.identityFingerprint = (TextView)findViewById(R.id.identity_fingerprint);
this.okButton = (Button)findViewById(R.id.ok_button);
this.compareButton = (Button)findViewById(R.id.compare_button);
}
String title = getIntent().getStringExtra("title");
private class CompareListener implements View.OnClickListener {
public void onClick(View v) {
initiateDisplay();
}
}
private class OkButtonListener implements View.OnClickListener {
public void onClick(View v) {
finish();
if (title != null) {
getSupportActionBar().setTitle(getIntent().getStringExtra("title"));
}
}