|
|
|
|
@ -16,19 +16,7 @@
|
|
|
|
|
*/
|
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.IdentityKey;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.InvalidKeyException;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
|
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;
|
|
|
|
|
@ -37,21 +25,34 @@ 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.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;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterCipher;
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
|
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
|
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
|
|
|
|
import org.thoughtcrime.securesms.util.MemoryCleaner;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|