Number check fixed
This commit is contained in:
+2
-2
@@ -11,8 +11,8 @@ android {
|
|||||||
compileSdkVersion 36
|
compileSdkVersion 36
|
||||||
buildToolsVersion '36.0.0'
|
buildToolsVersion '36.0.0'
|
||||||
useLibrary 'org.apache.http.legacy'
|
useLibrary 'org.apache.http.legacy'
|
||||||
versionCode 148
|
versionCode 149
|
||||||
versionName "1.8.7"
|
versionName "1.8.8"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class ActivityManageActionSetSystemSetting extends Activity
|
|||||||
selectedDataType.equalsIgnoreCase("Long")
|
selectedDataType.equalsIgnoreCase("Long")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(Miscellaneous.isNumericDecimal(etSettingValue.getText().toString()) || !Miscellaneous.isNumeric(etSettingValue.getText().toString()))
|
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || Miscellaneous.isNonDecimalNumber(etSettingValue.getText().toString()))
|
||||||
{
|
{
|
||||||
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ import java.security.SecureRandom;
|
|||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -1130,12 +1131,18 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
return executedSuccesfully;
|
return executedSuccesfully;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static char getDecimalSeparator()
|
||||||
|
{
|
||||||
|
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
|
||||||
|
return symbols.getDecimalSeparator(); // ',' or '.'
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isNumericDecimal(String strNum)
|
public static boolean isNumericDecimal(String strNum)
|
||||||
{
|
{
|
||||||
if (strNum == null)
|
if (strNum == null)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double d = Double.parseDouble(strNum);
|
double d = Double.parseDouble(strNum);
|
||||||
@@ -1147,6 +1154,14 @@ public class Miscellaneous extends Service
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNonDecimalNumber(String number)
|
||||||
|
{
|
||||||
|
if (number == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return !number.contains(String.valueOf(getDecimalSeparator()));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isNumeric(String str)
|
public static boolean isNumeric(String str)
|
||||||
{
|
{
|
||||||
return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal.
|
return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal.
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
* Fixed: Crash when starting service and show service icon was deactivated in app settings
|
* Fixed: Crash when starting service and show service icon was deactivated in app settings
|
||||||
* Fixed: "Bluetooth connect" permission was not requested for turning Bluetooth on or off.
|
* Fixed: "Bluetooth connect" permission was not requested for turning Bluetooth on or off.
|
||||||
* Fixed: Another app started/stopped couldn't be added when UI language was Dutch.
|
* Fixed: Another app started/stopped couldn't be added when UI language was Dutch.
|
||||||
|
* Fixed: Check for non-decimal number in some input fields
|
||||||
Reference in New Issue
Block a user