Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
scan initiates using webcam, but even though the scan appears to be successful, rathe...
authormiles <miles@localhost>
Tue, 24 Sep 2013 20:25:52 +0000 (20:25 +0000)
committermiles <miles@localhost>
Tue, 24 Sep 2013 20:25:52 +0000 (20:25 +0000)
svn path=/; revision=511

Personnel/justin/lab inventory/bin/classes.dex
Personnel/justin/lab inventory/bin/lab inventory.apk
Personnel/justin/lab inventory/src/com/jaiswallab/lab/inventory/MainActivity.java

index d18e7d09940aeb7483c70841f5c97694ba9d34b1..3d32b177bdc539d99d62856ec49598168d4a1ba7 100644 (file)
Binary files a/Personnel/justin/lab inventory/bin/classes.dex and b/Personnel/justin/lab inventory/bin/classes.dex differ
index c6c2e9a2d66574d19964f89413df165082db1a4f..4e27faf1c0b4275288a33fa57065cc7e9dc9aa17 100644 (file)
Binary files a/Personnel/justin/lab inventory/bin/lab inventory.apk and b/Personnel/justin/lab inventory/bin/lab inventory.apk differ
index d79a97ca360b7333f55bf6c01f5bc20493ceeae4..7298762fb1e34c1d8422433d961af0e6dc82fcb3 100644 (file)
@@ -2,6 +2,7 @@ package com.jaiswallab.lab.inventory;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.Calendar;
 
 import com.google.zxing.*;
@@ -62,9 +63,10 @@ public class MainActivity extends Activity {
        printingNewQR = false;
        recognizingQR = true;
        text1.setText("Recognize QR button clicked");
+       
        IntentIntegrator intentIntegrator = new IntentIntegrator(this);
        intentIntegrator.initiateScan();
-       //startActivityForResult(intentIntegrator, 0);
+       return;
     }
     
     // This method is called at click of the scan new QR button
@@ -74,20 +76,26 @@ public class MainActivity extends Activity {
        addNewQR();
     }
     
-    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
-       IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
-       if (scanResult != null) {
-               String contents = scanResult.getContents();
-               if(printingNewQR) {
-                       return;
-               } else if(recognizingQR){
-                       displayQRInfo(contents);
-               }
-               text1.setText(contents);
-               // handle scan result
+    public void onActivityResult (int requestCode, int resultCode, Intent intent) {
+       switch (requestCode) {
+       case IntentIntegrator.REQUEST_CODE: 
+               IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
+               if (scanResult != null) {
+                       String contents = scanResult.getContents();
+                       if(printingNewQR) {
+                               return;
+                       } else if(recognizingQR){
+                               displayQRInfo(contents);
+                       }
+                       text1.setText(contents);
+               }
+               break;
        }
+
+       
        
-         // else continue with any other code you need in the method
+       /*
+*/     
        }
     
     
@@ -135,18 +143,17 @@ public class MainActivity extends Activity {
            if(barcode_bitmap != null) text3.setText("BARCODE EXISTS");
            else text3.setText("barcode null :(");
            
-           //String barcodeUrl = MediaStore.Images.Media.insertImage(getContentResolver(), barcode_bitmap, "NEW QR", "A newly created QR code");
-               savePhoto(barcode_bitmap);
-           //text2.setText(barcodeUrl);
+               String filepath = savePhoto(barcode_bitmap);
 
-/*         
-           Uri barcodeUri = Uri.parse(barcodeUrl);
 
+           
+           Uri barcodeUri = Uri.parse(filepath);
+           
                Intent printIntent = new Intent(this, PrintDialogActivity.class);
-               printIntent.setDataAndType(barcodeUri, "image/bmp"); //TODO make sure image/bmp is correct.
+               printIntent.setDataAndType(barcodeUri, "image/bmp"); //TODO make sure image/bmp is correct.0
                printIntent.putExtra("title", "NEW QR");
                startActivity(printIntent);
-       */    
+         
        } catch (WriterException e) { //eek }
 
        }       
@@ -158,13 +165,14 @@ public class MainActivity extends Activity {
     //this will use the information passed to it to reference an existing ID in the database
     //it will display the database information in a useful format
     public void displayQRInfo(String id) {
+        setContentView(R.layout.activity_main);
+       text1.setText(id);
        return;
     }
     
-       public void savePhoto(Bitmap bmp) throws Exception {
+       public String savePhoto(Bitmap bmp) throws Exception {
                File root = android.os.Environment.getExternalStorageDirectory();
-           File dir = new File (root.getAbsolutePath() + "/foldername");
-           dir.mkdirs();
+           File dir = new File (root.getAbsolutePath() + "/Pictures");
            
            FileOutputStream out = null;
                Calendar c = Calendar.getInstance();
@@ -179,15 +187,24 @@ public class MainActivity extends Activity {
                if(imageFileName!=null) text4.setText("file seems to be created");
                try {
                        out = new FileOutputStream(imageFileName);
-                       bmp.compress(Bitmap.CompressFormat.JPEG, 100, out);
-                       out.flush();
-                       out.close();
+                       if (bmp.compress(Bitmap.CompressFormat.JPEG, 100, out)) text1.setText("bitmap successfully compressed");
+                       try {
+                               out.flush();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+                       try {
+                               out.close();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
                        text4.setText(imageFileName.toString());
                        out = null;
                } catch (Exception e) {
                        System.out.println("unable to save photo");
                        e.printStackTrace();
                }
+               return imageFileName.toString();
        }
 
        public String fromInt(int val) {