OSDN Git Service

T29417
authoryuji <yuji@debian.com>
Sat, 1 Sep 2012 01:47:30 +0000 (10:47 +0900)
committeryuji <yuji@debian.com>
Sat, 1 Sep 2012 01:47:30 +0000 (10:47 +0900)
source/workspace/EverFolder/src/com/yuji/ef/OAuthActivity.java

index d96b708..4474b53 100644 (file)
@@ -1,4 +1,5 @@
 package com.yuji.ef;
+
 //package com.evernote.android.sample;
 
 import java.io.File;
@@ -87,17 +88,17 @@ public class OAuthActivity extends BaseActivity {
        private String fileName;
 
        private boolean isInit = true;
-       
+
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.oauth);
 
-//             msgArea = (TextView) findViewById(R.id.message);
-//             btnAuth = (Button) findViewById(R.id.auth_button);
-//             btnSelect = (Button) findViewById(R.id.select_button);
-//             btnSave = (Button) findViewById(R.id.save_button);
+               // msgArea = (TextView) findViewById(R.id.message);
+               // btnAuth = (Button) findViewById(R.id.auth_button);
+               // btnSelect = (Button) findViewById(R.id.select_button);
+               // btnSave = (Button) findViewById(R.id.save_button);
 
                setupSession();
        }
@@ -108,7 +109,7 @@ public class OAuthActivity extends BaseActivity {
 
                // Complete the Evernote authentication process if necessary
                // TODO
-               //if (!session.completeAuthentication()) {
+               // if (!session.completeAuthentication()) {
                if (!isInit && !session.completeAuthentication()) {
                        // We only want to do this when we're resuming after
                        // authentication...
@@ -117,14 +118,15 @@ public class OAuthActivity extends BaseActivity {
                }
 
                updateUi();
-               
+
                // ADD
-               if (isInit){
+               if (isInit) {
                        isInit = false;
-               }
-               else {
-                       EvernoteUtil util = EvernoteUtil.getInstance();
-                       util.setSession(session);
+               } else {
+                       if (session.completeAuthentication()) {
+                               EvernoteUtil util = EvernoteUtil.getInstance();
+                               util.setSession(session);
+                       }
                        finish();
                }
        }
@@ -153,12 +155,11 @@ public class OAuthActivity extends BaseActivity {
                }
 
                updateUi();
-               
+
                // ADD
                try {
                        startAuth(null);
-               }
-               catch (Throwable t){
+               } catch (Throwable t) {
                        t.printStackTrace();
                }
        }
@@ -168,13 +169,13 @@ public class OAuthActivity extends BaseActivity {
         */
        private void updateUi() {
                if (session.isLoggedIn()) {
-//                     btnAuth.setText(R.string.label_log_out);
-//                     btnSave.setEnabled(true);
-//                     btnSelect.setEnabled(true);
+                       // btnAuth.setText(R.string.label_log_out);
+                       // btnSave.setEnabled(true);
+                       // btnSelect.setEnabled(true);
                } else {
-//                     btnAuth.setText(R.string.label_log_in);
-//                     btnSave.setEnabled(false);
-//                     btnSelect.setEnabled(false);
+                       // btnAuth.setText(R.string.label_log_in);
+                       // btnSave.setEnabled(false);
+                       // btnSelect.setEnabled(false);
                }
        }
 
@@ -184,11 +185,11 @@ public class OAuthActivity extends BaseActivity {
         * Sends the user to the image gallery to choose an image to share.
         */
        public void startAuth(View view) {
-//             if (session.isLoggedIn()) {
-//                     session.logOut();
-//             } else {
-//                     session.authenticate(this);
-//             }
+               // if (session.isLoggedIn()) {
+               // session.logOut();
+               // } else {
+               // session.authenticate(this);
+               // }
                if (session.isLoggedIn()) {
                        session.logOut();
                }
@@ -215,7 +216,7 @@ public class OAuthActivity extends BaseActivity {
                if (requestCode == SELECT_IMAGE) {
                        // Callback from our 'startSelectImage' action
                        if (resultCode == Activity.RESULT_OK) {
-//                             endSelectImage(data);
+                               // endSelectImage(data);
                        }
                }
        }