diff options
| -rw-r--r-- | res/values/strings.xml | 8 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgCompass.java | 9 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgData.java | 1 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeocaches.java | 66 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeoinit.java | 55 |
5 files changed, 77 insertions, 62 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index d955479..2d0b629 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -460,6 +460,10 @@ <string name="init_sendToCgeo_registering">Registering your device for "Send to c:geo"…</string> <string name="init_sendToCgeo_register_ok">Registration successful. PIN code is ####. Use it on c:geo website to add this device to your browser.</string> <string name="init_sendToCgeo_register_fail">Registration failed.</string> + + <string name="sendToCgeo_download_fail">c:geo failed to download caches. No internet connection or send2c:geo is down.</string> + <string name="sendToCgeo_no_registration">c:geo failed to download caches. Registration for send2c:geo expired. Please register in settings.</string> + <!-- auth --> <string name="auth_twitter">Twitter</string> @@ -920,6 +924,7 @@ · Rainer S. (code)\n · Ray (code, loc. JA)\n · <a href="http://seromenho.com/">Ricardo Seromenho</a> (localization PT)\n + · <a href="http://www.rfc1149.net/sam.html">Samuel Tardieu</a> (code, localization FR)\n · <a href="http://www.sammyshp.de/">SammysHP</a> (code, localization DE)\n · serenity (localization FR)\n · Shan, a.k.a. ShakurNO (localization NO)\n @@ -931,6 +936,7 @@ \n · <a href="http://code.google.com/p/mapsforge/">Mapsforge</a> (OSM-rendering)\n · <a href="http://thenounproject.com/">The Noun Project</a> (basis for attribute icons)\n + · <a href="http://commons.apache.org/">The Apache Commons Project</a>\n </string> <!-- changelog --> @@ -940,12 +946,14 @@ · new: experimental support for .gpx from opencaching.com\n · new: scan QR code to open cache description\n · new: context menu on stored caches button (main screen)\n + · new: compass immediately shows the right direction\n · fix: performance of GPX import\n · fix: performance of deleting caches from list\n · fix: return to list after GPX import\n · fix: fill signature when logging offline\n · fix: show strikethrough in caches\n · fix: no more empty map previews\n + · fix: send2c:geo\n \n\n <b>26.08.2011</b>\n · new: street view\n diff --git a/src/cgeo/geocaching/cgCompass.java b/src/cgeo/geocaching/cgCompass.java index 7ecee4b..f45501d 100644 --- a/src/cgeo/geocaching/cgCompass.java +++ b/src/cgeo/geocaching/cgCompass.java @@ -35,6 +35,7 @@ public class cgCompass extends View { private int compassArrowHeight = 0; private int compassOverlayWidth = 0; private int compassOverlayHeight = 0; + private boolean initialDisplay; private Handler changeHandler = new Handler() { @Override @@ -76,6 +77,7 @@ public class cgCompass extends View { setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG); remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0); + initialDisplay = true; wantStop = false; watchdog = new changeThread(); @@ -104,6 +106,13 @@ public class cgCompass extends View { } protected synchronized void updateNorth(double northHeadingIn, double cacheHeadingIn) { + if (initialDisplay) { + // We will force the compass to move brutally if this is the first + // update since it is visible. + azimuth = northHeadingIn; + heading = cacheHeadingIn; + initialDisplay = false; + } northHeading = northHeadingIn; cacheHeading = cacheHeadingIn; } diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java index d83edb9..195ce3d 100644 --- a/src/cgeo/geocaching/cgData.java +++ b/src/cgeo/geocaching/cgData.java @@ -1211,6 +1211,7 @@ public class cgData { values.put("longitude", cache.coords.getLongitude()); values.put("reliable_latlon", 1); } else if (!rel) { // new cache neither stored cache is not reliable, just update + // FIXME: if the user is not logged in, coords may be null values.put("latitude", cache.coords.getLatitude()); values.put("longitude", cache.coords.getLongitude()); values.put("reliable_latlon", 0); diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java index d52d2a7..7a423b1 100644 --- a/src/cgeo/geocaching/cgeocaches.java +++ b/src/cgeo/geocaching/cgeocaches.java @@ -417,7 +417,16 @@ public class cgeocaches extends AbstractListActivity { waitDialog.setOnCancelListener(null); } getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - showToast(res.getString(R.string.gpx_import_no_files)); + showToast(res.getString(R.string.sendToCgeo_download_fail)); + finish(); + return; + } else if (msg.what == -3) { + if (waitDialog != null) { + waitDialog.dismiss(); + waitDialog.setOnCancelListener(null); + } + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + showToast(res.getString(R.string.sendToCgeo_no_registration)); finish(); return; } else { @@ -2066,33 +2075,40 @@ public class cgeocaches extends AbstractListActivity { } cgResponse responseFromWeb = base.request(false, "send2.cgeo.org", "/read.html", "GET", "code=" + cgBase.urlencode_rfc3986(deviceCode), 0, true); - if ((responseFromWeb.getStatusCode() == 200) - && (responseFromWeb.getData().length() > 2)) { - - String GCcode = responseFromWeb.getData(); - - delay = 1; - Message mes = new Message(); - mes.what = 1; - mes.obj = GCcode; - handler.sendMessage(mes); - yield(); - - base.storeCache(app, cgeocaches.this, null, GCcode, reason, null); - - Message mes1 = new Message(); - mes1.what = 2; - mes1.obj = GCcode; - handler.sendMessage(mes1); - yield(); - } else { - delay = 0; - handler.sendEmptyMessage(0); - yield(); + if (responseFromWeb.getStatusCode() == 200) { + if (responseFromWeb.getData().length() > 2) { + + String GCcode = responseFromWeb.getData(); + + delay = 1; + Message mes = new Message(); + mes.what = 1; + mes.obj = GCcode; + handler.sendMessage(mes); + yield(); + + base.storeCache(app, cgeocaches.this, null, GCcode, + reason, null); + + Message mes1 = new Message(); + mes1.what = 2; + mes1.obj = GCcode; + handler.sendMessage(mes1); + yield(); + } else if ("RG".equals(responseFromWeb.getData())) { + //Server returned RG (registration) and this device no longer registered. + settings.setWebNameCode(null, null); + needToStop = true; + handler.sendEmptyMessage(-3); + return; + } else { + delay = 0; + handler.sendEmptyMessage(0); + yield(); + } } if (responseFromWeb.getStatusCode() != 200) { needToStop = true; - settings.setWebNameCode(null, null); handler.sendEmptyMessage(-2); return; } diff --git a/src/cgeo/geocaching/cgeoinit.java b/src/cgeo/geocaching/cgeoinit.java index 39b8e51..a0140fa 100644 --- a/src/cgeo/geocaching/cgeoinit.java +++ b/src/cgeo/geocaching/cgeoinit.java @@ -187,7 +187,7 @@ public class cgeoinit extends AbstractActivity { } } } - + @Override public boolean onContextItemSelected(MenuItem item) { LogTemplate template = LogTemplateProvider.getTemplate(item.getItemId()); @@ -196,7 +196,7 @@ public class cgeoinit extends AbstractActivity { } return super.onContextItemSelected(item); } - + private boolean insertSignatureTemplate(final LogTemplate template) { EditText sig = (EditText) findViewById(R.id.signature); String insertText = "[" + template.getTemplateString() + "]"; @@ -318,11 +318,11 @@ public class cgeoinit extends AbstractActivity { captchaButton.setChecked(true); } captchaButton.setOnClickListener(new cgeoChangeCaptcha()); - + final CheckBox dirImgButton = (CheckBox) findViewById(R.id.loaddirectionimg); dirImgButton.setChecked(settings.getLoadDirImg()); dirImgButton.setOnClickListener(new View.OnClickListener() { - + @Override public void onClick(View v) { settings.setLoadDirImg(!settings.getLoadDirImg()); @@ -414,7 +414,7 @@ public class cgeoinit extends AbstractActivity { final CheckBox logOffline = (CheckBox) findViewById(R.id.log_offline); logOffline.setChecked(settings.getLogOffline()); logOffline.setOnClickListener(new View.OnClickListener() { - + @Override public void onClick(View v) { settings.setLogOffline(!settings.getLogOffline()); @@ -519,35 +519,20 @@ public class cgeoinit extends AbstractActivity { } public boolean saveValues() { - String usernameNew = ((EditText) findViewById(R.id.username)).getText().toString(); - String passwordNew = ((EditText) findViewById(R.id.password)).getText().toString(); - String passvoteNew = ((EditText) findViewById(R.id.passvote)).getText().toString(); - String signatureNew = ((EditText) findViewById(R.id.signature)).getText().toString(); - String altitudeNew = ((EditText) findViewById(R.id.altitude)).getText().toString(); - String mfmapFileNew = ((EditText) findViewById(R.id.mapfile)).getText().toString(); - - if (usernameNew == null) { - usernameNew = ""; - } - if (passwordNew == null) { - passwordNew = ""; - } - if (passvoteNew == null) { - passvoteNew = ""; - } - if (signatureNew == null) { - signatureNew = ""; - } + String usernameNew = StringUtils.trimToEmpty(((EditText) findViewById(R.id.username)).getText().toString()); + String passwordNew = StringUtils.trimToEmpty(((EditText) findViewById(R.id.password)).getText().toString()); + String passvoteNew = StringUtils.trimToEmpty(((EditText) findViewById(R.id.passvote)).getText().toString()); + String signatureNew = StringUtils.trimToEmpty(((EditText) findViewById(R.id.signature)).getText().toString()); + String altitudeNew = StringUtils.trimToNull(((EditText) findViewById(R.id.altitude)).getText().toString()); + String mfmapFileNew = StringUtils.trimToEmpty(((EditText) findViewById(R.id.mapfile)).getText().toString()); int altitudeNewInt = 0; - if (altitudeNew == null) { - altitudeNewInt = 0; - } else { - altitudeNewInt = new Integer(altitudeNew); - } - - if (mfmapFileNew == null) { - mfmapFileNew = ""; + if (altitudeNew != null) { + try { + altitudeNewInt = Integer.parseInt(altitudeNew); + } catch (NumberFormatException e) { + altitudeNewInt = 0; + } } final boolean status1 = settings.setLogin(usernameNew, passwordNew); @@ -556,11 +541,7 @@ public class cgeoinit extends AbstractActivity { final boolean status4 = settings.setAltCorrection(altitudeNewInt); final boolean status5 = settings.setMapFile(mfmapFileNew); - if (status1 && status2 && status3 && status4 && status5) { - return true; - } - - return false; + return status1 && status2 && status3 && status4 && status5; } private class cgeoChangeTwitter implements View.OnClickListener { |
