From 914fce9dfb643d77c3d3e9417f0a0bc5e2ac8043 Mon Sep 17 00:00:00 2001 From: rmceoin Date: Sat, 3 Oct 2009 22:42:11 +0000 Subject: [PATCH] OI Safe: major lifecycle updates. Moved several items from onCreate to onResume. Also fixed bug where frontdoor was launched from both onCreate and onResume resulting in duplicate frontdoors git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2312 72b678ce-9140-0410-bee8-679b907dd61a --- res/values/strings.xml | 1 + src/org/openintents/safe/AskPassword.java | 4 +- src/org/openintents/safe/CategoryEdit.java | 18 ++-- src/org/openintents/safe/CategoryList.java | 27 ++---- src/org/openintents/safe/ChangePass.java | 7 +- src/org/openintents/safe/Help.java | 5 +- src/org/openintents/safe/IntentHandler.java | 2 +- src/org/openintents/safe/PassEdit.java | 96 ++++++++++++++++----- src/org/openintents/safe/PassGen.java | 6 +- src/org/openintents/safe/PassList.java | 42 ++++----- src/org/openintents/safe/PassView.java | 35 +++----- src/org/openintents/safe/Passwords.java | 25 +++++- src/org/openintents/safe/Preferences.java | 5 +- src/org/openintents/safe/Restore.java | 8 +- src/org/openintents/safe/Search.java | 8 +- 15 files changed, 166 insertions(+), 123 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6b9817f..3c6362a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -188,6 +188,7 @@ Open OI Safe Lock Continue + Generate Password Password Length Uppercase [A-Z] Lowercase [a-z] diff --git a/src/org/openintents/safe/AskPassword.java b/src/org/openintents/safe/AskPassword.java index ec8ac77..2548929 100644 --- a/src/org/openintents/safe/AskPassword.java +++ b/src/org/openintents/safe/AskPassword.java @@ -53,7 +53,7 @@ import android.widget.Toast; */ public class AskPassword extends Activity { - private boolean debug = false; + private boolean debug = true; private static String TAG = "AskPassword"; public static String EXTRA_IS_LOCAL = "org.openintents.safe.bundle.EXTRA_IS_REMOTE"; @@ -96,7 +96,7 @@ public class AskPassword extends Activity { return; } - if (debug) Log.d(TAG, "onCreate()"); + if (debug) Log.d(TAG,"onCreate("+icicle+")"); dbHelper = new DBHelper(this); diff --git a/src/org/openintents/safe/CategoryEdit.java b/src/org/openintents/safe/CategoryEdit.java index faf3e55..25832dd 100644 --- a/src/org/openintents/safe/CategoryEdit.java +++ b/src/org/openintents/safe/CategoryEdit.java @@ -57,13 +57,10 @@ public class CategoryEdit extends Activity { public void onCreate(Bundle icicle) { super.onCreate(icicle); - if (debug) Log.d(TAG, "onCreate"); + if (debug) Log.d(TAG,"onCreate("+icicle+")"); frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); String title = getResources().getString(R.string.app_name) + " - " + @@ -81,8 +78,10 @@ public class CategoryEdit extends Activity { Bundle extras = getIntent().getExtras(); RowId = extras != null ? extras.getLong(CategoryList.KEY_ID) : null; } - - populateFields(); + if ((RowId==null) || (RowId<1)) { + finish(); // no valid category + return; + } confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { @@ -119,7 +118,7 @@ public class CategoryEdit extends Activity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } @@ -132,9 +131,12 @@ public class CategoryEdit extends Activity { startActivity(frontdoor); return; } - populateFields(); IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); + + Passwords.Initialize(this); + + populateFields(); } private void saveState() { diff --git a/src/org/openintents/safe/CategoryList.java b/src/org/openintents/safe/CategoryList.java index bb6ebff..318b2d5 100644 --- a/src/org/openintents/safe/CategoryList.java +++ b/src/org/openintents/safe/CategoryList.java @@ -68,7 +68,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; */ public class CategoryList extends ListActivity { - private static boolean debug = false; + private static boolean debug = true; private static final String TAG = "CategoryList"; // Menu Item order @@ -197,25 +197,12 @@ public class CategoryList extends ListActivity { public void onCreate(Bundle icicle) { super.onCreate(icicle); - if (debug) Log.d(TAG,"onCreate()"); + if (debug) Log.d(TAG,"onCreate("+icicle+")"); restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); - if (isSignedIn()==false) { - Intent frontdoor = new Intent(this, FrontDoor.class); - frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - startActivity(frontdoor); - return; - } - - try { - Passwords.InitCrypto(CryptoHelper.EncryptionMedium, salt, masterKey); - } catch (Exception e) { - e.printStackTrace(); - Toast.makeText(CategoryList.this, "CategoryList: " + getString(R.string.crypto_error), - Toast.LENGTH_SHORT).show(); - } - + Passwords.Initialize(this); + setContentView(R.layout.cat_list); String title = getResources().getString(R.string.app_name) + " - " + getResources().getString(R.string.categories); @@ -232,8 +219,6 @@ public class CategoryList extends ListActivity { filter.addAction (CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); -// fillData(); - final ListView list = getListView(); list.setFocusable(true); list.setOnCreateContextMenuListener(this); @@ -259,6 +244,8 @@ public class CategoryList extends ListActivity { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); lockOnScreenLock = sp.getBoolean(Preferences.PREFERENCE_LOCK_ON_SCREEN_LOCK, true); + Passwords.Initialize(this); + ListAdapter la=getListAdapter(); if (la!=null) { if (debug) Log.d(TAG,"onResume: count="+la.getCount()); @@ -307,7 +294,7 @@ public class CategoryList extends ListActivity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } diff --git a/src/org/openintents/safe/ChangePass.java b/src/org/openintents/safe/ChangePass.java index 2c5d6c6..687ec8b 100644 --- a/src/org/openintents/safe/ChangePass.java +++ b/src/org/openintents/safe/ChangePass.java @@ -94,9 +94,6 @@ public class ChangePass extends Activity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); setContentView(R.layout.chg_pass); @@ -130,7 +127,7 @@ public class ChangePass extends Activity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } @@ -146,6 +143,8 @@ public class ChangePass extends Activity { } IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); + + Passwords.Initialize(this); } @Override diff --git a/src/org/openintents/safe/Help.java b/src/org/openintents/safe/Help.java index e554e39..18e2a8c 100644 --- a/src/org/openintents/safe/Help.java +++ b/src/org/openintents/safe/Help.java @@ -63,9 +63,6 @@ public class Help extends Activity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); //Setup layout @@ -113,7 +110,7 @@ public class Help extends Activity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } diff --git a/src/org/openintents/safe/IntentHandler.java b/src/org/openintents/safe/IntentHandler.java index c0f2fe2..a49f1a0 100644 --- a/src/org/openintents/safe/IntentHandler.java +++ b/src/org/openintents/safe/IntentHandler.java @@ -49,7 +49,7 @@ import android.widget.Toast; */ public class IntentHandler extends Activity { - private static final boolean debug = false; + private static final boolean debug = true; private static String TAG = "IntentHandler"; private static final int REQUEST_CODE_ASK_PASSWORD = 1; diff --git a/src/org/openintents/safe/PassEdit.java b/src/org/openintents/safe/PassEdit.java index 08fdbda..583e0d8 100644 --- a/src/org/openintents/safe/PassEdit.java +++ b/src/org/openintents/safe/PassEdit.java @@ -47,7 +47,7 @@ import android.widget.Toast; */ public class PassEdit extends Activity { - private static boolean debug = false; + private static boolean debug = true; private static String TAG = "PassEdit"; public static final int REQUEST_GEN_PASS = 10; @@ -58,6 +58,12 @@ public class PassEdit extends Activity { public static final int GEN_PASSWORD_INDEX = Menu.FIRST + 3; public static final int RESULT_DELETED = RESULT_FIRST_USER; + + public static final String KEY_DESCRIPTION = "description"; + public static final String KEY_WEBSITE = "website"; + public static final String KEY_USERNAME = "username"; + public static final String KEY_PASSWORD = "password"; + public static final String KEY_NOTE = "note"; private EditText descriptionText; private EditText passwordText; @@ -86,20 +92,36 @@ public class PassEdit extends Activity { public void onCreate(Bundle icicle) { super.onCreate(icicle); - if (debug) Log.d(TAG,"onCreate()"); - + if (debug) Log.d(TAG,"onCreate("+icicle+")"); + + RowId = icicle != null ? icicle.getLong(PassList.KEY_ID) : null; + if (RowId == null) { + Bundle extras = getIntent().getExtras(); + RowId = extras != null ? extras.getLong(PassList.KEY_ID) : null; + } + CategoryId = icicle != null ? icicle.getLong(PassList.KEY_CATEGORY_ID) : null; + if (CategoryId == null) { + Bundle extras = getIntent().getExtras(); + CategoryId = extras != null ? extras.getLong(PassList.KEY_CATEGORY_ID) : null; + } + if (debug) Log.d(TAG,"RowId="+RowId); + if (debug) Log.d(TAG,"CategoryId="+CategoryId); + + if ((RowId==null) || (CategoryId==null) || + (RowId<1) || (CategoryId<1)) { + // invalid Row or Category + finish(); + return; + } + frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); String title = getResources().getString(R.string.app_name) + " - " + getResources().getString(R.string.edit_entry); setTitle(title); - setContentView(R.layout.pass_edit); descriptionText = (EditText) findViewById(R.id.description); @@ -108,20 +130,19 @@ public class PassEdit extends Activity { noteText = (EditText) findViewById(R.id.note); websiteText = (EditText) findViewById(R.id.website); - Button goButton = (Button) findViewById(R.id.go); - - RowId = icicle != null ? icicle.getLong(PassList.KEY_ID) : null; - if (RowId == null) { - Bundle extras = getIntent().getExtras(); - RowId = extras != null ? extras.getLong(PassList.KEY_ID) : null; - } - CategoryId = icicle != null ? icicle.getLong(PassList.KEY_CATEGORY_ID) : null; - if (CategoryId == null) { - Bundle extras = getIntent().getExtras(); - CategoryId = extras != null ? extras.getLong(PassList.KEY_CATEGORY_ID) : null; + if (icicle!=null) { + String plainDescription = icicle.getString(PassEdit.KEY_DESCRIPTION); + if (plainDescription == null) { + descriptionText.setText(plainDescription); + populated=true; + } + String plainPassword = icicle.getString(PassEdit.KEY_PASSWORD); + String plainUsername = icicle.getString(PassEdit.KEY_USERNAME); + String plainNote = icicle.getString(PassEdit.KEY_NOTE); + String plainWebsite = icicle.getString(PassEdit.KEY_WEBSITE); } - if (debug) Log.d(TAG,"RowId="+RowId); - if (debug) Log.d(TAG,"CategoryId="+CategoryId); + + Button goButton = (Button) findViewById(R.id.go); entryEdited = false; @@ -167,18 +188,32 @@ public class PassEdit extends Activity { outState.putLong(PassList.KEY_ID, -1); } outState.putLong(PassList.KEY_CATEGORY_ID, CategoryId); + + String plainDescription = getTextFromField(descriptionText); + String plainWebsite = getTextFromField(websiteText); + String plainUsername = getTextFromField(usernameText); + String plainPassword = getTextFromField(passwordText); + String plainNote = getTextFromField(noteText); + + outState.putString(PassEdit.KEY_DESCRIPTION, plainDescription); + outState.putString(PassEdit.KEY_WEBSITE, plainWebsite); + outState.putString(PassEdit.KEY_USERNAME, plainUsername); + outState.putString(PassEdit.KEY_PASSWORD, plainPassword); + outState.putString(PassEdit.KEY_NOTE, plainNote); } @Override protected void onPause() { super.onPause(); + if (debug) Log.d(TAG,"onResume()"); + if (isFinishing() && discardEntry==false) { savePassword(); } try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } @@ -189,13 +224,17 @@ public class PassEdit extends Activity { if (debug) Log.d(TAG,"onResume()"); if (CategoryList.isSignedIn()==false) { - saveState(); + if (Passwords.isCryptoInitialized()) { + saveState(); + } startActivity(frontdoor); return; } IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); + Passwords.Initialize(this); + populateFields(); } @@ -386,6 +425,19 @@ public class PassEdit extends Activity { } } + /** + * Get the text from an EditText field. + * + * @param e EditText to retrieve text from. + * @return The field's text. If e==null returns null. + */ + private String getTextFromField(EditText e) { + if (e==null) { + return null; + } + return e.getText().toString(); + } + @Override public void onUserInteraction() { super.onUserInteraction(); diff --git a/src/org/openintents/safe/PassGen.java b/src/org/openintents/safe/PassGen.java index 3fc8d12..56a2d07 100644 --- a/src/org/openintents/safe/PassGen.java +++ b/src/org/openintents/safe/PassGen.java @@ -130,14 +130,12 @@ public class PassGen extends Activity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); setContentView(R.layout.pass_gen); - String title = getResources().getString(R.string.app_name) + " - Generate Password"; + String title = getString(R.string.app_name) + " - " + + getString(R.string.generate_password); setTitle(title); pass_view = (EditText) findViewById(R.id.pass_view); diff --git a/src/org/openintents/safe/PassList.java b/src/org/openintents/safe/PassList.java index e3cadb4..8da645a 100644 --- a/src/org/openintents/safe/PassList.java +++ b/src/org/openintents/safe/PassList.java @@ -61,7 +61,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; */ public class PassList extends ListActivity { - private static final boolean debug = false; + private static final boolean debug = true; private static final String TAG = "PassList"; // Menu Item order @@ -134,34 +134,24 @@ public class PassList extends ListActivity { public void onCreate(Bundle icicle) { super.onCreate(icicle); - if (debug) Log.d(TAG,"onCreate()"); - - frontdoor = new Intent(this, FrontDoor.class); - frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - return; - } - restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); + if (debug) Log.d(TAG,"onCreate("+icicle+")"); - setContentView(R.layout.pass_list); - CategoryId = icicle != null ? icicle.getLong(CategoryList.KEY_ID) : null; if (CategoryId == null) { Bundle extras = getIntent().getExtras(); CategoryId = extras != null ? extras.getLong(CategoryList.KEY_ID) : null; } - if (CategoryId<1) { - finish(); // no valid category less than one + if (debug) Log.d(TAG,"CategoryId="+CategoryId); + if ((CategoryId==null) || (CategoryId<1)) { + finish(); // no valid category return; } - - String categoryName=Passwords.getCategoryEntry(CategoryId).plainName; - String title = getResources().getString(R.string.app_name) + " - " + - getResources().getString(R.string.passwords) + " -" + - categoryName; - setTitle(title); -// fillData(); + frontdoor = new Intent(this, FrontDoor.class); + frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); + restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); + + setContentView(R.layout.pass_list); final ListView list = getListView(); list.setFocusable(true); @@ -175,6 +165,7 @@ public class PassList extends ListActivity { protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); + if (debug) Log.d(TAG,"onSaveInstanceState(): CategoryId="+CategoryId); // remember which Category we're looking at if (CategoryId != null) { outState.putLong(CategoryList.KEY_ID, CategoryId); @@ -197,7 +188,7 @@ public class PassList extends ListActivity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } removeDialog(DECRYPT_PROGRESS_KEY); } @@ -215,6 +206,14 @@ public class PassList extends ListActivity { IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); + Passwords.Initialize(this); + + String categoryName=Passwords.getCategoryEntry(CategoryId).plainName; + String title = getResources().getString(R.string.app_name) + " - " + + getResources().getString(R.string.passwords) + " -" + + categoryName; + setTitle(title); + ListAdapter la=getListAdapter(); if (la!=null) { if (debug) Log.d(TAG,"onResume: count="+la.getCount()); @@ -288,6 +287,7 @@ public class PassList extends ListActivity { fillerThread = new Thread(new Runnable() { public void run(){ + if (debug) Log.d(TAG,"CategoryId="+CategoryId); rows=Passwords.getPassEntries(CategoryId, true, true); passDescriptions.clear(); if (rows!=null) { diff --git a/src/org/openintents/safe/PassView.java b/src/org/openintents/safe/PassView.java index 51e86c8..ef000b9 100644 --- a/src/org/openintents/safe/PassView.java +++ b/src/org/openintents/safe/PassView.java @@ -39,8 +39,6 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.Window; -import android.view.WindowManager; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; @@ -52,7 +50,7 @@ import android.widget.Toast; */ public class PassView extends Activity implements View.OnClickListener { - private static boolean debug = false; + private static boolean debug = true; private static String TAG = "PassView"; public static final int EDIT_PASSWORD_INDEX = Menu.FIRST; @@ -87,13 +85,10 @@ public class PassView extends Activity implements View.OnClickListener { public void onCreate(Bundle icicle) { super.onCreate(icicle); - if (debug) Log.d(TAG,"onCreate()"); + if (debug) Log.d(TAG,"onCreate("+icicle+")"); frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); String title = getResources().getString(R.string.app_name) + " - " @@ -126,8 +121,12 @@ public class PassView extends Activity implements View.OnClickListener { CategoryId = extras != null ? extras.getLong(PassList.KEY_CATEGORY_ID) : null; } - populateFields(); - + if ((RowId==null) || (CategoryId==null) || + (RowId<1) || (CategoryId<1)) { + // invalid Row or Category + finish(); + return; + } goButton.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { String link = websiteText.getText().toString(); @@ -178,14 +177,8 @@ public class PassView extends Activity implements View.OnClickListener { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } - // hide the window from view - Window w=getWindow(); - WindowManager.LayoutParams attrs=w.getAttributes(); - attrs.alpha=0; - w.setAttributes(attrs); -// w.setLayout(0, 0); } @Override @@ -200,12 +193,10 @@ public class PassView extends Activity implements View.OnClickListener { } IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); - // show the window - Window w=getWindow(); - WindowManager.LayoutParams attrs=w.getAttributes(); - attrs.alpha=1; - w.setAttributes(attrs); -// w.setLayout(getWallpaperDesiredMinimumWidth(), getWallpaperDesiredMinimumWidth()); + + Passwords.Initialize(this); + + populateFields(); } @Override diff --git a/src/org/openintents/safe/Passwords.java b/src/org/openintents/safe/Passwords.java index fbd2a77..b8e3d32 100644 --- a/src/org/openintents/safe/Passwords.java +++ b/src/org/openintents/safe/Passwords.java @@ -27,6 +27,7 @@ import java.util.Set; import android.content.Context; import android.util.Log; +import android.widget.Toast; /** * Abstraction layer for storing encrypted and decrypted versions @@ -39,7 +40,7 @@ import android.util.Log; */ public class Passwords { - private static final boolean debug = false; + private static final boolean debug = true; private static final String TAG = "Passwords"; private static HashMap passEntries=null; @@ -49,6 +50,8 @@ public class Passwords { private static HashMap> packageAccessEntries=null; private static CryptoHelper ch=null; + private static boolean cryptoInitialized=false; + private static DBHelper dbHelper=null; public static void Initialize(Context ctx) { @@ -57,6 +60,21 @@ public class Passwords { if (ch==null) { ch = new CryptoHelper(); } + if ((cryptoInitialized==false) && + (CategoryList.getSalt()!=null) && + (CategoryList.getMasterKey()!=null)) + { + try { + Passwords.InitCrypto(CryptoHelper.EncryptionMedium, + CategoryList.getSalt(), CategoryList.getMasterKey()); + cryptoInitialized=true; + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(ctx, "CategoryList: " + ctx.getString(R.string.crypto_error), + Toast.LENGTH_SHORT).show(); + } + } + if (dbHelper==null) { dbHelper = new DBHelper(ctx); } @@ -88,6 +106,7 @@ public class Passwords { public static void InitCrypto(int strength, String salt, String masterKey) throws Exception { + if (debug) Log.d(TAG,"InitCrypto("+strength+","+salt+","+masterKey); try { ch.init(strength,salt); ch.setPassword(masterKey); @@ -98,6 +117,9 @@ public class Passwords { } } + public static boolean isCryptoInitialized() { + return cryptoInitialized; + } public static void deleteAll() { dbHelper.deleteDatabase(); Reset(); @@ -256,6 +278,7 @@ public class Passwords { } public static List getPassEntries(long categoryId, boolean decrypt, boolean descriptionOnly) { + if (debug) Log.d(TAG,"getPassEntries("+categoryId+","+decrypt+","+descriptionOnly+")"); Collection passwords=passEntries.values(); List passList=new ArrayList(); Iterator passIter=passwords.iterator(); diff --git a/src/org/openintents/safe/Preferences.java b/src/org/openintents/safe/Preferences.java index ffb0619..6b510f3 100644 --- a/src/org/openintents/safe/Preferences.java +++ b/src/org/openintents/safe/Preferences.java @@ -43,9 +43,6 @@ public class Preferences extends PreferenceActivity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); // Load the preferences from an XML resource @@ -75,7 +72,7 @@ public class Preferences extends PreferenceActivity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } diff --git a/src/org/openintents/safe/Restore.java b/src/org/openintents/safe/Restore.java index a25c7bc..9bdbadd 100644 --- a/src/org/openintents/safe/Restore.java +++ b/src/org/openintents/safe/Restore.java @@ -88,12 +88,10 @@ public class Restore extends Activity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if ((!firstTime) && (CategoryList.isSignedIn()==false)) { - startActivity(frontdoor); - return; - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); + Passwords.Initialize(this); + setContentView(R.layout.restore); String title = getResources().getString(R.string.app_name) + " - " + getResources().getString(R.string.restore); @@ -146,7 +144,7 @@ public class Restore extends Activity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } diff --git a/src/org/openintents/safe/Search.java b/src/org/openintents/safe/Search.java index e106675..ebb2fe9 100644 --- a/src/org/openintents/safe/Search.java +++ b/src/org/openintents/safe/Search.java @@ -98,9 +98,6 @@ public class Search extends ListActivity { frontdoor = new Intent(this, FrontDoor.class); frontdoor.setAction(CryptoIntents.ACTION_AUTOLOCK); - if (CategoryList.isSignedIn()==false) { - startActivity(frontdoor); - } restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER); etSearchCriteria = (EditText) findViewById(R.id.search_criteria); @@ -132,7 +129,7 @@ public class Search extends ListActivity { try { unregisterReceiver(mIntentReceiver); } catch (IllegalArgumentException e) { - if (debug) Log.d(TAG,"IllegalArgumentException"); + //if (debug) Log.d(TAG,"IllegalArgumentException"); } } @@ -148,7 +145,8 @@ public class Search extends ListActivity { } IntentFilter filter = new IntentFilter(CryptoIntents.ACTION_CRYPTO_LOGGED_OUT); registerReceiver(mIntentReceiver, filter); - + + Passwords.Initialize(this); } protected void onListItemClick(ListView l, View v, int position, long id) { -- 2.50.1