{"action":"created","comment":{"url":"https://api.github.com/repos/MADWI/AppZUT/pulls/comments/87710054","pull_request_review_id":8313180,"id":87710054,"diff_hunk":"@@ -0,0 +1,148 @@\n+package pl.edu.zut.mad.appzut.fragments;\n+\n+import android.annotation.SuppressLint;\n+import android.graphics.Bitmap;\n+import android.os.Bundle;\n+import android.support.annotation.Nullable;\n+import android.support.v4.app.Fragment;\n+import android.view.LayoutInflater;\n+import android.view.View;\n+import android.view.ViewGroup;\n+import android.webkit.JavascriptInterface;\n+import android.webkit.WebResourceResponse;\n+import android.webkit.WebView;\n+import android.webkit.WebViewClient;\n+import android.widget.Toast;\n+\n+import java.io.UnsupportedEncodingException;\n+import java.net.URLDecoder;\n+\n+import butterknife.BindView;\n+import butterknife.ButterKnife;\n+import pl.edu.zut.mad.appzut.R;\n+import pl.edu.zut.mad.appzut.network.DataLoadingManager;\n+import pl.edu.zut.mad.appzut.network.ScheduleEdzLoader;\n+\n+public class WebPlanFragment extends Fragment {\n+\n+    @BindView(R.id.web_view_plan)\n+    WebView web;\n+\n+    @BindView(R.id.please_wait)\n+    View pleaseWaitView;\n+\n+    public static final String USERNAME_ARG = \"username\";\n+    public static final String PASSWORD_ARG = \"password\";\n+\n+    private String username;\n+    private String password;\n+\n+    @Override\n+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {\n+        View view = inflater.inflate(R.layout.fragment_web_plan, container, false);\n+        ButterKnife.bind(this, view);\n+        username = getArguments().getString(USERNAME_ARG);\n+        password = getArguments().getString(PASSWORD_ARG);\n+        return view;\n+    }\n+\n+    @Override\n+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n+        super.onViewCreated(view, savedInstanceState);\n+        initWebView();\n+    }\n+\n+    @SuppressLint(\"AddJavascriptInterface\")\n+    private void initWebView() {\n+        pleaseWaitView.setVisibility(View.VISIBLE);\n+        web.getSettings().setJavaScriptEnabled(true);\n+        web.addJavascriptInterface(this, \"android\");\n+        web.setWebViewClient(new WebViewClient(){\n+            private String mReceivedErrorForUrl;\n+\n+            @Override\n+            public void onPageFinished(WebView view, String url) {\n+                web.loadUrl(\"javascript:javascript:(function(){document.body.appendChild(document.createElement('script')).src='/appwizut-injected-script.js'})()\");\n+                web.loadUrl(\"javascript:var x =document.getElementById('ctl00_ctl00_ContentPlaceHolder_MiddleContentPlaceHolder_txtIdent').value = '\"+username+\"';\");\n+                web.loadUrl(\"javascript:var y =document.getElementById('ctl00_ctl00_ContentPlaceHolder_MiddleContentPlaceHolder_txtHaslo').value = '\"+password+\"';\");\n+                web.loadUrl(\"javascript:var z =document.getElementById('ctl00_ctl00_ContentPlaceHolder_MiddleContentPlaceHolder_butLoguj').click();\");\n+                web.loadUrl(\"javascript:android.onData(document.getElementById('ctl00_ctl00_ContentPlaceHolder_MiddleContentPlaceHolder_lblMessage').innerHTML)\");\n+            }\n+\n+            @Override\n+            @SuppressWarnings(\"deprecation\") // Newer version is not supported on older Android versions\n+            public WebResourceResponse shouldInterceptRequest(WebView view, String url) {\n+                if (url.endsWith(\"/appwizut-injected-script.js\")) {\n+                    return new WebResourceResponse(\n+                            \"text/javascript\",\n+                            \"utf-8\",\n+                            getResources().openRawResource(R.raw.grab_schedule)\n+                    );\n+                }\n+                return null;\n+            }\n+\n+            // Handle response from javascript\n+            @Override\n+            public boolean shouldOverrideUrlLoading(WebView view, String url) {\n+                if (url.startsWith(\"js-grabbed-table:\")) {\n+                    String tableJson;\n+                    try {\n+                        tableJson = URLDecoder.decode(url.substring(17), \"utf-8\");\n+                    } catch (UnsupportedEncodingException e) {\n+                        throw new RuntimeException(e);\n+                    }\n+                    tableGrabbedByJavascript(tableJson);\n+                    return true;\n+                }\n+                return false;\n+            }\n+\n+            @Override\n+            public void onPageStarted(WebView view, String url, Bitmap favicon) {\n+\n+            }\n+\n+            @Override\n+            @SuppressWarnings(\"deprecation\") // Newer version is not supported on older Android versions\n+            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {\n+                mReceivedErrorForUrl = failingUrl;\n+            }\n+        });\n+\n+        web.loadUrl(\"https://edziekanat.zut.edu.pl/WU/PodzGodzin.aspx\");\n+    }\n+\n+    public void tableGrabbedByJavascript(final String contents) {\n+        DataLoadingManager\n+                .getInstance(getContext())\n+                .getLoader(ScheduleEdzLoader.class)\n+                .setSourceTableJson(contents);\n+        getActivity().finish();\n+    }\n+\n+    @JavascriptInterface\n+    public void onData(String value) {","path":"app/src/main/java/pl/edu/zut/mad/appzut/fragments/WebPlanFragment.java","position":null,"original_position":125,"commit_id":"3a2ed2ff0b462d066aba8221cc3bfae7921930ae","original_commit_id":"3b9d9d949d5b1e090a3ee0f8bdd1907fd1347d6a","user":{"login":"Bartosz-Kozajda","id":13692368,"avatar_url":"https://avatars.githubusercontent.com/u/13692368?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartosz-Kozajda","html_url":"https://github.com/Bartosz-Kozajda","followers_url":"https://api.github.com/users/Bartosz-Kozajda/followers","following_url":"https://api.github.com/users/Bartosz-Kozajda/following{/other_user}","gists_url":"https://api.github.com/users/Bartosz-Kozajda/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartosz-Kozajda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartosz-Kozajda/subscriptions","organizations_url":"https://api.github.com/users/Bartosz-Kozajda/orgs","repos_url":"https://api.github.com/users/Bartosz-Kozajda/repos","events_url":"https://api.github.com/users/Bartosz-Kozajda/events{/privacy}","received_events_url":"https://api.github.com/users/Bartosz-Kozajda/received_events","type":"User","site_admin":false},"body":"changed to onLoginError","created_at":"2016-11-13T11:00:26Z","updated_at":"2016-11-13T11:00:26Z","html_url":"https://github.com/MADWI/AppZUT/pull/3#discussion_r87710054","pull_request_url":"https://api.github.com/repos/MADWI/AppZUT/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/comments/87710054"},"html":{"href":"https://github.com/MADWI/AppZUT/pull/3#discussion_r87710054"},"pull_request":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/MADWI/AppZUT/pulls/3","id":93415183,"html_url":"https://github.com/MADWI/AppZUT/pull/3","diff_url":"https://github.com/MADWI/AppZUT/pull/3.diff","patch_url":"https://github.com/MADWI/AppZUT/pull/3.patch","issue_url":"https://api.github.com/repos/MADWI/AppZUT/issues/3","number":3,"state":"open","locked":false,"title":"Login wrapper","user":{"login":"Bartosz-Kozajda","id":13692368,"avatar_url":"https://avatars.githubusercontent.com/u/13692368?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartosz-Kozajda","html_url":"https://github.com/Bartosz-Kozajda","followers_url":"https://api.github.com/users/Bartosz-Kozajda/followers","following_url":"https://api.github.com/users/Bartosz-Kozajda/following{/other_user}","gists_url":"https://api.github.com/users/Bartosz-Kozajda/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartosz-Kozajda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartosz-Kozajda/subscriptions","organizations_url":"https://api.github.com/users/Bartosz-Kozajda/orgs","repos_url":"https://api.github.com/users/Bartosz-Kozajda/repos","events_url":"https://api.github.com/users/Bartosz-Kozajda/events{/privacy}","received_events_url":"https://api.github.com/users/Bartosz-Kozajda/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-11T23:35:02Z","updated_at":"2016-11-13T11:00:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"153a1d39c90f446458429d65ada08e894e328283","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MADWI/AppZUT/pulls/3/commits","review_comments_url":"https://api.github.com/repos/MADWI/AppZUT/pulls/3/comments","review_comment_url":"https://api.github.com/repos/MADWI/AppZUT/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MADWI/AppZUT/issues/3/comments","statuses_url":"https://api.github.com/repos/MADWI/AppZUT/statuses/3a2ed2ff0b462d066aba8221cc3bfae7921930ae","head":{"label":"MADWI:LoginWrapper","ref":"LoginWrapper","sha":"3a2ed2ff0b462d066aba8221cc3bfae7921930ae","user":{"login":"MADWI","id":1652059,"avatar_url":"https://avatars.githubusercontent.com/u/1652059?v=3","gravatar_id":"","url":"https://api.github.com/users/MADWI","html_url":"https://github.com/MADWI","followers_url":"https://api.github.com/users/MADWI/followers","following_url":"https://api.github.com/users/MADWI/following{/other_user}","gists_url":"https://api.github.com/users/MADWI/gists{/gist_id}","starred_url":"https://api.github.com/users/MADWI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MADWI/subscriptions","organizations_url":"https://api.github.com/users/MADWI/orgs","repos_url":"https://api.github.com/users/MADWI/repos","events_url":"https://api.github.com/users/MADWI/events{/privacy}","received_events_url":"https://api.github.com/users/MADWI/received_events","type":"Organization","site_admin":false},"repo":{"id":70145629,"name":"AppZUT","full_name":"MADWI/AppZUT","owner":{"login":"MADWI","id":1652059,"avatar_url":"https://avatars.githubusercontent.com/u/1652059?v=3","gravatar_id":"","url":"https://api.github.com/users/MADWI","html_url":"https://github.com/MADWI","followers_url":"https://api.github.com/users/MADWI/followers","following_url":"https://api.github.com/users/MADWI/following{/other_user}","gists_url":"https://api.github.com/users/MADWI/gists{/gist_id}","starred_url":"https://api.github.com/users/MADWI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MADWI/subscriptions","organizations_url":"https://api.github.com/users/MADWI/orgs","repos_url":"https://api.github.com/users/MADWI/repos","events_url":"https://api.github.com/users/MADWI/events{/privacy}","received_events_url":"https://api.github.com/users/MADWI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MADWI/AppZUT","description":null,"fork":false,"url":"https://api.github.com/repos/MADWI/AppZUT","forks_url":"https://api.github.com/repos/MADWI/AppZUT/forks","keys_url":"https://api.github.com/repos/MADWI/AppZUT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MADWI/AppZUT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MADWI/AppZUT/teams","hooks_url":"https://api.github.com/repos/MADWI/AppZUT/hooks","issue_events_url":"https://api.github.com/repos/MADWI/AppZUT/issues/events{/number}","events_url":"https://api.github.com/repos/MADWI/AppZUT/events","assignees_url":"https://api.github.com/repos/MADWI/AppZUT/assignees{/user}","branches_url":"https://api.github.com/repos/MADWI/AppZUT/branches{/branch}","tags_url":"https://api.github.com/repos/MADWI/AppZUT/tags","blobs_url":"https://api.github.com/repos/MADWI/AppZUT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MADWI/AppZUT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MADWI/AppZUT/git/refs{/sha}","trees_url":"https://api.github.com/repos/MADWI/AppZUT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MADWI/AppZUT/statuses/{sha}","languages_url":"https://api.github.com/repos/MADWI/AppZUT/languages","stargazers_url":"https://api.github.com/repos/MADWI/AppZUT/stargazers","contributors_url":"https://api.github.com/repos/MADWI/AppZUT/contributors","subscribers_url":"https://api.github.com/repos/MADWI/AppZUT/subscribers","subscription_url":"https://api.github.com/repos/MADWI/AppZUT/subscription","commits_url":"https://api.github.com/repos/MADWI/AppZUT/commits{/sha}","git_commits_url":"https://api.github.com/repos/MADWI/AppZUT/git/commits{/sha}","comments_url":"https://api.github.com/repos/MADWI/AppZUT/comments{/number}","issue_comment_url":"https://api.github.com/repos/MADWI/AppZUT/issues/comments{/number}","contents_url":"https://api.github.com/repos/MADWI/AppZUT/contents/{+path}","compare_url":"https://api.github.com/repos/MADWI/AppZUT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MADWI/AppZUT/merges","archive_url":"https://api.github.com/repos/MADWI/AppZUT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MADWI/AppZUT/downloads","issues_url":"https://api.github.com/repos/MADWI/AppZUT/issues{/number}","pulls_url":"https://api.github.com/repos/MADWI/AppZUT/pulls{/number}","milestones_url":"https://api.github.com/repos/MADWI/AppZUT/milestones{/number}","notifications_url":"https://api.github.com/repos/MADWI/AppZUT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MADWI/AppZUT/labels{/name}","releases_url":"https://api.github.com/repos/MADWI/AppZUT/releases{/id}","deployments_url":"https://api.github.com/repos/MADWI/AppZUT/deployments","created_at":"2016-10-06T10:55:12Z","updated_at":"2016-10-06T10:57:11Z","pushed_at":"2016-11-13T10:57:53Z","git_url":"git://github.com/MADWI/AppZUT.git","ssh_url":"git@github.com:MADWI/AppZUT.git","clone_url":"https://github.com/MADWI/AppZUT.git","svn_url":"https://github.com/MADWI/AppZUT","homepage":null,"size":227,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"MADWI:master","ref":"master","sha":"3fef5a1dd850b5ffcb4e080b694d788e1beb2b9e","user":{"login":"MADWI","id":1652059,"avatar_url":"https://avatars.githubusercontent.com/u/1652059?v=3","gravatar_id":"","url":"https://api.github.com/users/MADWI","html_url":"https://github.com/MADWI","followers_url":"https://api.github.com/users/MADWI/followers","following_url":"https://api.github.com/users/MADWI/following{/other_user}","gists_url":"https://api.github.com/users/MADWI/gists{/gist_id}","starred_url":"https://api.github.com/users/MADWI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MADWI/subscriptions","organizations_url":"https://api.github.com/users/MADWI/orgs","repos_url":"https://api.github.com/users/MADWI/repos","events_url":"https://api.github.com/users/MADWI/events{/privacy}","received_events_url":"https://api.github.com/users/MADWI/received_events","type":"Organization","site_admin":false},"repo":{"id":70145629,"name":"AppZUT","full_name":"MADWI/AppZUT","owner":{"login":"MADWI","id":1652059,"avatar_url":"https://avatars.githubusercontent.com/u/1652059?v=3","gravatar_id":"","url":"https://api.github.com/users/MADWI","html_url":"https://github.com/MADWI","followers_url":"https://api.github.com/users/MADWI/followers","following_url":"https://api.github.com/users/MADWI/following{/other_user}","gists_url":"https://api.github.com/users/MADWI/gists{/gist_id}","starred_url":"https://api.github.com/users/MADWI/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MADWI/subscriptions","organizations_url":"https://api.github.com/users/MADWI/orgs","repos_url":"https://api.github.com/users/MADWI/repos","events_url":"https://api.github.com/users/MADWI/events{/privacy}","received_events_url":"https://api.github.com/users/MADWI/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MADWI/AppZUT","description":null,"fork":false,"url":"https://api.github.com/repos/MADWI/AppZUT","forks_url":"https://api.github.com/repos/MADWI/AppZUT/forks","keys_url":"https://api.github.com/repos/MADWI/AppZUT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MADWI/AppZUT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MADWI/AppZUT/teams","hooks_url":"https://api.github.com/repos/MADWI/AppZUT/hooks","issue_events_url":"https://api.github.com/repos/MADWI/AppZUT/issues/events{/number}","events_url":"https://api.github.com/repos/MADWI/AppZUT/events","assignees_url":"https://api.github.com/repos/MADWI/AppZUT/assignees{/user}","branches_url":"https://api.github.com/repos/MADWI/AppZUT/branches{/branch}","tags_url":"https://api.github.com/repos/MADWI/AppZUT/tags","blobs_url":"https://api.github.com/repos/MADWI/AppZUT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MADWI/AppZUT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MADWI/AppZUT/git/refs{/sha}","trees_url":"https://api.github.com/repos/MADWI/AppZUT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MADWI/AppZUT/statuses/{sha}","languages_url":"https://api.github.com/repos/MADWI/AppZUT/languages","stargazers_url":"https://api.github.com/repos/MADWI/AppZUT/stargazers","contributors_url":"https://api.github.com/repos/MADWI/AppZUT/contributors","subscribers_url":"https://api.github.com/repos/MADWI/AppZUT/subscribers","subscription_url":"https://api.github.com/repos/MADWI/AppZUT/subscription","commits_url":"https://api.github.com/repos/MADWI/AppZUT/commits{/sha}","git_commits_url":"https://api.github.com/repos/MADWI/AppZUT/git/commits{/sha}","comments_url":"https://api.github.com/repos/MADWI/AppZUT/comments{/number}","issue_comment_url":"https://api.github.com/repos/MADWI/AppZUT/issues/comments{/number}","contents_url":"https://api.github.com/repos/MADWI/AppZUT/contents/{+path}","compare_url":"https://api.github.com/repos/MADWI/AppZUT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MADWI/AppZUT/merges","archive_url":"https://api.github.com/repos/MADWI/AppZUT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MADWI/AppZUT/downloads","issues_url":"https://api.github.com/repos/MADWI/AppZUT/issues{/number}","pulls_url":"https://api.github.com/repos/MADWI/AppZUT/pulls{/number}","milestones_url":"https://api.github.com/repos/MADWI/AppZUT/milestones{/number}","notifications_url":"https://api.github.com/repos/MADWI/AppZUT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MADWI/AppZUT/labels{/name}","releases_url":"https://api.github.com/repos/MADWI/AppZUT/releases{/id}","deployments_url":"https://api.github.com/repos/MADWI/AppZUT/deployments","created_at":"2016-10-06T10:55:12Z","updated_at":"2016-10-06T10:57:11Z","pushed_at":"2016-11-13T10:57:53Z","git_url":"git://github.com/MADWI/AppZUT.git","ssh_url":"git@github.com:MADWI/AppZUT.git","clone_url":"https://github.com/MADWI/AppZUT.git","svn_url":"https://github.com/MADWI/AppZUT","homepage":null,"size":227,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/3"},"html":{"href":"https://github.com/MADWI/AppZUT/pull/3"},"issue":{"href":"https://api.github.com/repos/MADWI/AppZUT/issues/3"},"comments":{"href":"https://api.github.com/repos/MADWI/AppZUT/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MADWI/AppZUT/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/MADWI/AppZUT/statuses/3a2ed2ff0b462d066aba8221cc3bfae7921930ae"}}}}
{"actor":{"display_login":"Bartosz-Kozajda"}}