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

View File

@ -1,51 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<TableLayout
android:layout_marginRight="16dip"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="1">
<TableRow>
<TextView
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/view_identity_activity__identity"
android:layout_marginRight="7dip" />
<TextView
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"
android:layout_margin="10dip"
android:padding="5dip"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:text="@android:string/ok"/>
android:padding="7dip" />
</LinearLayout>
</TableRow>
</TableLayout>
</ScrollView>

View File

@ -35,6 +35,7 @@
<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_delete">Delete</string>
<string name="ApplicationPreferencesActivity_my">My</string>
<!-- AttachmentTypeSelectorAdapter -->
@ -213,6 +214,7 @@
<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_verified_exclamation">Verified!</string>
<string name="ViewIdentityActivity_identity_fingerprint">Identity Fingerprint</string>
<!-- KeyExchangeInitiator -->
<string name="KeyExchangeInitiator_initiate_despite_existing_request_question">Initiate Despite Existing Request?</string>

View File

@ -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;
@ -31,17 +29,15 @@ import org.thoughtcrime.securesms.crypto.IdentityKey;
public class ViewIdentityActivity extends KeyScanningActivity {
private TextView identityFingerprint;
private Button compareButton;
private Button okButton;
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"));
}
}