]> hydra-www.ietfng.org Git - android-vcpass-oisafe/commitdiff
OI Safe: corrected bug with PassEdit with coming back to life
authorrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Sat, 3 Oct 2009 23:38:56 +0000 (23:38 +0000)
committerrmceoin <rmceoin@72b678ce-9140-0410-bee8-679b907dd61a>
Sat, 3 Oct 2009 23:38:56 +0000 (23:38 +0000)
when there was a bundle saved.   Now using onRestoreInstanceState
which is only called because there was a previous onSaveInstanceState
called we can safely indicate that the fields are already populated.

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

src/org/openintents/safe/CategoryList.java
src/org/openintents/safe/PassEdit.java

index 318b2d518acbee83b638315f6d9de762d007f2ed..65be2fff6ba972f6fa7e23114616312522c7a752 100644 (file)
@@ -313,7 +313,7 @@ public class CategoryList extends ListActivity {
                try {
                        unregisterReceiver(mIntentReceiver);
                } catch (IllegalArgumentException e) {
-                       if (debug) Log.d(TAG,"IllegalArgumentException");
+                       //if (debug) Log.d(TAG,"IllegalArgumentException");
                }
     }
     @Override
index 583e0d8ab5a8df2f1f3f5d0e1e55633c1d4a3309..243efa77a694a57fd5314a2ec0e4ab1c5a44d441 100644 (file)
@@ -59,12 +59,6 @@ public class PassEdit extends Activity {
 
        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;
        private EditText usernameText;
@@ -130,18 +124,6 @@ public class PassEdit extends Activity {
                noteText = (EditText) findViewById(R.id.note);
                websiteText = (EditText) findViewById(R.id.website);
 
-               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);
-               }
-
                Button goButton = (Button) findViewById(R.id.go);
 
                entryEdited = false;
@@ -182,30 +164,30 @@ public class PassEdit extends Activity {
        @Override
        protected void onSaveInstanceState(Bundle outState) {
                super.onSaveInstanceState(outState);
+
+               if (debug) Log.d(TAG,"onSaveInstanceState()");
                if (RowId != null) {
                        outState.putLong(PassList.KEY_ID, RowId);
                } else {
                        outState.putLong(PassList.KEY_ID, -1);
                }
                outState.putLong(PassList.KEY_CATEGORY_ID, CategoryId);
+       }
+
+       @Override
+       protected void onRestoreInstanceState(Bundle inState) {
+               super.onRestoreInstanceState(inState);
 
-               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);
+               if (debug) Log.d(TAG,"onRestoreInstanceState("+inState+")");
+               // because the various EditText automatically handle state
+               // when we come back there is no need to re-populate
+               populated=true;
        }
 
        @Override
        protected void onPause() {
                super.onPause();
-               if (debug) Log.d(TAG,"onResume()");
+               if (debug) Log.d(TAG,"onPause()");
 
                if (isFinishing() && discardEntry==false) {
                        savePassword();