{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/comments/75109476","id":75109476,"diff_hunk":"@@ -174,4 +197,69 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {\n                 break;\n         }\n     }\n+\n+    @Override\n+    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],\n+                                           @NonNull int[] grantResults) {\n+        switch (requestCode) {\n+            case REQUEST_WRITE_EXTERNAL_STORAGE:\n+                if (grantResults.length > 0 &&\n+                    grantResults[0] == PackageManager.PERMISSION_GRANTED)\n+                    takeScreenshot();\n+                else ToastUtils.showToast(this, R.string.permission_to_share_image);\n+                break;\n+        }\n+    }\n+\n+    private void checkLowBattery() {\n+        Intent batteryStatus =\n+            registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));\n+        assert batteryStatus != null;\n+        if (batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, Constants.DEFAULT_INTENT_VALUE) <\n+            BATTERY_LOW)\n+            new AlertDialog.Builder(this)\n+                .setTitle(R.string.low_battery_title)\n+                .setMessage(R.string.low_battery_message)\n+                .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {\n+                    public void onClick(DialogInterface dialog, int which) {\n+                    }\n+                }).show();\n+    }\n+\n+    private void requestShareScreenShot() {\n+        if (ContextCompat.checkSelfPermission(this,\n+            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)\n+            ActivityCompat.requestPermissions(this,\n+                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},\n+                REQUEST_WRITE_EXTERNAL_STORAGE);\n+        else takeScreenshot();\n+    }\n+\n+    private void takeScreenshot() {\n+        Date now = new Date();\n+        DateFormat.format(DATE_FORMAT, now);\n+        try {\n+            String path = String.format(IMAGE_PATH_FORMAT, Environment.getExternalStorageDirectory()\n+                .toString(), now);\n+            View rootView = getWindow().getDecorView().getRootView();\n+            rootView.setDrawingCacheEnabled(true);\n+            Bitmap bitmap = Bitmap.createBitmap(rootView.getDrawingCache());\n+            rootView.setDrawingCacheEnabled(false);\n+            File imageFile = new File(path);\n+            FileOutputStream outputStream = new FileOutputStream(imageFile);\n+            bitmap.compress(Bitmap.CompressFormat.JPEG, IMAGE_QUALITY, outputStream);\n+            outputStream.flush();\n+            outputStream.close();\n+            shareImage(imageFile);\n+        } catch (IOException e) {\n+            ToastUtils.showToast(this, R.string.something_error);\n+        }\n+    }\n+\n+    private void shareImage(File imageFile) {\n+        Intent intent = new Intent(Intent.ACTION_SEND);\n+        intent.setType(SHARE_IMAGE_TYPE);\n+        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imageFile));\n+        startActivity(intent);","path":"app/src/main/java/com/example/framgia/carobluetooth/ui/activity/BoardActivity.java","position":122,"original_position":122,"commit_id":"0601018c655d02cf17a522ec37e925df50b847d2","original_commit_id":"0601018c655d02cf17a522ec37e925df50b847d2","user":{"login":"ninhtpmn","id":10874605,"avatar_url":"https://avatars.githubusercontent.com/u/10874605?v=3","gravatar_id":"","url":"https://api.github.com/users/ninhtpmn","html_url":"https://github.com/ninhtpmn","followers_url":"https://api.github.com/users/ninhtpmn/followers","following_url":"https://api.github.com/users/ninhtpmn/following{/other_user}","gists_url":"https://api.github.com/users/ninhtpmn/gists{/gist_id}","starred_url":"https://api.github.com/users/ninhtpmn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ninhtpmn/subscriptions","organizations_url":"https://api.github.com/users/ninhtpmn/orgs","repos_url":"https://api.github.com/users/ninhtpmn/repos","events_url":"https://api.github.com/users/ninhtpmn/events{/privacy}","received_events_url":"https://api.github.com/users/ninhtpmn/received_events","type":"User","site_admin":false},"body":"thiếu check điều kiện, có thể gây crash nhé","created_at":"2016-08-17T12:08:01Z","updated_at":"2016-08-17T12:08:01Z","html_url":"https://github.com/framgia/CaroGame_01/pull/8#discussion_r75109476","pull_request_url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/comments/75109476"},"html":{"href":"https://github.com/framgia/CaroGame_01/pull/8#discussion_r75109476"},"pull_request":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8","id":81601228,"html_url":"https://github.com/framgia/CaroGame_01/pull/8","diff_url":"https://github.com/framgia/CaroGame_01/pull/8.diff","patch_url":"https://github.com/framgia/CaroGame_01/pull/8.patch","issue_url":"https://api.github.com/repos/framgia/CaroGame_01/issues/8","number":8,"state":"open","locked":false,"title":"check low battery, layout lanscape, share image","user":{"login":"dangquanuet","id":5498994,"avatar_url":"https://avatars.githubusercontent.com/u/5498994?v=3","gravatar_id":"","url":"https://api.github.com/users/dangquanuet","html_url":"https://github.com/dangquanuet","followers_url":"https://api.github.com/users/dangquanuet/followers","following_url":"https://api.github.com/users/dangquanuet/following{/other_user}","gists_url":"https://api.github.com/users/dangquanuet/gists{/gist_id}","starred_url":"https://api.github.com/users/dangquanuet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangquanuet/subscriptions","organizations_url":"https://api.github.com/users/dangquanuet/orgs","repos_url":"https://api.github.com/users/dangquanuet/repos","events_url":"https://api.github.com/users/dangquanuet/events{/privacy}","received_events_url":"https://api.github.com/users/dangquanuet/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-17T08:17:22Z","updated_at":"2016-08-17T12:08:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5867a8ae4d4824f3471b1d500a3975f65ba03e28","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8/commits","review_comments_url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8/comments","review_comment_url":"https://api.github.com/repos/framgia/CaroGame_01/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/CaroGame_01/issues/8/comments","statuses_url":"https://api.github.com/repos/framgia/CaroGame_01/statuses/0601018c655d02cf17a522ec37e925df50b847d2","head":{"label":"dangquanuet:toast_error","ref":"toast_error","sha":"0601018c655d02cf17a522ec37e925df50b847d2","user":{"login":"dangquanuet","id":5498994,"avatar_url":"https://avatars.githubusercontent.com/u/5498994?v=3","gravatar_id":"","url":"https://api.github.com/users/dangquanuet","html_url":"https://github.com/dangquanuet","followers_url":"https://api.github.com/users/dangquanuet/followers","following_url":"https://api.github.com/users/dangquanuet/following{/other_user}","gists_url":"https://api.github.com/users/dangquanuet/gists{/gist_id}","starred_url":"https://api.github.com/users/dangquanuet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangquanuet/subscriptions","organizations_url":"https://api.github.com/users/dangquanuet/orgs","repos_url":"https://api.github.com/users/dangquanuet/repos","events_url":"https://api.github.com/users/dangquanuet/events{/privacy}","received_events_url":"https://api.github.com/users/dangquanuet/received_events","type":"User","site_admin":false},"repo":{"id":65255572,"name":"CaroGame_01","full_name":"dangquanuet/CaroGame_01","owner":{"login":"dangquanuet","id":5498994,"avatar_url":"https://avatars.githubusercontent.com/u/5498994?v=3","gravatar_id":"","url":"https://api.github.com/users/dangquanuet","html_url":"https://github.com/dangquanuet","followers_url":"https://api.github.com/users/dangquanuet/followers","following_url":"https://api.github.com/users/dangquanuet/following{/other_user}","gists_url":"https://api.github.com/users/dangquanuet/gists{/gist_id}","starred_url":"https://api.github.com/users/dangquanuet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangquanuet/subscriptions","organizations_url":"https://api.github.com/users/dangquanuet/orgs","repos_url":"https://api.github.com/users/dangquanuet/repos","events_url":"https://api.github.com/users/dangquanuet/events{/privacy}","received_events_url":"https://api.github.com/users/dangquanuet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dangquanuet/CaroGame_01","description":"Caro Bluetooth Game (training)","fork":true,"url":"https://api.github.com/repos/dangquanuet/CaroGame_01","forks_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/forks","keys_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/teams","hooks_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/hooks","issue_events_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/issues/events{/number}","events_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/events","assignees_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/assignees{/user}","branches_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/branches{/branch}","tags_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/tags","blobs_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/git/refs{/sha}","trees_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/statuses/{sha}","languages_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/languages","stargazers_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/stargazers","contributors_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/contributors","subscribers_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/subscribers","subscription_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/subscription","commits_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/commits{/sha}","git_commits_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/git/commits{/sha}","comments_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/comments{/number}","issue_comment_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/issues/comments{/number}","contents_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/contents/{+path}","compare_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/merges","archive_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/downloads","issues_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/issues{/number}","pulls_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/pulls{/number}","milestones_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/milestones{/number}","notifications_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/labels{/name}","releases_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/releases{/id}","deployments_url":"https://api.github.com/repos/dangquanuet/CaroGame_01/deployments","created_at":"2016-08-09T02:24:27Z","updated_at":"2016-08-09T02:18:10Z","pushed_at":"2016-08-17T11:17:25Z","git_url":"git://github.com/dangquanuet/CaroGame_01.git","ssh_url":"git@github.com:dangquanuet/CaroGame_01.git","clone_url":"https://github.com/dangquanuet/CaroGame_01.git","svn_url":"https://github.com/dangquanuet/CaroGame_01","homepage":null,"size":395,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"ba5f2e01a4a52c7f2e9f4729dc8f643e595a4b34","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":65255183,"name":"CaroGame_01","full_name":"framgia/CaroGame_01","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/CaroGame_01","description":"Caro Bluetooth Game (training)","fork":false,"url":"https://api.github.com/repos/framgia/CaroGame_01","forks_url":"https://api.github.com/repos/framgia/CaroGame_01/forks","keys_url":"https://api.github.com/repos/framgia/CaroGame_01/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/CaroGame_01/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/CaroGame_01/teams","hooks_url":"https://api.github.com/repos/framgia/CaroGame_01/hooks","issue_events_url":"https://api.github.com/repos/framgia/CaroGame_01/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/CaroGame_01/events","assignees_url":"https://api.github.com/repos/framgia/CaroGame_01/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/CaroGame_01/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/CaroGame_01/tags","blobs_url":"https://api.github.com/repos/framgia/CaroGame_01/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/CaroGame_01/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/CaroGame_01/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/CaroGame_01/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/CaroGame_01/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/CaroGame_01/languages","stargazers_url":"https://api.github.com/repos/framgia/CaroGame_01/stargazers","contributors_url":"https://api.github.com/repos/framgia/CaroGame_01/contributors","subscribers_url":"https://api.github.com/repos/framgia/CaroGame_01/subscribers","subscription_url":"https://api.github.com/repos/framgia/CaroGame_01/subscription","commits_url":"https://api.github.com/repos/framgia/CaroGame_01/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/CaroGame_01/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/CaroGame_01/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/CaroGame_01/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/CaroGame_01/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/CaroGame_01/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/CaroGame_01/merges","archive_url":"https://api.github.com/repos/framgia/CaroGame_01/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/CaroGame_01/downloads","issues_url":"https://api.github.com/repos/framgia/CaroGame_01/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/CaroGame_01/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/CaroGame_01/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/CaroGame_01/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/CaroGame_01/labels{/name}","releases_url":"https://api.github.com/repos/framgia/CaroGame_01/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/CaroGame_01/deployments","created_at":"2016-08-09T02:18:10Z","updated_at":"2016-08-09T02:18:10Z","pushed_at":"2016-08-17T11:17:25Z","git_url":"git://github.com/framgia/CaroGame_01.git","ssh_url":"git@github.com:framgia/CaroGame_01.git","clone_url":"https://github.com/framgia/CaroGame_01.git","svn_url":"https://github.com/framgia/CaroGame_01","homepage":null,"size":404,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8"},"html":{"href":"https://github.com/framgia/CaroGame_01/pull/8"},"issue":{"href":"https://api.github.com/repos/framgia/CaroGame_01/issues/8"},"comments":{"href":"https://api.github.com/repos/framgia/CaroGame_01/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/CaroGame_01/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/CaroGame_01/statuses/0601018c655d02cf17a522ec37e925df50b847d2"}}}}
{"actor":{"display_login":"ninhtpmn"}}