Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
try again at saving the barcode to the photo gallery - appears to work, but then...
authormiles <miles@localhost>
Mon, 23 Sep 2013 19:27:47 +0000 (19:27 +0000)
committermiles <miles@localhost>
Mon, 23 Sep 2013 19:27:47 +0000 (19:27 +0000)
svn path=/; revision=509

Personnel/justin/lab inventory/AndroidManifest.xml
Personnel/justin/lab inventory/bin/AndroidManifest.xml
Personnel/justin/lab inventory/bin/classes.dex
Personnel/justin/lab inventory/bin/lab inventory.apk
Personnel/justin/lab inventory/bin/resources.ap_
Personnel/justin/lab inventory/src/com/jaiswallab/lab/inventory/MainActivity.java

index 47e72a3ad1fee86fed292d22ddc7ed4cf10dedc0..c8190bfd79f3353818a78c6145dd4f8c4fc8e559 100644 (file)
@@ -6,6 +6,9 @@
     <uses-sdk
         android:minSdkVersion="8"
         android:targetSdkVersion="18" />
+    
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
     <application
         android:icon="@drawable/ic_launcher"
index 47e72a3ad1fee86fed292d22ddc7ed4cf10dedc0..c8190bfd79f3353818a78c6145dd4f8c4fc8e559 100644 (file)
@@ -6,6 +6,9 @@
     <uses-sdk
         android:minSdkVersion="8"
         android:targetSdkVersion="18" />
+    
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
     <application
         android:icon="@drawable/ic_launcher"
index e244a1052d3918e0e94e7a82fcf0267ead65cd5e..cf733a1dfd9edbf4daca2c3bc85f4bcbf7f0c2eb 100644 (file)
Binary files a/Personnel/justin/lab inventory/bin/classes.dex and b/Personnel/justin/lab inventory/bin/classes.dex differ
index dbdafa8af8d74138be1cb305a0a54cf8a80848fc..0c8abf42b355be0c637560b1733acae87e544d57 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 c396c193881ad00900f691ac09e408a239e6acb7..9c49ed392087708021a891272f46f24397d4ee23 100644 (file)
Binary files a/Personnel/justin/lab inventory/bin/resources.ap_ and b/Personnel/justin/lab inventory/bin/resources.ap_ differ
index 5b1291af6de6a30cea0ee96d377d6e9a2a3a7bff..55363620e4bcff54da949ddaaad07c8f4602a9a8 100644 (file)
@@ -1,5 +1,9 @@
 package com.jaiswallab.lab.inventory;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Calendar;
+
 import com.google.zxing.*;
 import com.google.zxing.integration.android.*;
 import com.google.zxing.qrcode.QRCodeWriter;
@@ -12,9 +16,13 @@ import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Color;
+import android.media.MediaScannerConnection;
+import android.media.MediaScannerConnection.MediaScannerConnectionClient;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Environment;
 import android.provider.MediaStore;
+import android.util.Log;
 import android.view.Menu;
 import android.view.View;
 import android.widget.EditText;
@@ -59,7 +67,7 @@ public class MainActivity extends Activity {
     }
     
     // This method is called at click of the scan new QR button
-    public void printQRClick(View view) {
+    public void printQRClick(View view) throws Exception {
        printingNewQR = true;
        recognizingQR = false;
        addNewQR();
@@ -86,7 +94,7 @@ public class MainActivity extends Activity {
     //this will use the information passed to it to create a new ID in the database
     //it will also use any input from a variety of text edits in order to populate the database entry
     //can we store pictures in the database if desired?
-    public void addNewQR() {
+    public void addNewQR() throws Exception {
 
        int rand1 = (int) (100*Math.random());
        int rand2 = (int) (100*Math.random());
@@ -110,28 +118,25 @@ public class MainActivity extends Activity {
 
             Bitmap barcode_bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
 
-            for (int y = 0; y < barcode_matrix.length; ++y) //TODO possibly reverse x&y mapping here?
-            {
-                    for (int x = 0; x < barcode_matrix[y].length; ++x)
-                    {
-                            if (barcode_matrix[y][x] == -1)
-                            {
-                                    barcode_bitmap.setPixel(x, y, Color.WHITE);
-                            }
-                            else
-                            {
-                                    barcode_bitmap.setPixel(x, y, Color.BLACK);
-                            }
-                    }
-            }
+                       for (int y = 0; y < barcode_matrix.length; ++y) // TODO possibly reverse x&y mapping here?
+                       {
+                               for (int x = 0; x < barcode_matrix[y].length; ++x) {
+                                       if (barcode_matrix[y][x] == -1) {
+                                               barcode_bitmap.setPixel(x, y, Color.WHITE);
+                                       } else {
+                                               barcode_bitmap.setPixel(x, y, Color.BLACK);
+                                       }
+                               }
+                       }
 
             //imageView.SetImageBitmap(img); 
 
            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");
-               text2.setText(barcodeUrl);
+           //String barcodeUrl = MediaStore.Images.Media.insertImage(getContentResolver(), barcode_bitmap, "NEW QR", "A newly created QR code");
+               savePhoto(barcode_bitmap);
+           //text2.setText(barcodeUrl);
 
 /*         
            Uri barcodeUri = Uri.parse(barcodeUrl);
@@ -144,9 +149,8 @@ public class MainActivity extends Activity {
        } catch (WriterException e) { //eek }
 
        }       
-       
-       
        return;
+       
     }
     
     
@@ -156,4 +160,59 @@ public class MainActivity extends Activity {
        return;
     }
     
+       public void savePhoto(Bitmap bmp) throws Exception {
+               File imageFileFolder = new File(Environment.getExternalStorageDirectory(),
+                               "Rotate");
+               imageFileFolder.mkdir();
+               FileOutputStream out = null;
+               Calendar c = Calendar.getInstance();
+               String date = fromInt(c.get(Calendar.MONTH))
+                               + fromInt(c.get(Calendar.DAY_OF_MONTH))
+                               + fromInt(c.get(Calendar.YEAR))
+                               + fromInt(c.get(Calendar.HOUR_OF_DAY))
+                               + fromInt(c.get(Calendar.MINUTE))
+                               + fromInt(c.get(Calendar.SECOND));
+               text2.setText(date);
+               File imageFileName = new File(imageFileFolder, date.toString() + ".jpg");
+               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();
+                       scanPhoto(imageFileName.toString());
+                       text4.setText(imageFileName.toString());
+                       out = null;
+               } catch (Exception e) {
+                       System.out.println("unable to save photo");
+                       e.printStackTrace();
+               }
+       }
+
+       public String fromInt(int val) {
+               return String.valueOf(val);
+       }
+
+       public void scanPhoto(final String imageFileName) throws Exception {
+               MediaScannerConnection msConn = new MediaScannerConnection(this,
+                               new MediaScannerConnectionClient() {
+                                       public void onMediaScannerConnected() {
+                                               try {
+                                                       scanPhoto(imageFileName);
+                                               } catch (Exception e) {
+                                                       System.out.println("unable to scan photo!");
+                                                       e.printStackTrace();
+                                               }
+                                               Log.i("msClient obj  in Photo Utility",
+                                                               "connection established");
+                                       }
+
+                                       public void onScanCompleted(String path, Uri uri) {
+                                               finish();       
+                                               Log.i("msClient obj in Photo Utility", "scan completed");
+                                       }
+                               });
+               msConn.connect();
+       }
+
 }
\ No newline at end of file