{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/comments/31298540","id":31298540,"diff_hunk":"@@ -918,47 +917,93 @@ else if(needed == SessionFrame.STATE_COMMAND_ID) {\n             //overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);\n         }\n     }\n-    \n+\n+    /**\n+     * Create a form record and launch form entry activity. If there is an\n+     * existing incomplete form that uses the same case, ask the user if they\n+     * want to edit or delete that one.\n+     *\n+     * @param state Needed for FormRecord manipulations\n+     */\n     private void startFormEntry(AndroidSessionWrapper state) throws SessionUnavailableException{\n-        try {\n-            //If this is a new record (never saved before), which currently all should be \n-            if(state.getFormRecordId() == -1) {\n-                    \n-                //If form management isn't enabled we can't have these old forms around anyway\n-                if(CommCarePreferences.isIncompleteFormsEnabled()) {\n-                    //First, see if we've already started this form before\n-                    SessionStateDescriptor existing = state.searchForDuplicates();\n-                    \n-                    //I'm not proud of the second clause, here. Basically, only ask if we should continue entry if the\n-                    //saved state actually involved selecting some data.\n-                    if(existing != null && existing.getSessionDescriptor().contains(SessionFrame.STATE_DATUM_VAL)) {\n-                        createAskUseOldDialog(state, existing);\n-                        return;\n-                    }\n+        if (state.getFormRecordId() == -1) {\n+            if (CommCarePreferences.isIncompleteFormsEnabled() &&\n+                    state.getSessionStateDescriptor().getSessionDescriptor().contains(SessionFrame.STATE_DATUM_VAL)) {\n+                // Are existing (incomplete) forms using the same case?\n+                SessionStateDescriptor existing = state.searchForDuplicates();\n+                if (existing != null) {\n+                    // Ask user if they want to just edit existing form\n+                    // that uses the same case.\n+                    createAskUseOldDialog(state, existing);\n+                    return;\n                 }\n-                \n-                //Otherwise, generate a stub record and commit it\n-                state.commitStub();\n-            } else {\n-                Logger.log(\"form-entry\", \"Somehow ended up starting form entry with old state?\");\n             }\n-            \n-            //We should now have a valid record for our state. Time to get to form entry.\n-            FormRecord record = state.getFormRecord();\n \n-            if (platform == null &&\n-                    CommCareApplication._().getCurrentApp() != null) {\n-                platform = CommCareApplication._().getCommCarePlatform();\n-            }\n+            // Generate a stub form record and commit it\n+            state.commitStub();\n+        } else {\n+            Logger.log(\"form-entry\",\n+                    \"Somehow ended up starting form entry with old state?\");\n+        }\n \n-            //TODO: May need to pass session over manually\n-            formEntry(platform.getFormContentUri(record.getFormNamespace()), record, CommCareActivity.getTitle(this, null));\n-            \n-        } catch (StorageFullException e) {\n-            throw new RuntimeException(e);\n+        FormRecord record = state.getFormRecord();\n+\n+        if (platform == null &&\n+                CommCareApplication._().getCurrentApp() != null) {\n+            platform = CommCareApplication._().getCommCarePlatform();\n         }\n+\n+        formEntry(platform.getFormContentUri(record.getFormNamespace()),\n+                record, CommCareActivity.getTitle(this, null));\n     }\n-    \n+\n+    private void formEntry(Uri formUri, FormRecord r) throws SessionUnavailableException{\n+        formEntry(formUri, r, null);\n+    }\n+\n+    private void formEntry(Uri formUri, FormRecord r, String headerTitle) throws SessionUnavailableException {\n+        //TODO: This is... just terrible. Specify where external instance data","path":"app/src/org/commcare/dalvik/activities/CommCareHomeActivity.java","position":96,"original_position":96,"commit_id":"14c5d8289dee30823003b3a2e521560840c2c703","original_commit_id":"db364b00f9488142685904c409b5b31b4f4318b8","user":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"body":"Moved this method next to startFormEntry and ran the code re-formatter on it.","created_at":"2015-05-29T04:35:56Z","updated_at":"2015-05-29T04:35:56Z","html_url":"https://github.com/dimagi/commcare-odk/pull/315#discussion_r31298540","pull_request_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/comments/31298540"},"html":{"href":"https://github.com/dimagi/commcare-odk/pull/315#discussion_r31298540"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315","id":36473121,"html_url":"https://github.com/dimagi/commcare-odk/pull/315","diff_url":"https://github.com/dimagi/commcare-odk/pull/315.diff","patch_url":"https://github.com/dimagi/commcare-odk/pull/315.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/315","number":315,"state":"open","locked":false,"title":"startFormEntry refactor","user":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"body":"Noticed that a (most likely) costly incomplete form search could often be ruled out by checking if the session descriptor contained \"CASE_ID\" in it first.\r\n\r\nFigured I'd do some style refactoring while I was changing that.","created_at":"2015-05-29T04:24:01Z","updated_at":"2015-05-29T04:35:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7494f7f8a015ff7ec5d30eecc65ba0858438f16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/315/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-odk/statuses/14c5d8289dee30823003b3a2e521560840c2c703","head":{"label":"dimagi:reorder-cond-to-avoid-form-search","ref":"reorder-cond-to-avoid-form-search","sha":"14c5d8289dee30823003b3a2e521560840c2c703","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20939877,"name":"commcare-odk","full_name":"dimagi/commcare-odk","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-odk","description":"","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-odk","forks_url":"https://api.github.com/repos/dimagi/commcare-odk/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-odk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-odk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-odk/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-odk/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-odk/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-odk/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-odk/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-odk/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-odk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-odk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-odk/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-odk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-odk/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-odk/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-odk/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-odk/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-odk/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-odk/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-odk/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-odk/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-odk/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-odk/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-odk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-odk/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-odk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-odk/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-odk/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-odk/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-odk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-odk/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-odk/releases{/id}","created_at":"2014-06-17T21:17:26Z","updated_at":"2015-05-06T16:04:54Z","pushed_at":"2015-05-29T04:25:37Z","git_url":"git://github.com/dimagi/commcare-odk.git","ssh_url":"git@github.com:dimagi/commcare-odk.git","clone_url":"https://github.com/dimagi/commcare-odk.git","svn_url":"https://github.com/dimagi/commcare-odk","homepage":null,"size":53961,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":3,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"d8d42a09f06afd03fe095a15fbaba79c005967c9","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20939877,"name":"commcare-odk","full_name":"dimagi/commcare-odk","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-odk","description":"","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-odk","forks_url":"https://api.github.com/repos/dimagi/commcare-odk/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-odk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-odk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-odk/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-odk/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-odk/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-odk/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-odk/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-odk/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-odk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-odk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-odk/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-odk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-odk/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-odk/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-odk/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-odk/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-odk/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-odk/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-odk/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-odk/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-odk/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-odk/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-odk/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-odk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-odk/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-odk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-odk/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-odk/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-odk/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-odk/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-odk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-odk/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-odk/releases{/id}","created_at":"2014-06-17T21:17:26Z","updated_at":"2015-05-06T16:04:54Z","pushed_at":"2015-05-29T04:25:37Z","git_url":"git://github.com/dimagi/commcare-odk.git","ssh_url":"git@github.com:dimagi/commcare-odk.git","clone_url":"https://github.com/dimagi/commcare-odk.git","svn_url":"https://github.com/dimagi/commcare-odk","homepage":null,"size":53961,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":20,"forks":4,"open_issues":20,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315"},"html":{"href":"https://github.com/dimagi/commcare-odk/pull/315"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-odk/issues/315"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-odk/issues/315/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-odk/pulls/315/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-odk/statuses/14c5d8289dee30823003b3a2e521560840c2c703"}}}}