Clean up identity key view activity

pull/1/head
Moxie Marlinspike 11 years ago
parent 95eb62190a
commit 8c1ca6c9e0

@ -118,7 +118,6 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ViewIdentityActivity" <activity android:name=".ViewIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__public_identity_key" android:label="@string/AndroidManifest__public_identity_key"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
@ -135,12 +134,6 @@
android:label="@string/AndroidManifest__verify_identity" android:label="@string/AndroidManifest__verify_identity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".SaveIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__save_identity"
android:windowSoftInputMode="stateVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".ReviewIdentitiesActivity" <activity android:name=".ReviewIdentitiesActivity"
android:label="@string/AndroidManifest__manage_identity_keys" android:label="@string/AndroidManifest__manage_identity_keys"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
@ -153,11 +146,6 @@
<activity android:name=".ApplicationPreferencesActivity" <activity android:name=".ApplicationPreferencesActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".VerifyImportedIdentityActivity"
android:theme="@style/Theme.Sherlock.Light.Dialog"
android:label="@string/AndroidManifest__verify_imported_identity"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<activity android:name=".RegistrationActivity" <activity android:name=".RegistrationActivity"
android:windowSoftInputMode="stateUnchanged" android:windowSoftInputMode="stateUnchanged"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/> android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>

@ -1,51 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent">
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1">
<TableRow> <LinearLayout android:layout_width="fill_parent"
<TextView android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginLeft="16dip"
android:text="@string/view_identity_activity__identity" android:layout_marginRight="16dip"
android:layout_marginRight="7dip" /> android:layout_gravity="center"
<TextView android:orientation="vertical">
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:id="@+id/identity_fingerprint"
android:text=""
android:padding="3dip" />
</TableRow>
<TableRow>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_span="2">
<Button android:id="@+id/compare_button"
android:layout_margin="10dip"
android:padding="5dip"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="@string/view_identity_activity__qr_code" />
<Button android:id="@+id/ok_button" <TextView
android:layout_margin="10dip" android:layout_width="fill_parent"
android:padding="5dip" android:layout_height="wrap_content"
android:layout_width="100dip" android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content" android:typeface="monospace"
android:text="@android:string/ok"/> android:id="@+id/identity_fingerprint"
android:text=""
</LinearLayout> android:padding="7dip" />
</TableRow>
</TableLayout> </LinearLayout>
</ScrollView> </ScrollView>

@ -35,7 +35,8 @@
<string name="ApplicationPreferencesActivity_delete_all_old_messages_now">Delete all old messages now?</string> <string name="ApplicationPreferencesActivity_delete_all_old_messages_now">Delete all old messages now?</string>
<string name="ApplicationPreferencesActivity_are_you_sure_you_would_like_to_immediately_trim_all_conversation_threads_to_the_s_most_recent_messages">Are you sure you would like to immediately trim all conversation threads to the %s most recent messages?</string> <string name="ApplicationPreferencesActivity_are_you_sure_you_would_like_to_immediately_trim_all_conversation_threads_to_the_s_most_recent_messages">Are you sure you would like to immediately trim all conversation threads to the %s most recent messages?</string>
<string name="ApplicationPreferencesActivity_delete">Delete</string> <string name="ApplicationPreferencesActivity_delete">Delete</string>
<string name="ApplicationPreferencesActivity_my">My</string>
<!-- AttachmentTypeSelectorAdapter --> <!-- AttachmentTypeSelectorAdapter -->
<string name="AttachmentTypeSelectorAdapter_picture">Picture</string> <string name="AttachmentTypeSelectorAdapter_picture">Picture</string>
@ -213,7 +214,8 @@
<string name="ViewIdentityActivity_not_verified_exclamation">NOT Verified!</string> <string name="ViewIdentityActivity_not_verified_exclamation">NOT Verified!</string>
<string name="ViewIdentityActivity_the_scanned_key_matches_exclamation">The scanned key matches!</string> <string name="ViewIdentityActivity_the_scanned_key_matches_exclamation">The scanned key matches!</string>
<string name="ViewIdentityActivity_verified_exclamation">Verified!</string> <string name="ViewIdentityActivity_verified_exclamation">Verified!</string>
<string name="ViewIdentityActivity_identity_fingerprint">Identity Fingerprint</string>
<!-- KeyExchangeInitiator --> <!-- KeyExchangeInitiator -->
<string name="KeyExchangeInitiator_initiate_despite_existing_request_question">Initiate Despite Existing Request?</string> <string name="KeyExchangeInitiator_initiate_despite_existing_request_question">Initiate Despite Existing Request?</string>
<string name="KeyExchangeInitiator_youve_already_sent_a_session_initiation_request_to_this_recipient_are_you_sure">You\'ve already sent a session initiation request to this recipient, are you sure you\'d like to send another? This will invalidate the first request.</string> <string name="KeyExchangeInitiator_youve_already_sent_a_session_initiation_request_to_this_recipient_are_you_sure">You\'ve already sent a session initiation request to this recipient, are you sure you\'d like to send another? This will invalidate the first request.</string>

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

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

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

@ -17,8 +17,6 @@
package org.thoughtcrime.securesms; package org.thoughtcrime.securesms;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import org.thoughtcrime.securesms.crypto.IdentityKey; import org.thoughtcrime.securesms.crypto.IdentityKey;
@ -30,18 +28,16 @@ import org.thoughtcrime.securesms.crypto.IdentityKey;
*/ */
public class ViewIdentityActivity extends KeyScanningActivity { public class ViewIdentityActivity extends KeyScanningActivity {
private TextView identityFingerprint; private TextView identityFingerprint;
private Button compareButton;
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);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.view_identity_activity); setContentView(R.layout.view_identity_activity);
initializeResources(); initializeResources();
initializeListeners();
initializeFingerprint(); 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() { 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); String title = getIntent().getStringExtra("title");
this.compareButton = (Button)findViewById(R.id.compare_button);
}
private class CompareListener implements View.OnClickListener {
public void onClick(View v) {
initiateDisplay();
}
}
private class OkButtonListener implements View.OnClickListener { if (title != null) {
public void onClick(View v) { getSupportActionBar().setTitle(getIntent().getStringExtra("title"));
finish();
} }
} }

Loading…
Cancel
Save