]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: ensured all finish()'s have a return, fixed a bug
authorrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 6 Mar 2009 01:16:00 +0000 (01:16 +0000)
committerrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Fri, 6 Mar 2009 01:16:00 +0000 (01:16 +0000)
with CategoryEdit with crash on orientation change.  Also made
all checks for isSignedIn() consistently formated.

git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@1972 72b678ce-9140-0410-bee8-679b907dd61a

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/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

index 1295441bc6525e20895ab421f8dbd35edbdf1e6b..1a4c40a51be14b317032924867c07ec4650f7b8e 100644 (file)
@@ -101,6 +101,7 @@ public class CategoryEdit extends Activity {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
                        finish();
+                       return;
                }
                populateFields();
     }
@@ -127,8 +128,11 @@ public class CategoryEdit extends Activity {
      */
     private void populateFields() {
        if (debug) Log.d(TAG, "populateFields");
-               if (RowId != null) {
+               if ((RowId != null) && (RowId > 0)) {
                    CategoryEntry catEntry = Passwords.getCategoryEntry(RowId);
+                   if (catEntry==null) {
+                       return;
+                   }
                    nameText.setText(catEntry.plainName);
                }
     }
index ffbecdabe89d8167ddeefe2dc3b283385afe1054..6150113450f76f650b5f20bb8361f0237197fd7e 100644 (file)
@@ -194,10 +194,11 @@ public class CategoryList extends ListActivity {
 
                restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
                
-               if (!isSignedIn()) {
+               if (isSignedIn()==false) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
                        finish();
+                       return;
        }
                
                try {
@@ -238,10 +239,11 @@ public class CategoryList extends ListActivity {
 
                if (debug) Log.d(TAG,"onResume()");
 
-               if (!isSignedIn()) {
+               if (isSignedIn()==false) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
                        finish();
+                       return;
        }
 
         showFirstTimeWarningDialog();
index 0e06de3038c549991df8c97fbc292f1461b4f438..d00faf25570e9cfe267e93a652fcd2422c54cbcb 100644 (file)
@@ -76,6 +76,7 @@ public class ChangePass extends Activity {
 
                if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
                }
                
                setContentView(R.layout.chg_pass);
@@ -108,6 +109,18 @@ public class ChangePass extends Activity {
                }
     }
 
+    @Override
+    protected void onResume() {
+               super.onResume();
+
+               if (debug) Log.d(TAG,"onResume()");
+
+               if (CategoryList.isSignedIn()==false) {
+                       finish();
+                       return;
+       }
+    }
+    
     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
index 4f8e62fdbadfa55831f076c68e03fd175293d4d5..e3422d8061516dbf3ee8d014f56d5de07caebb9d 100644 (file)
@@ -42,6 +42,11 @@ public class Help extends Activity {
     public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
 
+               if (CategoryList.isSignedIn()==false) {
+                       finish();
+                       return;
+               }
+
                //Setup layout
                setContentView(R.layout.help);
                String title = getResources().getString(R.string.app_name) + " - " +
@@ -80,14 +85,16 @@ public class Help extends Activity {
         }
 
     }
+
        @Override
        protected void onResume() {
                super.onResume();
 
                if (debug) Log.d(TAG,"onResume()");
 
-               if (CategoryList.isSignedIn() == false) {
+               if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
                }
        }
 
index cdec050d2a0529a526d815c1bc524ec2dffb96e1..b1f7f95039f15dcd6eb21b828f8c242d0b6afec5 100644 (file)
@@ -88,7 +88,7 @@ public class PassEdit extends Activity {
                if (debug) Log.d(TAG,"onCreate()");
                
                frontdoor = new Intent(this, FrontDoor.class);
-               if (!CategoryList.isSignedIn()) {
+               if (CategoryList.isSignedIn()==false) {
                        startActivity(frontdoor);
                        // normally we'd do a finish() here, but
                        // by starting frontdoor from here the user could
@@ -176,9 +176,10 @@ public class PassEdit extends Activity {
 
                if (debug) Log.d(TAG,"onResume()");
 
-               if (CategoryList.isSignedIn() == false) {
+               if (CategoryList.isSignedIn()==false) {
                        saveState();
                        finish();
+                       return;
                }
                populateFields();
        }
index 49840fff7638a1aba1f8c10153398a0c6afae28b..071a8e95c6937533d735ea778a170b5a309c1bf3 100644 (file)
@@ -106,6 +106,11 @@ public class PassGen extends Activity {
     public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                
+               if (CategoryList.isSignedIn()==false) {
+                       finish();
+                       return;
+               }
+
                setContentView(R.layout.pass_gen);
                
                String title = getResources().getString(R.string.app_name) + " - Generate Password";
@@ -193,8 +198,9 @@ public class PassGen extends Activity {
     protected void onResume() {
                super.onResume();
 
-               if (!CategoryList.isSignedIn()) {
+               if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
                }
     }
 
index 287428f53aa455f32b1f4deaae35ff43e1e23008..3a6fffc38ac114f877ac061a5bed7a67881a657a 100644 (file)
@@ -120,8 +120,9 @@ public class PassList extends ListActivity {
                super.onCreate(icicle);
                
                if (debug) Log.d(TAG,"onCreate()");
-               if (!CategoryList.isSignedIn()) {
+               if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
        }
                restartTimerIntent = new Intent (CryptoIntents.ACTION_RESTART_TIMER);
 
@@ -134,6 +135,7 @@ public class PassList extends ListActivity {
                }
                if (CategoryId<1) {
                        finish();       // no valid category less than one
+                       return;
                }
                
                String categoryName=Passwords.getCategoryEntry(CategoryId).plainName;
@@ -185,6 +187,7 @@ public class PassList extends ListActivity {
 
                if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
                }
     }
     
index d29545d826470379ab05ac6659ce396eb1d936ab..77c8a258687f751950c10addc169aa06bb3e9cac 100644 (file)
@@ -69,8 +69,9 @@ public class PassView extends Activity {
                super.onCreate(icicle);
 
                if (debug) Log.d(TAG,"onCreate()");
-               if (!CategoryList.isSignedIn()) {
+               if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
        }
 
                String title = getResources().getString(R.string.app_name) + " - "
@@ -158,8 +159,9 @@ public class PassView extends Activity {
 
                if (debug) Log.d(TAG,"onResume()");
 
-               if (CategoryList.isSignedIn() == false) {
+               if (CategoryList.isSignedIn()==false) {
                        finish();
+                       return;
                }
        }
 
index d009d502aa3a20faf80f4d2d1c287a9ef3340446..231317e0de748bf8089232266bbd41f3f3296f3e 100644 (file)
@@ -199,6 +199,9 @@ public class Passwords {
        
        public static CategoryEntry getCategoryEntry(Long id) {
                CategoryEntry catEntry=categoryEntries.get(id);
+               if (catEntry==null) {
+                       return null;
+               }
                if (catEntry.nameNeedsDecrypt) {
                        if (debug) Log.d(TAG,"decrypt cat");
                    try {
index 22c87396b5504a4efc31069a1cda9a12e0a11ac9..82a92e859bb2fc1c58d27fa13d07235318028fbb 100644 (file)
@@ -16,8 +16,23 @@ public class Preferences extends PreferenceActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         
+               if (CategoryList.isSignedIn()==false) {
+                       finish();
+                       return;
+               }
+
         // Load the preferences from an XML resource
         addPreferencesFromResource(R.xml.preferences);
     }
 
+    @Override
+       protected void onResume() {
+               super.onResume();
+
+               if (CategoryList.isSignedIn()==false) {
+                       finish();
+                       return;
+               }
+       }
+
 }
index 9b98ec90cc4466dd58879909dbd6d1242533d4ee..4c8873c480acb4053a56dd773fa14e777282ad05 100644 (file)
@@ -70,10 +70,11 @@ public class Restore extends Activity {
                    firstTime = extras != null ? extras.getBoolean(Restore.KEY_FIRST_TIME) : false;
                }
 
-               if ((!firstTime) && (!CategoryList.isSignedIn())) {
+               if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
                        finish();
+                       return;
                }
 
                setContentView(R.layout.restore);
@@ -127,10 +128,11 @@ public class Restore extends Activity {
                
                if (debug) Log.d(TAG,"onResume()");
                
-               if ((!firstTime) && (!CategoryList.isSignedIn())) {
+               if ((!firstTime) && (CategoryList.isSignedIn()==false)) {
                        Intent frontdoor = new Intent(this, FrontDoor.class);
                        startActivity(frontdoor);               
                        finish();
+                       return;
                }
        }