<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ </activity>
+ <activity
+ android:label="Add Item"
+ android:name=".ItemCreationActivity" >
</activity>
</application>
--- /dev/null
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.jaiswallab.lab.inventory"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <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"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.READ_CALENDAR"/>
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/title_activity_main" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:label="Add Item"
+ android:name=".ItemCreationActivity" >
+ </activity>
+ </application>
+
+
+</manifest>
\ No newline at end of file
--- /dev/null
+# cache for current jar dependency. DO NOT EDIT.
+# format is <lastModified> <length> <SHA-1> <path>
+# Encoding is UTF-8
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
-<item android:drawable="@drawable/grey_button"></item>
+ <item android:state_pressed="true"
+ android:drawable="@drawable/light_grey_button" /> <!-- pressed -->
+ <item android:drawable="@drawable/grey_button"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/grey_button"></item>
+ <item android:state_pressed="true"
+ android:drawable="@drawable/light_grey_button" /> <!-- pressed -->
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/grey_button"></item>
+ <item android:state_pressed="true"
+ android:drawable="@drawable/light_grey_button" /> <!-- pressed -->
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/grey_button"></item>
+ <item android:state_pressed="true"
+ android:drawable="@drawable/light_grey_button" /> <!-- pressed -->
</selector>
\ No newline at end of file
--- /dev/null
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@color/light_blue" >
+
+ <EditText
+ android:id="@+id/addInfo1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/addInfo2"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:layout_marginTop="64dp"
+ android:ems="10" />
+
+ <Button
+ android:id="@+id/Button01"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/green_button"
+ android:onClick="createClick"
+ android:text="Create" />
+
+ <EditText
+ android:id="@+id/addInfo3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/Button01"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/addInfo2"
+ android:ems="10" />
+
+ <EditText
+ android:id="@+id/addInfo2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/addInfo3"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/addInfo1"
+ android:ems="10" />
+
+ <TextView
+ android:id="@+id/label1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/addInfo1"
+ android:layout_alignBottom="@+id/addInfo1"
+ android:layout_marginRight="14dp"
+ android:layout_toLeftOf="@+id/addInfo1"
+ android:text="Type:"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <TextView
+ android:id="@+id/label2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/addInfo2"
+ android:layout_alignBottom="@+id/addInfo2"
+ android:layout_alignRight="@+id/label1"
+ android:text="Quantity:"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <TextView
+ android:id="@+id/label3"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/addInfo3"
+ android:layout_alignBottom="@+id/addInfo3"
+ android:layout_alignRight="@+id/label2"
+ android:text="Curator Name:"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+</RelativeLayout>
\ No newline at end of file
android:layout_below="@+id/editText2"
android:ems="10" />
- <EditText
- android:id="@+id/editText1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_below="@+id/button2"
- android:ems="10" />
-
- <Button
- android:id="@+id/button2"
- style="?android:attr/buttonStyleSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/button1"
- android:layout_toLeftOf="@+id/editText2"
- android:onClick="updateInventoryItem"
- android:background="@drawable/update_button"
- android:text="Update Item" />
-
<EditText
android:id="@+id/editText4"
android:layout_width="wrap_content"
android:layout_below="@+id/editText4"
android:ems="10" />
- <Button
- android:id="@+id/button3"
- style="?android:attr/buttonStyleSmall"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_below="@+id/editText5"
- android:onClick="viewMoreInformation"
- android:text="More Information" />
-
<TextView
- android:id="@+id/textView1"
+ android:id="@+id/label1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText1"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
- android:id="@+id/TextView01"
+ android:id="@+id/label4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText2"
- android:layout_alignLeft="@+id/textView1"
+ android:layout_alignLeft="@+id/label1"
android:text="Room:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
- android:id="@+id/TextView04"
+ android:id="@+id/label5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText3"
- android:layout_alignLeft="@+id/TextView01"
+ android:layout_alignLeft="@+id/label4"
android:text="Cupboard:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
- android:id="@+id/TextView03"
+ android:id="@+id/label3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/editText5"
- android:layout_alignLeft="@+id/TextView04"
+ android:layout_alignLeft="@+id/label5"
android:text="Freezer:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
- android:id="@+id/TextView02"
+ android:id="@+id/label2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/editText5"
- android:layout_alignLeft="@+id/TextView03"
+ android:layout_alignLeft="@+id/label3"
android:text="Shelf:"
android:textAppearance="?android:attr/textAppearanceSmall" />
+ <EditText
+ android:id="@+id/editText1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/button1"
+ android:ems="10" />
+
<Button
- android:id="@+id/button1"
+ android:id="@+id/button2"
+ style="?android:attr/buttonStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBaseline="@+id/button3"
+ android:layout_alignBottom="@+id/button3"
+ android:layout_alignParentLeft="true"
+ android:layout_marginLeft="20dp"
+ android:background="@drawable/update_button"
+ android:onClick="updateInventoryItem"
+ android:text="Update Item" />
+
+ <Button
+ android:id="@+id/button3"
+ style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
+ android:layout_below="@+id/editText5"
+ android:layout_marginTop="34dp"
+ android:onClick="viewMoreInformation"
+ android:text="More Information" />
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignLeft="@+id/button3"
android:layout_alignParentTop="true"
- android:layout_marginRight="10dp"
- android:layout_marginTop="10dp"
android:background="@drawable/green_button"
android:onClick="recognizeQRClick"
android:text="@string/recognize_qr_button" />
+ <Button
+ android:id="@+id/Button01"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/editText1"
+ android:layout_alignRight="@+id/button2"
+ android:background="@drawable/green_button"
+ android:onClick="newItemClick"
+ android:text="New Item" />
+
</RelativeLayout>
\ No newline at end of file
<string name="recognize_qr_button">New Scan</string>
<string name="print_qr_button">Print new QR</string>
<color name="light_green">#9962B1D0</color>
- <color name="light_blue">#FF4282D3</color>
+ <color name="light_blue">#5ED0DB</color>
</resources>
\ No newline at end of file
--- /dev/null
+package com.jaiswallab.lab.inventory;
+
+import android.os.Bundle;
+import java.io.BufferedReader;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import java.util.Calendar;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import com.jaiswallab.lab.inventory.ItemCreationActivity.HttpGetTask;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+import android.widget.EditText;
+
+
+public class ItemCreationActivity extends Activity {
+ EditText text1;
+ EditText text2;
+ EditText text3;
+ Activity alt_this = this;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_add);
+ text1 = (EditText) findViewById(R.id.addInfo1);
+ text2 = (EditText) findViewById(R.id.addInfo2);
+ text3 = (EditText) findViewById(R.id.addInfo3);
+ }
+
+ public void createClick(View view) {
+ String params = "";
+ if((text1.getText() != null) && (!text1.getText().equals(""))) {
+ params = params + "&type=" + text1.getText();
+ }
+ if((text2.getText() != null) && (!text2.getText().equals(""))) {
+ params = params + "&quantity=" + text2.getText();
+ }
+ if((text3.getText() != null) && (!text3.getText().equals(""))) {
+ params = params + "&name=" + text3.getText();
+ }
+
+ Intent itemCreation = new Intent(alt_this, MainActivity.class);
+ startActivity(itemCreation);
+ //String url = "http://jaiswallab.cgrb.oregonstate.edu/inventory/edit_item.php?" + params;
+ //new HttpGetTask().execute(url);
+ }
+
+ public class HttpGetTask extends AsyncTask<String, Integer, String> {
+ String result = "Failed: Invalid QR Code";
+
+ protected String doInBackground(String... urls) {
+ String url = urls[0];
+ BufferedReader inStream = null;
+ try {
+ HttpClient httpClient = new DefaultHttpClient();
+ HttpGet httpRequest = new HttpGet(url);
+ HttpResponse response = httpClient.execute(httpRequest);
+ inStream = new BufferedReader(
+ new InputStreamReader(
+ response.getEntity().getContent()));
+
+ StringBuffer buffer = new StringBuffer("");
+ String line = "";
+ String NL = System.getProperty("line.separator");
+ while ((line = inStream.readLine()) != null) {
+ buffer.append(line + NL);
+ }
+ inStream.close();
+
+ result = buffer.toString();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (inStream != null) {
+ try {
+ inStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+ protected void onPostExecute(String result) {
+ Intent itemCreation = new Intent(alt_this, MainActivity.class);
+ startActivity(itemCreation);
+ }
+ }
+}
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.Scanner;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import org.apache.http.HttpEntity;
+import java.util.Calendar;
import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.util.EncodingUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-
-import com.google.zxing.*;
-import com.google.zxing.qrcode.QRCodeWriter;
-import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
-import com.google.zxing.qrcode.encoder.ByteMatrix;
-import com.google.zxing.qrcode.encoder.Encoder;
import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.IntentSender;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.content.IntentSender.SendIntentException;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.AssetManager;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.content.res.Resources.Theme;
-import android.database.DatabaseErrorHandler;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Color;
-import android.graphics.drawable.Drawable;
-import android.media.MediaScannerConnection;
-import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.UserHandle;
-import android.provider.MediaStore;
-import android.util.Log;
-import android.view.Display;
import android.view.Menu;
import android.view.View;
-import android.webkit.WebView;
import android.widget.EditText;
public class MainActivity extends Activity {
boolean printingNewQR = false;
boolean recognizingQR = false;
private String contents = "";
- private boolean scanSuccess;
private String code = "";
+ private boolean scanSuccess;
private EditText text1;
private EditText text2;
private EditText text3;
public void recognizeQRClick(View view) throws CloneNotSupportedException {
printingNewQR = false;
recognizingQR = true;
+ text1.setText("");
+ text2.setText("");
+ text3.setText("");
+ text4.setText("");
+ text5.setText("");
IntentIntegrator intentIntegrator = new IntentIntegrator(this);
intentIntegrator.initiateScan();
}
}
+ public void newItemClick(View view) {
+ Intent itemCreation = new Intent(MainActivity.this, ItemCreationActivity.class);
+ startActivity(itemCreation);
+ }
+
public void updateInventoryItem(View view) {
if(scanSuccess) {
String params = "";
case IntentIntegrator.REQUEST_CODE:
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
- String contents = scanResult.getContents();
+ contents = scanResult.getContents();
if(recognizingQR){
scanSuccess = false;
recognizingQR = false;
//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) {
- httpGet(id);
+ httpGet(id);
return;
}
-
- public String savePhoto(Bitmap bmp) throws Exception {
- File root = android.os.Environment.getExternalStorageDirectory();
- File dir = new File (root.getAbsolutePath() + "/Pictures");
-
- 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(dir, date.toString() + ".jpg");
- if(imageFileName!=null) text4.setText("file seems to be created");
- try {
- out = new FileOutputStream(imageFileName);
- 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) {
return String.valueOf(val);
private class HttpGetTask extends AsyncTask<String, Integer, String> {
String result = "Failed: Invalid QR Code";
-
+
protected String doInBackground(String... urls) {
String url = urls[0];
BufferedReader inStream = null;