Added option to include warnings in data log manager shared data list - also adds progress bar to show something is happening. Fixes #64

This commit is contained in:
Graham Jones
2022-08-06 20:14:14 +01:00
parent 0ea3cd91f3
commit 1eb2333a8d
3 changed files with 42 additions and 3 deletions

View File

@@ -24,9 +24,12 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.SimpleAdapter;
import android.widget.TextView;
@@ -111,6 +114,10 @@ public class LogManagerControlActivity extends AppCompatActivity {
(Button) findViewById(R.id.refresh_button);
remoteDbBtn.setOnClickListener(onRefreshBtn);
CheckBox includeWarningsCb =
(CheckBox) findViewById(R.id.include_warnings_cb);
includeWarningsCb.setOnCheckedChangeListener(onIncludeWarningsCb);
ListView lv = (ListView) findViewById(R.id.eventLogListView);
lv.setOnItemClickListener(onEventListClick);
@@ -189,7 +196,11 @@ public class LogManagerControlActivity extends AppCompatActivity {
private void initialiseServiceConnection() {
mLm = mConnection.mSdServer.mLm;
startUiTimer(mUiTimerPeriodFast);
getRemoteEvents();
final CheckBox includeWarningsCb = (CheckBox) findViewById(R.id.include_warnings_cb);
getRemoteEvents(includeWarningsCb.isChecked());
ProgressBar pb = (ProgressBar)findViewById(R.id.remoteAccessPb);
pb.setIndeterminate(true);
pb.setVisibility(View.VISIBLE);
// Populate events list - we only do it once when the activity is created because the query might slow down the UI.
// We could try this code in updateUI() and see though.
// Based on https://www.tutlane.com/tutorial/android/android-sqlite-listview-with-examples
@@ -206,7 +217,8 @@ public class LogManagerControlActivity extends AppCompatActivity {
}
private void getRemoteEvents() {
private void getRemoteEvents(boolean includeWarnings) {
mRemoteEventsList = null; // clear existing data
// Retrieve events from remote database
mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
Log.v(TAG, "getRemoteEvents()");
@@ -255,7 +267,11 @@ public class LogManagerControlActivity extends AppCompatActivity {
eventHashMap.put("type", typeStr);
eventHashMap.put("subType", subType);
eventHashMap.put("desc", desc);
mRemoteEventsList.add(eventHashMap);
if (osdAlarmState!=1 | includeWarnings) {
mRemoteEventsList.add(eventHashMap);
} else {
Log.v(TAG,"getRemoteEvents - skipping warning");
}
}
Log.v(TAG, "getRemoteEvents() - set mRemoteEventsList(). Updating UI");
updateUi();
@@ -311,6 +327,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
}
// Remote Database List View
if (mRemoteEventsList != null) {
ProgressBar pb = (ProgressBar)findViewById(R.id.remoteAccessPb);
pb.setIndeterminate(false);
pb.setVisibility(View.INVISIBLE);
ListView lv = (ListView) findViewById(R.id.remoteEventsLv);
ListAdapter adapter = new RemoteEventsAdapter(LogManagerControlActivity.this, mRemoteEventsList, R.layout.log_entry_layout_remote,
new String[]{"id", "dataTime", "type", "subType", "osdAlarmStateStr", "desc"},
@@ -514,6 +533,14 @@ public class LogManagerControlActivity extends AppCompatActivity {
}
};
CompoundButton.OnCheckedChangeListener onIncludeWarningsCb =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Log.v(TAG, "onIncludeWarningsCb");
initialiseServiceConnection();
}
};
AdapterView.OnItemClickListener onEventListClick =
new AdapterView.OnItemClickListener() {

View File

@@ -117,8 +117,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/refreshBtn" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/remoteAccessPb" />
</LinearLayout>
<CheckBox
android:id="@+id/include_warnings_cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/include_warnings">
</CheckBox>
<ListView
android:id="@+id/remoteEventsLv"

View File

@@ -437,4 +437,5 @@
<string name="mark_unverified_events_unknown_dialog_message">Please confirm that all genuine seizure events have been verified before marking all unverified events as type \'unknown\'. \n\nContinue to mark unverified events as Unknown?</string>
<string name="not_logged_in_dialog_title">Not Logged in to Data Sharing</string>
<string name="not_logged_in_dialog_message">You must be logged in to the Data Sharing system to be able to report seizures.</string>
<string name="include_warnings">Include Warnings</string>
</resources>