Number check fixed
This commit is contained in:
@@ -106,7 +106,7 @@ public class ActivityManageActionSetSystemSetting extends Activity
|
||||
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();
|
||||
return;
|
||||
|
||||
@@ -96,6 +96,7 @@ import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -1114,28 +1115,34 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
}
|
||||
|
||||
// executes a command on the system
|
||||
private static boolean canExecuteCommand(String command)
|
||||
{
|
||||
boolean executedSuccesfully;
|
||||
try
|
||||
{
|
||||
Runtime.getRuntime().exec(command);
|
||||
executedSuccesfully = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
executedSuccesfully = false;
|
||||
}
|
||||
// executes a command on the system
|
||||
private static boolean canExecuteCommand(String command)
|
||||
{
|
||||
boolean executedSuccesfully;
|
||||
try
|
||||
{
|
||||
Runtime.getRuntime().exec(command);
|
||||
executedSuccesfully = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
executedSuccesfully = false;
|
||||
}
|
||||
|
||||
return executedSuccesfully;
|
||||
}
|
||||
|
||||
public static char getDecimalSeparator()
|
||||
{
|
||||
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
|
||||
return symbols.getDecimalSeparator(); // ',' or '.'
|
||||
}
|
||||
|
||||
return executedSuccesfully;
|
||||
}
|
||||
public static boolean isNumericDecimal(String strNum)
|
||||
{
|
||||
if (strNum == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
double d = Double.parseDouble(strNum);
|
||||
@@ -1146,6 +1153,14 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user