Mercurial > hg > ccmiandroid
comparison src/uk/ac/qmul/eecs/ccmi/activities/CcmiEditorAppActivity.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 |
comparison
equal
deleted
inserted
replaced
0:e0ee6ac3a45f | 1:66b3a838feca |
---|---|
28 import org.simpleframework.xml.core.Persister; | 28 import org.simpleframework.xml.core.Persister; |
29 | 29 |
30 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService; | 30 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService; |
31 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService.SoundEvent; | 31 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService.SoundEvent; |
32 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibleDialogBuilder; | 32 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibleDialogBuilder; |
33 import uk.ac.qmul.eecs.ccmi.utilities.ILogger; | |
33 import uk.ac.qmul.eecs.ccmi.xmlparser.Diagram; | 34 import uk.ac.qmul.eecs.ccmi.xmlparser.Diagram; |
34 import android.content.Intent; | 35 import android.content.Intent; |
35 import android.content.res.AssetManager; | 36 import android.content.res.AssetManager; |
36 import android.os.Bundle; | 37 import android.os.Bundle; |
37 import android.support.v4.app.DialogFragment; | 38 import android.support.v4.app.DialogFragment; |
38 import android.view.View; | 39 import android.view.View; |
39 import android.widget.AdapterView; | 40 import android.widget.AdapterView; |
40 import android.widget.AdapterView.OnItemClickListener; | 41 import android.widget.AdapterView.OnItemClickListener; |
41 import android.widget.AdapterView.OnItemLongClickListener; | 42 import android.widget.AdapterView.OnItemLongClickListener; |
42 import android.widget.ArrayAdapter; | 43 import android.widget.ArrayAdapter; |
44 import android.widget.TextView; | |
43 | 45 |
44 /** | 46 /** |
45 * | 47 * |
46 * The main activity. It displays the diagram through the hierarchical view | 48 * The main activity. It displays the diagram through the hierarchical view |
47 * of the <a href="http://ccmi.eecs.qmul.ac.uk"> CCmI Diagram Editor </a> | 49 * of the <a href="http://ccmi.eecs.qmul.ac.uk"> CCmI Diagram Editor </a> |
69 super.onCreate(savedInstanceState); | 71 super.onCreate(savedInstanceState); |
70 | 72 |
71 list.setOnItemClickListener(this); | 73 list.setOnItemClickListener(this); |
72 list.setOnItemLongClickListener(this); | 74 list.setOnItemLongClickListener(this); |
73 | 75 |
76 | |
77 ILogger.log("--- APPLICATION STARTED ---"); | |
78 | |
79 | |
74 /* init assets */ | 80 /* init assets */ |
75 AssetManager assetManager = getAssets(); | 81 AssetManager assetManager = getAssets(); |
76 try { | 82 try { |
77 file = assetManager.list("diagrams")[0]; | 83 file = assetManager.list("diagrams")[0]; |
78 in = assetManager.open("diagrams/"+file); | 84 in = assetManager.open("diagrams/"+file); |
94 } | 100 } |
95 | 101 |
96 /*----- listeners to implement the navigation ----*/ | 102 /*----- listeners to implement the navigation ----*/ |
97 @Override | 103 @Override |
98 public void onItemClick(AdapterView<?> av, View v, int pos, long id) { | 104 public void onItemClick(AdapterView<?> av, View v, int pos, long id) { |
105 ILogger.logTap(((TextView)v).getText()); | |
99 if(!navigation.goNext(pos)){ | 106 if(!navigation.goNext(pos)){ |
100 accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR); | 107 accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR); |
108 ILogger.logError("end of tree"); | |
101 return; | 109 return; |
102 } | 110 } |
103 accessibilityService.playSound(AccessibilityService.SoundEvent.V_EXPAND); | 111 accessibilityService.playSound(AccessibilityService.SoundEvent.V_EXPAND); |
104 accessibilityService.speak("Displaying " + getHeaderText()); | 112 accessibilityService.speak("displaying " + getHeaderText()); |
113 ILogger.logActivity(getHeaderText()); | |
105 } | 114 } |
106 | 115 |
107 /** | 116 /** |
108 * The activity listens to long clicks performed on the list view. | 117 * The activity listens to long clicks performed on the list view. |
109 * | 118 * |
110 * When a user long clicks an item, a dialog is displayed accordingly. For example if the types of nodes and | 119 * When a user long clicks an item, a dialog is displayed accordingly. For example if the types of nodes and |
111 * edges are listed when the user long clicks, then a dialog for insertion of a new node or edge is displayed. | 120 * edges are listed when the user long clicks, then a dialog for insertion of a new node or edge is displayed. |
112 */ | 121 */ |
113 @Override | 122 @Override |
114 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { | 123 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { |
124 ILogger.logLongTap(((TextView)view).getText()); | |
115 boolean doneSomething = navigation.getController().performEditAction(parent, view, position, id, this); | 125 boolean doneSomething = navigation.getController().performEditAction(parent, view, position, id, this); |
116 if(!doneSomething) | 126 if(!doneSomething){ |
117 accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR); | 127 accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR); |
128 ILogger.logError("no action available on this item"); | |
129 } | |
118 return doneSomething; | 130 return doneSomething; |
119 } | 131 } |
120 | 132 |
121 /** | 133 /** |
122 * When the back button is pressed the activity will cursor back in the tree | 134 * When the back button is pressed the activity will cursor back in the tree |
123 * view, which means the parent of the currently displayed items will be displayed | 135 * view, which means the parent of the currently displayed items will be displayed |
124 * together with its siblings. | 136 * together with its siblings. |
125 */ | 137 */ |
126 @Override | 138 @Override |
127 public void onBackPressed() { | 139 public void onBackPressed() { |
140 ILogger.logTap("back"); | |
128 if(navigation.goPrevious()){ | 141 if(navigation.goPrevious()){ |
129 accessibilityService.playSound(SoundEvent.V_COLLAPSE); | 142 accessibilityService.playSound(SoundEvent.V_COLLAPSE); |
130 accessibilityService.speak("Displaying "+getHeaderText()); | 143 accessibilityService.speak("Displaying "+getHeaderText()); |
144 ILogger.logActivity(getHeaderText()); | |
131 update(); | 145 update(); |
132 }else{ | 146 }else{ |
133 accessibilityService.playSound(SoundEvent.V_EDITING_MODE, true); | 147 accessibilityService.playSound(SoundEvent.V_EDITING_MODE, true); |
134 dialogBuilder.displayDialog(R.layout.alert_dialog_confirm_exit,"Exit Dialog",new AccessibleDialogBuilder.ButtonClickListener() { | 148 dialogBuilder.displayDialog(R.layout.alert_dialog_confirm_exit,"Exit Dialog",new AccessibleDialogBuilder.ButtonClickListener() { |
135 @Override | 149 @Override |
136 public void onClick(View v, DialogFragment dialogFragment, String tag) { | 150 public void onClick(View v, DialogFragment dialogFragment, String tag) { |
137 if("EXIT".equals(v.getTag())){ | 151 if("EXIT".equals(v.getTag())){ |
152 ILogger.logButton("exit"); | |
138 accessibilityService.speak(getResources().getString(R.string.exitMessage)); | 153 accessibilityService.speak(getResources().getString(R.string.exitMessage)); |
154 ILogger.log("--- EXIT ---"); | |
155 ILogger.dispose(); | |
139 finish(); | 156 finish(); |
140 }else if("CANCEL".equals(v.getTag())){ | 157 }else if("CANCEL".equals(v.getTag())){ |
158 ILogger.logButton("cancel"); | |
159 accessibilityService.playSound(SoundEvent.V_CANCEL); | |
141 accessibilityService.speak("Cancel"); | 160 accessibilityService.speak("Cancel"); |
142 accessibilityService.stopSound(); | 161 accessibilityService.stopSound(); |
143 dialogFragment.dismiss(); | 162 dialogFragment.dismiss(); |
144 }else if("OPEN".equals(v.getTag())){ | 163 }else if("OPEN".equals(v.getTag())){ |
164 ILogger.logButton("open"); | |
145 /* start the activity to open a file */ | 165 /* start the activity to open a file */ |
146 Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Open.class); | 166 Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Open.class); |
147 intent.putExtra("extension", CCMI_EXTENSION); | 167 intent.putExtra("extension", CCMI_EXTENSION); |
148 startActivityForResult(intent,OPEN_REQUEST); | 168 startActivityForResult(intent,OPEN_REQUEST); |
149 dialogFragment.dismiss(); | 169 dialogFragment.dismiss(); |
150 }else if("SAVE".equals(v.getTag())){ | 170 }else if("SAVE".equals(v.getTag())){ |
171 ILogger.logButton("save"); | |
151 Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Save.class); | 172 Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Save.class); |
152 intent.putExtra("extension", CCMI_EXTENSION); | 173 intent.putExtra("extension", CCMI_EXTENSION); |
153 startActivityForResult(intent,SAVE_REQUEST); | 174 startActivityForResult(intent,SAVE_REQUEST); |
154 dialogFragment.dismiss(); | 175 dialogFragment.dismiss(); |
155 } | 176 } |
163 if(resultCode == RESULT_OK){ | 184 if(resultCode == RESULT_OK){ |
164 if(requestCode == OPEN_REQUEST){ | 185 if(requestCode == OPEN_REQUEST){ |
165 try { | 186 try { |
166 InputStream in = new FileInputStream(new File(data.getData().getPath())); | 187 InputStream in = new FileInputStream(new File(data.getData().getPath())); |
167 readXML(in); | 188 readXML(in); |
189 ILogger.logActivity(navigation.getCurrentPath()); | |
168 } catch (Exception e) { | 190 } catch (Exception e) { |
169 accessibilityService.playSound(SoundEvent.V_ERROR); | 191 accessibilityService.playSound(SoundEvent.V_ERROR); |
170 accessibilityService.speak("File could not be open"); | 192 accessibilityService.speak("File could not be open"); |
171 } | 193 } |
172 }else if(requestCode == SAVE_REQUEST){ | 194 }else if(requestCode == SAVE_REQUEST){ |