]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: major lifecycle updates. Moved several items from
authorrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Sat, 3 Oct 2009 22:42:11 +0000 (22:42 +0000)
committerrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Sat, 3 Oct 2009 22:42:11 +0000 (22:42 +0000)
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

15 files changed:
res/values/strings.xml
src/org/openintents/safe/AskPassword.java
src/org/openintents/safe/CategoryEdit.java
src/org/openintents/safe/CategoryList.java
src/org/openintents/safe/ChangePass.java
src/org/openintents/safe/Help.java
src/org/openintents/safe/IntentHandler.java
src/org/openintents/safe/PassEdit.java
src/org/openintents/safe/PassGen.java
src/org/openintents/safe/PassList.java
src/org/openintents/safe/PassView.java
src/org/openintents/safe/Passwords.java
src/org/openintents/safe/Preferences.java
src/org/openintents/safe/Restore.java
src/org/openintents/safe/Search.java

index 6b9817fb78297deec74d7443ed643b4b8a0c9dab..3c6362a313d6feff37f0400dca500b15854465c1 100644 (file)
        <string name="open_safe">Open OI Safe</string>\r
        <string name="lock">Lock</string>\r
        <string name="continue_text">Continue</string>\r
+       <string name="generate_password">Generate Password</string>\r
        <string name="pass_gen_length">Password Length</string>\r
        <string name="pass_gen_uppercase">Uppercase [A-Z]</string>\r
        <string name="pass_gen_lowercase">Lowercase [a-z]</string>\r
index ec8ac77e21a62e5dfd0712dedf88b4f79507c982..25489296cefc710c8b0b02aaffc6c93cb55f0180 100644 (file)
@@ -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);
                        
index faf3e552ebff9e5568d1c6c190f3ec6d20cc35c6..25832dd69f615d6b48131fac814213e7b150c54a 100644 (file)
@@ -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() {
index bb6ebffb8807402cf77db50e77d94cd6d617ba5c..318b2d518acbee83b638315f6d9de762d007f2ed 100644 (file)
@@ -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");
                }
     }
 
index 2c5d6c69bd9852324fd8a10dad6439a412f94239..687ec8b661610393c693062a5762c0f86c0e3ce5 100644 (file)
@@ -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
index e554e39a518fa72a9dd0f66abea7f70a5485dd53..18e2a8ceb4824fd1efcd069dc149f9dea62f7f41 100644 (file)
@@ -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");
                }
        }
 
index c0f2fe284a3ca03ec2eab973cdefd6dabf491c8b..a49f1a06b09d24de085b9de07f8481c3f1dadb69 100644 (file)
@@ -49,7 +49,7 @@ import android.widget.Toast;
  */\r
 public class IntentHandler extends Activity {\r
 \r
-       private static final boolean debug = false;\r
+       private static final boolean debug = true;\r
        private static String TAG = "IntentHandler";\r
        \r
        private static final int REQUEST_CODE_ASK_PASSWORD = 1;\r
index 08fdbda30d8866a92d27fd44199bc980be678b7b..583e0d8ab5a8df2f1f3f5d0e1e55633c1d4a3309 100644 (file)
@@ -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();
index 3fc8d12354ae162f3a6eb4967fb7cd9f4af683c0..56a2d07108465d2f4e5faab391ad9345f82c5862 100644 (file)
@@ -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);
index e3cadb40a23a87a5b419a4ec401785cff5544f22..8da645af3b3f138a036bd0b094e05cc3a009e0b1 100644 (file)
@@ -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) {
index 51e86c80b8ddf855012a1e7028ecda9a286ae1b1..ef000b98743b502a5c62028623d032d9d766736c 100644 (file)
@@ -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
index fbd2a770b77ef2c7571b6bcb10f22a5508abe777..b8e3d3269d2eb3c82542b283d2686d73027d1f43 100644 (file)
@@ -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<Long, PassEntry> passEntries=null;
@@ -49,6 +50,8 @@ public class Passwords {
        private static HashMap<Long, ArrayList<PackageAccessEntry>> 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<PassEntry> getPassEntries(long categoryId, boolean decrypt, boolean descriptionOnly) {
+               if (debug) Log.d(TAG,"getPassEntries("+categoryId+","+decrypt+","+descriptionOnly+")");
                Collection<PassEntry> passwords=passEntries.values();
                List<PassEntry> passList=new ArrayList<PassEntry>();
                Iterator<PassEntry> passIter=passwords.iterator();
index ffb0619ddba62ebb5af38d97be157f663d208a25..6b510f36d44cc366613a535fd520693714fec0e6 100644 (file)
@@ -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");
                }
        }
 
index a25c7bc57254392819e81b3182faaa597c42244a..9bdbadd5157f5d6b9b3be2ac393a86e41107d50a 100644 (file)
@@ -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");
                }
        }
 
index e1066754b5a7ab578eddd555e637c4b878098024..ebb2fe908d941c4c54ca2c01a8c0c4ab9d8966c4 100644 (file)
@@ -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) {