リビジョン | 4e92c5b735c1d685844a25dc49ebc40fa6fa2670 (tree) |
---|---|
日時 | 2012-11-23 12:18:19 |
作者 | Yuji Konishi <yuji.k64613@gmai...> |
コミッター | Yuji Konishi |
evernote-sdk-android1.0対応
@@ -0,0 +1 @@ | ||
1 | +Subproject commit 74134da5c5aa1f8445b4a72e6e5b0ae17e09957f |
@@ -4,10 +4,8 @@ | ||
4 | 4 | <classpathentry kind="src" path="gen"/> |
5 | 5 | <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> |
6 | 6 | <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> |
7 | - <classpathentry kind="lib" path="libs/evernote-client-android.jar"/> | |
8 | - <classpathentry kind="lib" path="libs/libthrift.jar"/> | |
9 | - <classpathentry kind="lib" path="libs/slf4j-android-1.5.8.jar"/> | |
10 | - <classpathentry kind="lib" path="libs/evernote-api-1.22.jar"/> | |
7 | + <classpathentry kind="lib" path="libs/en-thrift-1.0-SNAPSHOT.jar"/> | |
8 | + <classpathentry kind="lib" path="libs/libthrift-1.0-SNAPSHOT-client.jar"/> | |
11 | 9 | <classpathentry kind="lib" path="libs/scribe-1.3.1.jar"/> |
12 | 10 | <classpathentry kind="output" path="bin/classes"/> |
13 | 11 | </classpath> |
@@ -25,24 +25,20 @@ | ||
25 | 25 | android:launchMode="singleTop" > |
26 | 26 | </activity> |
27 | 27 | <activity |
28 | - android:name=".OAuthActivity" | |
28 | + android:name=".BookListActivity" | |
29 | 29 | android:launchMode="singleTop" > |
30 | 30 | </activity> |
31 | 31 | <activity |
32 | - android:name=".BookListActivity" | |
33 | - android:launchMode="singleTop" > | |
32 | + android:name="com.evernote.client.oauth.android.EvernoteOAuthActivity" | |
33 | + android:configChanges="orientation|keyboard" > | |
34 | 34 | </activity> |
35 | 35 | <activity |
36 | - android:name="com.evernote.client.oauth.android.EvernoteOAuthActivity" | |
37 | - android:launchMode="singleTask" | |
38 | - android:configChanges="orientation|keyboard"> | |
39 | - <intent-filter> | |
40 | - <!-- Change this to be en- followed by your consumer key --> | |
41 | - <data android:scheme="en-yuji-k64613" /> | |
42 | - <action android:name="android.intent.action.VIEW" /> | |
43 | - <category android:name="android.intent.category.BROWSABLE"/> | |
44 | - <category android:name="android.intent.category.DEFAULT" /> | |
45 | - </intent-filter> | |
36 | + android:name=".OAuthActivity" > | |
37 | + <intent-filter> | |
38 | + <action android:name="android.intent.action.MAIN" /> | |
39 | + | |
40 | + <category android:name="android.intent.category.LAUNCHER" /> | |
41 | + </intent-filter> | |
46 | 42 | </activity> |
47 | 43 | |
48 | 44 | <service |
@@ -178,89 +178,98 @@ public final class R { | ||
178 | 178 | public static final int bookCloseButton=0x7f080001; |
179 | 179 | public static final int bookList=0x7f080000; |
180 | 180 | public static final int checkBox=0x7f080002; |
181 | - public static final int frameLayout=0x7f08000c; | |
182 | - public static final int layout=0x7f080004; | |
183 | - public static final int leftButton=0x7f08000e; | |
184 | - public static final int mainButtonLayout=0x7f08000d; | |
185 | - public static final int mainConfirmMsg=0x7f080006; | |
186 | - public static final int mainMsgButtonLayout=0x7f080008; | |
187 | - public static final int mainMsgCancelButton=0x7f08000a; | |
188 | - public static final int mainMsgEditText=0x7f080007; | |
189 | - public static final int mainMsgLayout=0x7f080005; | |
190 | - public static final int mainMsgOkButton=0x7f080009; | |
191 | - public static final int rightButton=0x7f08000f; | |
192 | - public static final int scrollView=0x7f08000b; | |
193 | - public static final int settingBookButton=0x7f080015; | |
194 | - public static final int settingCloseButton=0x7f08001b; | |
195 | - public static final int settingConfirmMsg=0x7f080011; | |
196 | - public static final int settingListButton=0x7f080014; | |
197 | - public static final int settingLoginButton=0x7f080012; | |
198 | - public static final int settingLogoutButton=0x7f080013; | |
199 | - public static final int settingMsgLayout=0x7f080010; | |
200 | - public static final int settingUpdateButton=0x7f080016; | |
201 | - public static final int settingUpdateDateLayout=0x7f080018; | |
202 | - public static final int settingUpdateDateText=0x7f08001a; | |
203 | - public static final int settingUpdateSpinner=0x7f080017; | |
204 | - public static final int settingUpdateTitle=0x7f080019; | |
181 | + public static final int esdk__webview=0x7f080004; | |
182 | + public static final int frameLayout=0x7f08000d; | |
183 | + public static final int layout=0x7f080005; | |
184 | + public static final int leftButton=0x7f08000f; | |
185 | + public static final int mainButtonLayout=0x7f08000e; | |
186 | + public static final int mainConfirmMsg=0x7f080007; | |
187 | + public static final int mainMsgButtonLayout=0x7f080009; | |
188 | + public static final int mainMsgCancelButton=0x7f08000b; | |
189 | + public static final int mainMsgEditText=0x7f080008; | |
190 | + public static final int mainMsgLayout=0x7f080006; | |
191 | + public static final int mainMsgOkButton=0x7f08000a; | |
192 | + public static final int rightButton=0x7f080010; | |
193 | + public static final int scrollView=0x7f08000c; | |
194 | + public static final int settingBookButton=0x7f080016; | |
195 | + public static final int settingCloseButton=0x7f08001c; | |
196 | + public static final int settingConfirmMsg=0x7f080012; | |
197 | + public static final int settingListButton=0x7f080015; | |
198 | + public static final int settingLoginButton=0x7f080013; | |
199 | + public static final int settingLogoutButton=0x7f080014; | |
200 | + public static final int settingMsgLayout=0x7f080011; | |
201 | + public static final int settingUpdateButton=0x7f080017; | |
202 | + public static final int settingUpdateDateLayout=0x7f080019; | |
203 | + public static final int settingUpdateDateText=0x7f08001b; | |
204 | + public static final int settingUpdateSpinner=0x7f080018; | |
205 | + public static final int settingUpdateTitle=0x7f08001a; | |
205 | 206 | public static final int text2=0x7f080003; |
206 | 207 | } |
207 | 208 | public static final class layout { |
208 | 209 | public static final int book_list=0x7f030000; |
209 | 210 | public static final int check_list_item_1=0x7f030001; |
210 | - public static final int main=0x7f030002; | |
211 | - public static final int oauth=0x7f030003; | |
212 | - public static final int setting=0x7f030004; | |
211 | + public static final int esdk__webview=0x7f030002; | |
212 | + public static final int main=0x7f030003; | |
213 | + public static final int oauth=0x7f030004; | |
214 | + public static final int setting=0x7f030005; | |
213 | 215 | } |
214 | 216 | public static final class string { |
215 | - public static final int ErrorLogin=0x7f06002d; | |
216 | - public static final int ErrorNetwork=0x7f06002c; | |
217 | - public static final int ErrorSystem=0x7f06002e; | |
218 | - public static final int ErrorUpdate=0x7f06002b; | |
219 | - public static final int MenuAdd=0x7f060020; | |
220 | - public static final int MenuCut=0x7f06001e; | |
221 | - public static final int MenuDelete=0x7f060021; | |
222 | - public static final int MenuPaste=0x7f06001f; | |
223 | - public static final int MenuRename=0x7f060022; | |
224 | - public static final int MenuSetting=0x7f060023; | |
225 | - public static final int app_name=0x7f060000; | |
226 | - public static final int cancelButton=0x7f060003; | |
227 | - public static final int closeButton=0x7f060004; | |
228 | - public static final int dialogErrorTitle=0x7f060028; | |
229 | - public static final int dialogSystemError=0x7f060029; | |
230 | - public static final int mainAddMsg=0x7f060008; | |
231 | - public static final int mainConfirmMsg=0x7f060006; | |
232 | - public static final int mainConfirmTitle=0x7f060005; | |
233 | - public static final int mainDeleteMsg=0x7f060009; | |
234 | - public static final int mainLeftButton=0x7f06000b; | |
235 | - public static final int mainRenameMsg=0x7f06000a; | |
236 | - public static final int mainRightButton=0x7f06000c; | |
237 | - public static final int mainUpdateMsg=0x7f060007; | |
238 | - public static final int noButton=0x7f060002; | |
239 | - public static final int serviceUpdateDisableNetworkMsg=0x7f060024; | |
240 | - public static final int serviceUpdateNotLoggedkMsg=0x7f060025; | |
241 | - public static final int serviceUpdateReferenceDataMsg=0x7f060026; | |
242 | - public static final int serviceUpdateUnexpectedErrorkMsg=0x7f060027; | |
243 | - public static final int settingBookButton=0x7f060019; | |
244 | - public static final int settingBookTitle=0x7f060018; | |
245 | - public static final int settingConfirmMsg=0x7f06000e; | |
246 | - public static final int settingConfirmTitle=0x7f06000d; | |
247 | - public static final int settingDoListMsg=0x7f060011; | |
248 | - public static final int settingDoSelectMsg=0x7f060013; | |
249 | - public static final int settingDoUpdateMsg=0x7f060012; | |
250 | - public static final int settingListButton=0x7f060017; | |
251 | - public static final int settingLoginButton=0x7f060015; | |
252 | - public static final int settingLoginMsg=0x7f060010; | |
253 | - public static final int settingLoginTitle=0x7f060014; | |
254 | - public static final int settingLogoutButton=0x7f060016; | |
255 | - public static final int settingUpdateButton=0x7f06001b; | |
256 | - public static final int settingUpdateDateTitle=0x7f06001d; | |
257 | - public static final int settingUpdateMsg=0x7f06000f; | |
258 | - public static final int settingUpdateTimeTitle=0x7f06001c; | |
259 | - public static final int settingUpdateTitle=0x7f06001a; | |
260 | - public static final int toastSystem=0x7f06002a; | |
261 | - public static final int yesButton=0x7f060001; | |
217 | + public static final int ErrorLogin=0x7f050034; | |
218 | + public static final int ErrorNetwork=0x7f050033; | |
219 | + public static final int ErrorSystem=0x7f050035; | |
220 | + public static final int ErrorUpdate=0x7f050032; | |
221 | + public static final int MenuAdd=0x7f050027; | |
222 | + public static final int MenuCut=0x7f050025; | |
223 | + public static final int MenuDelete=0x7f050028; | |
224 | + public static final int MenuPaste=0x7f050026; | |
225 | + public static final int MenuRename=0x7f050029; | |
226 | + public static final int MenuSetting=0x7f05002a; | |
227 | + public static final int app_name=0x7f050007; | |
228 | + public static final int cancelButton=0x7f05000a; | |
229 | + public static final int closeButton=0x7f05000b; | |
230 | + public static final int dialogErrorTitle=0x7f05002f; | |
231 | + public static final int dialogSystemError=0x7f050030; | |
232 | + public static final int esdk__err_api_setup=0x7f050005; | |
233 | + public static final int esdk__err_authentication=0x7f050004; | |
234 | + public static final int esdk__err_protocol_version=0x7f050003; | |
235 | + public static final int esdk__evernote=0x7f050000; | |
236 | + public static final int esdk__evernote_login_failed=0x7f050001; | |
237 | + public static final int esdk__evernote_login_successful=0x7f050002; | |
238 | + public static final int esdk__loading=0x7f050006; | |
239 | + public static final int mainAddMsg=0x7f05000f; | |
240 | + public static final int mainConfirmMsg=0x7f05000d; | |
241 | + public static final int mainConfirmTitle=0x7f05000c; | |
242 | + public static final int mainDeleteMsg=0x7f050010; | |
243 | + public static final int mainLeftButton=0x7f050012; | |
244 | + public static final int mainRenameMsg=0x7f050011; | |
245 | + public static final int mainRightButton=0x7f050013; | |
246 | + public static final int mainUpdateMsg=0x7f05000e; | |
247 | + public static final int noButton=0x7f050009; | |
248 | + public static final int serviceUpdateDisableNetworkMsg=0x7f05002b; | |
249 | + public static final int serviceUpdateNotLoggedkMsg=0x7f05002c; | |
250 | + public static final int serviceUpdateReferenceDataMsg=0x7f05002d; | |
251 | + public static final int serviceUpdateUnexpectedErrorkMsg=0x7f05002e; | |
252 | + public static final int settingBookButton=0x7f050020; | |
253 | + public static final int settingBookTitle=0x7f05001f; | |
254 | + public static final int settingConfirmMsg=0x7f050015; | |
255 | + public static final int settingConfirmTitle=0x7f050014; | |
256 | + public static final int settingDoListMsg=0x7f050018; | |
257 | + public static final int settingDoSelectMsg=0x7f05001a; | |
258 | + public static final int settingDoUpdateMsg=0x7f050019; | |
259 | + public static final int settingListButton=0x7f05001e; | |
260 | + public static final int settingLoginButton=0x7f05001c; | |
261 | + public static final int settingLoginMsg=0x7f050017; | |
262 | + public static final int settingLoginTitle=0x7f05001b; | |
263 | + public static final int settingLogoutButton=0x7f05001d; | |
264 | + public static final int settingUpdateButton=0x7f050022; | |
265 | + public static final int settingUpdateDateTitle=0x7f050024; | |
266 | + public static final int settingUpdateMsg=0x7f050016; | |
267 | + public static final int settingUpdateTimeTitle=0x7f050023; | |
268 | + public static final int settingUpdateTitle=0x7f050021; | |
269 | + public static final int toastSystem=0x7f050031; | |
270 | + public static final int yesButton=0x7f050008; | |
262 | 271 | } |
263 | 272 | public static final class style { |
264 | - public static final int BookCheckBox=0x7f050000; | |
273 | + public static final int BookCheckBox=0x7f060000; | |
265 | 274 | } |
266 | 275 | } |
@@ -1,21 +0,0 @@ | ||
1 | - Copyright (c) 2004-2008 QOS.ch | |
2 | - All rights reserved. | |
3 | - | |
4 | - Permission is hereby granted, free of charge, to any person obtaining | |
5 | - a copy of this software and associated documentation files (the | |
6 | - "Software"), to deal in the Software without restriction, including | |
7 | - without limitation the rights to use, copy, modify, merge, publish, | |
8 | - distribute, sublicense, and/or sell copies of the Software, and to | |
9 | - permit persons to whom the Software is furnished to do so, subject to | |
10 | - the following conditions: | |
11 | - | |
12 | - The above copyright notice and this permission notice shall be | |
13 | - included in all copies or substantial portions of the Software. | |
14 | - | |
15 | - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
16 | - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
17 | - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
18 | - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |
19 | - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
20 | - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
21 | - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -11,5 +11,7 @@ | ||
11 | 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt |
12 | 12 | |
13 | 13 | # Project target. |
14 | -target=android-7 | |
14 | +#target=android-7 | |
15 | +target=android-16 | |
15 | 16 | |
17 | +android.library.reference.1=../../../../evernote-sdk-android1.0/lib/evernote-sdk-android/library |
@@ -1,12 +1,12 @@ | ||
1 | 1 | package com.yuji.ef; |
2 | 2 | |
3 | +import android.app.Activity; | |
4 | +import android.content.Intent; | |
3 | 5 | import android.os.Bundle; |
4 | 6 | import android.view.View; |
5 | -import android.widget.Toast; | |
6 | 7 | |
7 | 8 | import com.evernote.client.oauth.android.EvernoteSession; |
8 | 9 | import com.yuji.ef.utility.BaseActivity; |
9 | -import com.yuji.ef.utility.EvernoteUtil; | |
10 | 10 | import com.yuji.ef.utility.OAuthUtil; |
11 | 11 | |
12 | 12 | /** |
@@ -18,199 +18,48 @@ import com.yuji.ef.utility.OAuthUtil; | ||
18 | 18 | * directly to Evernote using the Cloud API. |
19 | 19 | */ |
20 | 20 | public class OAuthActivity extends BaseActivity { |
21 | - | |
22 | - /*************************************************************************** | |
23 | - * You MUST change the following values to run this sample application. * | |
24 | - ***************************************************************************/ | |
25 | - | |
26 | - // Your Evernote API key. See http://dev.evernote.com/documentation/cloud/ | |
27 | - // Please obfuscate your code to help keep these values secret. | |
28 | - // private static final String CONSUMER_KEY = "yuji-k64613"; | |
29 | - // private static final String CONSUMER_SECRET = "98b2cbf35f747d2d"; | |
30 | - | |
31 | - /*************************************************************************** | |
32 | - * Change these values as needed to use this code in your own application. * | |
33 | - ***************************************************************************/ | |
34 | - | |
35 | - // Name of this application, for logging | |
36 | - // private static final String TAG = "HelloEDAM"; | |
37 | - | |
38 | - // A directory on disk where your application stores temporary data | |
39 | - // private static final String APP_DATA_PATH = | |
40 | - // "/Android/data/com.evernote.android.sample/temp/"; | |
41 | - // private static final String APP_DATA_PATH = | |
42 | - // "/Android/data/com.yuji.ef/temp/"; | |
43 | - | |
44 | - // Change to "www.evernote.com" to use the Evernote production service | |
45 | - // instead of the sandbox | |
46 | - // private static final String EVERNOTE_HOST = "sandbox.evernote.com"; | |
47 | - // private static final String EVERNOTE_HOST = "www.evernote.com"; | |
48 | - | |
49 | - // private static final String APP_NAME = "FolderErver"; | |
50 | - // private static final String APP_VERSION = "1.0.0"; | |
51 | - | |
52 | - /*************************************************************************** | |
53 | - * The following values are simply part of the demo application. * | |
54 | - ***************************************************************************/ | |
55 | - | |
56 | - // Activity result request codes | |
57 | - // private static final int SELECT_IMAGE = 1; | |
58 | - | |
59 | - // The ENML preamble to every Evernote note. | |
60 | - // Note content goes between <en-note> and </en-note> | |
61 | - // private static final String NOTE_PREFIX = | |
62 | - // "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + | |
63 | - // "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" + | |
64 | - // "<en-note>"; | |
65 | - | |
66 | - // The ENML postamble to every Evernote note | |
67 | - // private static final String NOTE_SUFFIX = "</en-note>"; | |
68 | - | |
69 | - // Used to interact with the Evernote web service | |
70 | - // private EvernoteSession session; | |
71 | - | |
72 | - // UI elements that we update | |
73 | - // private Button btnAuth; | |
74 | - // private Button btnSave; | |
75 | - // private Button btnSelect; | |
76 | - // private TextView msgArea; | |
77 | - | |
78 | - // The path to and MIME type of the currently selected image from the | |
79 | - // gallery | |
80 | - // private String filePath; | |
81 | - // private String mimeType; | |
82 | - // private String fileName; | |
83 | - | |
84 | - // ADD | |
85 | 21 | private OAuthUtil util = OAuthUtil.getInstance(); |
86 | - private boolean isInit = true; | |
87 | 22 | |
88 | - /** Called when the activity is first created. */ | |
89 | 23 | @Override |
90 | 24 | public void onCreate(Bundle savedInstanceState) { |
91 | 25 | super.onCreate(savedInstanceState); |
92 | - // setContentView(R.layout.main); | |
93 | 26 | setContentView(R.layout.oauth); |
94 | 27 | |
95 | - // DELETE | |
96 | - // msgArea = (TextView)findViewById(R.id.message); | |
97 | - // btnAuth = (Button) findViewById(R.id.auth_button); | |
98 | - // btnSelect = (Button) findViewById(R.id.select_button); | |
99 | - // btnSave = (Button) findViewById(R.id.save_button); | |
100 | - | |
101 | 28 | setupSession(); |
102 | 29 | } |
103 | 30 | |
104 | 31 | @Override |
105 | - public void onResume() { | |
106 | - super.onResume(); | |
107 | - | |
108 | - // Complete the Evernote authentication process if necessary | |
109 | - // EDIT | |
110 | - // if (!session.completeAuthentication(getPreferencesForAuthData())) { | |
111 | - // // We only want to do this when we're resuming after | |
112 | - // authentication... | |
113 | - // Toast.makeText(this, "Evernote login failed", | |
114 | - // Toast.LENGTH_LONG).show(); | |
115 | - // } | |
116 | - boolean isCompleteAuth = util.isCompleteAuth(this); | |
117 | - if (!isInit && !isCompleteAuth) { | |
118 | - // We only want to do this when we're resuming after | |
119 | - // authentication... | |
120 | - Toast.makeText(this, getString(R.string.ErrorLogin), | |
121 | - Toast.LENGTH_LONG).show(); | |
122 | - } | |
123 | - | |
124 | - updateUi(); | |
125 | - | |
126 | - // ADD | |
127 | - if (isInit) { | |
128 | - isInit = false; | |
129 | - } else { | |
130 | - EvernoteUtil.getInstance().setSession(util.getSession()); | |
131 | - if (isCompleteAuth) { | |
32 | + public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
33 | + super.onActivityResult(requestCode, resultCode, data); | |
34 | + | |
35 | + switch (requestCode) { | |
36 | + case EvernoteSession.REQUEST_CODE_OAUTH: | |
37 | + if (resultCode == Activity.RESULT_OK) { | |
132 | 38 | util.setLoginTime(this); |
133 | - } | |
134 | - else { | |
39 | + } else { | |
135 | 40 | util.logout(this); |
136 | 41 | } |
137 | 42 | finish(); |
43 | + break; | |
138 | 44 | } |
139 | 45 | } |
140 | 46 | |
141 | - /** | |
142 | - * Evernote authentication data will be stored to this SharedPreferences if | |
143 | - * we are resuming as a result of a successful OAuth authorization. You may | |
144 | - * wish to pass a different SharedPreferences so that Evernote settings are | |
145 | - * stored along with other settings persisted by your application. | |
146 | - */ | |
147 | - // private SharedPreferences getPreferencesForAuthData() { | |
148 | - // return getPreferences(MODE_PRIVATE); | |
149 | - // } | |
150 | - | |
151 | - /** | |
152 | - * Setup the EvernoteSession used to access the Evernote API. | |
153 | - */ | |
154 | 47 | private void setupSession() { |
155 | - // EDIT | |
156 | - // ApplicationInfo info = | |
157 | - // new ApplicationInfo(CONSUMER_KEY, CONSUMER_SECRET, EVERNOTE_HOST, | |
158 | - // APP_NAME, APP_VERSION); | |
159 | - // | |
160 | - // // Retrieve persisted authentication information | |
161 | - // session = new EvernoteSession(info, getPreferencesForAuthData(), | |
162 | - // getTempDir()); | |
163 | 48 | util.setupSession(this); |
164 | - updateUi(); | |
165 | - | |
166 | - // ADD | |
167 | 49 | startAuth(null); |
168 | 50 | } |
169 | 51 | |
170 | - /** | |
171 | - * Update the UI based on Evernote authentication state. | |
172 | - */ | |
173 | - private void updateUi() { | |
174 | - // DELETE | |
175 | - // if (session.isLoggedIn()) { | |
176 | - // btnAuth.setText(R.string.label_log_out); | |
177 | - // btnSave.setEnabled(true); | |
178 | - // btnSelect.setEnabled(true); | |
179 | - // } else { | |
180 | - // btnAuth.setText(R.string.label_log_in); | |
181 | - // btnSave.setEnabled(false); | |
182 | - // btnSelect.setEnabled(false); | |
183 | - // } | |
184 | - } | |
185 | - | |
186 | - /** | |
187 | - * Called when the user taps the "Log in to Evernote" button. Initiates the | |
188 | - * Evernote OAuth process, or logs out if the user is already logged in. | |
189 | - */ | |
190 | 52 | public void startAuth(View view) { |
191 | - // ADD | |
192 | - EvernoteSession session = util.getSession(); | |
53 | + EvernoteSession mEvernoteSession = util.getSession(); | |
193 | 54 | |
194 | - // EDIT | |
195 | - // if (session.isLoggedIn()) { | |
196 | - // session.logOut(util.getPreferencesForAuthData(this)); | |
197 | - // } else { | |
198 | - // session.authenticate(this); | |
199 | - // } | |
200 | - if (session.isLoggedIn()) { | |
201 | - session.logOut(util.getPreferencesForAuthData(this)); | |
55 | + if (mEvernoteSession.isLoggedIn()) { | |
56 | + mEvernoteSession.logOut(getApplicationContext()); | |
202 | 57 | } |
203 | - session.authenticate(this); | |
204 | - | |
58 | + mEvernoteSession.authenticate(this); | |
205 | 59 | updateUi(); |
206 | 60 | } |
207 | 61 | |
208 | - /** | |
209 | - * Get a temporary directory that can be used by this application to store | |
210 | - * potentially large files sent to and retrieved from the Evernote API. | |
211 | - */ | |
212 | - // private File getTempDir() { | |
213 | - // return new File(Environment.getExternalStorageDirectory(), | |
214 | - // APP_DATA_PATH); | |
215 | - // } | |
62 | + private void updateUi() { | |
63 | + ; | |
64 | + } | |
216 | 65 | } |
@@ -7,7 +7,6 @@ import android.content.Context; | ||
7 | 7 | import android.content.SharedPreferences; |
8 | 8 | import android.os.Environment; |
9 | 9 | |
10 | -import com.evernote.client.conn.ApplicationInfo; | |
11 | 10 | import com.evernote.client.oauth.android.EvernoteSession; |
12 | 11 | import com.yuji.ef.common.Constant; |
13 | 12 | import com.yuji.ef.pref.EditPrefUtil; |
@@ -20,16 +19,13 @@ public class OAuthUtil { | ||
20 | 19 | // Debian |
21 | 20 | //private static final String CONSUMER_SECRET = "G5r7t1nHC+AIf6dYHuIVC7Jr/iVIMtgMZ0PObN6xV2Q="; |
22 | 21 | // Mac |
23 | - private static final String CONSUMER_SECRET = "a/E89hlW9foWMh/ReopNucX+/WQ9WTs4YwvHP1cGH9s=" ; | |
22 | + private static final String CONSUMER_SECRET = "a/E89hlW9foWMh/ReopNucX+/WQ9WTs4YwvHP1cGH9s=" ; | |
24 | 23 | private static final String APP_DATA_PATH = "/Android/data/com.yuji.ef/temp/"; |
25 | - private static final String EVERNOTE_HOST = "www.evernote.com"; | |
26 | - | |
27 | - private static final String APP_NAME = "FolderErver"; | |
28 | - private static final String APP_VERSION = "1.0.0"; | |
24 | + private static final String EVERNOTE_HOST = EvernoteSession.HOST_PRODUCTION; | |
29 | 25 | |
30 | 26 | private static OAuthUtil instance = null; |
31 | 27 | private static String consumerSecret = null; |
32 | - private EvernoteSession session; | |
28 | + private EvernoteSession mEvernoteSession; | |
33 | 29 | |
34 | 30 | public static OAuthUtil getInstance() { |
35 | 31 | if (instance == null) { |
@@ -42,19 +38,23 @@ public class OAuthUtil { | ||
42 | 38 | |
43 | 39 | } |
44 | 40 | |
41 | + public EvernoteSession getSession() { | |
42 | + return mEvernoteSession; | |
43 | + } | |
44 | + | |
45 | 45 | public EvernoteSession setupSession(Context context) { |
46 | - if (consumerSecret == null){ | |
46 | + if (consumerSecret == null) { | |
47 | 47 | Encryption en = Encryption.getInstance(); |
48 | - //String s = en.getEncrypted(context, ""); | |
48 | + // String s = en.getEncrypted(context, ""); | |
49 | 49 | consumerSecret = en.getDecrypted(context, CONSUMER_SECRET); |
50 | 50 | } |
51 | - | |
52 | - ApplicationInfo info = new ApplicationInfo(CONSUMER_KEY, | |
53 | - consumerSecret, EVERNOTE_HOST, APP_NAME, APP_VERSION); | |
54 | 51 | |
55 | 52 | // Retrieve persisted authentication information |
56 | - session = new EvernoteSession(info, | |
57 | - getPreferencesForAuthData(context), getTempDir()); | |
53 | + File tempDir = getTempDir(); | |
54 | + // mEvernoteSession = EvernoteSession.init(context, CONSUMER_KEY, | |
55 | + // CONSUMER_SECRET, EVERNOTE_HOST, null); | |
56 | + mEvernoteSession = EvernoteSession.init(context, CONSUMER_KEY, | |
57 | + consumerSecret, EVERNOTE_HOST, tempDir); | |
58 | 58 | |
59 | 59 | // セッションの期限切れをチェック |
60 | 60 | EditPrefUtil pref = new EditPrefUtil(context); |
@@ -64,24 +64,19 @@ public class OAuthUtil { | ||
64 | 64 | long diff = (now - loginTime) / 1000; |
65 | 65 | |
66 | 66 | //if (loginTime > 0 && diff > 60){ // 1分 |
67 | - if (loginTime > 0 && diff > (365 - 1) * 24 * 60 * 60){ // 余裕を持って1日前に削除 | |
67 | + if (loginTime > 0 && diff > (365 - 1) * 24 * 60 * 60) { // 余裕を持って1日前に削除 | |
68 | 68 | logout(context); |
69 | 69 | pref.put(Constant.PREF_LOGIN_DATE, 0L); |
70 | 70 | pref.update(); |
71 | 71 | |
72 | - session = new EvernoteSession(info, | |
73 | - getPreferencesForAuthData(context), getTempDir()); | |
72 | + // 再作成 | |
73 | + // mEvernoteSession = new EvernoteSession(info, | |
74 | + // getPreferencesForAuthData(context), getTempDir()); | |
75 | + mEvernoteSession = EvernoteSession.init(context, CONSUMER_KEY, | |
76 | + consumerSecret, EVERNOTE_HOST, tempDir); | |
74 | 77 | } |
75 | - | |
76 | - return session; | |
77 | - } | |
78 | 78 | |
79 | - public boolean isCompleteAuth(Context context) { | |
80 | - if (session == null) { | |
81 | - return false; | |
82 | - } | |
83 | - return session | |
84 | - .completeAuthentication(getPreferencesForAuthData(context)); | |
79 | + return mEvernoteSession; | |
85 | 80 | } |
86 | 81 | |
87 | 82 | public SharedPreferences getPreferencesForAuthData(Context context) { |
@@ -94,16 +89,10 @@ public class OAuthUtil { | ||
94 | 89 | APP_DATA_PATH); |
95 | 90 | } |
96 | 91 | |
97 | - public EvernoteSession getSession() { | |
98 | - return session; | |
99 | - } | |
100 | - | |
101 | - public void logout(Context context){ | |
102 | - session.logOut(getPreferencesForAuthData(context)); | |
103 | - | |
104 | - EditPrefUtil pref = new EditPrefUtil(context); | |
105 | - pref.put(Constant.PREF_LOGIN_DATE, 0L); | |
106 | - pref.update(); | |
92 | + public void logout(Context context) { | |
93 | + if (mEvernoteSession != null && mEvernoteSession.isLoggedIn()) { | |
94 | + mEvernoteSession.logOut(context); | |
95 | + } | |
107 | 96 | } |
108 | 97 | |
109 | 98 | public void setLoginTime(Context context) { |