Tidied up shared data manager and added highlighting for unconfirmed seizures and real seizures.

This commit is contained in:
Graham Jones
2022-02-09 19:53:55 +00:00
parent e7e8f79346
commit b24c448528
6 changed files with 104 additions and 48 deletions

Binary file not shown.

View File

@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="uk.org.openseizuredetector"
android:versionCode="92"
android:versionName="4.0.0e">
android:versionName="4.0.0f">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

View File

@@ -6,6 +6,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.CountDownTimer;
@@ -19,6 +20,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.LinearLayout;
@@ -33,9 +35,14 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class LogManagerControlActivity extends AppCompatActivity {
private String TAG = "LogManagerControlActivity";
@@ -264,7 +271,7 @@ public class LogManagerControlActivity extends AppCompatActivity {
// Remote Database List View
if (mRemoteEventsList != null) {
ListView lv = (ListView) findViewById(R.id.remoteEventsLv);
ListAdapter adapter = new SimpleAdapter(LogManagerControlActivity.this, mRemoteEventsList, R.layout.log_entry_layout_remote,
ListAdapter adapter = new RemoteEventsAdapter(LogManagerControlActivity.this, mRemoteEventsList, R.layout.log_entry_layout_remote,
new String[]{"dataTime", "type", "subType", "osdAlarmStateStr", "desc"},
new int[]{R.id.event_date_remote_tv, R.id.event_type_remote_tv, R.id.event_subtype_remote_tv,
R.id.event_alarmState_remote_tv, R.id.event_notes_remote_tv});
@@ -528,4 +535,58 @@ public class LogManagerControlActivity extends AppCompatActivity {
}
private class RemoteEventsAdapter extends SimpleAdapter {
/**
* Constructor
*
* @param context The context where the View associated with this SimpleAdapter is running
* @param data A List of Maps. Each entry in the List corresponds to one row in the list. The
* Maps contain the data for each row, and should include all the entries specified in
* "from"
* @param resource Resource identifier of a view layout that defines the views for this list
* item. The layout file should include at least those named views defined in "to"
* @param from A list of column names that will be added to the Map associated with each
* item.
* @param to The views that should display column in the "from" parameter. These should all be
* TextViews. The first N views in this list are given the values of the first N columns
*/
public RemoteEventsAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
super(context, data, resource, from, to);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
Map<String, ?> dataItem = (Map<String,?>)getItem(position);
Log.i(TAG,dataItem.toString());
switch(dataItem.get("type").toString()) {
case "null":
v.setBackgroundColor(Color.parseColor("#ffaaaa"));
break;
case "Seizure":
v.setBackgroundColor(Color.parseColor("#ff1a1a"));
break;
default:
v.setBackgroundColor(Color.TRANSPARENT);
}
// Convert date format to something more readable.
TextView tv = (TextView) v.findViewById(R.id.event_date_remote_tv);
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
Date dataTime = dateFormat.parse(dataItem.get("dataTime").toString());
dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
tv.setText(dateFormat.format(dataTime));
} catch (ParseException e) {
Log.e(TAG,"remoteEventsAdapter.getView: Error Parsing dataDate "+e.getLocalizedMessage());
tv.setText("---");
}
return(v);
}
};
}

View File

@@ -4,24 +4,47 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/cancelBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cancel" />
<Button
android:id="@+id/OKBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EventId: " />
<TextView
android:id="@+id/eventIdTv"
android:layout_width="wrap_content"
@@ -33,11 +56,13 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Event Date: "
android:textSize="20sp" />
<TextView
android:id="@+id/eventDateTv"
android:layout_width="wrap_content"
@@ -50,11 +75,13 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alarm State: "
android:textSize="20sp" />
<TextView
android:id="@+id/eventAlarmStateTv"
android:layout_width="wrap_content"
@@ -67,6 +94,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -109,25 +137,6 @@
android:hint="notes about event" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/cancelBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cancel" />
<Button
android:id="@+id/OKBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -49,25 +49,6 @@
android:layout_height="wrap_content"
android:text="000" />
</LinearLayout>
<!--
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/pruneDatabaseBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prune_database" />
<Button
android:id="@+id/reportSeizureBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/report_seizure" />
</LinearLayout>
-->
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -122,7 +103,11 @@
android:layout_height="wrap_content"
android:text="@string/remote_database"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/check_seizures_message"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -149,7 +134,7 @@
<ListView
android:id="@+id/remoteEventsLv"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />

View File

@@ -293,7 +293,7 @@
<string name="O2SatThreshMinSummary">O2 Saturation Low Alarm Level (%)</string>
<string name="title_activity_authenticate">Log in to OpenSeizureDetector Data Sharing</string>
<string name="logout">Log Out</string>
<string name="logged_in_with_token">Logged in with Token</string>
<string name="logged_in_with_token">Logged in to\nData Sharing</string>
<string name="local_database">Logged Data Manager</string>
<string name="remote_database">Shared Data</string>
<string name="num_local_events">Number of Events Stored on Phone: </string>
@@ -346,4 +346,5 @@
<string name="local_data">Local Data</string>
<string name="shared_data">Shared Data</string>
<string name="prune_database">Prune Database</string>
<string name="check_seizures_message">Please select the events highlighted in pink to say if they are real seizures or false alarms</string>
</resources>