Merge lp:~snert/financisto/main into lp:~financisto-dev/financisto/trunk
- main
- Merge into trunk
Proposed by
Jan Scheithauer
Status: | Needs review |
---|---|
Proposed branch: | lp:~snert/financisto/main |
Merge into: | lp:~financisto-dev/financisto/trunk |
Diff against target: |
485 lines (+262/-17) (has conflicts) 9 files modified
.bzrignore (+3/-0) .classpath (+18/-12) res/values-de/strings.xml (+7/-1) res/values/strings.xml (+7/-0) res/xml/preferences.xml (+9/-0) src/ru/orangesoftware/financisto/activity/MainActivity.java (+144/-4) src/ru/orangesoftware/financisto/export/CsvExportTaskDropbox.java (+40/-0) src/ru/orangesoftware/financisto/export/Export.java (+19/-0) src/ru/orangesoftware/financisto/utils/MyPreferences.java (+15/-0) Text conflict in src/ru/orangesoftware/financisto/activity/MainActivity.java Text conflict in src/ru/orangesoftware/financisto/export/Export.java |
To merge this branch: | bzr merge lp:~snert/financisto/main |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Financisto Developers | Pending | ||
Review via email:
|
Commit message
Description of the change
rudimentary dropbox integration
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2010-12-09 15:02:12 +0000 |
3 | +++ .bzrignore 2011-02-18 22:55:34 +0000 |
4 | @@ -11,3 +11,6 @@ |
5 | Financisto.ipr |
6 | Financisto.iws |
7 | .settings |
8 | +.DS_Store |
9 | +.checkstyle |
10 | +financisto.keystore |
11 | |
12 | === modified file '.classpath' |
13 | --- .classpath 2010-12-09 15:02:12 +0000 |
14 | +++ .classpath 2011-02-18 22:55:34 +0000 |
15 | @@ -1,12 +1,18 @@ |
16 | -<?xml version="1.0" encoding="UTF-8"?> |
17 | -<classpath> |
18 | - <classpathentry kind="src" path="gen"/> |
19 | - <classpathentry kind="src" path="src"/> |
20 | - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> |
21 | - <classpathentry kind="lib" path="lib/trace-0.2.0.jar"/> |
22 | - <classpathentry exported="true" kind="lib" path="lib/rfc2445-no-joda.jar"/> |
23 | - <classpathentry kind="lib" path="lib/GDocsAPI.jar"/> |
24 | - <classpathentry kind="lib" path="lib/CWAC-WakefulIntentService.jar"/> |
25 | - <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Android 2.2 Google APIs"/> |
26 | - <classpathentry kind="output" path="bin"/> |
27 | -</classpath> |
28 | +<?xml version="1.0" encoding="UTF-8"?> |
29 | +<classpath> |
30 | + <classpathentry kind="src" path="gen"/> |
31 | + <classpathentry kind="src" path="src"/> |
32 | + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> |
33 | + <classpathentry kind="lib" path="lib/trace-0.2.0.jar"/> |
34 | + <classpathentry exported="true" kind="lib" path="lib/rfc2445-no-joda.jar"/> |
35 | + <classpathentry kind="lib" path="lib/GDocsAPI.jar"/> |
36 | + <classpathentry kind="lib" path="lib/CWAC-WakefulIntentService.jar"/> |
37 | + <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Android 2.2 Google APIs"/> |
38 | + <classpathentry kind="lib" path="lib/apache-mime4j-0.6.jar"/> |
39 | + <classpathentry kind="lib" path="lib/dropbox-client-1.0-SNAPSHOT.jar"/> |
40 | + <classpathentry kind="lib" path="lib/httpmime-4.0.jar"/> |
41 | + <classpathentry kind="lib" path="lib/json_simple-1.1.jar"/> |
42 | + <classpathentry kind="lib" path="lib/signpost-commonshttp4-1.2.1.1.jar"/> |
43 | + <classpathentry kind="lib" path="lib/signpost-core-1.2.1.1.jar"/> |
44 | + <classpathentry kind="output" path="bin"/> |
45 | +</classpath> |
46 | |
47 | === added file 'lib/apache-mime4j-0.6.jar' |
48 | Binary files lib/apache-mime4j-0.6.jar 1970-01-01 00:00:00 +0000 and lib/apache-mime4j-0.6.jar 2011-02-18 22:55:34 +0000 differ |
49 | === added file 'lib/dropbox-client-1.0-SNAPSHOT.jar' |
50 | Binary files lib/dropbox-client-1.0-SNAPSHOT.jar 1970-01-01 00:00:00 +0000 and lib/dropbox-client-1.0-SNAPSHOT.jar 2011-02-18 22:55:34 +0000 differ |
51 | === added file 'lib/httpmime-4.0.jar' |
52 | Binary files lib/httpmime-4.0.jar 1970-01-01 00:00:00 +0000 and lib/httpmime-4.0.jar 2011-02-18 22:55:34 +0000 differ |
53 | === added file 'lib/json_simple-1.1.jar' |
54 | Binary files lib/json_simple-1.1.jar 1970-01-01 00:00:00 +0000 and lib/json_simple-1.1.jar 2011-02-18 22:55:34 +0000 differ |
55 | === added file 'lib/signpost-commonshttp4-1.2.1.1.jar' |
56 | Binary files lib/signpost-commonshttp4-1.2.1.1.jar 1970-01-01 00:00:00 +0000 and lib/signpost-commonshttp4-1.2.1.1.jar 2011-02-18 22:55:34 +0000 differ |
57 | === added file 'lib/signpost-core-1.2.1.1.jar' |
58 | Binary files lib/signpost-core-1.2.1.1.jar 1970-01-01 00:00:00 +0000 and lib/signpost-core-1.2.1.1.jar 2011-02-18 22:55:34 +0000 differ |
59 | === modified file 'res/values-de/strings.xml' |
60 | --- res/values-de/strings.xml 2011-01-06 00:27:00 +0000 |
61 | +++ res/values-de/strings.xml 2011-02-18 22:55:34 +0000 |
62 | @@ -621,5 +621,11 @@ |
63 | <string name="donate">Spenden</string> |
64 | <string name="donate_error">Android Market ist auf dem Gerät nicht verfügbar</string> |
65 | <string name="type">Typ</string> |
66 | - |
67 | + <string name="csv_export_dropbox">CSV Export Dropbox</string> |
68 | + <string name="dropbox_backup">Dropbox</string> |
69 | + <string name="dropbox_user_login">Login</string> |
70 | + <string name="dropbox_user_login_summary">Dropbox-Login (Benutzername)</string> |
71 | + <string name="dropbox_user_password">Passwort</string> |
72 | + <string name="dropbox_user_password_summary">Dropbox Passwort</string> |
73 | + <string name="dropbox_credentials_not_configured">Bitte geben Sie die Dropbox-Zugangsdaten in den Einstellungen an.</string> |
74 | </resources> |
75 | |
76 | === modified file 'res/values/strings.xml' |
77 | --- res/values/strings.xml 2011-02-18 09:00:25 +0000 |
78 | +++ res/values/strings.xml 2011-02-18 22:55:34 +0000 |
79 | @@ -616,6 +616,13 @@ |
80 | <string name="donate">Make a donation</string> |
81 | <string name="donate_error">Android Market is not available on your device</string> |
82 | <string name="type">Type</string> |
83 | + <string name="csv_export_dropbox">CSV Export Dropbox</string> |
84 | + <string name="dropbox_backup">Dropbox</string> |
85 | + <string name="dropbox_user_login">Login</string> |
86 | + <string name="dropbox_user_login_summary">Dropbox-Login</string> |
87 | + <string name="dropbox_user_password">Password</string> |
88 | + <string name="dropbox_user_password_summary">Dropbox Password</string> |
89 | + <string name="dropbox_credentials_not_configured">Please set Dropbox account login and password on Preferences.</string> |
90 | |
91 | <string name="qif_export">QIF Export</string> |
92 | <string name="qif_export_inprogress">Exporting data to QIF..</string> |
93 | |
94 | === modified file 'res/xml/preferences.xml' |
95 | --- res/xml/preferences.xml 2010-12-11 14:17:43 +0000 |
96 | +++ res/xml/preferences.xml 2011-02-18 22:55:34 +0000 |
97 | @@ -123,6 +123,15 @@ |
98 | <EditTextPreference android:key="backup_folder" |
99 | android:title="@string/backup_folder" android:summary="@string/backup_folder_summary"/> |
100 | </PreferenceCategory> |
101 | + <PreferenceCategory android:title="@string/dropbox_backup"> |
102 | + <EditTextPreference android:key="dropbox_user_login" |
103 | + android:title="@string/dropbox_user_login" android:summary="@string/dropbox_user_login_summary"/> |
104 | + <EditTextPreference |
105 | + android:key="dropbox_user_password" |
106 | + android:title="@string/dropbox_user_password" |
107 | + android:password="true" |
108 | + android:summary="@string/dropbox_user_password_summary"/> |
109 | + </PreferenceCategory> |
110 | <PreferenceCategory android:title="@string/other"> |
111 | <CheckBoxPreference android:key="include_transfers_into_reports" |
112 | android:title="@string/include_transfers_into_reports" |
113 | |
114 | === modified file 'src/ru/orangesoftware/financisto/activity/MainActivity.java' |
115 | --- src/ru/orangesoftware/financisto/activity/MainActivity.java 2011-02-18 09:00:25 +0000 |
116 | +++ src/ru/orangesoftware/financisto/activity/MainActivity.java 2011-02-18 22:55:34 +0000 |
117 | @@ -10,6 +10,30 @@ |
118 | ******************************************************************************/ |
119 | package ru.orangesoftware.financisto.activity; |
120 | |
121 | +import java.io.IOException; |
122 | +import java.util.HashMap; |
123 | +import java.util.List; |
124 | +import java.util.Properties; |
125 | + |
126 | +import ru.orangesoftware.financisto.R; |
127 | +import ru.orangesoftware.financisto.backup.Backup; |
128 | +import ru.orangesoftware.financisto.backup.DatabaseExport; |
129 | +import ru.orangesoftware.financisto.backup.DatabaseImport; |
130 | +import ru.orangesoftware.financisto.backup.SettingsNotConfiguredException; |
131 | +import ru.orangesoftware.financisto.blotter.WhereFilter; |
132 | +import ru.orangesoftware.financisto.db.DatabaseAdapter; |
133 | +import ru.orangesoftware.financisto.db.DatabaseHelper; |
134 | +import ru.orangesoftware.financisto.dialog.WebViewDialog; |
135 | +import ru.orangesoftware.financisto.export.BackupExportTask; |
136 | +import ru.orangesoftware.financisto.export.CsvExportTask; |
137 | +import ru.orangesoftware.financisto.export.CsvExportTaskDropbox; |
138 | +import ru.orangesoftware.financisto.export.ImportExportAsyncTask; |
139 | +import ru.orangesoftware.financisto.export.ImportExportAsyncTaskListener; |
140 | +import ru.orangesoftware.financisto.model.Currency; |
141 | +import ru.orangesoftware.financisto.utils.CurrencyCache; |
142 | +import ru.orangesoftware.financisto.utils.EntityEnum; |
143 | +import ru.orangesoftware.financisto.utils.EnumUtils; |
144 | +import ru.orangesoftware.financisto.utils.MyPreferences; |
145 | import android.app.AlertDialog; |
146 | import android.app.Dialog; |
147 | import android.app.ProgressDialog; |
148 | @@ -25,9 +49,17 @@ |
149 | import android.os.Handler; |
150 | import android.os.Message; |
151 | import android.util.Log; |
152 | -import android.view.*; |
153 | +import android.view.LayoutInflater; |
154 | +import android.view.Menu; |
155 | +import android.view.MenuItem; |
156 | +import android.view.View; |
157 | import android.view.View.OnClickListener; |
158 | -import android.widget.*; |
159 | +import android.view.Window; |
160 | +import android.widget.LinearLayout; |
161 | +import android.widget.ListAdapter; |
162 | +import android.widget.TabHost; |
163 | +import android.widget.TextView; |
164 | +import android.widget.Toast; |
165 | import api.wireless.gdata.client.AbstructParserFactory; |
166 | import api.wireless.gdata.client.GDataParserFactory; |
167 | import api.wireless.gdata.client.ServiceDataClient; |
168 | @@ -40,7 +72,12 @@ |
169 | import api.wireless.gdata.parser.ParseException; |
170 | import api.wireless.gdata.util.AuthenticationException; |
171 | import api.wireless.gdata.util.ServiceException; |
172 | + |
173 | +import com.dropbox.client.DropboxAPI; |
174 | +import com.dropbox.client.DropboxAPI.Account; |
175 | +import com.dropbox.client.DropboxAPI.Config; |
176 | import com.nullwire.trace.ExceptionHandler; |
177 | +<<<<<<< TREE |
178 | import ru.orangesoftware.financisto.R; |
179 | import ru.orangesoftware.financisto.backup.Backup; |
180 | import ru.orangesoftware.financisto.backup.DatabaseExport; |
181 | @@ -65,18 +102,30 @@ |
182 | import java.util.HashMap; |
183 | import java.util.List; |
184 | import java.util.Properties; |
185 | +======= |
186 | +>>>>>>> MERGE-SOURCE |
187 | |
188 | public class MainActivity extends TabActivity implements TabHost.OnTabChangeListener { |
189 | |
190 | + final static public String ACCOUNT_PREFS_NAME = "prefs"; |
191 | + final static public String ACCESS_KEY_NAME = "ACCESS_KEY"; |
192 | + final static public String ACCESS_SECRET_NAME = "ACCESS_SECRET"; |
193 | + |
194 | private static final int ACTIVITY_PIN = 1; |
195 | private static final int ACTIVITY_CSV_EXPORT = 2; |
196 | +<<<<<<< TREE |
197 | private static final int ACTIVITY_QIF_EXPORT = 3; |
198 | |
199 | +======= |
200 | + private static final int ACTIVITY_CSV_EXPORT_DROPBOX = 3; |
201 | + |
202 | +>>>>>>> MERGE-SOURCE |
203 | private static final int MENU_PREFERENCES = Menu.FIRST+1; |
204 | private static final int MENU_ABOUT = Menu.FIRST+2; |
205 | private static final int MENU_BACKUP = Menu.FIRST+3; |
206 | private static final int MENU_RESTORE = Menu.FIRST+4; |
207 | private static final int MENU_CSV_EXPORT = Menu.FIRST+5; |
208 | +<<<<<<< TREE |
209 | private static final int MENU_SCHEDULED_TRANSACTIONS = Menu.FIRST+6; |
210 | private static final int MENU_BACKUP_GDOCS = Menu.FIRST+7; |
211 | private static final int MENU_RESTORE_GDOCS = Menu.FIRST+8; |
212 | @@ -84,6 +133,15 @@ |
213 | private static final int MENU_MASS_OP = Menu.FIRST+10; |
214 | private static final int MENU_DONATE = Menu.FIRST+11; |
215 | private static final int MENU_QIF_EXPORT = Menu.FIRST+12; |
216 | +======= |
217 | + private static final int MENU_CSV_EXPORT_DROPBOX = Menu.FIRST+6; |
218 | + private static final int MENU_SCHEDULED_TRANSACTIONS = Menu.FIRST+7; |
219 | + private static final int MENU_BACKUP_GDOCS = Menu.FIRST+8; |
220 | + private static final int MENU_RESTORE_GDOCS = Menu.FIRST+9; |
221 | + private static final int MENU_ENTITIES = Menu.FIRST+10; |
222 | + private static final int MENU_MASS_OP = Menu.FIRST+11; |
223 | + private static final int MENU_DONATE = Menu.FIRST+12; |
224 | +>>>>>>> MERGE-SOURCE |
225 | |
226 | private final HashMap<String, Boolean> started = new HashMap<String, Boolean>(); |
227 | |
228 | @@ -135,7 +193,7 @@ |
229 | finish(); |
230 | System.exit(-1); |
231 | } |
232 | - } else if (requestCode == ACTIVITY_CSV_EXPORT) { |
233 | + } else if (requestCode == ACTIVITY_CSV_EXPORT || requestCode == ACTIVITY_CSV_EXPORT_DROPBOX) { |
234 | if (resultCode == RESULT_OK) { |
235 | WhereFilter filter = WhereFilter.fromIntent(data); |
236 | Currency currency = new Currency(); |
237 | @@ -145,7 +203,13 @@ |
238 | currency.decimals = data.getIntExtra(CsvExportActivity.CSV_EXPORT_DECIMALS, 2); |
239 | currency.decimalSeparator = data.getStringExtra(CsvExportActivity.CSV_EXPORT_DECIMAL_SEPARATOR); |
240 | currency.groupSeparator = data.getStringExtra(CsvExportActivity.CSV_EXPORT_GROUP_SEPARATOR); |
241 | - doCsvExport(filter, currency, fieldSeparator, includeHeader); |
242 | + if(requestCode == ACTIVITY_CSV_EXPORT){ |
243 | + doCsvExport(filter, currency, fieldSeparator, includeHeader); |
244 | + }else if(requestCode == ACTIVITY_CSV_EXPORT_DROPBOX){ |
245 | + doCsvExportDropbox(filter, currency, fieldSeparator, includeHeader); |
246 | + }else{ |
247 | + throw new RuntimeException("undefined requestCode: " + requestCode); |
248 | + } |
249 | } |
250 | } else if (requestCode == ACTIVITY_QIF_EXPORT) { |
251 | if (resultCode == RESULT_OK) { |
252 | @@ -161,11 +225,30 @@ |
253 | new CsvExportTask(this, d, filter, currency, fieldSeparator, includeHeader).execute((String[])null); |
254 | } |
255 | |
256 | +<<<<<<< TREE |
257 | private void doQifExport(WhereFilter filter, long[] selectedAccounts) { |
258 | ProgressDialog d = ProgressDialog.show(this, null, getString(R.string.qif_export_inprogress), true); |
259 | new QifExportTask(this, d, filter, selectedAccounts).execute((String[])null); |
260 | } |
261 | |
262 | +======= |
263 | + private void doCsvExportDropbox(WhereFilter filter, Currency currency, char fieldSeparaotr, boolean includeHeader) { |
264 | + String droboxUsername = MyPreferences.getDropboxUserLogin(this); |
265 | + String droboxPassword = MyPreferences.getDropboxUserPassword(this); |
266 | + if( (droboxUsername==null||droboxUsername.equals("")) || (droboxPassword==null||droboxPassword.equals(""))) { |
267 | + showErrorPopup(this,R.string.dropbox_credentials_not_configured); |
268 | + return; |
269 | + } |
270 | + DropboxAPI api = createDropboxApi(droboxUsername, droboxPassword); |
271 | + if(api==null){ |
272 | +// FIXME: api = null what to do?? |
273 | + return; |
274 | + } |
275 | + ProgressDialog d = ProgressDialog.show(this, null, getString(R.string.csv_export_inprogress), true); |
276 | + new CsvExportTaskDropbox(this, d, filter, currency, fieldSeparaotr, includeHeader, api).execute((String[])null); |
277 | + } |
278 | + |
279 | +>>>>>>> MERGE-SOURCE |
280 | private void initialLoad() { |
281 | long t2, t1, t0 = System.currentTimeMillis(); |
282 | DatabaseAdapter db = new DatabaseAdapter(this); |
283 | @@ -263,7 +346,11 @@ |
284 | menu.addSubMenu(0, MENU_BACKUP_GDOCS, 0, R.string.backup_database_gdocs); |
285 | menu.addSubMenu(0, MENU_RESTORE_GDOCS, 0, R.string.restore_database_gdocs); |
286 | menu.addSubMenu(0, MENU_CSV_EXPORT, 0, R.string.csv_export); |
287 | +<<<<<<< TREE |
288 | menu.addSubMenu(0, MENU_QIF_EXPORT, 0, R.string.qif_export); |
289 | +======= |
290 | + menu.addSubMenu(0, MENU_CSV_EXPORT_DROPBOX, 0, R.string.csv_export_dropbox); |
291 | +>>>>>>> MERGE-SOURCE |
292 | menu.addSubMenu(0, MENU_DONATE, 0, R.string.donate); |
293 | menu.addSubMenu(0, MENU_ABOUT, 0, R.string.about); |
294 | return true; |
295 | @@ -307,9 +394,15 @@ |
296 | case MENU_CSV_EXPORT: |
297 | doCsvExport(); |
298 | break; |
299 | +<<<<<<< TREE |
300 | case MENU_QIF_EXPORT: |
301 | doQifExport(); |
302 | break; |
303 | +======= |
304 | + case MENU_CSV_EXPORT_DROPBOX: |
305 | + doCsvExportDropbox(); |
306 | + break; |
307 | +>>>>>>> MERGE-SOURCE |
308 | case MENU_BACKUP: |
309 | doBackup(); |
310 | break; |
311 | @@ -393,6 +486,42 @@ |
312 | return googleDocsClient; |
313 | } |
314 | |
315 | + /** |
316 | + * Connects to Dropbox |
317 | + */ |
318 | + protected DropboxAPI createDropboxApi(String droboxUsername, String droboxPassword){ |
319 | + DropboxAPI api = new DropboxAPI(); |
320 | + Config mConfig = api.getConfig(null, false); |
321 | + mConfig.consumerKey=""; |
322 | + mConfig.consumerSecret=""; |
323 | + mConfig.server="api.dropbox.com"; |
324 | + mConfig.contentServer="api-content.dropbox.com"; |
325 | + mConfig.port=80; |
326 | + |
327 | + try { |
328 | + int success = DropboxAPI.STATUS_NONE; |
329 | + if (!api.isAuthenticated()) { |
330 | + mConfig = api.authenticate(mConfig, droboxUsername, droboxPassword); |
331 | + success = mConfig.authStatus; |
332 | + if (success != DropboxAPI.STATUS_SUCCESS) { |
333 | + return null; |
334 | + } |
335 | + } |
336 | + Account mAccount = api.accountInfo(); |
337 | + |
338 | + if (!mAccount.isError()) { |
339 | + showToast("Login successful: " + mAccount.displayName); |
340 | + return api; |
341 | + } else { |
342 | + showToast("Login not successful"); |
343 | + return null; |
344 | + } |
345 | + } catch (Exception e) { |
346 | + showToast("Error in logging in. " + e.getMessage()); |
347 | + return null; |
348 | + } |
349 | + } |
350 | + |
351 | private void doBackup() { |
352 | ProgressDialog d = ProgressDialog.show(this, null, getString(R.string.backup_database_inprogress), true); |
353 | new BackupExportTask(this, d).execute((String[])null); |
354 | @@ -410,6 +539,12 @@ |
355 | Intent intent = new Intent(this, CsvExportActivity.class); |
356 | startActivityForResult(intent, ACTIVITY_CSV_EXPORT); |
357 | } |
358 | + |
359 | + private void doCsvExportDropbox() { |
360 | + Intent intent = new Intent(this, CsvExportActivity.class); |
361 | + startActivityForResult(intent, ACTIVITY_CSV_EXPORT_DROPBOX); |
362 | + } |
363 | + |
364 | |
365 | private void doQifExport() { |
366 | Intent intent = new Intent(this, QifExportActivity.class); |
367 | @@ -722,4 +857,9 @@ |
368 | |
369 | } |
370 | |
371 | + public void showToast(String msg) { |
372 | + Toast error = Toast.makeText(this, msg, Toast.LENGTH_LONG); |
373 | + error.show(); |
374 | + } |
375 | + |
376 | } |
377 | |
378 | === added file 'src/ru/orangesoftware/financisto/export/CsvExportTaskDropbox.java' |
379 | --- src/ru/orangesoftware/financisto/export/CsvExportTaskDropbox.java 1970-01-01 00:00:00 +0000 |
380 | +++ src/ru/orangesoftware/financisto/export/CsvExportTaskDropbox.java 2011-02-18 22:55:34 +0000 |
381 | @@ -0,0 +1,40 @@ |
382 | +package ru.orangesoftware.financisto.export; |
383 | + |
384 | +import ru.orangesoftware.financisto.blotter.WhereFilter; |
385 | +import ru.orangesoftware.financisto.db.DatabaseAdapter; |
386 | +import ru.orangesoftware.financisto.model.Currency; |
387 | +import android.app.ProgressDialog; |
388 | +import android.content.Context; |
389 | + |
390 | +import com.dropbox.client.DropboxAPI; |
391 | + |
392 | +public class CsvExportTaskDropbox extends ImportExportAsyncTask { |
393 | + |
394 | + private final WhereFilter filter; |
395 | + private final Currency currency; |
396 | + private final char fieldSeparator; |
397 | + private final boolean includeHeader; |
398 | + private final DropboxAPI dropboxApi; |
399 | + |
400 | + public CsvExportTaskDropbox(Context context, ProgressDialog dialog, WhereFilter filter, Currency currency, |
401 | + char fieldSeparator, boolean includeHeader, DropboxAPI dropboxApi) { |
402 | + super(context, dialog, null); |
403 | + this.filter = filter; |
404 | + this.currency = currency; |
405 | + this.fieldSeparator = fieldSeparator; |
406 | + this.includeHeader = includeHeader; |
407 | + this.dropboxApi = dropboxApi; |
408 | + } |
409 | + |
410 | + @Override |
411 | + protected Object work(Context context, DatabaseAdapter db, String...params) throws Exception { |
412 | + CSVExport export = new CSVExport(db, filter, currency, fieldSeparator, includeHeader); |
413 | + return export.exportDropbox(dropboxApi); |
414 | + } |
415 | + |
416 | + @Override |
417 | + protected String getSuccessMessage(Object result) { |
418 | + return String.valueOf(result); |
419 | + } |
420 | + |
421 | +} |
422 | |
423 | === modified file 'src/ru/orangesoftware/financisto/export/Export.java' |
424 | --- src/ru/orangesoftware/financisto/export/Export.java 2011-02-07 17:11:32 +0000 |
425 | +++ src/ru/orangesoftware/financisto/export/Export.java 2011-02-18 22:55:34 +0000 |
426 | @@ -22,6 +22,8 @@ |
427 | import java.text.SimpleDateFormat; |
428 | import java.util.Date; |
429 | |
430 | +import com.dropbox.client.DropboxAPI; |
431 | + |
432 | import ru.orangesoftware.financisto.backup.SettingsNotConfiguredException; |
433 | import android.content.pm.PackageManager.NameNotFoundException; |
434 | import android.os.Environment; |
435 | @@ -81,7 +83,24 @@ |
436 | return fileName; |
437 | } |
438 | |
439 | +<<<<<<< TREE |
440 | private String generateFilename() { |
441 | +======= |
442 | + public String exportDropbox(DropboxAPI api) throws Exception{ |
443 | + // generation backup file |
444 | + String fileName = generateFilename(); |
445 | + File path = getPath(); |
446 | + path.mkdirs(); |
447 | + File file = new File(path, fileName); |
448 | + FileOutputStream outputStream = new FileOutputStream(file); |
449 | + generateBackup(outputStream); |
450 | + api.putFile("dropbox", "/", file); |
451 | + return fileName; |
452 | + } |
453 | + |
454 | + private String generateFilename() |
455 | + { |
456 | +>>>>>>> MERGE-SOURCE |
457 | SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd'_'HHmmss'_'SSS"); |
458 | return df.format(new Date())+getExtension(); |
459 | } |
460 | |
461 | === modified file 'src/ru/orangesoftware/financisto/utils/MyPreferences.java' |
462 | --- src/ru/orangesoftware/financisto/utils/MyPreferences.java 2011-01-30 13:13:22 +0000 |
463 | +++ src/ru/orangesoftware/financisto/utils/MyPreferences.java 2011-02-18 22:55:34 +0000 |
464 | @@ -186,6 +186,21 @@ |
465 | } |
466 | |
467 | /** |
468 | + * Get drobox user login registered on preferences |
469 | + */ |
470 | + public static String getDropboxUserLogin(Context context){ |
471 | + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); |
472 | + return sharedPreferences.getString("dropbox_user_login", null); |
473 | + } |
474 | + |
475 | + /** |
476 | + * Get drobox user password registered on preferences |
477 | + */ |
478 | + public static String getDropboxUserPassword(Context context){ |
479 | + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); |
480 | + return sharedPreferences.getString("dropbox_user_password", null); |
481 | + } |
482 | + /** |
483 | * Gets the string representing reference currency registered on preferences to display chart reports. |
484 | * @param context The activity context |
485 | * @return The string representing the currency registered as a reference to display chart reports or null if not configured yet. |