Mercurial > hg > ccmiandroid
diff src/uk/ac/qmul/eecs/ccmi/activities/TreeNavigation.java @ 1:66b3a838feca logging tip
Added logging of user interaction
author | Fiore Martin <fiore@eecs.qmul.ac.uk> |
---|---|
date | Tue, 12 Feb 2013 15:31:48 +0000 |
parents | e0ee6ac3a45f |
children |
line wrap: on
line diff
--- a/src/uk/ac/qmul/eecs/ccmi/activities/TreeNavigation.java Thu Dec 13 20:00:21 2012 +0000 +++ b/src/uk/ac/qmul/eecs/ccmi/activities/TreeNavigation.java Tue Feb 12 15:31:48 2013 +0000 @@ -30,6 +30,7 @@ import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService.SoundEvent; import uk.ac.qmul.eecs.ccmi.accessibility.AccessibleCheckbox; import uk.ac.qmul.eecs.ccmi.accessibility.AccessibleDialogBuilder; +import uk.ac.qmul.eecs.ccmi.utilities.ILogger; import uk.ac.qmul.eecs.ccmi.utilities.Stack; import uk.ac.qmul.eecs.ccmi.xmlparser.Diagram; import uk.ac.qmul.eecs.ccmi.xmlparser.DiagramUpdater; @@ -501,7 +502,7 @@ }; /* - * Responds to the long cick of the user. It acts according to the list item clicked + * Responds to the long click of the user. It acts according to the list item clicked * by the user (and therefore according to the hierarchy level currently displayed). * When a dialog needs to be shown, it used dialogBuilder.displayDialog() and register itself * as buttoClickListener to handle the click of the user in the same class. @@ -522,19 +523,25 @@ /* construct the node and add it to the diagram */ Node node = new Node(((NodeType)clickedItem).getType(),properties); diagramUpdater.addNode(node); + dialogBuilder.getAccessibilityService().playSound(SoundEvent.V_OK); dialogBuilder.getAccessibilityService().speak("Node "+ node +" created"); + ILogger.log("Node "+ node +" created"); }else{ // user clicked on edge List<EdgeType> edgeTypes = diagram.getPrototypes().getEdgeTypes(); clickedItem = edgeTypes.get(position - nodeTypes.size()); /* respect min and max attached nodes */ if(selectedNodes.size() < ((EdgeType)clickedItem).getMinAttachedNodes()){ + dialogBuilder.getAccessibilityService().playSound(SoundEvent.V_ERROR); dialogBuilder.getAccessibilityService().speak("you must select at least "+ ((EdgeType)clickedItem).getMinAttachedNodes()+" nodes"); + ILogger.logError("selected nodes < "+((EdgeType)clickedItem).getMinAttachedNodes()); return true; } if(selectedNodes.size() > ((EdgeType)clickedItem).getMaxAttachedNodes()){ + dialogBuilder.getAccessibilityService().playSound(SoundEvent.V_ERROR); dialogBuilder.getAccessibilityService().speak("you must select at most "+ ((EdgeType)clickedItem).getMaxAttachedNodes()+" nodes"); + ILogger.logError("selected nodes > "+((EdgeType)clickedItem).getMaxAttachedNodes()); return true; } @@ -547,6 +554,7 @@ edge.getAttachedNodes().add(new EdgeNode(n.getId())); } diagramUpdater.addEdge(edge); + dialogBuilder.getAccessibilityService().playSound(SoundEvent.V_OK); StringBuilder builder = new StringBuilder(); builder.append(edge).append(" created between "); for(int i=0; i<selectedNodes.size(); i++){ @@ -560,6 +568,7 @@ } selectedNodes.clear(); // when an edge is added the selected node are cleared dialogBuilder.getAccessibilityService().speak(builder.toString()); + ILogger.log(builder.toString()); } /* update the view */ cachedList = buildCurrentChildList(); @@ -611,16 +620,18 @@ return false; } - /* this is the callback triggered when the user clicks on any bottom of the dialog shown. v is the button + /* this is the callback triggered when the user clicks on any botton of the dialog shown. v is the button * The method first checks for the dialog tag to understand which dialog it's handling, then it checks * for the button tag to understand which button the user pressed. The first check though is on "CANCEL" * button as its tag it's the same for all the dialog */ @Override public void onClick(View v, DialogFragment dialogFragment, String dialogTag) { Object buttonTag = v.getTag(); + ILogger.logButton(buttonTag.toString()); AccessibilityService accessibility = dialogBuilder.getAccessibilityService(); if("CANCEL".equals(buttonTag)){ + accessibility.playSound(SoundEvent.V_CANCEL); accessibility.speak("Cancel"); dialogFragment.dismiss(); return; @@ -631,10 +642,12 @@ selectedNodes.add((Node)clickedItem); accessibility.playSound(SoundEvent.V_OK); accessibility.speak(clickedItem + " selected"); + ILogger.log(clickedItem + " selected"); }else if("UNSELECT".equals(buttonTag)){ selectedNodes.remove(clickedItem); accessibility.playSound(SoundEvent.V_OK); accessibility.speak(clickedItem + " unselected"); + ILogger.log(clickedItem + " unselected"); }else if("RENAME".equals(buttonTag)){ dialogFragment.dismiss(); dialogBuilder.displayDialog(R.layout.alert_dialog_rename, RENAME_DIALOG_TAG+clickedItem, this); @@ -654,19 +667,23 @@ if(text.length() == 0){ accessibility.playSound(SoundEvent.V_ERROR); accessibility.speak("Text cannot be empty"); + ILogger.logError("text empty"); return; } String oldName = clickedItem.toString(); diagramUpdater.rename(clickedItem,text); accessibility.playSound(SoundEvent.V_OK); accessibility.speak(oldName+" renamed to "+clickedItem); + ILogger.log(oldName+" renamed to "+clickedItem); }else if(dialogTag.startsWith(CONFIRMATION_DIALOG_TAG)){ /* if it reaches this point it's a "YES" as a "NO" button has "CANCEL" as its tag */ /* and the match against "CANCEL" match is performed first of all */ diagramUpdater.delete(clickedItem); /* if it's a selected node, remove it from selected */ selectedNodes.remove(clickedItem); + accessibility.playSound(SoundEvent.V_OK); accessibility.speak(clickedItem+" Deleted"); + ILogger.log(clickedItem+" Deleted"); /* update the headers which show the number of children the current item contains */ if(path.current() instanceof NodeType || path.current() instanceof EdgeType){ cachedHeaderTexts.pop(); @@ -683,11 +700,13 @@ if(text.length() == 0){ accessibility.playSound(SoundEvent.V_ERROR); accessibility.speak("Text cannot be empty"); + ILogger.logError("text empty"); return; } diagramUpdater.addProperty((Node)path.get(ITEM_LEVEL),((NodeProperty)clickedItem),text); accessibility.playSound(SoundEvent.V_OK); accessibility.speak("Property "+text+" added"); + ILogger.log("Property "+text+" added"); }else if(EDIT_NODE_REF_DIALOG_TAG.equals(dialogTag)){ if("EDIT_LABEL".equals(buttonTag)){ dialogFragment.dismiss(); @@ -708,6 +727,7 @@ if(heads == null || heads.length == 0){ accessibility.playSound(SoundEvent.V_ERROR); accessibility.speak("There are no arrow heads defined for "+edge); + ILogger.logError("There are no arrow heads defined for "+edge); return; } dialogBuilder.displaySelectionDialog(EDIT_ARROWHEAD_DIALOG_TAG, heads, this); @@ -718,16 +738,19 @@ if(text.length() == 0){ accessibility.playSound(SoundEvent.V_ERROR); accessibility.speak("Text cannot be empty"); + ILogger.logError("Text empty"); return; } diagramUpdater.setLabel((EdgeNode)clickedItem,text); accessibility.playSound(SoundEvent.V_OK); accessibility.speak("Label set to "+clickedItem);// EdgeNode.toString = EdgeNode.getLabel + ILogger.log("Label set to "+clickedItem); }else if(EDIT_ARROWHEAD_DIALOG_TAG.equals(dialogTag)){ Spinner spinner = (Spinner)dialogFragment.getDialog().findViewById(R.id.selectionSpinner); - ((EdgeNode)clickedItem).setHead(spinner.getSelectedItem().toString()); + diagramUpdater.setArrowHead((EdgeNode)clickedItem, spinner.getSelectedItem().toString()); accessibility.playSound(SoundEvent.V_OK); accessibility.speak("Arrow head set to "+spinner.getSelectedItem().toString()); + ILogger.log("Arrow head set to "+spinner.getSelectedItem().toString()); }else if(EDIT_PROPERTY_DIALOG_TAG.equals(dialogTag)){ if("RENAME".equals(buttonTag)){ dialogFragment.dismiss(); @@ -766,11 +789,19 @@ AccessibleCheckbox checkbox = (AccessibleCheckbox)dialogFragment.getDialog().findViewById(R.id.checkBox); boolean[] checks = checkbox.getChecks(); List<Integer> modifiers = new ArrayList<Integer>(checks.length); + StringBuilder modifiersString = new StringBuilder(); for(int i=0; i<checks.length; i++){ - if(checks[i]) + if(checks[i]){ modifiers.add(i); + modifiersString.append(i).append(' '); + } } diagramUpdater.setModifiers((PropertyValue)clickedItem, modifiers); + accessibility.playSound(SoundEvent.V_OK); + accessibility.speak("modifiers set for "+path.current()); + if(modifiersString.length() == 0) + modifiersString.append("no modifiers"); + ILogger.log("modifiers set for "+path.current()+": "+ modifiersString.toString()); } /* update the view */ cachedList = buildCurrentChildList();