/** * Updates criterias in the retrieved AccessibilityObjects based on if we should be attentive to * the users selected disabilities and the users selected disabilities. * * @param accessibilityObject The AccessibilityObject to update criterias in. * @param selectedDisabilities The users selected disabilities. * @param attentive True if we should be attentive to the users selected disabilities. */ private void updateCriteriasInAccesibilityObject( AccessibilityObject accessibilityObject, boolean[] selectedDisabilities, boolean attentive) { for (Block b : accessibilityObject.getBlocks()) { for (AccessibilityPackage p : b.getPackages()) { for (Criteria c : p.getCriterias()) { // Take Attentive/Available choice into consideration. // Request should match the criteria's "attentive/available belonging". // We should not show hidden criterias either. if (!(attentive == c.isNotice()) || c.isHidden()) { c.setShow(false); continue; } boolean disabilities = checkDisabilities(c, selectedDisabilities); c.setShow(disabilities); } } } }
/** * Checks if the provided criteria has any of the selected disabilities. * * @param criteria Criteria to check disabilities for. * @param selectedDisabilities The selected disabilities to look for. * @return True if any of the selected disabilities are found. */ private boolean checkDisabilities(Criteria criteria, boolean[] selectedDisabilities) { boolean result = false; for (String disability : criteria.getDisabilities()) { // Since we don't want to add the accessibility information multiple times, move on to next // criteria when it is added. result |= "hear".equals(disability) && selectedDisabilities[0]; result |= "see".equals(disability) && selectedDisabilities[1]; result |= "move".equals(disability) && selectedDisabilities[2]; result |= "substances".equals(disability) && selectedDisabilities[3]; result |= "information".equals(disability) && selectedDisabilities[4]; } return result; }