Fix review identity activity UI.

This commit is contained in:
Moxie Marlinspike 2012-07-23 21:43:55 -07:00
parent a1b077c349
commit a66cc636c6
6 changed files with 126 additions and 122 deletions

View File

@ -73,12 +73,15 @@
android:windowSoftInputMode="stateVisible"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".ReviewIdentitiesActivity"
android:label="Manage Identity Keys"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"/>
<activity android:name=".ApplicationPreferencesActivity" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<activity android:name=".PassphraseCreateActivity" android:theme="@android:style/Theme.Dialog" android:label="Create Passphrase" android:launchMode="singleInstance" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<activity android:name=".SendKeyActivity" android:theme="@android:style/Theme.Dialog" android:label="Initiate Key Exchange" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<activity android:name=".ReceiveKeyActivity" android:theme="@android:style/Theme.Dialog" android:label="Complete Key Exchange" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<activity android:name=".VerifyImportedIdentityActivity" android:theme="@android:style/Theme.Dialog" android:label="Verify Imported Identity" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<activity android:name=".ReviewIdentitiesActivity" android:theme="@android:style/Theme.Dialog" android:label="Manage Identity Keys (Long click)" android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout"></activity>
<service android:enabled="true" android:name=".service.KeyCachingService"></service>
<service android:enabled="true" android:name=".service.SendReceiveService"></service>

View File

@ -3,7 +3,7 @@
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingRight="10dip">
android:padding="15dip">
<TextView android:id="@+id/identity_name"
android:layout_width="wrap_content"
@ -17,21 +17,4 @@
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
<ImageView android:id="@+id/valid_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/valid"
android:visibility="gone"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<ImageView android:id="@+id/invalid_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/invalid"
android:visibility="gone"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</org.thoughtcrime.securesms.IdentityKeyView>

View File

@ -3,7 +3,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:orientation="vertical"
android:paddingLeft="16dip"
android:paddingRight="16dip">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
@ -17,6 +19,6 @@
android:layout_height="wrap_content"
android:text="You don't currently have any identity keys in your trust database."
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="10dip" />
android:padding="20dip" />
</LinearLayout>

View File

@ -1,7 +1,9 @@
<?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"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
@ -9,11 +11,11 @@
<TableRow>
<TextView
android:textSize="12sp"
android:text="Your identity:"
android:padding="3dip" />
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Identity:"
android:layout_marginRight="7dip" />
<TextView
android:textSize="20sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:typeface="monospace"
android:id="@+id/identity_fingerprint"
android:text=""

View File

@ -19,21 +19,18 @@ package org.thoughtcrime.securesms;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* Activity for displaying user identity keys.
* List item view for displaying user identity keys.
*
* @author Moxie Marlinspike
*/
public class IdentityKeyView extends RelativeLayout {
private TextView identityName;
private ImageView validImage;
private ImageView invalidImage;
private String identityKeyString;
public IdentityKeyView(Context context) {
super(context);
@ -48,16 +45,17 @@ public class IdentityKeyView extends RelativeLayout {
super(context, attributeSet);
}
public void set(String name, boolean valid) {
public void set(String name, String identityKeyString) {
identityName.setText(name);
validImage.setVisibility(valid ? View.VISIBLE : View.GONE);
invalidImage.setVisibility(valid ? View.GONE : View.VISIBLE);
this.identityKeyString = identityKeyString;
}
public String getIdentityKeyString() {
return this.identityKeyString;
}
private void initializeResources() {
this.identityName = (TextView)findViewById(R.id.identity_name);
this.validImage = (ImageView)findViewById(R.id.valid_indicator);
this.invalidImage = (ImageView)findViewById(R.id.invalid_indicator);
}
}

View File

@ -16,7 +16,24 @@
*/
package org.thoughtcrime.securesms;
import java.io.IOException;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.actionbarsherlock.app.SherlockListActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import org.thoughtcrime.securesms.crypto.IdentityKey;
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
@ -27,31 +44,15 @@ import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.MemoryCleaner;
import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.Toast;
import java.io.IOException;
/**
* Activity for reviewing/managing saved identity keys.
*
* @author Moxie Marlinspike
*/
public class ReviewIdentitiesActivity extends ListActivity {
public class ReviewIdentitiesActivity extends SherlockListActivity {
private static final int MENU_OPTION_VIEW = 1;
private static final int MENU_OPTION_DELETE = 2;
private MasterSecret masterSecret;
@ -61,6 +62,7 @@ public class ReviewIdentitiesActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.review_identities);
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
initializeResources();
registerForContextMenu(this.getListView());
@ -74,14 +76,18 @@ public class ReviewIdentitiesActivity extends ListActivity {
super.onDestroy();
}
@Override
public void onListItemClick(ListView listView, View view, int position, long id) {
viewIdentity(((IdentityKeyView)view).getIdentityKeyString());
}
@Override
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
menu.add(0, MENU_OPTION_VIEW, Menu.NONE, "View Key");
menu.add(0, MENU_OPTION_DELETE, Menu.NONE, "Delete");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
public boolean onContextItemSelected(android.view.MenuItem item) {
Cursor cursor = ((CursorAdapter)this.getListAdapter()).getCursor();
String identityKeyString = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_KEY));
String identityName = cursor.getString(cursor.getColumnIndexOrThrow(IdentityDatabase.IDENTITY_NAME));
@ -91,13 +97,19 @@ public class ReviewIdentitiesActivity extends ListActivity {
case MENU_OPTION_DELETE:
deleteIdentity(identityName, identityKeyString);
return true;
case MENU_OPTION_VIEW:
viewIdentity(identityKeyString);
return true;
}
return false;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: finish(); return true;
}
return false;
}
private void initializeResources() {
this.masterSecret = (MasterSecret)getIntent().getParcelableExtra("master_secret");
@ -142,7 +154,8 @@ public class ReviewIdentitiesActivity extends ListActivity {
}
public void onClick(DialogInterface arg0, int arg1) {
DatabaseFactory.getIdentityDatabase(ReviewIdentitiesActivity.this).deleteIdentity(name, keyString);
DatabaseFactory.getIdentityDatabase(ReviewIdentitiesActivity.this)
.deleteIdentity(name, keyString);
}
}
@ -176,7 +189,10 @@ public class ReviewIdentitiesActivity extends ListActivity {
valid = false;
}
((IdentityKeyView)view).set(identityName, valid);
if (!valid)
identityName = "Invalid Identity!";
((IdentityKeyView)view).set(identityName, identityKeyString);
}
@Override