aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo
diff options
context:
space:
mode:
authorSammysHP <sven@sammyshp.de>2013-07-21 12:14:46 +0200
committerSammysHP <sven@sammyshp.de>2013-07-21 12:14:46 +0200
commit7fd1fe234d7638d45f97348acc3c4f744573dd30 (patch)
treeda488b117ff60ce584fcedfa59cb9a1b8977773a /main/src/cgeo
parent1ad39511ca7719ea22e203d9c729e2b2bfe58556 (diff)
downloadcgeo-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/src/cgeo')
-rw-r--r--main/src/cgeo/geocaching/export/FieldnoteExport.java24
-rw-r--r--main/src/cgeo/geocaching/settings/Settings.java18
2 files changed, 28 insertions, 14 deletions
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);
+ }
+
}