]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: Suggested change of structure. Unfortunately, this does not work yet, so...
authorpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 15 Mar 2009 03:26:21 +0000 (03:26 +0000)
committerpeli0101 <peli0101@72b678ce-9140-0410-bee8-679b907dd61a>
Sun, 15 Mar 2009 03:26:21 +0000 (03:26 +0000)
git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@1993 72b678ce-9140-0410-bee8-679b907dd61a

AndroidManifest.xml
src/org/openintents/safe/CategoryList.java
src/org/openintents/safe/Passwords.java

index 7262ba23a262e9616c43d0aca4c35ad025a4027c..8797381a1d173143d0506c9ccc2d40b23338662b 100644 (file)
@@ -36,7 +36,7 @@
                        android:theme="@android:style/Theme.Translucent.NoTitleBar">
                <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-                       <category android:name="android.intent.category.LAUNCHER" />\r
+                       <!-- <category android:name="android.intent.category.LAUNCHER" />  -->\r
             </intent-filter>           
         </activity>
         
         <activity class=".PassView" android:name="PassView" android:label="@string/app_name" />
         <activity class=".PassList" android:name="PassList" android:label="@string/app_name" />
         <activity class=".PassEdit" android:name="PassEdit" android:label="@string/app_name" />
-        <activity class=".CategoryList" android:name="CategoryList" android:label="@string/app_name" />
+        <activity class=".CategoryList" android:name="CategoryList" android:label="@string/app_name" >\r
+               <intent-filter>\r
+                <action android:name="android.intent.action.MAIN" />\r
+                       <category android:name="android.intent.category.LAUNCHER" />\r
+            </intent-filter>\r
+        </activity>
         <activity class=".AskPassword" android:name="AskPassword" android:label="@string/app_name"/>\r
         <activity class=".Help" android:name="Help" android:label="@string/app_name" />
         <activity class=".ChangePass" android:name="ChangePass" android:label="@string/app_name" />
index 6150113450f76f650b5f20bb8361f0237197fd7e..f6c0f862cd9605a3aebb45f60a944cfc7c31d642 100644 (file)
@@ -90,6 +90,7 @@ public class CategoryList extends ListActivity {
     public static final int REQUEST_ADD_CATEGORY = 2;
     public static final int REQUEST_OPEN_CATEGORY = 3;
     public static final int REQUEST_RESTORE = 4;
+    public static final int REQUEST_ASK_PASSWORD = 5;
     
     protected static final int MSG_IMPORT = 0x101; 
     protected static final int MSG_FILLDATA = MSG_IMPORT + 1; 
@@ -133,6 +134,7 @@ public class CategoryList extends ListActivity {
             }
         }
     };
+    boolean mIntentReceiverRegistered = false;
 
     public Handler myViewUpdateHandler = new Handler(){
        // @Override
@@ -196,9 +198,9 @@ public class CategoryList extends ListActivity {
                
                if (isSignedIn()==false) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
-                       startActivity(frontdoor);               
-                       finish();
-                       return;
+                       startActivityForResult(frontdoor, REQUEST_ASK_PASSWORD);                
+                       //finish();
+                       //return;
        }
                
                try {
@@ -224,6 +226,7 @@ public class CategoryList extends ListActivity {
         filter.addAction(Intent.ACTION_SCREEN_OFF);
         filter.addAction (CryptoIntents.ACTION_CRYPTO_LOGGED_OUT);
         registerReceiver(mIntentReceiver, filter);
+        mIntentReceiverRegistered = true;
 
                fillData();
 
@@ -241,12 +244,13 @@ public class CategoryList extends ListActivity {
 
                if (isSignedIn()==false) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
-                       startActivity(frontdoor);               
-                       finish();
-                       return;
-       }
+                       startActivityForResult(frontdoor, REQUEST_ASK_PASSWORD);                
+                       //finish();
+                       //return;
+       } else {
 
-        showFirstTimeWarningDialog();
+               showFirstTimeWarningDialog();
+       }
     }
 
        /**
@@ -298,7 +302,10 @@ public class CategoryList extends ListActivity {
     @Override
     public void onDestroy() {
                super.onDestroy();
-               unregisterReceiver(mIntentReceiver);
+               if (mIntentReceiverRegistered) {
+                       unregisterReceiver(mIntentReceiver);
+                       mIntentReceiverRegistered = false;
+               }
                if (debug) Log.d(TAG,"onDestroy()");
     }
     @Override
@@ -578,8 +585,8 @@ public class CategoryList extends ListActivity {
                masterKey=null;
            Intent frontdoor = new Intent(this, FrontDoor.class);
            frontdoor.setAction(Intent.ACTION_MAIN);
-           startActivity(frontdoor);
-           finish();
+           startActivityForResult(frontdoor, REQUEST_ASK_PASSWORD);
+           //finish();
     }
     
        /**
@@ -626,12 +633,34 @@ public class CategoryList extends ListActivity {
     protected void onActivityResult(int requestCode, int resultCode, Intent i) {
        super.onActivityResult(requestCode, resultCode, i);
 
+       switch (requestCode) {
+       case REQUEST_ADD_CATEGORY:
+       case REQUEST_OPEN_CATEGORY:
+       case REQUEST_RESTORE:
+               if (resultCode == RESULT_OK) {
+                       fillData();
+               }
+               break;
+       case REQUEST_EDIT_CATEGORY:
+               if (resultCode == RESULT_OK) {
+                       fillData();
+                       setSelection(lastPosition);
+               }
+               break;
+       case REQUEST_ASK_PASSWORD:
+               if (isSignedIn()==false) {              
+                       finish();
+               }
+               break;
+       }
+       /*
        if (resultCode == RESULT_OK) {
                fillData();
                if (requestCode==REQUEST_EDIT_CATEGORY) {
                        setSelection(lastPosition);
                }
        }
+       */
     }
 
     private void prePopulate() {
index 231317e0de748bf8089232266bbd41f3f3296f3e..a70829d0d8c8b59254acd09a92e16f1a1a9bf89b 100644 (file)
@@ -104,7 +104,11 @@ public class Passwords {
        }
        
        public static boolean getPrePopulate() {
-               return dbHelper.getPrePopulate();
+               if (dbHelper != null) {
+                       return dbHelper.getPrePopulate();
+               } else {
+                       return false;
+               }
        }
        
        public static void clearPrePopulate() {