{"action":"created","comment":{"url":"https://api.github.com/repos/opendatakit/collect/pulls/comments/179634159","pull_request_review_id":109916084,"id":179634159,"diff_hunk":"@@ -0,0 +1,75 @@\n+/*\n+ * Copyright 2018 Nafundi\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.odk.collect.android.utilities;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+public class MediaManager {\n+\n+    private static MediaManager singleton;\n+    \n+    private Map<String, String> originalFiles;\n+    private Map<String, String> recentFiles;\n+\n+    private MediaManager() {\n+        originalFiles = new HashMap<>();\n+        recentFiles = new HashMap<>();\n+    }\n+\n+    public static MediaManager getInstance() {\n+        if (singleton == null) {\n+            singleton = new MediaManager();\n+        }\n+        return singleton;\n+    }\n+\n+    public void markOriginalFileOrDelete(String index, String fileName) {\n+        if (originalFiles.containsKey(index)) {\n+            MediaUtils.deleteImageFileFromMediaProvider(fileName);\n+        } else {\n+            originalFiles.put(index, fileName);\n+        }\n+    }\n+\n+    public void markRecentFile(String index, String fileName) {","path":"collect_app/src/main/java/org/odk/collect/android/utilities/MediaManager.java","position":49,"original_position":49,"commit_id":"226a83e0e77242cdad34e6661c72273811ed2808","original_commit_id":"226a83e0e77242cdad34e6661c72273811ed2808","user":{"login":"lognaturel","id":967540,"avatar_url":"https://avatars3.githubusercontent.com/u/967540?v=4","gravatar_id":"","url":"https://api.github.com/users/lognaturel","html_url":"https://github.com/lognaturel","followers_url":"https://api.github.com/users/lognaturel/followers","following_url":"https://api.github.com/users/lognaturel/following{/other_user}","gists_url":"https://api.github.com/users/lognaturel/gists{/gist_id}","starred_url":"https://api.github.com/users/lognaturel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lognaturel/subscriptions","organizations_url":"https://api.github.com/users/lognaturel/orgs","repos_url":"https://api.github.com/users/lognaturel/repos","events_url":"https://api.github.com/users/lognaturel/events{/privacy}","received_events_url":"https://api.github.com/users/lognaturel/received_events","type":"User","site_admin":false},"body":"It's not clear from the name that this may also delete a file. Maybe something like `replaceRecentFileForQuestion`?","created_at":"2018-04-06T00:20:05Z","updated_at":"2018-04-06T00:35:29Z","html_url":"https://github.com/opendatakit/collect/pull/2053#discussion_r179634159","pull_request_url":"https://api.github.com/repos/opendatakit/collect/pulls/2053","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/comments/179634159"},"html":{"href":"https://github.com/opendatakit/collect/pull/2053#discussion_r179634159"},"pull_request":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/2053"}}},"pull_request":{"url":"https://api.github.com/repos/opendatakit/collect/pulls/2053","id":177154036,"html_url":"https://github.com/opendatakit/collect/pull/2053","diff_url":"https://github.com/opendatakit/collect/pull/2053.diff","patch_url":"https://github.com/opendatakit/collect/pull/2053.patch","issue_url":"https://api.github.com/repos/opendatakit/collect/issues/2053","number":2053,"state":"open","locked":false,"title":"Media files are lost when user changes them but then ignores the changes","user":{"login":"grzesiek2010","id":3276264,"avatar_url":"https://avatars1.githubusercontent.com/u/3276264?v=4","gravatar_id":"","url":"https://api.github.com/users/grzesiek2010","html_url":"https://github.com/grzesiek2010","followers_url":"https://api.github.com/users/grzesiek2010/followers","following_url":"https://api.github.com/users/grzesiek2010/following{/other_user}","gists_url":"https://api.github.com/users/grzesiek2010/gists{/gist_id}","starred_url":"https://api.github.com/users/grzesiek2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grzesiek2010/subscriptions","organizations_url":"https://api.github.com/users/grzesiek2010/orgs","repos_url":"https://api.github.com/users/grzesiek2010/repos","events_url":"https://api.github.com/users/grzesiek2010/events{/privacy}","received_events_url":"https://api.github.com/users/grzesiek2010/received_events","type":"User","site_admin":false},"body":"Closes #2049 \r\n\r\n#### What has been done to verify that this works as intended?\r\nI tested mentioned scenario.\r\n\r\n#### Why is this the best possible solution? Were any other approaches considered?\r\nMy second idea was to just get rid of removing media files at all during filling a form and then at the end check all answers and remove unused media files but it might be too complex (too much time needed) when a form is really big or user changed media files many times, so I decided to implement such a singleton.\r\n\r\n#### Are there any risks to merging this code? If so, what are they?\r\n\r\n#### Do we need any specific form for testing your changes? If so, please attach one.\r\nAny form with media questions","created_at":"2018-03-23T18:40:57Z","updated_at":"2018-04-06T00:35:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c46cb0e0af1b5958269517e5d30996fe2e803756","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/opendatakit/collect/pulls/2053/commits","review_comments_url":"https://api.github.com/repos/opendatakit/collect/pulls/2053/comments","review_comment_url":"https://api.github.com/repos/opendatakit/collect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opendatakit/collect/issues/2053/comments","statuses_url":"https://api.github.com/repos/opendatakit/collect/statuses/226a83e0e77242cdad34e6661c72273811ed2808","head":{"label":"grzesiek2010:COLLECT-2049","ref":"COLLECT-2049","sha":"226a83e0e77242cdad34e6661c72273811ed2808","user":{"login":"grzesiek2010","id":3276264,"avatar_url":"https://avatars1.githubusercontent.com/u/3276264?v=4","gravatar_id":"","url":"https://api.github.com/users/grzesiek2010","html_url":"https://github.com/grzesiek2010","followers_url":"https://api.github.com/users/grzesiek2010/followers","following_url":"https://api.github.com/users/grzesiek2010/following{/other_user}","gists_url":"https://api.github.com/users/grzesiek2010/gists{/gist_id}","starred_url":"https://api.github.com/users/grzesiek2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grzesiek2010/subscriptions","organizations_url":"https://api.github.com/users/grzesiek2010/orgs","repos_url":"https://api.github.com/users/grzesiek2010/repos","events_url":"https://api.github.com/users/grzesiek2010/events{/privacy}","received_events_url":"https://api.github.com/users/grzesiek2010/received_events","type":"User","site_admin":false},"repo":{"id":75389799,"name":"collect","full_name":"grzesiek2010/collect","owner":{"login":"grzesiek2010","id":3276264,"avatar_url":"https://avatars1.githubusercontent.com/u/3276264?v=4","gravatar_id":"","url":"https://api.github.com/users/grzesiek2010","html_url":"https://github.com/grzesiek2010","followers_url":"https://api.github.com/users/grzesiek2010/followers","following_url":"https://api.github.com/users/grzesiek2010/following{/other_user}","gists_url":"https://api.github.com/users/grzesiek2010/gists{/gist_id}","starred_url":"https://api.github.com/users/grzesiek2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grzesiek2010/subscriptions","organizations_url":"https://api.github.com/users/grzesiek2010/orgs","repos_url":"https://api.github.com/users/grzesiek2010/repos","events_url":"https://api.github.com/users/grzesiek2010/events{/privacy}","received_events_url":"https://api.github.com/users/grzesiek2010/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grzesiek2010/collect","description":"ODK Collect is an Android app for filling out forms. It's been used to collect millions of data points in challenging environments around the world. Contribute and make the world a better place! ✨🌍✨","fork":true,"url":"https://api.github.com/repos/grzesiek2010/collect","forks_url":"https://api.github.com/repos/grzesiek2010/collect/forks","keys_url":"https://api.github.com/repos/grzesiek2010/collect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grzesiek2010/collect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grzesiek2010/collect/teams","hooks_url":"https://api.github.com/repos/grzesiek2010/collect/hooks","issue_events_url":"https://api.github.com/repos/grzesiek2010/collect/issues/events{/number}","events_url":"https://api.github.com/repos/grzesiek2010/collect/events","assignees_url":"https://api.github.com/repos/grzesiek2010/collect/assignees{/user}","branches_url":"https://api.github.com/repos/grzesiek2010/collect/branches{/branch}","tags_url":"https://api.github.com/repos/grzesiek2010/collect/tags","blobs_url":"https://api.github.com/repos/grzesiek2010/collect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grzesiek2010/collect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grzesiek2010/collect/git/refs{/sha}","trees_url":"https://api.github.com/repos/grzesiek2010/collect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grzesiek2010/collect/statuses/{sha}","languages_url":"https://api.github.com/repos/grzesiek2010/collect/languages","stargazers_url":"https://api.github.com/repos/grzesiek2010/collect/stargazers","contributors_url":"https://api.github.com/repos/grzesiek2010/collect/contributors","subscribers_url":"https://api.github.com/repos/grzesiek2010/collect/subscribers","subscription_url":"https://api.github.com/repos/grzesiek2010/collect/subscription","commits_url":"https://api.github.com/repos/grzesiek2010/collect/commits{/sha}","git_commits_url":"https://api.github.com/repos/grzesiek2010/collect/git/commits{/sha}","comments_url":"https://api.github.com/repos/grzesiek2010/collect/comments{/number}","issue_comment_url":"https://api.github.com/repos/grzesiek2010/collect/issues/comments{/number}","contents_url":"https://api.github.com/repos/grzesiek2010/collect/contents/{+path}","compare_url":"https://api.github.com/repos/grzesiek2010/collect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grzesiek2010/collect/merges","archive_url":"https://api.github.com/repos/grzesiek2010/collect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grzesiek2010/collect/downloads","issues_url":"https://api.github.com/repos/grzesiek2010/collect/issues{/number}","pulls_url":"https://api.github.com/repos/grzesiek2010/collect/pulls{/number}","milestones_url":"https://api.github.com/repos/grzesiek2010/collect/milestones{/number}","notifications_url":"https://api.github.com/repos/grzesiek2010/collect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grzesiek2010/collect/labels{/name}","releases_url":"https://api.github.com/repos/grzesiek2010/collect/releases{/id}","deployments_url":"https://api.github.com/repos/grzesiek2010/collect/deployments","created_at":"2016-12-02T11:26:41Z","updated_at":"2016-12-02T11:26:43Z","pushed_at":"2018-04-05T11:23:22Z","git_url":"git://github.com/grzesiek2010/collect.git","ssh_url":"git@github.com:grzesiek2010/collect.git","clone_url":"https://github.com/grzesiek2010/collect.git","svn_url":"https://github.com/grzesiek2010/collect","homepage":"https://github.com/opendatakit/collect","size":39175,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"opendatakit:master","ref":"master","sha":"4fbbefe5c0451b0a0592fae4bda59bdc2723cea1","user":{"login":"opendatakit","id":6222985,"avatar_url":"https://avatars0.githubusercontent.com/u/6222985?v=4","gravatar_id":"","url":"https://api.github.com/users/opendatakit","html_url":"https://github.com/opendatakit","followers_url":"https://api.github.com/users/opendatakit/followers","following_url":"https://api.github.com/users/opendatakit/following{/other_user}","gists_url":"https://api.github.com/users/opendatakit/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatakit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatakit/subscriptions","organizations_url":"https://api.github.com/users/opendatakit/orgs","repos_url":"https://api.github.com/users/opendatakit/repos","events_url":"https://api.github.com/users/opendatakit/events{/privacy}","received_events_url":"https://api.github.com/users/opendatakit/received_events","type":"Organization","site_admin":false},"repo":{"id":40213809,"name":"collect","full_name":"opendatakit/collect","owner":{"login":"opendatakit","id":6222985,"avatar_url":"https://avatars0.githubusercontent.com/u/6222985?v=4","gravatar_id":"","url":"https://api.github.com/users/opendatakit","html_url":"https://github.com/opendatakit","followers_url":"https://api.github.com/users/opendatakit/followers","following_url":"https://api.github.com/users/opendatakit/following{/other_user}","gists_url":"https://api.github.com/users/opendatakit/gists{/gist_id}","starred_url":"https://api.github.com/users/opendatakit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opendatakit/subscriptions","organizations_url":"https://api.github.com/users/opendatakit/orgs","repos_url":"https://api.github.com/users/opendatakit/repos","events_url":"https://api.github.com/users/opendatakit/events{/privacy}","received_events_url":"https://api.github.com/users/opendatakit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opendatakit/collect","description":"ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨","fork":false,"url":"https://api.github.com/repos/opendatakit/collect","forks_url":"https://api.github.com/repos/opendatakit/collect/forks","keys_url":"https://api.github.com/repos/opendatakit/collect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opendatakit/collect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opendatakit/collect/teams","hooks_url":"https://api.github.com/repos/opendatakit/collect/hooks","issue_events_url":"https://api.github.com/repos/opendatakit/collect/issues/events{/number}","events_url":"https://api.github.com/repos/opendatakit/collect/events","assignees_url":"https://api.github.com/repos/opendatakit/collect/assignees{/user}","branches_url":"https://api.github.com/repos/opendatakit/collect/branches{/branch}","tags_url":"https://api.github.com/repos/opendatakit/collect/tags","blobs_url":"https://api.github.com/repos/opendatakit/collect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opendatakit/collect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opendatakit/collect/git/refs{/sha}","trees_url":"https://api.github.com/repos/opendatakit/collect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opendatakit/collect/statuses/{sha}","languages_url":"https://api.github.com/repos/opendatakit/collect/languages","stargazers_url":"https://api.github.com/repos/opendatakit/collect/stargazers","contributors_url":"https://api.github.com/repos/opendatakit/collect/contributors","subscribers_url":"https://api.github.com/repos/opendatakit/collect/subscribers","subscription_url":"https://api.github.com/repos/opendatakit/collect/subscription","commits_url":"https://api.github.com/repos/opendatakit/collect/commits{/sha}","git_commits_url":"https://api.github.com/repos/opendatakit/collect/git/commits{/sha}","comments_url":"https://api.github.com/repos/opendatakit/collect/comments{/number}","issue_comment_url":"https://api.github.com/repos/opendatakit/collect/issues/comments{/number}","contents_url":"https://api.github.com/repos/opendatakit/collect/contents/{+path}","compare_url":"https://api.github.com/repos/opendatakit/collect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opendatakit/collect/merges","archive_url":"https://api.github.com/repos/opendatakit/collect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opendatakit/collect/downloads","issues_url":"https://api.github.com/repos/opendatakit/collect/issues{/number}","pulls_url":"https://api.github.com/repos/opendatakit/collect/pulls{/number}","milestones_url":"https://api.github.com/repos/opendatakit/collect/milestones{/number}","notifications_url":"https://api.github.com/repos/opendatakit/collect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opendatakit/collect/labels{/name}","releases_url":"https://api.github.com/repos/opendatakit/collect/releases{/id}","deployments_url":"https://api.github.com/repos/opendatakit/collect/deployments","created_at":"2015-08-04T23:21:33Z","updated_at":"2018-04-05T21:50:54Z","pushed_at":"2018-04-05T23:59:41Z","git_url":"git://github.com/opendatakit/collect.git","ssh_url":"git@github.com:opendatakit/collect.git","clone_url":"https://github.com/opendatakit/collect.git","svn_url":"https://github.com/opendatakit/collect","homepage":"https://docs.opendatakit.org/collect-intro","size":37583,"stargazers_count":223,"watchers_count":223,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":598,"mirror_url":null,"archived":false,"open_issues_count":225,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":598,"open_issues":225,"watchers":223,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/2053"},"html":{"href":"https://github.com/opendatakit/collect/pull/2053"},"issue":{"href":"https://api.github.com/repos/opendatakit/collect/issues/2053"},"comments":{"href":"https://api.github.com/repos/opendatakit/collect/issues/2053/comments"},"review_comments":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/2053/comments"},"review_comment":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opendatakit/collect/pulls/2053/commits"},"statuses":{"href":"https://api.github.com/repos/opendatakit/collect/statuses/226a83e0e77242cdad34e6661c72273811ed2808"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"lognaturel"}}