Skip to content

Commit

Permalink
Request data from production server + do not reload pages onResume
Browse files Browse the repository at this point in the history
  • Loading branch information
sqall01 committed Sep 12, 2019
1 parent 0e8075a commit f8fd5da
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
applicationId "de.alertr.chasrmap"
minSdkVersion 26
targetSdkVersion 28
versionCode 16
versionCode 17
versionName "1.0"
}
buildTypes {
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/java/de/alertr/chasrmap/MapLive.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ protected void onCreate(Bundle savedInstanceState) {
String userAgent = this.getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME +
"; " + System.getProperty("http.agent");
webSettings.setUserAgentString(userAgent);

// Request map (do it onCreate since otherwise we reload the page each time
// the app comes up to the foreground).
String url = pref_host + "/map.php#mode=live" +
"&device_name=" + device +
"&secret_hash=" + pref_secret_hash;
String auth = WebHelper.PARAM_USER + "=" + pref_username;
auth += "&" + WebHelper.PARAM_PASS + "=" + pref_password;
map.postUrl(url, auth.getBytes());
}

/**
Expand All @@ -112,13 +121,6 @@ protected void onResume() {
if (Logger.DEBUG) {
Log.d(TAG, "[onResume]");
}

String url = pref_host + "/map.php#mode=live" +
"&device_name=" + device +
"&secret_hash=" + pref_secret_hash;
String auth = WebHelper.PARAM_USER + "=" + pref_username;
auth += "&" + WebHelper.PARAM_PASS + "=" + pref_password;
map.postUrl(url, auth.getBytes());
}

@Override
Expand Down
22 changes: 13 additions & 9 deletions app/src/main/java/de/alertr/chasrmap/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,25 @@ else if (pref_units.equals(getString(R.string.pref_units_nautical))) {
String userAgent = this.getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME +
"; " + System.getProperty("http.agent");

/*
// TODO Android dev user agent
userAgent = this.getString(R.string.app_name) + " Test/" + BuildConfig.VERSION_NAME +
"; " + System.getProperty("http.agent");
*/


webSettings.setUserAgentString(userAgent);

// Request map (do it onCreate since otherwise we reload the page each time
// the app comes up to the foreground).
String url = pref_host + "/map.php#mode=view" +
"&device_name=" + device +
"&secret_hash=" + pref_secret_hash +
"&start=" + startTime +
"&end=" + endTime;
String auth = WebHelper.PARAM_USER + "=" + pref_username;
auth += "&" + WebHelper.PARAM_PASS + "=" + pref_password;
map.postUrl(url, auth.getBytes());
}

/**
Expand All @@ -142,15 +155,6 @@ protected void onResume() {
if (Logger.DEBUG) {
Log.d(TAG, "[onResume]");
}

String url = pref_host + "/map.php#mode=view" +
"&device_name=" + device +
"&secret_hash=" + pref_secret_hash +
"&start=" + startTime +
"&end=" + endTime;
String auth = WebHelper.PARAM_USER + "=" + pref_username;
auth += "&" + WebHelper.PARAM_PASS + "=" + pref_password;
map.postUrl(url, auth.getBytes());
}

@Override
Expand Down

0 comments on commit f8fd5da

Please sign in to comment.