aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/res/values-cs/strings.xml2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/Login.java12
-rw-r--r--main/src/cgeo/geocaching/network/Network.java16
3 files changed, 23 insertions, 7 deletions
diff --git a/main/res/values-cs/strings.xml b/main/res/values-cs/strings.xml
index 63eb494..fd262e1 100644
--- a/main/res/values-cs/strings.xml
+++ b/main/res/values-cs/strings.xml
@@ -523,7 +523,7 @@
<string name="map_view_map">pohled do mapy</string>
<string name="map_trail_show">zobrazit záznam trasy</string>
<string name="map_trail_hide">skrýt záznam trasy</string>
- <string name="map_live_enable">povolit aktivní mapu</string>
+ <string name="map_live_enable">povolit aktivní mapu</string>
<string name="map_live_disable">zakázat aktivní mapu</string>
<string name="map_static_title">statické mapy</string>
<string name="map_static_loading">načítání statických map…</string>
diff --git a/main/src/cgeo/geocaching/connector/gc/Login.java b/main/src/cgeo/geocaching/connector/gc/Login.java
index 5584ffe..39f81f0 100644
--- a/main/src/cgeo/geocaching/connector/gc/Login.java
+++ b/main/src/cgeo/geocaching/connector/gc/Login.java
@@ -30,7 +30,7 @@ import java.util.regex.Matcher;
public abstract class Login {
- private final static String ENGLISH = "English&#9660;";
+ private final static String ENGLISH = "<a href=\"#\">English&#9660;</a>";
// false = not logged in
private static boolean actualLoginStatus = false;
@@ -39,6 +39,8 @@ public abstract class Login {
private static String actualStatus = "";
private final static Map<String, SimpleDateFormat> gcCustomDateFormats;
+ public static final String LANGUAGE_CHANGE_URI = "http://www.geocaching.com/my/souvenirs.aspx";
+
static {
final String[] formats = new String[] {
"MM/dd/yyyy",
@@ -218,7 +220,7 @@ public abstract class Login {
// get find count
getLoginStatus(Network.getResponseData(Network.getRequest("http://www.geocaching.com/email/")));
} else {
- final String page = Network.getResponseData(Network.getRequest("http://www.geocaching.com/default.aspx"));
+ final String page = Network.getResponseData(Network.getRequest(LANGUAGE_CHANGE_URI));
getLoginStatus(page);
if (page == null) {
Log.e("Failed to read viewstates to set geocaching.com language");
@@ -227,8 +229,10 @@ public abstract class Login {
"__EVENTTARGET", "ctl00$uxLocaleList$uxLocaleList$ctl00$uxLocaleItem", // switch to english
"__EVENTARGUMENT", "");
Login.transferViewstates(page, params);
- final HttpResponse response = Network.postRequest("http://www.geocaching.com/default.aspx", params);
- if (!Network.isSuccess(response)) {
+ final HttpResponse response = Network.postRequest(LANGUAGE_CHANGE_URI, params, new Parameters("Referer", LANGUAGE_CHANGE_URI));
+ if (Network.isSuccess(response)) {
+ Log.i("changed language on geocaching.com to English");
+ } else {
Log.e("Failed to set geocaching.com language to English");
}
}
diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java
index c73dd30..5911146 100644
--- a/main/src/cgeo/geocaching/network/Network.java
+++ b/main/src/cgeo/geocaching/network/Network.java
@@ -136,6 +136,18 @@ public abstract class Network {
}
/**
+ * POST HTTP request
+ *
+ * @param uri the URI to request
+ * @param params the parameters to add to the POST request
+ * @params headers the headers to add to the request
+ * @return the HTTP response, or null in case of an encoding error params
+ */
+ public static HttpResponse postRequest(final String uri, final Parameters params, final Parameters headers) {
+ return request("POST", uri, params, headers, null);
+ }
+
+ /**
* Multipart POST HTTP request
*
* @param uri the URI to request
@@ -173,9 +185,9 @@ public abstract class Network {
* @param uri
* the URI to request
* @param params
- * the parameters to add the the GET request
+ * the parameters to add to the URI
* @param headers
- * the headers to add to the GET request
+ * the headers to add to the request
* @param cacheFile
* the cache file used to cache this query
* @return the HTTP response, or null in case of an encoding error in a POST request arguments