diff --git a/app/src/main/java/ryey/easer/core/data/storage/ConditionDataStorage.java b/app/src/main/java/ryey/easer/core/data/storage/ConditionDataStorage.java index 1b28082b..5be616f2 100644 --- a/app/src/main/java/ryey/easer/core/data/storage/ConditionDataStorage.java +++ b/app/src/main/java/ryey/easer/core/data/storage/ConditionDataStorage.java @@ -50,6 +50,25 @@ public static ConditionDataStorage getInstance(Context context) { @Override boolean isSafeToDelete(String name) { + ScriptDataStorage scriptDataStorage = ScriptDataStorage.getInstance(context); + for (String scriptName : scriptDataStorage.list()) { + ScriptStructure script = scriptDataStorage.get(scriptName); + if (script.isCondition()) { + if (script.getCondition().getName().equals(name)) { + return false; + } + } + } + ScenarioDataStorage scenarioDataStorage = ScenarioDataStorage.getInstance(context); + for (String scenarioName : scenarioDataStorage.list()) { + ScenarioStructure scenario = scenarioDataStorage.get(scenarioName); + EventData eventData = scenario.getEventData(); + if (eventData instanceof ConditionEventEventData) { + if (name.equals(((ConditionEventEventData) eventData).conditionName)) { + return false; + } + } + } return true; }