diff --git a/app/src/main/java/com/jens/automation2/Profile.java b/app/src/main/java/com/jens/automation2/Profile.java index ac29817f..5f40373e 100644 --- a/app/src/main/java/com/jens/automation2/Profile.java +++ b/app/src/main/java/com/jens/automation2/Profile.java @@ -458,29 +458,17 @@ public class Profile implements Comparable public boolean delete(Context context) { - if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.profileActive)) + Rule usingRule = this.isInUseByRules(); + if(usingRule != null) { - for (Rule rule : Rule.findRuleCandidatesByTriggerProfile(this)) - { - Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show(); - return false; - } - } - else if(Rule.isAnyRuleUsing(Action_Enum.changeSoundProfile)) - { - for (Rule rule : Rule.findRuleCandidatesByActionProfile(this)) - { - Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show(); - return false; - } + Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), usingRule.getName(), this.getName()), Toast.LENGTH_LONG).show(); + return false; } else { profileCollection.remove(this); return XmlFileInterface.writeFile(); } - - return false; } private boolean plausibilityCheck() diff --git a/fastlane/metadata/android/en-US/changelogs/118.txt b/fastlane/metadata/android/en-US/changelogs/118.txt index 68341d1c..a0f3dc18 100644 --- a/fastlane/metadata/android/en-US/changelogs/118.txt +++ b/fastlane/metadata/android/en-US/changelogs/118.txt @@ -6,4 +6,5 @@ * Fixed: Variables were not replaced when sending text messages * Fixed: Service wouldn't always start after device has been powered on * Fixed: Set ringtones on Android 11 and above -* Fixed: Permission read storage required for changing ringtones \ No newline at end of file +* Fixed: Permission read storage required for changing ringtones +* Fixed: Profile that were not in use, could not be deleted. \ No newline at end of file