diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 349bde8..67af3ba 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -27,7 +27,7 @@
-
+
@@ -94,7 +94,7 @@
-
+
@@ -128,7 +128,7 @@
-
+
@@ -458,7 +458,7 @@
-
+
diff --git a/Barcode_Reader_Python/.idea/workspace.xml b/Barcode_Reader_Python/.idea/workspace.xml
new file mode 100644
index 0000000..ab95389
--- /dev/null
+++ b/Barcode_Reader_Python/.idea/workspace.xml
@@ -0,0 +1,490 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ cam.read
+ dates_orig
+ dates
+ shelf_new
+ database_
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ DEFINITION_ORDER
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1529543214918
+
+
+ 1529543214918
+
+
+ 1529689633554
+
+
+
+ 1529689633554
+
+
+ 1529690495712
+
+
+
+ 1529690495712
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Barcode_Reader_Python/database_append.py b/Barcode_Reader_Python/database_append.py
index 0a26aea..8c3c9c1 100644
--- a/Barcode_Reader_Python/database_append.py
+++ b/Barcode_Reader_Python/database_append.py
@@ -1,19 +1,4 @@
-import pyrebase
-
-config = {
- "apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
- "authDomain": "foodcloud-f6eb1.firebaseapp.com",
- "databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
- "storageBucket": "foodcloud-f6eb1.appspot.com"
-}
-
-firebase = pyrebase.initialize_app(config)
-
-auth = firebase.auth()
-
-user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro2018')
-
-db = firebase.database()
+import json
data_format_prod = {
'Prod_Name': None, 'BBD': None, 'Nutrients': [], 'Calories': 0, 'Allergens': [],
@@ -76,7 +61,12 @@ Products = [data_1_prod, data_2_prod]
Processes = [data_1_proc, data_2_proc]
for i in range(len(Products)):
- db.child("Products").child(str(i + 1)).set(Products[i])
+ with open('../database/content/Products/'+str(i+1) + '.json', 'w') as outfile:
+ json.dump(Products[i], outfile)
+ outfile.close()
+
for i in range(len(Processes)):
- db.child("Processes").child(str(i + 1)).set(Processes[i])
+ with open('../database/content/Processes/'+str(i+1) + '.json', 'w') as outfile:
+ json.dump(Processes[i], outfile)
+ outfile.close()
\ No newline at end of file
diff --git a/FoodCloud/.idea/caches/build_file_checksums.ser b/FoodCloud/.idea/caches/build_file_checksums.ser
index e6e0ba6..dbf289a 100644
Binary files a/FoodCloud/.idea/caches/build_file_checksums.ser and b/FoodCloud/.idea/caches/build_file_checksums.ser differ
diff --git a/FoodCloud/.idea/misc.xml b/FoodCloud/.idea/misc.xml
index c0f68ed..99202cc 100644
--- a/FoodCloud/.idea/misc.xml
+++ b/FoodCloud/.idea/misc.xml
@@ -25,7 +25,7 @@
-
+
diff --git a/FoodCloud/.idea/vcs.xml b/FoodCloud/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/FoodCloud/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/FoodCloud/app/build.gradle b/FoodCloud/app/build.gradle
index 930d108..1c94d1b 100644
--- a/FoodCloud/app/build.gradle
+++ b/FoodCloud/app/build.gradle
@@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 27
+ buildToolsVersion "27.0.3"
defaultConfig {
applicationId "gq.yigit.foodcloud"
minSdkVersion 24
@@ -19,6 +20,7 @@ android {
}
dependencies {
+ api 'com.google.http-client:google-http-client-android:1.22.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
@@ -30,5 +32,6 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.google.firebase:firebase-core:16.0.0'
compileOnly 'com.google.android.wearable:wearable:2.3.0'
+ implementation files('libs/GenAsync.jar')
}
apply plugin: 'com.google.gms.google-services'
diff --git a/FoodCloud/app/libs/GenAsync.jar b/FoodCloud/app/libs/GenAsync.jar
new file mode 100644
index 0000000..26ec4a9
Binary files /dev/null and b/FoodCloud/app/libs/GenAsync.jar differ
diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java
index 2719449..541c449 100644
--- a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java
+++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java
@@ -42,6 +42,7 @@ public class LearnMore extends AppCompatActivity implements View.OnClickListener
@Override
protected void onCreate(Bundle savedInstanceState) {
+
Bundle extras = getIntent().getExtras();
if (extras != null) {
prod_loc_more = extras.getString("key");
diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/MainActivity.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/MainActivity.java
index 5e43c12..ddf1848 100644
--- a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/MainActivity.java
+++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/MainActivity.java
@@ -2,17 +2,21 @@ package gq.yigit.foodcloud;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
-
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import android.content.Intent;
+import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
-public class MainActivity extends AppCompatActivity implements OnClickListener {
+import java.util.HashMap;
+
+
+public class MainActivity extends AppCompatActivity implements OnClickListener{
+ private static final String TAG = "MainActivity";
int cnt = 0;
private Button scanBtn;
private Button infoBtn;
@@ -28,6 +32,7 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
infoBtn = (Button)findViewById(R.id.info_button);
infoBtn.setOnClickListener(this);
+
}
public void onClick(View v){
@@ -57,5 +62,6 @@ public class MainActivity extends AppCompatActivity implements OnClickListener {
"No scan data received!", Toast.LENGTH_SHORT);
toast.show();
}
+
}
}
diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java
new file mode 100644
index 0000000..8bd4da9
--- /dev/null
+++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java
@@ -0,0 +1,93 @@
+package gq.yigit.foodcloud;
+
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+
+/**
+ * Created by ProgrammingKnowledge on 1/5/2016.
+ */
+public class PHPComm extends AsyncTask {
+ private static final String TAG = "MainActivity";
+ Context context;
+ AlertDialog alertDialog;
+ PHPComm (Context ctx) {
+ context = ctx;
+ }
+ static public String return_json;
+ @Override
+ protected String doInBackground(String... params) {
+ String type = params[0];
+ String login_url = "http://192.168.1.21/database/communication/comm.php";
+ if(type.equals("get")) {
+ try {
+ String id = params[1];
+ String value = params[2];
+ URL url = new URL(login_url);
+ HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
+ httpURLConnection.setRequestMethod("POST");
+ httpURLConnection.setDoOutput(true);
+ httpURLConnection.setDoInput(true);
+ OutputStream outputStream = httpURLConnection.getOutputStream();
+ BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
+ String post_data = URLEncoder.encode("id","UTF-8")+"="+URLEncoder.encode(id,"UTF-8")+"&"
+ +URLEncoder.encode("value","UTF-8")+"="+URLEncoder.encode(value,"UTF-8");
+ bufferedWriter.write(post_data);
+ bufferedWriter.flush();
+ bufferedWriter.close();
+ outputStream.close();
+ InputStream inputStream = httpURLConnection.getInputStream();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
+ String result="";
+ String line="";
+ while((line = bufferedReader.readLine())!= null) {
+ result += line;
+ }
+ bufferedReader.close();
+ inputStream.close();
+ httpURLConnection.disconnect();
+ return result;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ alertDialog = new AlertDialog.Builder(context).create();
+ alertDialog.setTitle("Login Status");
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ alertDialog.setMessage(result);
+ Log.d(TAG, "AlertBoxSet" + result);
+ setJson(result);
+ }
+
+ @Override
+ protected void onProgressUpdate(Void... values) {
+ super.onProgressUpdate(values);
+ }
+ static private void setJson(String json){
+ return_json = json;
+ }
+}
diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java
index 235faf0..3432a4a 100644
--- a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java
+++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java
@@ -1,17 +1,24 @@
package gq.yigit.foodcloud;
import android.content.Intent;
+import android.nfc.Tag;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Button;
+
+import com.google.api.client.json.JsonObjectParser;
import com.google.firebase.database.*;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import android.view.View.OnClickListener;
+import android.widget.Toast;
+
+import org.json.JSONException;
+import org.json.JSONObject;
public class ProductInfo extends AppCompatActivity implements OnClickListener {
private static final String TAG = "MainActivity";
@@ -26,14 +33,15 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
private String name;
private String cal;
private String cooked;
- private ArrayList nutrients;
+ private String nutrients;
+ private ArrayList nutrients_array;
private String bbd;
private String processed;
private String problematic;
- private ArrayList allergens;
- public ArrayList Prods;
- public Map someMap;
- public HashMap Prod;
+ private String allergens;
+ private ArrayList allergens_array;
+ public String json_str;
+ public JSONObject Prod;
private Button scanBtn;
private Button jrnyBtn;
public String prod_loc;
@@ -71,9 +79,8 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
scanBtn.setOnClickListener(this);
jrnyBtn = (Button)findViewById(R.id.journey);
jrnyBtn.setOnClickListener(this);
- myRef.addValueEventListener(new ValueEventListener() {
- @Override
- public void onDataChange(DataSnapshot dataSnapshot) {
+
+
Bundle extras = getIntent().getExtras();
if (extras != null) {
prod_loc = extras.getString("key");
@@ -81,26 +88,20 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
}
// This method is called once with the initial value and again
// whenever data at this location is updated.
- someMap = (Map) dataSnapshot.getValue();
- ArrayList al1 = new ArrayList();
- al1 = (ArrayList) someMap.get("Products");
- al1.remove(0);
- Prods = al1;
- Prod = (HashMap)al1.get((Integer.parseInt(prod_loc))-1);
- Log.d(TAG,"Value is : " + al1.get((Integer.parseInt(prod_loc))-1));
- Log.d(TAG,Prod.get("Calories").getClass().toString());
- name = Prod.get("Prod_Name").toString();
- cal = Prod.get("Calories").toString();
- cooked = Prod.get("Cooked").toString();
- nutrients = (ArrayList)Prod.get("Nutrients");
- bbd = Prod.get("BBD").toString();
- processed = Prod.get("Process").toString();
- allergens = (ArrayList)Prod.get("Allergens");
- problematic = Prod.get("Problematic").toString();
+ PHPComm comm = new PHPComm(this);
+ comm.execute("get", "1", "Products");
+ try {
+ json_str = PHPComm.return_json;
+ Log.d(TAG,"get json str" + json_str);
+ JSONObject jsonObj = new JSONObject(json_str);
+ }catch (JSONException e) {
+ Log.d(TAG, "An error occured with the json!");
+ }
+ /*
Name = (TextView) findViewById(R.id.name);
- Name.setText("Name : " + name);
+ Name.setText( name);
Cal = (TextView) findViewById(R.id.Calories);
- Cal.setText("Calories : " + cal);
+ Cal.setText(cal);
Allergens = (TextView) findViewById(R.id.allergens);
allergens_print = "";
if(allergens.isEmpty()) {
@@ -127,22 +128,18 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
}
Nutrients.setText("Nutrients : " + nutrients_print);
}
+
Cooked = (TextView) findViewById(R.id.cooked);
Cooked.setText("Cooked : " + cooked);
BBD = (TextView) findViewById(R.id.BBD);
- BBD.setText("BBD : " +bbd);
+ BBD.setText(bbd);
Processed = (TextView) findViewById(R.id.Process);
Processed.setText("Process : " + processed);
-
+ */
}
- @Override
- public void onCancelled(DatabaseError error) {
- // Failed to read value
- Log.w(TAG, "Failed to read value.", error.toException());
- }
- });
+
@@ -152,4 +149,3 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
}
-}
diff --git a/FoodCloud/app/src/main/res/layout/activity_main.xml b/FoodCloud/app/src/main/res/layout/activity_main.xml
index a461aeb..21c51c3 100644
--- a/FoodCloud/app/src/main/res/layout/activity_main.xml
+++ b/FoodCloud/app/src/main/res/layout/activity_main.xml
@@ -14,7 +14,7 @@
android:layout_width="231dp"
android:layout_height="89dp"
- android:layout_marginBottom="24dp"
+ android:layout_marginBottom="60dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/buttonshape"
@@ -28,6 +28,7 @@
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="@+id/imageView"
+ app:layout_constraintHorizontal_bias="0.485"
app:layout_constraintStart_toStartOf="@+id/imageView" />