Merge branch 'V4.2.x' into 178-v427-banglejs2-does-not-work-with-new-ble2-data-source

This commit is contained in:
Graham Jones
2024-05-09 20:37:15 +01:00
6 changed files with 42 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
OpenSeizureDetector Android App - Change Log
============================================
V4.2.8 - Fixed BLE2 data source to work with BangleJS2 watches
- Fixed crash in export data function when using european style comma based decimal separator.
V4.2.7 - BLE2 data source re-start fixed??
V4.2.6 - Fixed problem with notifications in Android 13
- Improved start-up checks for permissions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="141"
android:versionCode="142"
android:versionName="4.2.8">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

View File

@@ -35,11 +35,13 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class ExportDataActivity extends AppCompatActivity
implements View.OnClickListener {
@@ -198,8 +200,8 @@ public class ExportDataActivity extends AppCompatActivity
if (view == mExportBtn) {
mDateTxt.setText(String.format("%02d-%02d-%04d", mDay, mMonth + 1, mYear));
mTimeTxt.setText(String.format("%02d:%02d:%02d", mHour, mMinute, 00));
mDuration = Double.parseDouble(mDurationTxt.getText().toString());
mDuration = mUtil.parseToDouble(mDurationTxt.getText().toString());
String dateTimeStr = String.format("%04d-%02d-%02dT%02d:%02d:%02dZ", mYear, mMonth + 1, mDay, mHour, mMinute, 00);
//mUtil.showToast(dateTimeStr);
mEndDate = mUtil.string2date(dateTimeStr);

View File

@@ -111,7 +111,16 @@ public class FragmentOsdBaseClass extends Fragment {
updateUiHandler.post(new Runnable() {
@Override
public void run() {
updateUi();
// Check for context being null is an attempt to stop the crashes reported in Issue No 176
if (mContext != null) {
try {
updateUi();
} catch (Exception e) {
Log.e(TAG,"upateUiOnUiThread() - exception updating UI - "+e.getMessage());
}
} else {
Log.e(TAG,"updateUionUiThread() - mContext is null?? Can't show a Toast message because context is null....");
}
}
});
}

View File

@@ -59,6 +59,7 @@ import java.io.File;
import java.io.FileWriter;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -66,6 +67,7 @@ import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.function.Consumer;
/**
@@ -778,4 +780,27 @@ public class OsdUtil {
return allOk;
}
public double parseToDouble(String userInput) {
/**
* Parse a string to a double value, taking localisation into account.
* Using NumberFormat as recommended by https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/java/lang/Double.html#valueOf(java.lang.String)
*/
double retVal;
try {
Locale currentLocale;
if (android.os.Build.VERSION.SDK_INT < 24) {
currentLocale = mContext.getResources().getConfiguration().locale;
} else {
currentLocale = mContext.getResources().getConfiguration().getLocales().get(0);
}
NumberFormat nf = NumberFormat.getInstance(currentLocale);
retVal = nf.parse(userInput).doubleValue();
} catch (ParseException e) {
// Handle invalid input (e.g., non-numeric characters)
showToast("Invalid input. Please enter a valid numeric value.");
retVal = 0.0;
}
return(retVal);
}
}

View File

@@ -3,7 +3,7 @@
<string name="app_name">OpenSeizureDetector</string>
<string name="changelog">
"\n
\nV4.2.8 - Fixed problem with BangleJS2 not working with new BLE2 data source
\nV4.2.8 - Fixed problem with BangleJS2 not working with new BLE2 data, fixed crash in export data function, fixed (rare) crash when re-opening app from background)
\nV4.2.7 - Finally fixed BLE2 data source re-start after dropping connection?
\nV4.2.6 - Fixed issues with Android 13 notifications and BLE data source shutdown. Added support for V2.x of Garmin watch app, Added new BLE2 data source, signal strength and battery level graphs.
\nV4.2.4 - Fault alarm rather than crash if bluetooth system crashes.