From: rmceoin Date: Fri, 6 Mar 2009 01:16:00 +0000 (+0000) Subject: OI Safe: ensured all finish()'s have a return, fixed a bug X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=8570c74e6ebdba0424123e52aee01abceeae3755;p=android-vcpass-oisafe OI Safe: ensured all finish()'s have a return, fixed a bug 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 --- diff --git a/src/org/openintents/safe/CategoryEdit.java b/src/org/openintents/safe/CategoryEdit.java index 1295441..1a4c40a 100644 --- a/src/org/openintents/safe/CategoryEdit.java +++ b/src/org/openintents/safe/CategoryEdit.java @@ -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); } } diff --git a/src/org/openintents/safe/CategoryList.java b/src/org/openintents/safe/CategoryList.java index ffbecda..6150113 100644 --- a/src/org/openintents/safe/CategoryList.java +++ b/src/org/openintents/safe/CategoryList.java @@ -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(); diff --git a/src/org/openintents/safe/ChangePass.java b/src/org/openintents/safe/ChangePass.java index 0e06de3..d00faf2 100644 --- a/src/org/openintents/safe/ChangePass.java +++ b/src/org/openintents/safe/ChangePass.java @@ -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) { diff --git a/src/org/openintents/safe/Help.java b/src/org/openintents/safe/Help.java index 4f8e62f..e3422d8 100644 --- a/src/org/openintents/safe/Help.java +++ b/src/org/openintents/safe/Help.java @@ -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; } } diff --git a/src/org/openintents/safe/PassEdit.java b/src/org/openintents/safe/PassEdit.java index cdec050..b1f7f95 100644 --- a/src/org/openintents/safe/PassEdit.java +++ b/src/org/openintents/safe/PassEdit.java @@ -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(); } diff --git a/src/org/openintents/safe/PassGen.java b/src/org/openintents/safe/PassGen.java index 49840ff..071a8e9 100644 --- a/src/org/openintents/safe/PassGen.java +++ b/src/org/openintents/safe/PassGen.java @@ -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; } } diff --git a/src/org/openintents/safe/PassList.java b/src/org/openintents/safe/PassList.java index 287428f..3a6fffc 100644 --- a/src/org/openintents/safe/PassList.java +++ b/src/org/openintents/safe/PassList.java @@ -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; } } diff --git a/src/org/openintents/safe/PassView.java b/src/org/openintents/safe/PassView.java index d29545d..77c8a25 100644 --- a/src/org/openintents/safe/PassView.java +++ b/src/org/openintents/safe/PassView.java @@ -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; } } diff --git a/src/org/openintents/safe/Passwords.java b/src/org/openintents/safe/Passwords.java index d009d50..231317e 100644 --- a/src/org/openintents/safe/Passwords.java +++ b/src/org/openintents/safe/Passwords.java @@ -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 { diff --git a/src/org/openintents/safe/Preferences.java b/src/org/openintents/safe/Preferences.java index 22c8739..82a92e8 100644 --- a/src/org/openintents/safe/Preferences.java +++ b/src/org/openintents/safe/Preferences.java @@ -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; + } + } + } diff --git a/src/org/openintents/safe/Restore.java b/src/org/openintents/safe/Restore.java index 9b98ec9..4c8873c 100644 --- a/src/org/openintents/safe/Restore.java +++ b/src/org/openintents/safe/Restore.java @@ -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; } }