diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java index 3ed6cead..6fded02f 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java @@ -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); diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index ba51232b..4bdc29bf 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -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; diff --git a/fastlane/metadata/android/en-US/changelogs/122.txt b/fastlane/metadata/android/en-US/changelogs/122.txt index 61fe1deb..7af39dc5 100644 --- a/fastlane/metadata/android/en-US/changelogs/122.txt +++ b/fastlane/metadata/android/en-US/changelogs/122.txt @@ -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 \ No newline at end of file +* Fixed: Changed input type for decimal numbers when adding intent data +* Fixed: Battery level trigger not working when using direction falling-below \ No newline at end of file