Version 4.0.0k - Added userId and username to authenticate activity so user knows who they are logged in as.
This commit is contained in:
BIN
app/release/app-release-4.0.0k.apk
Normal file
BIN
app/release/app-release-4.0.0k.apk
Normal file
Binary file not shown.
BIN
app/release/old_versions/app-release-4.0.0i.apk
Normal file
BIN
app/release/old_versions/app-release-4.0.0i.apk
Normal file
Binary file not shown.
@@ -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">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<JSONObject> 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<String>() {
|
||||
@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<String, String> getHeaders() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
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.
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/login_to_osdapi" />
|
||||
android:text="@string/login_to_osdapi"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@@ -99,13 +99,51 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/logged_in_as_user_id" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userIdTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="userId" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text=" (" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/usernameTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="username" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text=")" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!--<TextView
|
||||
android:id="@+id/tokenTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/logged_in_with_token" />
|
||||
|
||||
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
<resources>
|
||||
<string name="app_name">OpenSeizureDetector</string>
|
||||
<string name="changelog">
|
||||
"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 "</string>
|
||||
"\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.
|
||||
"</string>
|
||||
<string name="UpgradeMsg">
|
||||
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 @@
|
||||
<string name="check_seizures_message">Please select the events highlighted in pink to say if they are real seizures or false alarms</string>
|
||||
<string name="error_server_not_running">ERROR: OpenSeizureDetector Server is not running - please re-start it</string>
|
||||
<string name="system_logs">System Logs</string>
|
||||
<string name="logged_in_as_user_id">Logged in as User Id:</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user