battery level trigger fixed

This commit is contained in:
Jens 2022-07-11 22:56:43 +02:00
parent 53e62068a5
commit eeb4f4a39e
3 changed files with 12 additions and 3 deletions

View File

@ -884,6 +884,7 @@ public class ActivityManageRule extends Activity
return alertDialog;
}
private AlertDialog getTriggerBatteryDialog(final Context myContext, final String[] choices)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
@ -898,6 +899,7 @@ public class ActivityManageRule extends Activity
triggerBattery = (which+1);
newTrigger.setTriggerType(Trigger_Enum.batteryLevel);
newTrigger.setBatteryLevel(triggerBattery);
newTrigger.setTriggerParameter2(String.valueOf(triggerBattery));
// Log.i("test", newTrigger.toString());
// Log.i("test", String.valueOf(newTrigger.getBatteryLevel()));
ruleToEdit.getTriggerSet().add(newTrigger);

View File

@ -794,9 +794,15 @@ public class Trigger
boolean checkBatteryLevel()
{
/*
-1 means value is not known, yet.
*/
if(BatteryReceiver.getBatteryLevel() == -1)
return false;
if(this.getTriggerParameter())
{
if(BatteryReceiver.getBatteryLevel() <= this.getBatteryLevel())
if(BatteryReceiver.getBatteryLevel() < this.getBatteryLevel())
{
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryLowerThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
return false;
@ -804,7 +810,7 @@ public class Trigger
}
else
{
if(this.getBatteryLevel() >= this.getBatteryLevel())
if(BatteryReceiver.getBatteryLevel() >= this.getBatteryLevel())
{
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryHigherThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
return false;

View File

@ -1,3 +1,4 @@
* New action: Keep phone turned on
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
* Fixed: Changed input type for decimal numbers when adding intent data
* Fixed: Changed input type for decimal numbers when adding intent data
* Fixed: Battery level trigger not working when using direction falling-below