Changeset 1469
- Timestamp:
- 11/15/08 08:45:38 (7 weeks ago)
- Location:
- branches/dev/j2merosa/org.javarosa.media.image/src/org/javarosa/media/image
- Files:
-
- 1 added
- 3 modified
-
activity/ImageCaptureActivity.java (modified) (7 diffs)
-
activity/ImageChooserActivity.java (modified) (5 diffs)
-
utilities/FileUtility.java (modified) (1 diff)
-
utilities/ImageSniffer.java (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/dev/j2merosa/org.javarosa.media.image/src/org/javarosa/media/image/activity/ImageCaptureActivity.java
r1460 r1469 55 55 private int width; 56 56 private int height; 57 private String fullName; 57 58 58 59 public ImageCaptureActivity(IShell shell) { … … 60 61 display = JavaRosaServiceProvider.instance().getDisplay(); 61 62 dataModel = new FileRMSUtility("image_store"); 62 width = 640;63 height = 480;63 width = 960; 64 height = 720; 64 65 } 65 66 … … 131 132 // stick the picture in here. 132 133 Hashtable table = new Hashtable(); 133 BasicDataPointer p = new BasicDataPointer("Image", imageData); 134 FileDataPointer p = new FileDataPointer(fullName); 135 //BasicDataPointer p = new BasicDataPointer("Image", imageData); 134 136 table.put(IMAGE_KEY, p); 135 137 return table; … … 197 199 imageData = mVideoControl.getSnapshot("encoding=jpeg&quality=100&width=" + width + "&height=" + height); 198 200 //image = Image.createImage(jpg, 0, jpg.length); 201 // Save to file no longer 202 String fileName = "test" + System.currentTimeMillis(); 203 fullName = saveFile(fileName + ".jpg", imageData); 199 204 doFinish(); 200 // Save to file no longer 201 //String fileName = "test" + System.currentTimeMillis(); 202 //boolean saved = saveFile(fileName + ".jpg", jpg); 205 203 206 } catch (Exception me) { 204 207 handleException(me); … … 221 224 jpg = mVideoControl.getSnapshot("encoding=jpeg&quality=100&width=" + width + "&height=" + height); 222 225 String fileName = "test" + System.currentTimeMillis(); 223 boolean saved = saveFile(fileName + ".jpg", jpg) ;226 boolean saved = saveFile(fileName + ".jpg", jpg) == ""; 224 227 if (saved) { 225 228 text += "Success!"; … … 247 250 } 248 251 249 private booleansaveFile(String filename, byte[] image) {252 private String saveFile(String filename, byte[] image) { 250 253 // TODO 251 254 String rootName = FileUtility.getDefaultRoot(); … … 253 256 FileUtility.createDirectory(restorepath); 254 257 String fullName = restorepath + "/" + filename; 255 System.out.println("Image saved."); 256 return FileUtility.createFile(fullName, image); 257 // not sure why this was being done twice 258 if (FileUtility.createFile(fullName, image)) { 259 System.out.println("Image saved."); 260 return fullName; 261 } else { 262 return ""; 263 } 264 258 265 } 259 266 -
branches/dev/j2merosa/org.javarosa.media.image/src/org/javarosa/media/image/activity/ImageChooserActivity.java
r1460 r1469 20 20 import org.javarosa.media.image.model.FileDataPointer; 21 21 import org.javarosa.media.image.storage.FileRMSUtility; 22 import org.javarosa.media.image.utilities.ImageSniffer; 22 23 import org.javarosa.media.image.utilities.ImageUtility; 23 24 … … 48 49 private Command markCommand; 49 50 private String currentKey; 51 private Thread snifferThread; 52 private ImageSniffer sniffer; 50 53 51 54 public ImageChooserActivity(IShell shell) { … … 67 70 68 71 public void destroy() { 69 // TODO Auto-generated method stub 70 72 sniffer.quit(); 71 73 } 72 74 … … 83 85 Object o = globalContext.getElement(currentKey); 84 86 IDataPointer pointer = (IDataPointer) o; 87 addImageToUI(pointer); 88 updateView(); 89 } 90 91 92 private void updateView() { 93 display.setView(DisplayViewFactory.createView(mainForm)); 94 } 95 96 public void setShell(IShell shell) { 97 this.shell = shell; 98 99 } 100 101 public void start(Context context) { 102 this.context = context; 103 mainForm = new Form("Image Chooser"); 104 mainForm.addCommand(cancelCommand); 105 mainForm.addCommand(cameraCommand); 106 mainForm.addCommand(browseCommand); 107 mainForm.addCommand(returnCommand); 108 mainForm.addCommand(viewCommand); 109 mainForm.addCommand(markCommand); 110 mainForm.setCommandListener(this); 111 112 mainForm.append("Use the menu options to take pictures or browse."); 113 114 // also create the sniffer 115 sniffer = new ImageSniffer("file://localhost/root1/photos/", this); 116 snifferThread = new Thread(sniffer); 117 snifferThread.start(); 118 updateView(); 119 } 120 121 public synchronized void addImageToUI(IDataPointer pointer) { 85 122 try { 86 123 if (pointer != null) { … … 95 132 96 133 } 97 display.setView(DisplayViewFactory.createView(mainForm)); 98 } 99 100 public void setShell(IShell shell) { 101 this.shell = shell; 102 103 } 104 105 public void start(Context context) { 106 this.context = context; 107 mainForm = new Form("Image Chooser"); 108 mainForm.addCommand(cancelCommand); 109 mainForm.addCommand(cameraCommand); 110 mainForm.addCommand(browseCommand); 111 mainForm.addCommand(returnCommand); 112 mainForm.addCommand(viewCommand); 113 mainForm.addCommand(markCommand); 114 mainForm.setCommandListener(this); 115 116 display.setView(DisplayViewFactory.createView(mainForm)); 117 118 } 134 } 135 119 136 120 137 private FileDataPointer captureNewImage() { -
branches/dev/j2merosa/org.javarosa.media.image/src/org/javarosa/media/image/utilities/FileUtility.java
r1460 r1469 69 69 public static Enumeration listDirectory(String directoryPath) { 70 70 FileConnection dir = null; 71 System.out.println("Listing the contents of: " + directoryPath); 71 72 try { 72 73 dir = (FileConnection) Connector.open(directoryPath);
