Applied Android Studio code formatting to all java files

This commit is contained in:
Graham Jones
2024-01-19 20:53:18 +00:00
parent d8b3582291
commit cfe612933f
40 changed files with 497 additions and 514 deletions

View File

@@ -66,8 +66,8 @@ public class AuthenticateActivity extends AppCompatActivity {
logoutBtn.setOnClickListener(onLogout);
// Components required only for osdapi backend
if (LogManager.USE_FIREBASE_BACKEND) { }
else {
if (LogManager.USE_FIREBASE_BACKEND) {
} else {
mConnection = new SdServiceConnection(getApplicationContext());
Button registerBtn = (Button) findViewById(R.id.RegisterBtn);
@@ -157,7 +157,6 @@ public class AuthenticateActivity extends AppCompatActivity {
}
// Called after the Firebase Auth UI has completed
private ActivityResultLauncher<Intent> signInLauncher = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(),

View File

@@ -68,6 +68,7 @@ public class CircBuf {
/**
* Returns a double array of buffer items in order of their insertion time
*
* @return double[] of buffer items
*/
public double[] getVals() {

View File

@@ -3,7 +3,9 @@ package uk.org.openseizuredetector;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -269,7 +271,6 @@ public class EditEventActivity extends AppCompatActivity {
}
} // updateUi()
View.OnClickListener onCancel =

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentDataSharing extends FragmentOsdBaseClass {
String TAG = "FragmentDataSharing";
public FragmentDataSharing() {
// Required empty public constructor
}

View File

@@ -99,6 +99,7 @@ public class FragmentHrAlg extends FragmentOsdBaseClass {
yAxis2.setDrawGridLines(false);
yAxis2.setEnabled(false);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentMlAlg extends FragmentOsdBaseClass {
String TAG = "FragmentMlAlg";
public FragmentMlAlg() {
// Required empty public constructor
}

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
public class FragmentOsdAlg extends FragmentOsdBaseClass {
String TAG = "FragmentOsdAlg";
public FragmentOsdAlg() {
// Required empty public constructor
}

View File

@@ -34,7 +34,6 @@ public class FragmentOsdBaseClass extends Fragment {
protected int alarmTextColour = Color.BLACK;
public FragmentOsdBaseClass() {
// Required empty public constructor
}

View File

@@ -13,6 +13,7 @@ import androidx.appcompat.widget.LinearLayoutCompat;
public class FragmentSystem extends FragmentOsdBaseClass {
String TAG = "FragmentSystem";
public FragmentSystem() {
// Required empty public constructor
}
@@ -51,7 +52,6 @@ public class FragmentSystem extends FragmentOsdBaseClass {
}
@Override
protected void updateUi() {
//Log.d(TAG,"updateUi()");

View File

@@ -9,6 +9,7 @@ import android.widget.TextView;
public class FragmentWebServer extends FragmentOsdBaseClass {
String TAG = "FragmentWebServer";
public FragmentWebServer() {
// Required empty public constructor
}

View File

@@ -1,5 +1,6 @@
package uk.org.openseizuredetector;
// Defines the servies and characteristics we need to subscribe to.
import java.util.HashMap;
public class GattAttributes {

View File

@@ -2,6 +2,7 @@ package uk.org.openseizuredetector;
/**
*
*/
import android.content.Context;
@@ -21,8 +22,7 @@ interface SdLocationReceiver {
}
public class LocationFinder implements LocationListener
{
public class LocationFinder implements LocationListener {
SdLocationReceiver mSdLocationReceiver = null;
Location mLastLocation = null;
OsdUtil mUtil;
@@ -56,7 +56,6 @@ public class LocationFinder implements LocationListener
}
public Location getLastLocation() {
return mLastLocation;
}

View File

@@ -510,8 +510,6 @@ public class LogManager {
}
/**
* Return an array list of objects representing the events in the database by calling the specified callback function.
*

View File

@@ -45,6 +45,7 @@ public class MainActivity2 extends AppCompatActivity {
private OsdUtil mUtil;
private SdServiceConnection mConnection;
final Handler serverStatusHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -127,8 +128,6 @@ public class MainActivity2 extends AppCompatActivity {
}
@Override
protected void onPause() {
super.onPause();
@@ -151,7 +150,6 @@ public class MainActivity2 extends AppCompatActivity {
}
@Override
public void onBackPressed() {
if (Objects.isNull(mFragmentPager) || mFragmentPager.getCurrentItem() == 0) {
@@ -278,14 +276,13 @@ public class MainActivity2 extends AppCompatActivity {
}
/**
* A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
* sequence.
*/
private class ScreenSlideFragmentPagerAdapter extends FragmentStateAdapter {
private String TAG = "ScreenSlideFragmentPagerAdapter";
public ScreenSlideFragmentPagerAdapter(FragmentActivity fa) {
super(fa);
}
@@ -329,7 +326,6 @@ public class MainActivity2 extends AppCompatActivity {
}
private void showAbout() {
mUtil.writeToSysLogFile("MainActivity.showAbout()");
View aboutView = getLayoutInflater().inflate(R.layout.about_layout, null, false);

View File

@@ -55,7 +55,6 @@ public class MlModelManager {
}
/**
* Retrieve the file containing the list of available ML models from the server.
* Calls the specified callback function, passing a JSONObject as a parameter when the data has been received and parsed.

View File

@@ -328,12 +328,12 @@ public class OsdUtil {
public void writeToSysLogFile(String msgStr, String logType) {
writeLogEntryToLocalDb(msgStr, logType);
}
public void writeToSysLogFile(String msgStr) {
writeLogEntryToLocalDb(msgStr, "v");
}
/**
* Write a message to the alarm log file, provided mLogAlarms is true.
*
@@ -404,8 +404,7 @@ public class OsdUtil {
public File[] getDataFilesList() {
File[] files = getDataStorageDir().listFiles();
Log.d("Files", "Size: " + files.length);
for (int i = 0; i < files.length; i++)
{
for (int i = 0; i < files.length; i++) {
Log.d("Files", "FileName:" + files[i].getName());
}
return (files);
@@ -459,6 +458,7 @@ public class OsdUtil {
* It first attempts to parse it as a long integer, in which case it is assumed to
* be a unix timestamp.
* If that fails it attempts to parse it as yyyy-MM-dd'T'HH:mm:ss'Z' format.
*
* @param dateStr String reprenting a date
* @return Date object or null if parsing fails.
*/
@@ -612,7 +612,6 @@ public class OsdUtil {
/**
* Executes the sqlite query (=SELECT statement)
* Use as new SelectQueryTask(xxx,xxx,xx,xxxx).execute()
*
*/
static private class SelectQueryTask extends AsyncTask<Void, Void, Cursor> {
// Based on https://stackoverflow.com/a/21120199/2104584
@@ -669,7 +668,6 @@ public class OsdUtil {
}
/**
* pruneSysLogDb() removes data that is older than 7 days
*/

View File

@@ -9,7 +9,9 @@ import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.preference.PreferenceManager;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
@@ -137,7 +139,6 @@ public class RemoteDbActivity extends AppCompatActivity {
//tv.setText(String.format("%d",datapointsCount));
// Remote Database Information
tv = (TextView) findViewById(R.id.authStatusTv);
btn = (Button) findViewById(R.id.auth_button);

View File

@@ -209,7 +209,6 @@ public class ReportSeizureActivity extends AppCompatActivity {
}
private void updateUi() {
//Log.v(TAG,"updateUi()");
TextView tv;

View File

@@ -99,7 +99,6 @@ public class SdAlgHr {
}
private boolean checkSimpleHr(double hrVal) {
/**
* Check heart rate value against simple thresholds
@@ -116,6 +115,7 @@ public class SdAlgHr {
/**
* Returns the average heart rate being used by the Adaptive heart rate algorithm
*
* @return Average Heart reate in bpm.
*/
public double getAdaptiveHrAverage() {
@@ -130,10 +130,13 @@ public class SdAlgHr {
return mAdaptiveHrBuff;
}
public CircBuf getHrHistBuff() { return mHrHist; }
public CircBuf getHrHistBuff() {
return mHrHist;
}
/**
* Returns the average heart rate being used by the Average heart rate algorithm
*
* @return Average Heart rate in bpm.
*/
public double getAverageHrAverage() {
@@ -177,7 +180,6 @@ public class SdAlgHr {
}
public ArrayList<Boolean> checkHr(double hrVal) {
/**
* Checks the current Heart Rate reading hrVal against the

View File

@@ -99,6 +99,7 @@ public class SdAlgNn {
* getPseizureFmt1 - calculate probability of sdData representing seizure-like movement
* using a model with input format #1, which is a simple vector of 125 accelerometer vector
* magnitude readings.
*
* @param sdData - seizure detector data as input to the model
* @return probability of data representing seizure-like movement.
*/

View File

@@ -154,7 +154,6 @@ public abstract class SdDataSource {
}
// Start timer to check status of watch regularly.
mDataStatusTime = new Time(Time.getCurrentTimezone());
// use a timer to check the status of the pebble app on the same frequency
@@ -825,7 +824,8 @@ public abstract class SdDataSource {
// Check we have seen a fidget within the required period, or else assume a fault because watch is not being worn
if (mFidgetDetectorEnabled) {
if (mLastFidget == null) mLastFidget = tnow; // Initialise last fidget time on startup.
if (mLastFidget == null)
mLastFidget = tnow; // Initialise last fidget time on startup.
double accStd = calcRawDataStd(mSdData);
if (accStd > mFidgetThreshold) {

View File

@@ -40,11 +40,11 @@ import java.nio.IntBuffer;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
/**
* Abstract class for a seizure detector data source. Subclasses include a pebble smart watch data source and a
* network data source.
@@ -744,9 +744,6 @@ public class SdDataSourceAw extends SdDataSource {
}
}

View File

@@ -368,6 +368,7 @@ public class SdDataSourceBLE extends SdDataSource {
}, 100);
}
}
private boolean permissionsOK() {
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
@@ -413,8 +414,7 @@ public class SdDataSourceBLE extends SdDataSource {
mSdData.mHR = (double) heartRate;
}
Log.d(TAG, String.format("onDataReceived(): CHAR_HEART_RATE_MEASUREMENT: %d", heartRate));
}
else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_DATA)
} else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_DATA)
|| characteristic.getUuid().toString().equals(CHAR_INFINITIME_ACC_DATA)) {
//Log.v(TAG,"Received OSD ACC DATA"+characteristic.getValue());
byte[] rawDataBytes = characteristic.getValue();
@@ -473,36 +473,30 @@ public class SdDataSourceBLE extends SdDataSource {
nRawData = 0;
}
}
}
else if (characteristic.getUuid().toString().equals(CHAR_OSD_BATT_DATA)) {
} else if (characteristic.getUuid().toString().equals(CHAR_OSD_BATT_DATA)) {
byte batteryPc = characteristic.getValue()[0];
mSdData.batteryPc = batteryPc;
Log.v(TAG, "onDataReceived(): CHAR_OSD_BATT_DATA: " + String.format("%d", batteryPc));
mSdData.haveSettings = true;
}
else if (characteristic.getUuid().toString().equals(CHAR_BATT_DATA)) {
} else if (characteristic.getUuid().toString().equals(CHAR_BATT_DATA)) {
byte batteryPc = characteristic.getValue()[0];
mSdData.batteryPc = batteryPc;
Log.v(TAG, "onDataReceived(): CHAR_BATT_DATA: " + String.format("%d", batteryPc));
mSdData.haveSettings = true;
}
else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_ID)) {
} else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_ID)) {
byte[] rawDataBytes = characteristic.getValue();
String watchId = new String(rawDataBytes, StandardCharsets.UTF_8);
Log.v(TAG, "Received Watch ID: " + watchId);
mSdData.watchSdName = watchId;
}
else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_FW)) {
} else if (characteristic.getUuid().toString().equals(CHAR_OSD_WATCH_FW)) {
byte[] rawDataBytes = characteristic.getValue();
String watchFwVer = new String(rawDataBytes, StandardCharsets.UTF_8);
Log.v(TAG, "Received Watch Firmware Version: " + watchFwVer);
mSdData.watchSdVersion = watchFwVer;
}
else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_FMT)) {
} else if (characteristic.getUuid().toString().equals(CHAR_OSD_ACC_FMT)) {
mAccFmt = characteristic.getValue()[0];
Log.v(TAG, "Received Acceleration format code: " + mAccFmt);
}
else {
} else {
Log.v(TAG, "Unrecognised Characteristic Updated " +
characteristic.getUuid().toString());
}
@@ -534,6 +528,7 @@ public class SdDataSourceBLE extends SdDataSource {
}
return (retArr);
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,

View File

@@ -38,7 +38,8 @@ public class SdDataSourceNetwork extends SdDataSource {
mName = "Network";
}
@Override public void start() {
@Override
public void start() {
// Update preferences.
Log.v(TAG, "start(): calling updatePrefs()");
mUtil.writeToSysLogFile("SdDataSourceNetwork().start()");
@@ -63,7 +64,8 @@ public class SdDataSourceNetwork extends SdDataSource {
}
@Override public void stop() {
@Override
public void stop() {
mUtil.writeToSysLogFile("SdDataSourceNetwork().stop()");
// Stop the data update timer
if (mDataUpdateTimer != null) {
@@ -76,7 +78,6 @@ public class SdDataSourceNetwork extends SdDataSource {
}
/**
* updatePrefs() - update basic settings from the SharedPreferences
* - defined in res/xml/prefs.xml
@@ -117,6 +118,7 @@ public class SdDataSourceNetwork extends SdDataSource {
private class DownloadSdDataTask extends AsyncTask<String, Void, SdData> {
private SdData sdData;
@Override
protected SdData doInBackground(String... urls) {
// params comes from the execute() call: params[0] is the url.
@@ -154,6 +156,7 @@ public class SdDataSourceNetwork extends SdDataSource {
return sdData;
}
}
// onPostExecute displays the results of the AsyncTask.
@Override
protected void onPostExecute(SdData sdData) {
@@ -187,6 +190,7 @@ public class SdDataSourceNetwork extends SdDataSource {
}
return "Done";
}
// onPostExecute displays the results of the AsyncTask.
@Override
protected void onPostExecute(String s) {
@@ -195,7 +199,6 @@ public class SdDataSourceNetwork extends SdDataSource {
}
// Given a URL, establishes an HttpUrlConnection and retrieves
// the web page content as a InputStream, which it returns as
// a string.
@@ -241,6 +244,4 @@ public class SdDataSourceNetwork extends SdDataSource {
}
}

View File

@@ -45,7 +45,6 @@ import java.util.TimerTask;
import java.util.UUID;
/**
* Abstract class for a seizure detector data source. Subclasses include a pebble smart watch data source and a
* network data source.
@@ -774,7 +773,6 @@ public class SdDataSourcePebble extends SdDataSource {
}
}

View File

@@ -95,9 +95,6 @@ public class SdDataSourcePhone extends SdDataSource implements SensorEventListen
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
@@ -183,8 +180,6 @@ public class SdDataSourcePhone extends SdDataSource implements SensorEventListen
}
}

View File

@@ -316,7 +316,6 @@ public class SdServer extends Service implements SdDataReceiver {
mSdDataSource.start();
// Record last time we sent an SMS so we can limit rate of SMS
// sending to one per minute. We set it to one minute ago (60000 milliseconds)
mSMSTime = new Time(Time.getCurrentTimezone());
@@ -1373,7 +1372,6 @@ public class SdServer extends Service implements SdDataReceiver {
/**
* onSdLocationReceived - called with the best estimate location after mLocationReceiver times out.
*
*/
private void sendSMS(String phoneNo, String msgStr) {
Log.i(TAG, "sendSMS() - Sending to " + phoneNo);
@@ -1781,6 +1779,7 @@ public class SdServer extends Service implements SdDataReceiver {
/**
* isNotificationShown - returns true if the specified notificationID is shown, otherwise returns false.
*
* @param notificationId - Notification ID to check
* @return true if the specified notification is displayed, otherwise false.
*/

View File

@@ -31,7 +31,6 @@ import android.os.IBinder;
import android.util.Log;
/**
* Defines callbacks for service binding, passed to bindService()
*/
@@ -68,6 +67,7 @@ public class SdServiceConnection implements ServiceConnection {
/**
* Check if the service has received seizure detector data.
*
* @return true if data has been received.
*/
public boolean hasSdData() {
@@ -81,6 +81,7 @@ public class SdServiceConnection implements ServiceConnection {
/**
* Check if the service has received seizure detector settings.
*
* @return true if settings have been received.
*/
public boolean hasSdSettings() {
@@ -96,6 +97,7 @@ public class SdServiceConnection implements ServiceConnection {
/**
* Check if the pebble watch is connected to the server device via bluetooth.
*
* @return true if watch connected.
*/
public boolean watchConnected() {
@@ -111,6 +113,7 @@ public class SdServiceConnection implements ServiceConnection {
/**
* Check if the openseizuredetector pebble watch app is running..
*
* @return true if watch app running.
*/
public boolean pebbleAppRunning() {

View File

@@ -113,8 +113,6 @@ public class StartupActivity extends AppCompatActivity {
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@@ -139,6 +139,7 @@ public abstract class WebApiConnection {
/**
* Mark all of the events with IDs contained in eventList as the specified type and subtype.
*
* @param eventList list of String IDs of the events to mark as unknown.
* @param typeStr
* @param subTypeStr
@@ -240,6 +241,7 @@ public abstract class WebApiConnection {
markUnverifiedEventsAsTypeSubtype("Unknown", "");
return true;
}
public boolean markUnverifiedEventsAsFalseAlarm() {
markUnverifiedEventsAsTypeSubtype("False Alarm", "");
return true;

View File

@@ -110,8 +110,6 @@ public class WebApiConnection_osdapi extends WebApiConnection {
}
public boolean isLoggedIn() {
String authToken = getStoredToken();
Log.v(TAG, "isLoggedIn(): token=" + authToken);
@@ -517,6 +515,7 @@ public class WebApiConnection_osdapi extends 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.
*/
@@ -572,8 +571,6 @@ public class WebApiConnection_osdapi extends WebApiConnection {
}
/**
* 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.
@@ -680,11 +677,10 @@ public class WebApiConnection_osdapi extends WebApiConnection {
}
/**
* Retrieve a trivial file from the server to check we have a good server connection.
* sets mServerConnectionOk.
*
* @return true if request sent successfully or else false.
*/
public boolean checkServerConnection() {