{"action":"created","comment":{"url":"https://api.github.com/repos/tkusd/android/pulls/comments/34947130","id":34947130,"diff_hunk":"@@ -1,18 +1,150 @@\n package tw.tkusd.appstudio.app;\n \n+import android.app.Activity;\n+import android.app.ProgressDialog;\n+import android.content.Intent;\n+import android.content.SharedPreferences;\n import android.os.Bundle;\n import android.support.v7.app.AppCompatActivity;\n import android.view.Menu;\n import android.view.MenuItem;\n+import android.view.View;\n+import android.widget.Button;\n+import android.widget.TextView;\n+import android.widget.Toast;\n \n+import com.android.volley.AuthFailureError;\n+import com.android.volley.Request;\n+import com.android.volley.Response;\n+import com.android.volley.VolleyError;\n+import com.android.volley.toolbox.JsonObjectRequest;\n+\n+import org.json.JSONException;\n+import org.json.JSONObject;\n+\n+import java.io.File;\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+import butterknife.ButterKnife;\n+import butterknife.InjectView;\n+import tw.tkusd.appstudio.Constant;\n import tw.tkusd.appstudio.R;\n+import tw.tkusd.appstudio.util.RequestHelper;\n \n public class WelcomeActivity extends AppCompatActivity {\n \n+    @InjectView(R.id.btn_logout)\n+    Button btnlogout;\n+    @InjectView(R.id.txtResult)\n+    TextView txtResult;\n+\n+\n+    private RequestHelper mRequestHelper;\n+    private ProgressDialog pDialog;\n+    public static final String TAG = WelcomeActivity.class.getSimpleName();\n+    String taketoken_id;\n+    String ID_URL=Constant.TOKEN_URL+\"/\"+taketoken_id;\n+\n+\n+\n     @Override\n-    protected void onCreate(Bundle savedInstanceState) {\n+    protected void onCreate(final Bundle savedInstanceState) {\n         super.onCreate(savedInstanceState);\n         setContentView(R.layout.activity_welcome);\n+        ButterKnife.inject(this);\n+        mRequestHelper = RequestHelper.getInstance(this);\n+        btnlogout.setOnClickListener(new View.OnClickListener() {\n+            @Override\n+            public void onClick(View v) {\n+                try {\n+                    getHeaders();\n+                    loadPreference();\n+                    delete();\n+                    removePreference();\n+                    if (taketoken_id == \"\") {\n+                        txtResult.setText(\"success\");\n+\n+                        Intent newAct = new Intent();\n+                        newAct.setClass(WelcomeActivity.this, LoginActivity.class);\n+                        startActivity(newAct);\n+                    } else {\n+                        txtResult.setText(\"delete failed\");\n+                    }\n+\n+                } catch (JSONException e) {\n+                    e.printStackTrace();\n+                } catch (AuthFailureError authFailureError) {\n+                    authFailureError.printStackTrace();\n+                }\n+            }\n+        });\n+    }\n+\n+    public void loadPreference() {\n+        int mode = Activity.MODE_PRIVATE;\n+        SharedPreferences mySharedPreference = getSharedPreferences(LoginActivity.MYPREFS, mode);\n+        taketoken_id = mySharedPreference.getString(\"tokenid\", \"null\");\n+    }\n+\n+    public void removePreference() {\n+        SharedPreferences settings =getSharedPreferences(LoginActivity.MYPREFS,MODE_PRIVATE);\n+        settings.edit().clear().commit();\n+        taketoken_id=settings.getString(\"tokenid\",\"\");\n+\n+    }\n+    public Map<String, String> getHeaders() throws AuthFailureError {\n+        HashMap<String, String> headers = new HashMap<>();\n+        headers.put(\"Content-Type\", \"application/json\");\n+\n+        return headers;}","path":"app/src/main/java/tw/tkusd/appstudio/app/WelcomeActivity.java","position":101,"original_position":101,"commit_id":"d14deaed5b417c28258657f835d796fb8db4d868","original_commit_id":"d14deaed5b417c28258657f835d796fb8db4d868","user":{"login":"tommy351","id":411425,"avatar_url":"https://avatars.githubusercontent.com/u/411425?v=3","gravatar_id":"","url":"https://api.github.com/users/tommy351","html_url":"https://github.com/tommy351","followers_url":"https://api.github.com/users/tommy351/followers","following_url":"https://api.github.com/users/tommy351/following{/other_user}","gists_url":"https://api.github.com/users/tommy351/gists{/gist_id}","starred_url":"https://api.github.com/users/tommy351/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommy351/subscriptions","organizations_url":"https://api.github.com/users/tommy351/orgs","repos_url":"https://api.github.com/users/tommy351/repos","events_url":"https://api.github.com/users/tommy351/events{/privacy}","received_events_url":"https://api.github.com/users/tommy351/received_events","type":"User","site_admin":false},"body":"括號請換行","created_at":"2015-07-18T12:26:44Z","updated_at":"2015-07-18T12:26:44Z","html_url":"https://github.com/tkusd/android/pull/7#discussion_r34947130","pull_request_url":"https://api.github.com/repos/tkusd/android/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/tkusd/android/pulls/comments/34947130"},"html":{"href":"https://github.com/tkusd/android/pull/7#discussion_r34947130"},"pull_request":{"href":"https://api.github.com/repos/tkusd/android/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/tkusd/android/pulls/7","id":40291296,"html_url":"https://github.com/tkusd/android/pull/7","diff_url":"https://github.com/tkusd/android/pull/7.diff","patch_url":"https://github.com/tkusd/android/pull/7.patch","issue_url":"https://api.github.com/repos/tkusd/android/issues/7","number":7,"state":"open","locked":false,"title":"Log in","user":{"login":"MelonH","id":11921264,"avatar_url":"https://avatars.githubusercontent.com/u/11921264?v=3","gravatar_id":"","url":"https://api.github.com/users/MelonH","html_url":"https://github.com/MelonH","followers_url":"https://api.github.com/users/MelonH/followers","following_url":"https://api.github.com/users/MelonH/following{/other_user}","gists_url":"https://api.github.com/users/MelonH/gists{/gist_id}","starred_url":"https://api.github.com/users/MelonH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MelonH/subscriptions","organizations_url":"https://api.github.com/users/MelonH/orgs","repos_url":"https://api.github.com/users/MelonH/repos","events_url":"https://api.github.com/users/MelonH/events{/privacy}","received_events_url":"https://api.github.com/users/MelonH/received_events","type":"User","site_admin":false},"body":"新增CustomRequest ，將登入頁面的註冊按鈕改為文字，登出刪除token和儲存紀錄","created_at":"2015-07-18T12:10:38Z","updated_at":"2015-07-18T12:26:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tkusd/android/pulls/7/commits","review_comments_url":"https://api.github.com/repos/tkusd/android/pulls/7/comments","review_comment_url":"https://api.github.com/repos/tkusd/android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tkusd/android/issues/7/comments","statuses_url":"https://api.github.com/repos/tkusd/android/statuses/d14deaed5b417c28258657f835d796fb8db4d868","head":{"label":"tkusd:log_in","ref":"log_in","sha":"d14deaed5b417c28258657f835d796fb8db4d868","user":{"login":"tkusd","id":12230426,"avatar_url":"https://avatars.githubusercontent.com/u/12230426?v=3","gravatar_id":"","url":"https://api.github.com/users/tkusd","html_url":"https://github.com/tkusd","followers_url":"https://api.github.com/users/tkusd/followers","following_url":"https://api.github.com/users/tkusd/following{/other_user}","gists_url":"https://api.github.com/users/tkusd/gists{/gist_id}","starred_url":"https://api.github.com/users/tkusd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkusd/subscriptions","organizations_url":"https://api.github.com/users/tkusd/orgs","repos_url":"https://api.github.com/users/tkusd/repos","events_url":"https://api.github.com/users/tkusd/events{/privacy}","received_events_url":"https://api.github.com/users/tkusd/received_events","type":"Organization","site_admin":false},"repo":{"id":35020949,"name":"android","full_name":"tkusd/android","owner":{"login":"tkusd","id":12230426,"avatar_url":"https://avatars.githubusercontent.com/u/12230426?v=3","gravatar_id":"","url":"https://api.github.com/users/tkusd","html_url":"https://github.com/tkusd","followers_url":"https://api.github.com/users/tkusd/followers","following_url":"https://api.github.com/users/tkusd/following{/other_user}","gists_url":"https://api.github.com/users/tkusd/gists{/gist_id}","starred_url":"https://api.github.com/users/tkusd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkusd/subscriptions","organizations_url":"https://api.github.com/users/tkusd/orgs","repos_url":"https://api.github.com/users/tkusd/repos","events_url":"https://api.github.com/users/tkusd/events{/privacy}","received_events_url":"https://api.github.com/users/tkusd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tkusd/android","description":"","fork":false,"url":"https://api.github.com/repos/tkusd/android","forks_url":"https://api.github.com/repos/tkusd/android/forks","keys_url":"https://api.github.com/repos/tkusd/android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkusd/android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkusd/android/teams","hooks_url":"https://api.github.com/repos/tkusd/android/hooks","issue_events_url":"https://api.github.com/repos/tkusd/android/issues/events{/number}","events_url":"https://api.github.com/repos/tkusd/android/events","assignees_url":"https://api.github.com/repos/tkusd/android/assignees{/user}","branches_url":"https://api.github.com/repos/tkusd/android/branches{/branch}","tags_url":"https://api.github.com/repos/tkusd/android/tags","blobs_url":"https://api.github.com/repos/tkusd/android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkusd/android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkusd/android/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkusd/android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkusd/android/statuses/{sha}","languages_url":"https://api.github.com/repos/tkusd/android/languages","stargazers_url":"https://api.github.com/repos/tkusd/android/stargazers","contributors_url":"https://api.github.com/repos/tkusd/android/contributors","subscribers_url":"https://api.github.com/repos/tkusd/android/subscribers","subscription_url":"https://api.github.com/repos/tkusd/android/subscription","commits_url":"https://api.github.com/repos/tkusd/android/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkusd/android/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkusd/android/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkusd/android/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkusd/android/contents/{+path}","compare_url":"https://api.github.com/repos/tkusd/android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkusd/android/merges","archive_url":"https://api.github.com/repos/tkusd/android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkusd/android/downloads","issues_url":"https://api.github.com/repos/tkusd/android/issues{/number}","pulls_url":"https://api.github.com/repos/tkusd/android/pulls{/number}","milestones_url":"https://api.github.com/repos/tkusd/android/milestones{/number}","notifications_url":"https://api.github.com/repos/tkusd/android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkusd/android/labels{/name}","releases_url":"https://api.github.com/repos/tkusd/android/releases{/id}","created_at":"2015-05-04T07:37:26Z","updated_at":"2015-05-07T15:39:45Z","pushed_at":"2015-07-18T12:10:38Z","git_url":"git://github.com/tkusd/android.git","ssh_url":"git@github.com:tkusd/android.git","clone_url":"https://github.com/tkusd/android.git","svn_url":"https://github.com/tkusd/android","homepage":null,"size":432,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"tkusd:master","ref":"master","sha":"f1a86441b94d2de6145947082fbceb97577cf206","user":{"login":"tkusd","id":12230426,"avatar_url":"https://avatars.githubusercontent.com/u/12230426?v=3","gravatar_id":"","url":"https://api.github.com/users/tkusd","html_url":"https://github.com/tkusd","followers_url":"https://api.github.com/users/tkusd/followers","following_url":"https://api.github.com/users/tkusd/following{/other_user}","gists_url":"https://api.github.com/users/tkusd/gists{/gist_id}","starred_url":"https://api.github.com/users/tkusd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkusd/subscriptions","organizations_url":"https://api.github.com/users/tkusd/orgs","repos_url":"https://api.github.com/users/tkusd/repos","events_url":"https://api.github.com/users/tkusd/events{/privacy}","received_events_url":"https://api.github.com/users/tkusd/received_events","type":"Organization","site_admin":false},"repo":{"id":35020949,"name":"android","full_name":"tkusd/android","owner":{"login":"tkusd","id":12230426,"avatar_url":"https://avatars.githubusercontent.com/u/12230426?v=3","gravatar_id":"","url":"https://api.github.com/users/tkusd","html_url":"https://github.com/tkusd","followers_url":"https://api.github.com/users/tkusd/followers","following_url":"https://api.github.com/users/tkusd/following{/other_user}","gists_url":"https://api.github.com/users/tkusd/gists{/gist_id}","starred_url":"https://api.github.com/users/tkusd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkusd/subscriptions","organizations_url":"https://api.github.com/users/tkusd/orgs","repos_url":"https://api.github.com/users/tkusd/repos","events_url":"https://api.github.com/users/tkusd/events{/privacy}","received_events_url":"https://api.github.com/users/tkusd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tkusd/android","description":"","fork":false,"url":"https://api.github.com/repos/tkusd/android","forks_url":"https://api.github.com/repos/tkusd/android/forks","keys_url":"https://api.github.com/repos/tkusd/android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkusd/android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkusd/android/teams","hooks_url":"https://api.github.com/repos/tkusd/android/hooks","issue_events_url":"https://api.github.com/repos/tkusd/android/issues/events{/number}","events_url":"https://api.github.com/repos/tkusd/android/events","assignees_url":"https://api.github.com/repos/tkusd/android/assignees{/user}","branches_url":"https://api.github.com/repos/tkusd/android/branches{/branch}","tags_url":"https://api.github.com/repos/tkusd/android/tags","blobs_url":"https://api.github.com/repos/tkusd/android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkusd/android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkusd/android/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkusd/android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkusd/android/statuses/{sha}","languages_url":"https://api.github.com/repos/tkusd/android/languages","stargazers_url":"https://api.github.com/repos/tkusd/android/stargazers","contributors_url":"https://api.github.com/repos/tkusd/android/contributors","subscribers_url":"https://api.github.com/repos/tkusd/android/subscribers","subscription_url":"https://api.github.com/repos/tkusd/android/subscription","commits_url":"https://api.github.com/repos/tkusd/android/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkusd/android/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkusd/android/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkusd/android/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkusd/android/contents/{+path}","compare_url":"https://api.github.com/repos/tkusd/android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkusd/android/merges","archive_url":"https://api.github.com/repos/tkusd/android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkusd/android/downloads","issues_url":"https://api.github.com/repos/tkusd/android/issues{/number}","pulls_url":"https://api.github.com/repos/tkusd/android/pulls{/number}","milestones_url":"https://api.github.com/repos/tkusd/android/milestones{/number}","notifications_url":"https://api.github.com/repos/tkusd/android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkusd/android/labels{/name}","releases_url":"https://api.github.com/repos/tkusd/android/releases{/id}","created_at":"2015-05-04T07:37:26Z","updated_at":"2015-05-07T15:39:45Z","pushed_at":"2015-07-18T12:10:38Z","git_url":"git://github.com/tkusd/android.git","ssh_url":"git@github.com:tkusd/android.git","clone_url":"https://github.com/tkusd/android.git","svn_url":"https://github.com/tkusd/android","homepage":null,"size":432,"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":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tkusd/android/pulls/7"},"html":{"href":"https://github.com/tkusd/android/pull/7"},"issue":{"href":"https://api.github.com/repos/tkusd/android/issues/7"},"comments":{"href":"https://api.github.com/repos/tkusd/android/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/tkusd/android/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/tkusd/android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tkusd/android/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/tkusd/android/statuses/d14deaed5b417c28258657f835d796fb8db4d868"}}}}