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:
@@ -24,9 +24,12 @@ import android.view.ViewConfiguration;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.SimpleAdapter;
|
import android.widget.SimpleAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -111,6 +114,10 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
(Button) findViewById(R.id.refresh_button);
|
(Button) findViewById(R.id.refresh_button);
|
||||||
remoteDbBtn.setOnClickListener(onRefreshBtn);
|
remoteDbBtn.setOnClickListener(onRefreshBtn);
|
||||||
|
|
||||||
|
CheckBox includeWarningsCb =
|
||||||
|
(CheckBox) findViewById(R.id.include_warnings_cb);
|
||||||
|
includeWarningsCb.setOnCheckedChangeListener(onIncludeWarningsCb);
|
||||||
|
|
||||||
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
ListView lv = (ListView) findViewById(R.id.eventLogListView);
|
||||||
lv.setOnItemClickListener(onEventListClick);
|
lv.setOnItemClickListener(onEventListClick);
|
||||||
|
|
||||||
@@ -189,7 +196,11 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
private void initialiseServiceConnection() {
|
private void initialiseServiceConnection() {
|
||||||
mLm = mConnection.mSdServer.mLm;
|
mLm = mConnection.mSdServer.mLm;
|
||||||
startUiTimer(mUiTimerPeriodFast);
|
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.
|
// 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.
|
// We could try this code in updateUI() and see though.
|
||||||
// Based on https://www.tutlane.com/tutorial/android/android-sqlite-listview-with-examples
|
// 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
|
// Retrieve events from remote database
|
||||||
mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
mLm.mWac.getEvents((JSONObject remoteEventsObj) -> {
|
||||||
Log.v(TAG, "getRemoteEvents()");
|
Log.v(TAG, "getRemoteEvents()");
|
||||||
@@ -255,7 +267,11 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
eventHashMap.put("type", typeStr);
|
eventHashMap.put("type", typeStr);
|
||||||
eventHashMap.put("subType", subType);
|
eventHashMap.put("subType", subType);
|
||||||
eventHashMap.put("desc", desc);
|
eventHashMap.put("desc", desc);
|
||||||
|
if (osdAlarmState!=1 | includeWarnings) {
|
||||||
mRemoteEventsList.add(eventHashMap);
|
mRemoteEventsList.add(eventHashMap);
|
||||||
|
} else {
|
||||||
|
Log.v(TAG,"getRemoteEvents - skipping warning");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.v(TAG, "getRemoteEvents() - set mRemoteEventsList(). Updating UI");
|
Log.v(TAG, "getRemoteEvents() - set mRemoteEventsList(). Updating UI");
|
||||||
updateUi();
|
updateUi();
|
||||||
@@ -311,6 +327,9 @@ public class LogManagerControlActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
// Remote Database List View
|
// Remote Database List View
|
||||||
if (mRemoteEventsList != null) {
|
if (mRemoteEventsList != null) {
|
||||||
|
ProgressBar pb = (ProgressBar)findViewById(R.id.remoteAccessPb);
|
||||||
|
pb.setIndeterminate(false);
|
||||||
|
pb.setVisibility(View.INVISIBLE);
|
||||||
ListView lv = (ListView) findViewById(R.id.remoteEventsLv);
|
ListView lv = (ListView) findViewById(R.id.remoteEventsLv);
|
||||||
ListAdapter adapter = new RemoteEventsAdapter(LogManagerControlActivity.this, mRemoteEventsList, R.layout.log_entry_layout_remote,
|
ListAdapter adapter = new RemoteEventsAdapter(LogManagerControlActivity.this, mRemoteEventsList, R.layout.log_entry_layout_remote,
|
||||||
new String[]{"id", "dataTime", "type", "subType", "osdAlarmStateStr", "desc"},
|
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 =
|
AdapterView.OnItemClickListener onEventListClick =
|
||||||
new AdapterView.OnItemClickListener() {
|
new AdapterView.OnItemClickListener() {
|
||||||
|
|||||||
@@ -117,8 +117,19 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/refreshBtn" />
|
android:text="@string/refreshBtn" />
|
||||||
|
<ProgressBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/remoteAccessPb" />
|
||||||
|
|
||||||
</LinearLayout>
|
</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
|
<ListView
|
||||||
android:id="@+id/remoteEventsLv"
|
android:id="@+id/remoteEventsLv"
|
||||||
|
|||||||
@@ -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="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_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="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>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user