diff options
| author | SammysHP <sven@sammyshp.de> | 2013-07-21 12:14:46 +0200 |
|---|---|---|
| committer | SammysHP <sven@sammyshp.de> | 2013-07-21 12:14:46 +0200 |
| commit | 7fd1fe234d7638d45f97348acc3c4f744573dd30 (patch) | |
| tree | da488b117ff60ce584fcedfa59cb9a1b8977773a /main | |
| parent | 1ad39511ca7719ea22e203d9c729e2b2bfe58556 (diff) | |
| download | cgeo-7fd1fe234d7638d45f97348acc3c4f744573dd30.zip cgeo-7fd1fe234d7638d45f97348acc3c4f744573dd30.tar.gz cgeo-7fd1fe234d7638d45f97348acc3c4f744573dd30.tar.bz2 | |
Fix #3035: Field note upload "since last export" should be controlled by
c:geo
Diffstat (limited to 'main')
| -rw-r--r-- | main/res/layout/fieldnote_export_dialog.xml | 1 | ||||
| -rw-r--r-- | main/res/values/preference_keys.xml | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/export/FieldnoteExport.java | 24 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/settings/Settings.java | 18 |
4 files changed, 29 insertions, 15 deletions
diff --git a/main/res/layout/fieldnote_export_dialog.xml b/main/res/layout/fieldnote_export_dialog.xml index 02ab182..9859b0f 100644 --- a/main/res/layout/fieldnote_export_dialog.xml +++ b/main/res/layout/fieldnote_export_dialog.xml @@ -19,7 +19,6 @@ <CheckBox
android:id="@+id/onlynew"
style="@style/checkbox_full"
- android:enabled="false"
android:text="@string/export_fieldnotes_onlynew" />
</LinearLayout>
\ No newline at end of file diff --git a/main/res/values/preference_keys.xml b/main/res/values/preference_keys.xml index eb851bf..0d4e4bb 100644 --- a/main/res/values/preference_keys.xml +++ b/main/res/values/preference_keys.xml @@ -85,4 +85,5 @@ <string name="pref_ocde_tokenpublic">ocde_tokenpublic</string> <string name="pref_temp_ocde_token_secret">ocde-temp-token-secret</string> <string name="pref_temp_ocde_token_public">ocde-temp-token-public</string> + <string name="pref_fieldnoteExportDate">fieldnoteExportDate</string> </resources> diff --git a/main/src/cgeo/geocaching/export/FieldnoteExport.java b/main/src/cgeo/geocaching/export/FieldnoteExport.java index 38b603c..9d0310c 100644 --- a/main/src/cgeo/geocaching/export/FieldnoteExport.java +++ b/main/src/cgeo/geocaching/export/FieldnoteExport.java @@ -9,6 +9,8 @@ import cgeo.geocaching.connector.gc.Login; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; +import cgeo.geocaching.settings.Settings; +import cgeo.geocaching.ui.Formatter; import cgeo.geocaching.utils.AsyncTaskWithProgress; import cgeo.geocaching.utils.IOUtils; import cgeo.geocaching.utils.Log; @@ -79,12 +81,9 @@ class FieldnoteExport extends AbstractExport { final CheckBox uploadOption = (CheckBox) layout.findViewById(R.id.upload); final CheckBox onlyNewOption = (CheckBox) layout.findViewById(R.id.onlynew); - uploadOption.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onlyNewOption.setEnabled(uploadOption.isChecked()); - } - }); + if (Settings.getFieldnoteExportDate() > 0) { + onlyNewOption.setText(getString(R.string.export_fieldnotes_onlynew) + "\n(" + Formatter.formatShortDateTime(activity, Settings.getFieldnoteExportDate()) + ')'); + } builder.setPositiveButton(R.string.export, new DialogInterface.OnClickListener() { @@ -134,7 +133,10 @@ class FieldnoteExport extends AbstractExport { int i = 0; for (final Geocache cache : caches) { if (cache.isLogOffline()) { - appendFieldNote(fieldNoteBuffer, cache, cgData.loadLogOffline(cache.getGeocode())); + final LogEntry log = cgData.loadLogOffline(cache.getGeocode()); + if (!onlyNew || onlyNew && log.date > Settings.getFieldnoteExportDate()) { + appendFieldNote(fieldNoteBuffer, cache, log); + } publishProgress(++i); } } @@ -195,10 +197,6 @@ class FieldnoteExport extends AbstractExport { "__EVENTARGUMENT", "", "ctl00$ContentBody$btnUpload", "Upload Field Note"); - if (onlyNew) { - uploadParams.put("ctl00$ContentBody$chkSuppressDate", "on"); - } - Login.putViewstates(uploadParams, viewstates); Network.getResponseData(Network.postRequest(uri, uploadParams, "ctl00$ContentBody$FieldNoteLoader", "text/plain", exportFile)); @@ -216,9 +214,7 @@ class FieldnoteExport extends AbstractExport { protected void onPostExecuteInternal(Boolean result) { if (null != activity) { if (result) { - // if (onlyNew) { - // // update last export time in settings when doing it ourself (currently we use the date check from gc.com) - // } + Settings.setFieldnoteExportDate(System.currentTimeMillis()); ActivityMixin.showToast(activity, getName() + ' ' + getString(R.string.export_exportedto) + ": " + exportFile.toString()); diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java index aabb13a..244c924 100644 --- a/main/src/cgeo/geocaching/settings/Settings.java +++ b/main/src/cgeo/geocaching/settings/Settings.java @@ -199,6 +199,10 @@ public final class Settings { return sharedPrefs.getInt(getKey(prefKeyId), defaultValue); } + private static long getLong(final int prefKeyId, final long defaultValue) { + return sharedPrefs.getLong(getKey(prefKeyId), defaultValue); + } + private static boolean getBoolean(final int prefKeyId, final boolean defaultValue) { return sharedPrefs.getBoolean(getKey(prefKeyId), defaultValue); } @@ -225,6 +229,12 @@ public final class Settings { return edit.commit(); } + private static boolean putLong(final int prefKeyId, final long value) { + final SharedPreferences.Editor edit = sharedPrefs.edit(); + edit.putLong(getKey(prefKeyId), value); + return edit.commit(); + } + private static boolean putFloat(final int prefKeyId, final float value) { final SharedPreferences.Editor edit = sharedPrefs.edit(); edit.putFloat(getKey(prefKeyId), value); @@ -974,4 +984,12 @@ public final class Settings { putBoolean(R.string.pref_units, imperial); } + public static long getFieldnoteExportDate() { + return getLong(R.string.pref_fieldnoteExportDate, 0); + } + + public static void setFieldnoteExportDate(final long date) { + putLong(R.string.pref_fieldnoteExportDate, date); + } + } |
