diff --git a/app/release/app-release-4.0.0k.apk b/app/release/app-release-4.0.0k.apk
new file mode 100644
index 0000000..9233a6c
Binary files /dev/null and b/app/release/app-release-4.0.0k.apk differ
diff --git a/app/release/old_versions/app-release-4.0.0i.apk b/app/release/old_versions/app-release-4.0.0i.apk
new file mode 100644
index 0000000..167e2d4
Binary files /dev/null and b/app/release/old_versions/app-release-4.0.0i.apk differ
diff --git a/app/release/app-release-4.0.0j.apk b/app/release/old_versions/app-release-4.0.0j.apk
similarity index 100%
rename from app/release/app-release-4.0.0j.apk
rename to app/release/old_versions/app-release-4.0.0j.apk
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bbc1e0f..f1fbff3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="uk.org.openseizuredetector"
android:versionCode="92"
- android:versionName="4.0.0j">
+ android:versionName="4.0.0k">
diff --git a/app/src/main/java/uk/org/openseizuredetector/AuthenticateActivity.java b/app/src/main/java/uk/org/openseizuredetector/AuthenticateActivity.java
index f0e454c..463967a 100644
--- a/app/src/main/java/uk/org/openseizuredetector/AuthenticateActivity.java
+++ b/app/src/main/java/uk/org/openseizuredetector/AuthenticateActivity.java
@@ -16,8 +16,13 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
+import org.json.JSONArray;
+import org.json.JSONException;
import org.json.JSONObject;
+import java.util.ArrayList;
+import java.util.HashMap;
+
public class AuthenticateActivity extends AppCompatActivity {
private String TAG = "AuthenticateActivity";
private EditText mUnameEt;
@@ -71,7 +76,6 @@ public class AuthenticateActivity extends AppCompatActivity {
super.onStart();
mUtil.bindToServer(getApplicationContext(), mConnection);
waitForConnection();
- updateUi();
}
@Override
@@ -103,6 +107,7 @@ public class AuthenticateActivity extends AppCompatActivity {
private void initialiseServiceConnection() {
mLm = mConnection.mSdServer.mLm;
mWac = mConnection.mSdServer.mLm.mWac;
+ updateUi();
}
private void updateUi() {
@@ -125,8 +130,25 @@ public class AuthenticateActivity extends AppCompatActivity {
Log.v(TAG, "Already Logged in - showing Log Out prompt");
loginLl.setVisibility(View.GONE);
logoutLl.setVisibility(View.VISIBLE);
- TextView tv = (TextView)findViewById(R.id.tokenTv);
- tv.setText("Logged in with Token:"+storedAuthToken);
+ //TextView tv = (TextView)findViewById(R.id.tokenTv);
+ //tv.setText("Logged in with Token: "+storedAuthToken);
+ if (mWac != null) {
+ mWac.getUserProfile((JSONObject profileObj) -> {
+ try {
+ Long userId = profileObj.getLong("id");
+ String userName = profileObj.getString("username");
+ TextView tv2 = (TextView) findViewById(R.id.userIdTv);
+ tv2.setText(userId.toString());
+ tv2 = (TextView) findViewById(R.id.usernameTv);
+ tv2.setText(userName);
+ } catch (JSONException e) {
+ Log.e(TAG, "Error Parsing profileObj: " + e.getMessage());
+ mUtil.showToast("Error Parsing profileObj - this should not happen!!!");
+ }
+ });
+ } else {
+ Log.i(TAG,"UpdateUI - not retrieving profile because mWac is null");
+ }
}
}
diff --git a/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java b/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java
index 6cd20d3..c390fc4 100644
--- a/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java
+++ b/app/src/main/java/uk/org/openseizuredetector/WebApiConnection.java
@@ -532,6 +532,66 @@ public class WebApiConnection {
}
+ /**
+ * Retieve the user profile of the authenticated user from the server, and return it to the callback function.
+ * @param callback - function to be called with a JSONObject as a parameter that contains the user profile data.
+ * @return true if request sent successfully, or else false.
+ */
+ public boolean getUserProfile(Consumer callback) {
+ Log.v(TAG, "getUserProfile()");
+ String urlStr = mUrlBase + "/api/accounts/profile/";
+ Log.v(TAG, "getUserProfile(): urlStr=" + urlStr);
+ final String authtoken = getStoredToken();
+
+ if (!isLoggedIn()) {
+ Log.v(TAG, "not logged in - doing nothing");
+ return (false);
+ }
+
+ StringRequest req = new StringRequest(Request.Method.GET, urlStr,
+ new Response.Listener() {
+ @Override
+ public void onResponse(String response) {
+ Log.v(TAG, "Response is: " + response);
+ try {
+ JSONObject retObj = new JSONObject(response);
+ callback.accept(retObj);
+ } catch (JSONException e) {
+ Log.e(TAG, "getUserProfile.onRespons(): Error: " + e.getMessage() + "," + e.toString());
+ callback.accept(null);
+ }
+ mServerConnectionOk = true;
+ }
+ },
+ new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ if (error != null) {
+ String responseBody = new String(error.networkResponse.data);
+ Log.e(TAG, "Create Event Error: " + error.toString() + ", message:" + error.getMessage() + ", Response Code:" + error.networkResponse.statusCode + ", Response: " + responseBody);
+ } else {
+ Log.e(TAG, "Create Event Error: returned null response");
+ }
+ mServerConnectionOk = false;
+ callback.accept(null);
+ }
+ }) {
+
+ @Override
+ public Map getHeaders() throws AuthFailureError {
+ Map params = new HashMap();
+ params.put("Content-Type", "application/json; charset=UTF-8");
+ params.put("Authorization", "Token " + getStoredToken());
+ return params;
+ }
+ };
+ mQueue.add(req);
+ return (true);
+ }
+
+
+
+
/**
* Retrieve the file containing the standard event types from the server.
* Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed.
diff --git a/app/src/main/res/layout/activity_authenticate.xml b/app/src/main/res/layout/activity_authenticate.xml
index 063b0cb..9be9ddd 100644
--- a/app/src/main/res/layout/activity_authenticate.xml
+++ b/app/src/main/res/layout/activity_authenticate.xml
@@ -20,8 +20,8 @@
+ android:text="@string/login_to_osdapi"
+ android:textAppearance="?android:attr/textAppearanceLarge" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
OpenSeizureDetector
- "V4.0 - Added logging of data to remote server
- \nV3.7.0 - Added support for Garmin Blood Oxygen Saturation measurements
- \nV3.6.2 - Fix of issue with log file permissions on some Android 10 devices and added more translatable strings with polish translation.
- \nV3.6.1 - Possible fix for issue with shutting down system and expanded Polish translation to all settings screens.
- \nV3.6 - Added phone sensor data source for testing without a watches
- \nV3.5 - Added support for SMS Annunciator App
- \nV3.4 - Added support for BLE Data Source "
+ "\nV4.0.0k - Added user name and user ID to login activity so the user knows who they are logged in as.
+ \nV4.0.0j - Added event ID to list in data log manager so users can refer to it when asking for assistance.
+ \n Moved system log to sqlite database and added list of it to data log manager activity.
+ \nV4.0.0i - Tidied up user settings and (hopefully) fixed issue with server not shutting down correctly sometimes.
+ "
OpenSeizureDetector does not collect any personal data.
This does mean that it is not possible for me to contact users if I find an
@@ -349,4 +347,5 @@
Please select the events highlighted in pink to say if they are real seizures or false alarms
ERROR: OpenSeizureDetector Server is not running - please re-start it
System Logs
+ Logged in as User Id: