Browse Source

python code configured to the new database

pull/1/head
Yiğit Çolakoğlu 7 years ago
parent
commit
30f79db3e4
10 changed files with 244 additions and 147 deletions
  1. +115
    -36
      Barcode_Reader_Python/.idea/workspace.xml
  2. +8
    -19
      Barcode_Reader_Python/database_read.py
  3. +13
    -2
      FoodCloud/app/src/main/java/gq/yigit/foodcloud/GetInfo.java
  4. +2
    -39
      FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java
  5. +9
    -2
      FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java
  6. +20
    -20
      FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java
  7. +9
    -3
      FoodCloud/app/src/main/res/layout/activity_learn_more.xml
  8. +9
    -0
      database/communication/.idea/php.xml
  9. +52
    -24
      database/communication/.idea/workspace.xml
  10. +7
    -2
      database/communication/comm.php

+ 115
- 36
Barcode_Reader_Python/.idea/workspace.xml View File

@ -2,19 +2,13 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7b5ef56c-2d3e-44d9-be69-b414f166f99b" name="Default" comment="">
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../FoodCloud/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPcomm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database_append.py" beforeDir="false" afterPath="$PROJECT_DIR$/database_append.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/.idea/caches/build_file_checksums.ser" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/.idea/caches/build_file_checksums.ser" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database_read.py" beforeDir="false" afterPath="$PROJECT_DIR$/database_read.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/GetInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/GetInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_main.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_main.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_product_info.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_product_info.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_learn_more.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../FoodCloud/app/src/main/res/layout/activity_learn_more.xml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
@ -32,16 +26,39 @@
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$sort_date.coverage" NAME="sort_date Coverage Results" MODIFIED="1529590504238" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$main.coverage" NAME="main Coverage Results" MODIFIED="1529672838644" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$Unnamed.coverage" NAME="raspberry_live Coverage Results" MODIFIED="1529543452123" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_actions.coverage" NAME="database_actions Coverage Results" MODIFIED="1529692830827" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_append.coverage" NAME="database_append Coverage Results" MODIFIED="1529768832056" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_append.coverage" NAME="database_append Coverage Results" MODIFIED="1529835022690" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/Barcode_Reader_Python$database_actions.coverage" NAME="database_actions Coverage Results" MODIFIED="1529835364313" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="database_append.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/database_append.py">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="database_read.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/database_read.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="51" column="70" lean-forward="true" selection-start-line="51" selection-start-column="70" selection-end-line="51" selection-end-column="70" />
<state relative-caret-position="51">
<caret line="3" column="23" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="generate_moves.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/generate_moves.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file leaf-file-name="main.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-600">
<caret line="16" column="37" selection-start-line="16" selection-start-column="37" selection-end-line="16" selection-end-column="37" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="sort_date.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/sort_date.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="47" lean-forward="true" selection-start-line="5" selection-start-column="47" selection-end-line="5" selection-end-column="47" />
</state>
</provider>
</entry>
@ -84,9 +101,9 @@
<option value="$PROJECT_DIR$/move.py" />
<option value="$PROJECT_DIR$/database_actions.py" />
<option value="$PROJECT_DIR$/main.py" />
<option value="$PROJECT_DIR$/database_read.py" />
<option value="$PROJECT_DIR$/Barcode_Reader_Python/database_append.py" />
<option value="$PROJECT_DIR$/database_append.py" />
<option value="$PROJECT_DIR$/database_read.py" />
</list>
</option>
</component>
@ -126,12 +143,12 @@
</panes>
</component>
<component name="PropertiesComponent">
<property name="SearchEverywhereHistoryKey" value="keymap&#9;ACTION&#9;ChangeKeymap" />
<property name="SearchEverywhereHistoryKey" value="plugin&#9;null&#9;null&#10;keymap&#9;ACTION&#9;ChangeKeymap" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -145,7 +162,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Python.database_append">
<component name="RunManager" selected="Python.database_actions">
<configuration name="RUN" type="PythonConfigurationType" factoryName="Python">
<module name="Barcode_Reader_Python" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -290,9 +307,9 @@
</list>
<recent_temporary>
<list>
<item itemvalue="Python.database_actions" />
<item itemvalue="Python.database_append" />
<item itemvalue="Python.pydevd" />
<item itemvalue="Python.database_actions" />
<item itemvalue="Python.main" />
<item itemvalue="Python.move" />
</list>
@ -336,7 +353,7 @@
<window_info anchor="bottom" id="Python Console" order="7" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49924126" weight="0.28426966" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.19925214" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2056624" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" />
<window_info anchor="right" id="SciView" order="3" weight="0.32928678" />
@ -356,24 +373,24 @@
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.24962063" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.26783004" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info active="true" anchor="bottom" id="Run" order="2" sideWeight="0.49924126" visible="true" weight="0.27056962" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32911393" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39873418" />
<window_info anchor="right" id="Database" order="4" />
<window_info anchor="bottom" id="Terminal" order="11" />
<window_info anchor="bottom" id="Event Log" order="12" sideWeight="0.5007587" side_tool="true" weight="0.4638365" />
<window_info anchor="bottom" id="Database Changes" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="right" id="SciView" order="3" weight="0.32928678" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32911393" />
<window_info anchor="bottom" id="Python Console" order="10" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info id="Favorites" order="2" side_tool="true" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -394,6 +411,41 @@
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" selection-start-line="14" selection-end-line="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_read.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_read.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="765">
<caret line="51" column="70" lean-forward="true" selection-start-line="51" selection-start-column="70" selection-end-line="51" selection-end-column="70" />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/helpers/pydev/pydevd.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16275">
@ -459,7 +511,6 @@
<entry file="file://$PROJECT_DIR$/barcodes.csv" />
<entry file="file://$PROJECT_DIR$/raspberry_zbar.py" />
<entry file="file://$PROJECT_DIR$/zbar_live.py" />
<entry file="file://$PROJECT_DIR$/sort_date.py" />
<entry file="file:///usr/lib/python2.7/dist-packages/serial/serialposix.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="214">
@ -475,14 +526,42 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/generate_moves.py" />
<entry file="file://$PROJECT_DIR$/main.py" />
<entry file="file://$PROJECT_DIR$/database_read.py" />
<entry file="file://$PROJECT_DIR$/Barcode_Reader_Python/database_append.py" />
<entry file="file:///usr/lib/python2.7/dist-packages/pluggy/__init__.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-9">
<caret line="632" column="47" selection-start-line="632" selection-start-column="47" selection-end-line="632" selection-end-column="47" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_append.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="340">
<caret line="51" column="70" lean-forward="true" selection-start-line="51" selection-start-column="70" selection-end-line="51" selection-end-column="70" />
<state relative-caret-position="210">
<caret line="14" selection-start-line="14" selection-end-line="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/database_read.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="51">
<caret line="3" column="23" selection-start-line="3" selection-start-column="23" selection-end-line="3" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/generate_moves.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-600">
<caret line="16" column="37" selection-start-line="16" selection-start-column="37" selection-end-line="16" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/sort_date.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="47" lean-forward="true" selection-start-line="5" selection-start-column="47" selection-end-line="5" selection-end-column="47" />
</state>
</provider>
</entry>


+ 8
- 19
Barcode_Reader_Python/database_read.py View File

@ -1,22 +1,11 @@
import pyrebase
import urllib2, urllib
config = {
"apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
"authDomain": "foodcloud-f6eb1.firebaseapp.com",
"databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
"storageBucket": "foodcloud-f6eb1.appspot.com"
}
def getData(id):
dbdata = [('id', id), ('value', 'Products'),('content','BBD')] # The first is the var name the second is the value
dbdata = urllib.urlencode(dbdata)
path = 'http://192.168.1.21/database/communication/comm.php' # the url you want to POST to
req = urllib2.Request(path, dbdata)
req.add_header("Content-type", "application/x-www-form-urlencoded")
page = urllib2.urlopen(req).read()
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro2018')
db = firebase.database()
database_content = db.child("Products").get().val()
def getDate(product):
return str((database_content[int(product)]['BBD']))

+ 13
- 2
FoodCloud/app/src/main/java/gq/yigit/foodcloud/GetInfo.java View File

@ -1,16 +1,27 @@
package gq.yigit.foodcloud;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
public class GetInfo extends AppCompatActivity {
public class GetInfo extends AppCompatActivity implements View.OnClickListener {
public Button back_to_main;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_get_info);
WebView myWebView = (WebView) findViewById(R.id.info);
myWebView.loadUrl("https://www.welthungerhilfe.org/our-work/approaches/food-security-standard/");
back_to_main = (Button) findViewById(R.id.back_to_main);
back_to_main.setOnClickListener(this);
}
public void onClick(View v){
Intent i = new Intent(GetInfo.this, MainActivity.class);
startActivity(i);
}
}

+ 2
- 39
FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java View File

@ -9,13 +9,6 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@ -36,9 +29,6 @@ public class LearnMore extends AppCompatActivity implements View.OnClickListener
public Button back_to_main;
public Map<String, Object> someMap;
public String prod_loc;
Map<String, String> map = new HashMap<String, String>();
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference();
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -46,7 +36,6 @@ public class LearnMore extends AppCompatActivity implements View.OnClickListener
Bundle extras = getIntent().getExtras();
if (extras != null) {
prod_loc_more = extras.getString("key");
//The key argument here must match that used in the other activity
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_learn_more);
@ -66,35 +55,9 @@ public class LearnMore extends AppCompatActivity implements View.OnClickListener
}
public void onClick(View v){
if(v.getId() == R.id.go_back_to_main){
if(v.getId() == R.id.back_to_main){
Intent i = new Intent(LearnMore.this, MainActivity.class);
startActivity(i);
}
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
prod_loc = extras.getString("key");
//The key argument here must match that used in the other activity
}
// This method is called once with the initial value and again
// whenever data at this location is updated.
someMap = (Map<String, Object>) dataSnapshot.getValue();
ArrayList al1 = new ArrayList();
al1 = (ArrayList) someMap.get("Production");
al1.remove(0);
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
}
}
}

+ 9
- 2
FoodCloud/app/src/main/java/gq/yigit/foodcloud/PHPComm.java View File

@ -20,6 +20,7 @@ import java.net.URLEncoder;
public class PHPComm extends AsyncTask<String,Void,String> {
private static final String TAG = "MainActivity";
public static String decide;
Context context;
AlertDialog alertDialog;
PHPComm (Context ctx) {
@ -29,7 +30,7 @@ public class PHPComm extends AsyncTask<String,Void,String> {
@Override
protected String doInBackground(String... params) {
String type = params[0];
String login_url = "http://192.168.1.21/database/communication/comm.php";
String login_url = "http://192.168.43.125/database/communication/comm.php";
if(type.equals("get")) {
try {
Log.d(TAG,"received get");
@ -61,8 +62,10 @@ public class PHPComm extends AsyncTask<String,Void,String> {
return result;
} catch (MalformedURLException e) {
e.printStackTrace();
Log.d(TAG,"MalformedURL");
} catch (IOException e) {
e.printStackTrace();
Log.d(TAG,"IOExcept");
}
}
return null;
@ -78,7 +81,11 @@ public class PHPComm extends AsyncTask<String,Void,String> {
protected void onPostExecute(String result) {
alertDialog.setMessage(result);
Log.d(TAG, "AlertBoxSet " + result);
ProductInfo.continueApp(result);
Log.d(TAG,decide);
if(decide == "Prod") {
ProductInfo.continueApp(result);
}
}
@Override


+ 20
- 20
FoodCloud/app/src/main/java/gq/yigit/foodcloud/ProductInfo.java View File

@ -14,22 +14,13 @@ END PRAYER
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.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -78,12 +69,14 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
Cooked = (TextView) findViewById(R.id.cooked);
BBD = (TextView) findViewById(R.id.BBD);
Processed = (TextView) findViewById(R.id.Process);
Nutrients = (TextView) findViewById(R.id.nutrients);
Bundle extras = getIntent().getExtras();
if (extras != null) {
prod_loc = extras.getString("key");
}
PHPComm comm = new PHPComm(this);
PHPComm.decide = "Prod";
comm.execute("get", prod_loc, "Products");
@ -123,6 +116,9 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
Log.d(TAG,"Received null data!");
}
Log.d(TAG,allergens);
if(processed.length() < 4){
Processed.setText("None");
}
if(allergens.length() < 7) {
Allergens.setText("None");
}else{
@ -138,28 +134,32 @@ public class ProductInfo extends AppCompatActivity implements OnClickListener {
}
Allergens.setText(allergens_print);
}
/*
Nutrients = (TextView) findViewById(R.id.nutrients);
nutrients_print = "";
if(nutrients.isEmpty()) {
Nutrients.setText("Nutrients : None");
if(nutrients.length() < 7) {
Nutrients.setText("None");
}else{
for(int i = 0; i < nutrients.size();i++) {
nutrients_print = nutrients_print + nutrients.get(i);
if(i != nutrients.size() -1){
for(int i = 0; i < nutrients_array.length();i++) {
try {
nutrients_print = nutrients_print + nutrients_array.get(i);
}catch (JSONException e){
Log.d(TAG,"An error occured with json");
}
if(i != nutrients_array.length()-1){
nutrients_print = nutrients_print + " , ";
}
}
Nutrients.setText("Nutrients : " + nutrients_print);
Nutrients.setText(nutrients_print);
}
*/
try {
Cal.setText(cal);
allergens_print = "";
Cooked.setText("Cooked : " + cooked);
Cooked.setText(cooked);
BBD.setText(bbd);
Processed.setText("Process : " + processed);
Processed.setText(processed);
Name.setText(name);
}catch(NullPointerException e){


+ 9
- 3
FoodCloud/app/src/main/res/layout/activity_learn_more.xml View File

@ -215,8 +215,10 @@
android:layout_width="160dp"
android:layout_height="36dp"
android:layout_marginEnd="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="120dp"
android:background="@drawable/buttonshape"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
@ -225,7 +227,11 @@
android:text="@string/back"
android:textColor="#000000"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="415dp" />
app:layout_constraintBottom_toBottomOf="@+id/imageView16"
app:layout_constraintEnd_toEndOf="@+id/trans2"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/packaging_cond"
app:layout_constraintTop_toBottomOf="@+id/trans2"
app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>

+ 9
- 0
database/communication/.idea/php.xml View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpIncludePathManager">
<include_path>
<path value="/etc/php/7.2/apache2" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
</project>

+ 52
- 24
database/communication/.idea/workspace.xml View File

@ -10,7 +10,7 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="conn.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/conn.php">
<provider selected="true" editor-type-id="text-editor">
@ -23,8 +23,8 @@
<file leaf-file-name="comm.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/comm.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162">
<caret line="14" column="13" selection-start-line="14" selection-start-column="13" selection-end-line="14" selection-end-column="13" />
<state relative-caret-position="133">
<caret line="12" column="8" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" />
</state>
</provider>
</entry>
@ -65,9 +65,14 @@
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
<component name="ProjectFrameBounds">
<option name="x" value="821" />
<option name="y" value="342" />
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="PHP 7.2">
<include_path>
<path value="/etc/php/7.2/apache2" />
</include_path>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="257" />
<option name="y" value="28" />
<option name="width" value="1390" />
<option name="height" value="988" />
</component>
@ -76,6 +81,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -87,16 +93,15 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="last_opened_file_path" value="/etc/php/7.2/apache2" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="settings.editor.selected.configurable" value="preferences.editor" />
<property name="settings.editor.selected.configurable" value="reference.settings.ide.settings.web.browsers" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -121,32 +126,34 @@
<option name="presentableId" value="Default" />
<updated>1529763756323</updated>
<workItem from="1529763757470" duration="7051000" />
<workItem from="1529831693990" duration="2459000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="7051000" />
<option name="totallyTimeSpent" value="9510000" />
</component>
<component name="ToolWindowManager">
<frame x="821" y="342" width="1390" height="988" extended-state="0" />
<frame x="0" y="24" width="1920" height="1030" extended-state="6" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25179857" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="right" id="Database" />
<window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
<window_info anchor="bottom" id="PHP-CGI Server" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="7" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.18229167" />
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
<window_info anchor="right" id="Database" order="3" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info id="Favorites" side_tool="true" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Message" order="0" />
</layout>
@ -159,7 +166,7 @@
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="2" />
<option name="time" value="4" />
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
@ -179,10 +186,31 @@
</entry>
<entry file="file://$PROJECT_DIR$/comm.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="162">
<state relative-caret-position="135">
<caret line="14" column="13" selection-start-line="14" selection-start-column="13" selection-end-line="14" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/conn.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="2" selection-start-line="12" selection-start-column="2" selection-end-line="12" selection-end-column="2" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/format.html">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret selection-end-line="9" selection-end-column="7" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/comm.php">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="133">
<caret line="12" column="8" selection-start-line="12" selection-start-column="8" selection-end-line="12" selection-end-column="8" />
</state>
</provider>
</entry>
</component>
</project>

+ 7
- 2
database/communication/comm.php View File

@ -9,10 +9,15 @@
$id = $_POST["id"];
$value = $_POST["value"];
$content = $_POST["content"];
$file_loc = "../content/" . $value . "/" . $id . ".json";
$myfile = fopen($file_loc, "r") or die("Unable to open file!");
$content = fread($myfile,filesize($file_loc));
echo $content;
$send = fread($myfile,filesize($file_loc));
if(isset($_POST["content"])){
$send = json_decode($send,true);
$send = $send[$content];
}
echo $send;
?>


Loading…
Cancel
Save