diff 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
line wrap: on
line diff
--- a/src/uk/ac/qmul/eecs/ccmi/activities/CcmiEditorAppActivity.java	Thu Dec 13 20:00:21 2012 +0000
+++ b/src/uk/ac/qmul/eecs/ccmi/activities/CcmiEditorAppActivity.java	Tue Feb 12 15:31:48 2013 +0000
@@ -30,6 +30,7 @@
 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService;
 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibilityService.SoundEvent;
 import uk.ac.qmul.eecs.ccmi.accessibility.AccessibleDialogBuilder;
+import uk.ac.qmul.eecs.ccmi.utilities.ILogger;
 import uk.ac.qmul.eecs.ccmi.xmlparser.Diagram;
 import android.content.Intent;
 import android.content.res.AssetManager;
@@ -40,6 +41,7 @@
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.AdapterView.OnItemLongClickListener;
 import android.widget.ArrayAdapter;
+import android.widget.TextView;
 
 /**
  * 
@@ -71,6 +73,10 @@
 		list.setOnItemClickListener(this);
 		list.setOnItemLongClickListener(this);
 		
+
+		ILogger.log("--- APPLICATION STARTED ---");
+		
+		
 		/* init assets */
 		AssetManager assetManager = getAssets();
 		try {
@@ -96,12 +102,15 @@
 	/*----- listeners to implement the navigation ----*/
 	@Override
 	public void onItemClick(AdapterView<?> av, View v, int pos, long id) {
+		ILogger.logTap(((TextView)v).getText());
 		if(!navigation.goNext(pos)){
 			accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR);
+			ILogger.logError("end of tree");
 			return;
 		}
 		accessibilityService.playSound(AccessibilityService.SoundEvent.V_EXPAND);
-		accessibilityService.speak("Displaying " + getHeaderText()); 
+		accessibilityService.speak("displaying " + getHeaderText());
+		ILogger.logActivity(getHeaderText());
 	}
 	
 	/**
@@ -112,9 +121,12 @@
 	 */
 	@Override
 	public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+		ILogger.logLongTap(((TextView)view).getText());
 		boolean doneSomething = navigation.getController().performEditAction(parent, view, position, id, this);
-		if(!doneSomething)
+		if(!doneSomething){
 			accessibilityService.playSound(AccessibilityService.SoundEvent.V_ERROR);
+			ILogger.logError("no action available on this item");
+		}
 		return doneSomething;
 	}
 
@@ -125,9 +137,11 @@
 	 */
 	@Override
 	public void onBackPressed() {
+		ILogger.logTap("back");
 		if(navigation.goPrevious()){
 			accessibilityService.playSound(SoundEvent.V_COLLAPSE);
 			accessibilityService.speak("Displaying "+getHeaderText());
+			ILogger.logActivity(getHeaderText());
 			update();
 		}else{
 			accessibilityService.playSound(SoundEvent.V_EDITING_MODE, true);
@@ -135,19 +149,26 @@
 				@Override
 				public void onClick(View v, DialogFragment dialogFragment, String tag) {
 					if("EXIT".equals(v.getTag())){
+						ILogger.logButton("exit");
 						accessibilityService.speak(getResources().getString(R.string.exitMessage));
+						ILogger.log("--- EXIT ---");
+						ILogger.dispose();
 						finish();
 					}else if("CANCEL".equals(v.getTag())){
+						ILogger.logButton("cancel");
+						accessibilityService.playSound(SoundEvent.V_CANCEL);
 						accessibilityService.speak("Cancel");
 						accessibilityService.stopSound();
 						dialogFragment.dismiss();
 					}else if("OPEN".equals(v.getTag())){
+						ILogger.logButton("open");
 						/* start the activity to open a file */
 						Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Open.class);
 						intent.putExtra("extension", CCMI_EXTENSION);
 						startActivityForResult(intent,OPEN_REQUEST);
 						dialogFragment.dismiss();
 					}else if("SAVE".equals(v.getTag())){
+						ILogger.logButton("save");
 						Intent intent = new Intent(CcmiEditorAppActivity.this, FileSelectorActivity.Save.class);
 						intent.putExtra("extension", CCMI_EXTENSION);
 						startActivityForResult(intent,SAVE_REQUEST);
@@ -165,6 +186,7 @@
 				try {
 					InputStream in = new FileInputStream(new File(data.getData().getPath()));
 					readXML(in);
+					ILogger.logActivity(navigation.getCurrentPath());
 				} catch (Exception e) {
 					accessibilityService.playSound(SoundEvent.V_ERROR);
 					accessibilityService.speak("File could not be open");