{"action":"created","comment":{"url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/comments/227506022","pull_request_review_id":167563725,"id":227506022,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzUwNjAyMg==","diff_hunk":"@@ -11,17 +27,116 @@ object ImageLoader {\n         val context = textWithMarkup.context\n \n         // Only if AppPreferences.displayImages(context) is true\n-        // loadImages(textWithMarkup.text as Spannable)\n+        // Setup image visualization inside the note\n+        if ( AppPreferences.displayInlineImages(context)\n+                // Storage permission has been granted\n+                && AppPermissions.isGranted(context, AppPermissions.Usage.EXTERNAL_FILES_ACCESS)) {\n+            // Load the associated image for each FileLinkSpan\n+            SpanUtils.forEachSpan(textWithMarkup.text as Spannable, FileLinkSpan::class.java) { span ->\n+                loadImage(textWithMarkup, span)\n+            }\n+        }\n     }\n \n-    private fun loadImages(text: Spannable) {\n-        SpanUtils.forEachSpan(text, FileLinkSpan::class.java) { span ->\n-            loadImage(span)\n+    private fun loadImage(textWithMarkup: TextViewWithMarkup, span: FileLinkSpan) {\n+        val path = span.path\n+\n+        if (hasSupportedExtension(path)) {\n+            val text = textWithMarkup.text as Spannable\n+            // Get the current context\n+            val context = App.getAppContext()\n+\n+            // Get the file\n+            val file = File(Environment.getExternalStorageDirectory(), path)\n+\n+            if(file.exists()) {\n+                // Get the Uri\n+                val contentUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + \".fileprovider\", file)\n+\n+                // Setup a placeholder\n+                val drawable = ColorDrawable(Color.TRANSPARENT)\n+                drawable.setBounds(0, 0, AppPreferences.setImageFixedWidth(context), AppPreferences.setImageFixedWidth(context))","path":"app/src/main/java/com/orgzly/android/ui/ImageLoader.kt","position":61,"original_position":61,"commit_id":"1e6a95a277904393a10802aab78c5de831aa8e45","original_commit_id":"1e6a95a277904393a10802aab78c5de831aa8e45","user":{"login":"nevenz","id":10671476,"node_id":"MDQ6VXNlcjEwNjcxNDc2","avatar_url":"https://avatars0.githubusercontent.com/u/10671476?v=4","gravatar_id":"","url":"https://api.github.com/users/nevenz","html_url":"https://github.com/nevenz","followers_url":"https://api.github.com/users/nevenz/followers","following_url":"https://api.github.com/users/nevenz/following{/other_user}","gists_url":"https://api.github.com/users/nevenz/gists{/gist_id}","starred_url":"https://api.github.com/users/nevenz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevenz/subscriptions","organizations_url":"https://api.github.com/users/nevenz/orgs","repos_url":"https://api.github.com/users/nevenz/repos","events_url":"https://api.github.com/users/nevenz/events{/privacy}","received_events_url":"https://api.github.com/users/nevenz/received_events","type":"User","site_admin":false},"body":"I still get the jump for the fixed size images. Looks like this is setting the height to the width, not calculating the ratio like for the actual image display.","created_at":"2018-10-23T18:11:06Z","updated_at":"2018-10-23T18:11:06Z","html_url":"https://github.com/orgzly/orgzly-android/pull/389#discussion_r227506022","pull_request_url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/comments/227506022"},"html":{"href":"https://github.com/orgzly/orgzly-android/pull/389#discussion_r227506022"},"pull_request":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389"}}},"pull_request":{"url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389","id":217520542,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NTIwNTQy","html_url":"https://github.com/orgzly/orgzly-android/pull/389","diff_url":"https://github.com/orgzly/orgzly-android/pull/389.diff","patch_url":"https://github.com/orgzly/orgzly-android/pull/389.patch","issue_url":"https://api.github.com/repos/orgzly/orgzly-android/issues/389","number":389,"state":"open","locked":false,"title":"Allow \"file:\" and \"[[...]]\" links, display images in notes","user":{"login":"aancel","id":5362942,"node_id":"MDQ6VXNlcjUzNjI5NDI=","avatar_url":"https://avatars0.githubusercontent.com/u/5362942?v=4","gravatar_id":"","url":"https://api.github.com/users/aancel","html_url":"https://github.com/aancel","followers_url":"https://api.github.com/users/aancel/followers","following_url":"https://api.github.com/users/aancel/following{/other_user}","gists_url":"https://api.github.com/users/aancel/gists{/gist_id}","starred_url":"https://api.github.com/users/aancel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aancel/subscriptions","organizations_url":"https://api.github.com/users/aancel/orgs","repos_url":"https://api.github.com/users/aancel/repos","events_url":"https://api.github.com/users/aancel/events{/privacy}","received_events_url":"https://api.github.com/users/aancel/received_events","type":"User","site_admin":false},"body":"Hello,\r\nFollowing the work on #382, I open a PR with new propositions.\r\nI reworked the code a bit to better integrate it with the previous code, and notably to handle `[[...]]` for file links (still linked to #360) in addition to the previous `file:` scheme.\r\nI also added an ImageSpan to display images in notes (rescaled to fit width, if larger than the window width), as a proposition to implement #147.\r\n\r\nAs before, this PR has been tested with API 16 (Nexus 5), API 23 (Pixel 2) & API 27 (Pixel 2 XL)\r\n\r\nA small note sample, I used to test this:\r\n```\r\n[[Download/test.jpg]]\r\n\r\nfile:Download/test2.png\r\n\r\n[[Download/test3.png][Test]]\r\n```\r\nRight now, named links are not replaced with an ImageSpan.\r\nFurthemore regarding to the application performance, maybe adding a setting to toggle off image display could be a good idea. What do you think about this ?","created_at":"2018-09-23T17:23:17Z","updated_at":"2018-10-23T18:11:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c68d268c66fd448c331a3a0f4411a0ca09c9aaa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389/commits","review_comments_url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389/comments","review_comment_url":"https://api.github.com/repos/orgzly/orgzly-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/orgzly/orgzly-android/issues/389/comments","statuses_url":"https://api.github.com/repos/orgzly/orgzly-android/statuses/1e6a95a277904393a10802aab78c5de831aa8e45","head":{"label":"aancel:update-external-file-image","ref":"update-external-file-image","sha":"1e6a95a277904393a10802aab78c5de831aa8e45","user":{"login":"aancel","id":5362942,"node_id":"MDQ6VXNlcjUzNjI5NDI=","avatar_url":"https://avatars0.githubusercontent.com/u/5362942?v=4","gravatar_id":"","url":"https://api.github.com/users/aancel","html_url":"https://github.com/aancel","followers_url":"https://api.github.com/users/aancel/followers","following_url":"https://api.github.com/users/aancel/following{/other_user}","gists_url":"https://api.github.com/users/aancel/gists{/gist_id}","starred_url":"https://api.github.com/users/aancel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aancel/subscriptions","organizations_url":"https://api.github.com/users/aancel/orgs","repos_url":"https://api.github.com/users/aancel/repos","events_url":"https://api.github.com/users/aancel/events{/privacy}","received_events_url":"https://api.github.com/users/aancel/received_events","type":"User","site_admin":false},"repo":{"id":147433128,"node_id":"MDEwOlJlcG9zaXRvcnkxNDc0MzMxMjg=","name":"orgzly-android","full_name":"aancel/orgzly-android","private":false,"owner":{"login":"aancel","id":5362942,"node_id":"MDQ6VXNlcjUzNjI5NDI=","avatar_url":"https://avatars0.githubusercontent.com/u/5362942?v=4","gravatar_id":"","url":"https://api.github.com/users/aancel","html_url":"https://github.com/aancel","followers_url":"https://api.github.com/users/aancel/followers","following_url":"https://api.github.com/users/aancel/following{/other_user}","gists_url":"https://api.github.com/users/aancel/gists{/gist_id}","starred_url":"https://api.github.com/users/aancel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aancel/subscriptions","organizations_url":"https://api.github.com/users/aancel/orgs","repos_url":"https://api.github.com/users/aancel/repos","events_url":"https://api.github.com/users/aancel/events{/privacy}","received_events_url":"https://api.github.com/users/aancel/received_events","type":"User","site_admin":false},"html_url":"https://github.com/aancel/orgzly-android","description":"Outliner for taking notes and managing to-do lists","fork":true,"url":"https://api.github.com/repos/aancel/orgzly-android","forks_url":"https://api.github.com/repos/aancel/orgzly-android/forks","keys_url":"https://api.github.com/repos/aancel/orgzly-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aancel/orgzly-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aancel/orgzly-android/teams","hooks_url":"https://api.github.com/repos/aancel/orgzly-android/hooks","issue_events_url":"https://api.github.com/repos/aancel/orgzly-android/issues/events{/number}","events_url":"https://api.github.com/repos/aancel/orgzly-android/events","assignees_url":"https://api.github.com/repos/aancel/orgzly-android/assignees{/user}","branches_url":"https://api.github.com/repos/aancel/orgzly-android/branches{/branch}","tags_url":"https://api.github.com/repos/aancel/orgzly-android/tags","blobs_url":"https://api.github.com/repos/aancel/orgzly-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aancel/orgzly-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aancel/orgzly-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/aancel/orgzly-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aancel/orgzly-android/statuses/{sha}","languages_url":"https://api.github.com/repos/aancel/orgzly-android/languages","stargazers_url":"https://api.github.com/repos/aancel/orgzly-android/stargazers","contributors_url":"https://api.github.com/repos/aancel/orgzly-android/contributors","subscribers_url":"https://api.github.com/repos/aancel/orgzly-android/subscribers","subscription_url":"https://api.github.com/repos/aancel/orgzly-android/subscription","commits_url":"https://api.github.com/repos/aancel/orgzly-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/aancel/orgzly-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/aancel/orgzly-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/aancel/orgzly-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/aancel/orgzly-android/contents/{+path}","compare_url":"https://api.github.com/repos/aancel/orgzly-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aancel/orgzly-android/merges","archive_url":"https://api.github.com/repos/aancel/orgzly-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aancel/orgzly-android/downloads","issues_url":"https://api.github.com/repos/aancel/orgzly-android/issues{/number}","pulls_url":"https://api.github.com/repos/aancel/orgzly-android/pulls{/number}","milestones_url":"https://api.github.com/repos/aancel/orgzly-android/milestones{/number}","notifications_url":"https://api.github.com/repos/aancel/orgzly-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aancel/orgzly-android/labels{/name}","releases_url":"https://api.github.com/repos/aancel/orgzly-android/releases{/id}","deployments_url":"https://api.github.com/repos/aancel/orgzly-android/deployments","created_at":"2018-09-04T23:41:08Z","updated_at":"2018-10-15T16:31:56Z","pushed_at":"2018-10-22T21:57:38Z","git_url":"git://github.com/aancel/orgzly-android.git","ssh_url":"git@github.com:aancel/orgzly-android.git","clone_url":"https://github.com/aancel/orgzly-android.git","svn_url":"https://github.com/aancel/orgzly-android","homepage":"http://www.orgzly.com","size":29354,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"orgzly:master","ref":"master","sha":"813f4f9af059c5a235dfa69b4b1d62060614c897","user":{"login":"orgzly","id":10672741,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjcyNzQx","avatar_url":"https://avatars0.githubusercontent.com/u/10672741?v=4","gravatar_id":"","url":"https://api.github.com/users/orgzly","html_url":"https://github.com/orgzly","followers_url":"https://api.github.com/users/orgzly/followers","following_url":"https://api.github.com/users/orgzly/following{/other_user}","gists_url":"https://api.github.com/users/orgzly/gists{/gist_id}","starred_url":"https://api.github.com/users/orgzly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orgzly/subscriptions","organizations_url":"https://api.github.com/users/orgzly/orgs","repos_url":"https://api.github.com/users/orgzly/repos","events_url":"https://api.github.com/users/orgzly/events{/privacy}","received_events_url":"https://api.github.com/users/orgzly/received_events","type":"Organization","site_admin":false},"repo":{"id":80837945,"node_id":"MDEwOlJlcG9zaXRvcnk4MDgzNzk0NQ==","name":"orgzly-android","full_name":"orgzly/orgzly-android","private":false,"owner":{"login":"orgzly","id":10672741,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwNjcyNzQx","avatar_url":"https://avatars0.githubusercontent.com/u/10672741?v=4","gravatar_id":"","url":"https://api.github.com/users/orgzly","html_url":"https://github.com/orgzly","followers_url":"https://api.github.com/users/orgzly/followers","following_url":"https://api.github.com/users/orgzly/following{/other_user}","gists_url":"https://api.github.com/users/orgzly/gists{/gist_id}","starred_url":"https://api.github.com/users/orgzly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orgzly/subscriptions","organizations_url":"https://api.github.com/users/orgzly/orgs","repos_url":"https://api.github.com/users/orgzly/repos","events_url":"https://api.github.com/users/orgzly/events{/privacy}","received_events_url":"https://api.github.com/users/orgzly/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/orgzly/orgzly-android","description":"Outliner for taking notes and managing to-do lists","fork":false,"url":"https://api.github.com/repos/orgzly/orgzly-android","forks_url":"https://api.github.com/repos/orgzly/orgzly-android/forks","keys_url":"https://api.github.com/repos/orgzly/orgzly-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/orgzly/orgzly-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/orgzly/orgzly-android/teams","hooks_url":"https://api.github.com/repos/orgzly/orgzly-android/hooks","issue_events_url":"https://api.github.com/repos/orgzly/orgzly-android/issues/events{/number}","events_url":"https://api.github.com/repos/orgzly/orgzly-android/events","assignees_url":"https://api.github.com/repos/orgzly/orgzly-android/assignees{/user}","branches_url":"https://api.github.com/repos/orgzly/orgzly-android/branches{/branch}","tags_url":"https://api.github.com/repos/orgzly/orgzly-android/tags","blobs_url":"https://api.github.com/repos/orgzly/orgzly-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/orgzly/orgzly-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/orgzly/orgzly-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/orgzly/orgzly-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/orgzly/orgzly-android/statuses/{sha}","languages_url":"https://api.github.com/repos/orgzly/orgzly-android/languages","stargazers_url":"https://api.github.com/repos/orgzly/orgzly-android/stargazers","contributors_url":"https://api.github.com/repos/orgzly/orgzly-android/contributors","subscribers_url":"https://api.github.com/repos/orgzly/orgzly-android/subscribers","subscription_url":"https://api.github.com/repos/orgzly/orgzly-android/subscription","commits_url":"https://api.github.com/repos/orgzly/orgzly-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/orgzly/orgzly-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/orgzly/orgzly-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/orgzly/orgzly-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/orgzly/orgzly-android/contents/{+path}","compare_url":"https://api.github.com/repos/orgzly/orgzly-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/orgzly/orgzly-android/merges","archive_url":"https://api.github.com/repos/orgzly/orgzly-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/orgzly/orgzly-android/downloads","issues_url":"https://api.github.com/repos/orgzly/orgzly-android/issues{/number}","pulls_url":"https://api.github.com/repos/orgzly/orgzly-android/pulls{/number}","milestones_url":"https://api.github.com/repos/orgzly/orgzly-android/milestones{/number}","notifications_url":"https://api.github.com/repos/orgzly/orgzly-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/orgzly/orgzly-android/labels{/name}","releases_url":"https://api.github.com/repos/orgzly/orgzly-android/releases{/id}","deployments_url":"https://api.github.com/repos/orgzly/orgzly-android/deployments","created_at":"2017-02-03T14:48:34Z","updated_at":"2018-10-23T14:07:40Z","pushed_at":"2018-10-22T21:57:40Z","git_url":"git://github.com/orgzly/orgzly-android.git","ssh_url":"git@github.com:orgzly/orgzly-android.git","clone_url":"https://github.com/orgzly/orgzly-android.git","svn_url":"https://github.com/orgzly/orgzly-android","homepage":"http://www.orgzly.com","size":29416,"stargazers_count":914,"watchers_count":914,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":120,"mirror_url":null,"archived":false,"open_issues_count":169,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":120,"open_issues":169,"watchers":914,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389"},"html":{"href":"https://github.com/orgzly/orgzly-android/pull/389"},"issue":{"href":"https://api.github.com/repos/orgzly/orgzly-android/issues/389"},"comments":{"href":"https://api.github.com/repos/orgzly/orgzly-android/issues/389/comments"},"review_comments":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389/comments"},"review_comment":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/orgzly/orgzly-android/pulls/389/commits"},"statuses":{"href":"https://api.github.com/repos/orgzly/orgzly-android/statuses/1e6a95a277904393a10802aab78c5de831aa8e45"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nevenz"}}