@ -0,0 +1,60 @@ | |||
#include <Wire.h> | |||
#define SLAVE_ADDRESS 0x04 | |||
int number = 0; | |||
int state = 0; | |||
void setup() { | |||
pinMode(13, OUTPUT); | |||
Serial.begin(9600); // start serial for output | |||
// initialize i2c as slave | |||
Wire.begin(SLAVE_ADDRESS); | |||
// define callbacks for i2c communication | |||
Wire.onReceive(receiveData); | |||
Wire.onRequest(sendData); | |||
Serial.println("Ready!"); | |||
} | |||
void loop() { | |||
delay(100); | |||
} | |||
// callback for received data | |||
void receiveData(int byteCount) { | |||
while (Wire.available()) { | |||
number = Wire.read(); | |||
Serial.println(number); | |||
if (number == 1) { | |||
if (state == 0) { | |||
Serial.println("LED ON"); | |||
state = 1; | |||
} | |||
else { | |||
Serial.println("LED OFF"); | |||
state = 0; | |||
} | |||
} | |||
} | |||
} | |||
// callback for sending data | |||
void sendData() { | |||
Wire.write(number); | |||
Serial.println("Sending..."); | |||
Wire.begin(0x08); | |||
delay(100); | |||
} |
@ -0,0 +1 @@ | |||
2018-06-15 23:18:13.020993,2 |
@ -0,0 +1,35 @@ | |||
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', 'Ygtclksbl1') | |||
db = firebase.database() | |||
data_format_prod = {'Prod_Name':None, 'BBD':None,'Nutrients':[],'Calories':0,'Allergens':[],'Problematic':False,'Process':None, 'ED':None} | |||
data_format_proc = {'Harvested':{'Date':'','Location':'','Product':''},'Transport1':{'Duration':0,'Moved to,from':'-','Condition':True,'Stopped':False},'Process':{'Location':'','Processes':''},'Transport2':{'Duration':0,'Moved to,from':'-','Condition':0,'Stopped':False},'Packaging':{'Location':'','Material':'','Cancerogen':True}} | |||
data_2_prod = {'Prod_Name':"Chocolate", 'BBD':"28.01.2019",'Nutrients':['Lactose','Glucose','Cocoa'],'Calories':180,'Cooked':False,'Allergens':[""],'Problematic':False,'Process':''} | |||
data_1_prod = {'Prod_Name':"Milk", 'BBD':"24.08.2018",'Nutrients':['Protein','Fat','Lactose','Glucose'],'Calories':120,'Cooked':False,'Allergens':['Lactose'],'Problematic':False,'Process':'Pastorized'} | |||
data_2_proc = {'Harvested':{'Date':'24.04.2018','Location':'','Product':''},'Transport1':{'Duration':0,'Moved to,from':'-','Condition':0,'Stopped':False},'Process':{'Location':'','Processes':''},'Transport1':{'Duration':0,'Moved to,from':'-','Condition':0,'Stopped':False},'Packaging':{'Location':'','Material':'','Cancerogen':''}} | |||
database_content = db.child("Products").get().val() | |||
def getDate(product): | |||
return str((database_content[int(product)]['BBD'])) | |||
#db.child("Products").child("1").set(data_1_prod) | |||
#db.child("Products").child("2").set(data_2_prod) | |||
@ -0,0 +1,45 @@ | |||
from pyzbar import pyzbar | |||
import argparse | |||
import cv2 | |||
import time | |||
import database_actions | |||
dates = [] | |||
reps = 0 | |||
barcodes = None | |||
prevcode = None | |||
exp_date = [] | |||
cam = cv2.VideoCapture(0) | |||
while(reps<2): | |||
while(barcodes == None or barcodes == []): | |||
ret , image = cam.read() | |||
barcodes = pyzbar.decode(image) | |||
cv2.imshow("Image", image) | |||
if cv2.waitKey(1) & 0xFF == ord('q'): | |||
break | |||
for barcode in barcodes: | |||
(x, y, w, h) = barcode.rect | |||
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2) | |||
barcodeData = barcode.data.decode("utf-8") | |||
barcodeType = barcode.type | |||
if(barcodeData != prevcode): | |||
text = "{} ({})".format(barcodeData, barcodeType) | |||
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, | |||
0.5, (0, 0, 255), 2) | |||
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData)) | |||
dates.append(database_actions.getDate(barcodeData)) | |||
exp_date.append(int(barcodeData)) | |||
reps += 1 | |||
prevcode = barcodeData | |||
barcodes = None | |||
cv2.imshow("Image", image) | |||
if cv2.waitKey(1) & 0xFF == ord('q'): | |||
break | |||
print dates | |||
@ -0,0 +1,71 @@ | |||
# import the necessary packages | |||
from imutils.video import VideoStream | |||
from pyzbar import pyzbar | |||
import argparse | |||
import datetime | |||
import imutils | |||
import time | |||
import cv2 | |||
# construct the argument parser and parse the arguments | |||
ap = argparse.ArgumentParser() | |||
ap.add_argument("-o", "--output", type=str, default="barcodes.csv", | |||
help="path to output CSV file containing barcodes") | |||
args = vars(ap.parse_args()) | |||
# initialize the video stream and allow the camera sensor to warm up | |||
print("[INFO] starting video stream...") | |||
# vs = VideoStream(src=0).start() | |||
vs = VideoStream().start() | |||
time.sleep(2.0) | |||
# open the output CSV file for writing and initialize the set of | |||
# barcodes found thus far | |||
csv = open(args["output"], "w") | |||
found = set() | |||
# loop over the frames from the video stream | |||
while True: | |||
# grab the frame from the threaded video stream and resize it to | |||
# have a maximum width of 400 pixels | |||
frame = vs.read() | |||
frame = imutils.resize(frame, width=400) | |||
# find the barcodes in the frame and decode each of the barcodes | |||
barcodes = pyzbar.decode(frame) | |||
# loop over the detected barcodes | |||
for barcode in barcodes: | |||
# extract the bounding box location of the barcode and draw | |||
# the bounding box surrounding the barcode on the image | |||
(x, y, w, h) = barcode.rect | |||
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2) | |||
# the barcode data is a bytes object so if we want to draw it | |||
# on our output image we need to convert it to a string first | |||
barcodeData = barcode.data.decode("utf-8") | |||
barcodeType = barcode.type | |||
# draw the barcode data and barcode type on the image | |||
text = "{} ({})".format(barcodeData, barcodeType) | |||
cv2.putText(frame, text, (x, y - 10), | |||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2) | |||
# if the barcode text is currently not in our CSV file, write | |||
# the timestamp + barcode to disk and update the set | |||
if barcodeData not in found: | |||
csv.write("{},{}\n".format(datetime.datetime.now(), | |||
barcodeData)) | |||
csv.flush() | |||
found.add(barcodeData) | |||
# show the output frame | |||
cv2.imshow("Barcode Scanner", frame) | |||
key = cv2.waitKey(1) & 0xFF | |||
# if the `q` key was pressed, break from the loop | |||
if key == ord("q"): | |||
break | |||
# close the output CSV file do a bit of cleanup | |||
print("[INFO] cleaning up...") | |||
csv.close() | |||
cv2.destroyAllWindows() | |||
vs.stop() |
@ -0,0 +1,106 @@ | |||
import sort_date | |||
exp_date , dates_orig = sort_date.calcDate() | |||
shelf_back = exp_date[:] | |||
try: | |||
expired = exp_date.count(-1) | |||
for i in range(expired): | |||
shelf_back.pop(shelf_back.index(-1)) | |||
shelf_new = sorted(shelf_back) | |||
for i in range(expired): | |||
shelf_new.append(-1) | |||
except ValueError: | |||
print('') | |||
exp_date.append(None) | |||
shelf_new.append(None) | |||
repeats = 0 | |||
correct_locs = [] | |||
temp = None | |||
moved_item = None | |||
moved_item_loc = None | |||
print "\n\n\n//////////////////////////////////////////////////////////////////////////////" | |||
print(" {} ".format(exp_date)) | |||
print(" {} ".format(shelf_new)) | |||
print "/////////////////////////////////////////////////////////////////////////////\n\n\n" | |||
def backArray(myArray): | |||
global shelf_back | |||
shelf_back = [] | |||
for i in range(len(myArray)): | |||
shelf_back.append(myArray[i]) | |||
def eqArray(myArray): | |||
global exp_date | |||
exp_date = [] | |||
for i in range(len(myArray)): | |||
exp_date.append(myArray[i]) | |||
def place(): | |||
global exp_date | |||
global shelf_new | |||
global repeats | |||
global shelf_back | |||
repeats += 1 | |||
backArray(exp_date) | |||
if (exp_date[len(exp_date)-1] != None): | |||
empty_loc = exp_date.index(None) | |||
moved_item_loc = exp_date.index(shelf_new[empty_loc]) | |||
reps=0 | |||
while True: | |||
reps += 1 | |||
if(moved_item_loc in correct_locs): | |||
exp_date.pop(moved_item_loc) | |||
moved_item_loc = exp_date.index(shelf_new[empty_loc]) + reps | |||
continue | |||
break | |||
eqArray(shelf_back) | |||
moved_item = exp_date[moved_item_loc] | |||
if(exp_date[moved_item_loc] != shelf_new[moved_item_loc]): | |||
exp_date[moved_item_loc] = None | |||
exp_date[empty_loc] = moved_item | |||
correct_locs.append(empty_loc) | |||
print " Moved item {0} to location {1}. Location {2} is now empty!".format(moved_item,empty_loc + 1, moved_item_loc + 1) | |||
print "============================================================================" | |||
else: | |||
print " Leaving item {0} in location {1}. Location {2} is still empty!".format(moved_item, moved_item_loc + 1,empty_loc + 1) | |||
print "============================================================================" | |||
correct_locs.append(moved_item_loc) | |||
place() | |||
else: | |||
return | |||
while True: | |||
if(repeats < len(exp_date)): | |||
for i in range(len(exp_date)): | |||
if(exp_date[len(exp_date)-1] == None): | |||
if(exp_date[i] == shelf_new[i]): | |||
continue | |||
else: | |||
exp_date[len(exp_date)-1] = exp_date[i] | |||
print '\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' | |||
print ' TEMP IS EMPTY, MOVING {0} FROM LOCATION {1} TO THE TEMP'.format(exp_date[i],i+1) | |||
print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' | |||
print "============================================================================" | |||
exp_date[i] = None | |||
else: | |||
break | |||
place() | |||
try: | |||
print('***********************************************************************************') | |||
print(' The last {} items have expired, throwing them away.'.format(len(exp_date)-shelf_new.index(-1)-1)) | |||
print('***********************************************************************************') | |||
except ValueError: | |||
print(" No items have expired") | |||
print('***********************************************************************************') |
@ -0,0 +1,60 @@ | |||
exp_date = [1,1,7,6,3,9,10,2,8] | |||
shelf_new = sorted(exp_date) | |||
print shelf_new | |||
moves = {} | |||
cont = 1 | |||
reps = 0 | |||
prev_processed = [] | |||
lastloc = None | |||
check = False | |||
curpro = 0 | |||
lastpro = 0 | |||
proreps = 0 | |||
for i in range(len(shelf_new)): | |||
curpro = shelf_new[i] | |||
if(curpro == lastpro): | |||
proreps += 1 | |||
else: | |||
proreps = 0 | |||
moves[i] = shelf_new.index(exp_date[i]) + proreps | |||
lastpro = curpro | |||
print exp_date | |||
print shelf_new | |||
print moves | |||
length = len(moves) | |||
print('\n') | |||
while(reps < length): | |||
if(reps != 0): | |||
curloc = min(moves, key=lambda x:abs(x-curloc)) | |||
else: | |||
curloc = next(iter(moves.values())) | |||
while(cont == 1): | |||
check = curloc in prev_processed | |||
if(moves[curloc] in prev_processed): | |||
print curloc, | |||
moves.pop(curloc) | |||
print('\n=========================================\n' ) | |||
cont = 0 | |||
reps += 1 | |||
continue | |||
else: | |||
if(curloc == moves[curloc]): | |||
cont = 0 | |||
reps += 1 | |||
moves.pop(curloc) | |||
print('\n=========================================' ) | |||
print(str(curloc) + ' location correct!') | |||
print('=========================================' ) | |||
continue | |||
print curloc, | |||
print " -> ", | |||
lastloc = curloc | |||
prev_processed.append(curloc) | |||
curloc = moves[curloc] | |||
moves.pop(lastloc) | |||
reps += 1 | |||
cont = 1 |
@ -0,0 +1,117 @@ | |||
def dateComp(date_one,date_two): | |||
date_one_id = date_one.split('.') | |||
date_two_id = date_two.split('.') | |||
if(int(date_one_id[2]) > int(date_two_id[2])): | |||
return True | |||
elif(int(date_one_id[2]) == int(date_two_id[2])): | |||
if(int(date_one_id[1]) > int(date_two_id[1])): | |||
return True | |||
elif(int(date_one_id[1]) == int(date_two_id[1])): | |||
if(int(date_one_id[0]) > int(date_two_id[0])): | |||
return True | |||
elif(int(date_one_id[0]) == int(date_two_id[0])): | |||
return True | |||
return False | |||
def addItem(list_bas,item,item_loc): | |||
new_list = list_bas[0:item_loc] | |||
new_list.append(item) | |||
for i in range(len(list_bas) - item_loc): | |||
new_list.append(list_bas[item_loc + i]) | |||
return new_list | |||
def expDate(current_date,prod_dates): | |||
thrown_away = [] | |||
thrown_locs = [] | |||
thrown_number = 0 | |||
for i in range(len(prod_dates)): | |||
if(dateComp(current_date,prod_dates[i])): | |||
thrown_away.append(prod_dates[i]) | |||
thrown_locs.append(i) | |||
for i in range(len(thrown_locs)): | |||
prod_dates.pop(thrown_locs[i]-thrown_number) | |||
thrown_number += 1 | |||
def dateSort(current_date,prod_dates): | |||
loc = None | |||
sorted_dates = [] | |||
prev_placed = True | |||
for i in range(len(prod_dates)): | |||
if(dateComp(prod_dates[i],current_date)): | |||
sorted_dates.append(prod_dates[i]) | |||
loc = i | |||
break | |||
for i in range(len(prod_dates)): | |||
if(loc == i): | |||
continue | |||
prev_placed = True | |||
for j in range(len(sorted_dates)): | |||
if(prev_placed): | |||
if(j==0): | |||
if(dateComp(sorted_dates[j],prod_dates[i])): | |||
sorted_dates = addItem(sorted_dates,prod_dates[i],0) | |||
prev_placed = False | |||
continue | |||
if(j == len(sorted_dates) - 1 ): | |||
if(dateComp(prod_dates[i],sorted_dates[j])): | |||
sorted_dates = addItem(sorted_dates,prod_dates[i],len(sorted_dates)) | |||
else: | |||
sorted_dates = addItem(sorted_dates,prod_dates[i],len(sorted_dates)-1) | |||
continue | |||
if(dateComp(prod_dates[i],sorted_dates[j])): | |||
if(dateComp(sorted_dates[j+1],prod_dates[i])): | |||
sorted_dates = addItem(sorted_dates,prod_dates[i],j+1) | |||
prev_placed = False | |||
continue | |||
if(dateComp(sorted_dates[j],prod_dates[i])): | |||
if(dateComp(prod_dates[i],sorted_dates[j-1])): | |||
sorted_dates = addItem(sorted_dates,prod_dates[i],i) | |||
prev_placed = False | |||
continue | |||
return sorted_dates | |||
def dateToint(sorted_dates,unsorted_dates,date_current): | |||
date_num = 0 | |||
prev_date = None | |||
sorted_dateInt = [] | |||
unsorted_dateInt = [] | |||
for i in range(len(sorted_dates)): | |||
if(dateComp(date_current,sorted_dates[i])): | |||
sorted_dateInt.append(-1) | |||
continue | |||
if(prev_date == sorted_dates[i]): | |||
sorted_dateInt.append(date_num) | |||
continue | |||
date_num += 1 | |||
sorted_dateInt.append(date_num) | |||
prev_date = sorted_dates[i] | |||
for i in unsorted_dates: | |||
unsorted_dateInt.append(sorted_dateInt[sorted_dates.index(i)]) | |||
return unsorted_dateInt | |||
def listDif(list1,list2): | |||
listOrig = list1 | |||
for i in list2: | |||
if(i in listOrig): | |||
listOrig.pop(listOrig.index(i)) | |||
return listOrig | |||
def calcDate(): | |||
date_cur = '23.06.2018' | |||
exp_dates = ['23.06.2019','22.06.2019','11.06.2018','24.06.2018','23.08.2018','23.04.2018'] | |||
exp_dates_process = exp_dates[:] | |||
sorted_date = dateSort(date_cur,exp_dates_process) | |||
date_int = dateToint(sorted_date,exp_dates,date_cur) | |||
return date_int,sorted_date | |||
@ -0,0 +1,38 @@ | |||
# import the necessary packages | |||
from pyzbar import pyzbar | |||
import argparse | |||
import cv2 | |||
# construct the argument parser and parse the arguments | |||
ap = argparse.ArgumentParser() | |||
ap.add_argument("-i", "--image", required=True, | |||
help="path to input image") | |||
args = vars(ap.parse_args()) | |||
# load the input image | |||
image = cv2.imread(args["image"]) | |||
# find the barcodes in the image and decode each of the barcodes | |||
barcodes = pyzbar.decode(image) | |||
# loop over the detected barcodes | |||
for barcode in barcodes: | |||
# extract the bounding box location of the barcode and draw the | |||
# bounding box surrounding the barcode on the image | |||
(x, y, w, h) = barcode.rect | |||
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2) | |||
# the barcode data is a bytes object so if we want to draw it on | |||
# our output image we need to convert it to a string first | |||
barcodeData = barcode.data.decode("utf-8") | |||
barcodeType = barcode.type | |||
# draw the barcode data and barcode type on the image | |||
text = "{} ({})".format(barcodeData, barcodeType) | |||
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, | |||
0.5, (0, 0, 255), 2) | |||
# print the barcode type and data to the terminal | |||
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData)) | |||
# show the output image | |||
cv2.imshow("Image", image) | |||
cv2.waitKey(0) |
@ -0,0 +1,45 @@ | |||
from pyzbar import pyzbar | |||
import argparse | |||
import cv2 | |||
import time | |||
import database_actions | |||
dates = [] | |||
reps = 0 | |||
barcodes = None | |||
prevcode = None | |||
exp_date = [] | |||
cam = cv2.VideoCapture(0) | |||
while(reps<2): | |||
while(barcodes == None or barcodes == []): | |||
ret , image = cam.read() | |||
barcodes = pyzbar.decode(image) | |||
cv2.imshow("Image", image) | |||
if cv2.waitKey(1) & 0xFF == ord('q'): | |||
break | |||
for barcode in barcodes: | |||
(x, y, w, h) = barcode.rect | |||
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2) | |||
barcodeData = barcode.data.decode("utf-8") | |||
barcodeType = barcode.type | |||
if(barcodeData != prevcode): | |||
text = "{} ({})".format(barcodeData, barcodeType) | |||
cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, | |||
0.5, (0, 0, 255), 2) | |||
print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData)) | |||
dates.append(database_actions.getDate(barcodeData)) | |||
exp_date.append(int(barcodeData)) | |||
reps += 1 | |||
prevcode = barcodeData | |||
barcodes = None | |||
cv2.imshow("Image", image) | |||
if cv2.waitKey(1) & 0xFF == ord('q'): | |||
break | |||
print dates | |||
@ -0,0 +1,10 @@ | |||
*.iml | |||
.gradle | |||
/local.properties | |||
/.idea/libraries | |||
/.idea/modules.xml | |||
/.idea/workspace.xml | |||
.DS_Store | |||
/build | |||
/captures | |||
.externalNativeBuild |
@ -0,0 +1,19 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="WizardSettings"> | |||
<option name="children"> | |||
<map> | |||
<entry key="imageWizard"> | |||
<value> | |||
<PersistentState /> | |||
</value> | |||
</entry> | |||
<entry key="vectorWizard"> | |||
<value> | |||
<PersistentState /> | |||
</value> | |||
</entry> | |||
</map> | |||
</option> | |||
</component> | |||
</project> |
@ -0,0 +1,29 @@ | |||
<component name="ProjectCodeStyleConfiguration"> | |||
<code_scheme name="Project" version="173"> | |||
<Objective-C-extensions> | |||
<file> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> | |||
</file> | |||
<class> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> | |||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> | |||
</class> | |||
<extensions> | |||
<pair source="cpp" header="h" fileNamingConvention="NONE" /> | |||
<pair source="c" header="h" fileNamingConvention="NONE" /> | |||
</extensions> | |||
</Objective-C-extensions> | |||
</code_scheme> | |||
</component> |
@ -0,0 +1,18 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="GradleSettings"> | |||
<option name="linkedExternalProjectsSettings"> | |||
<GradleProjectSettings> | |||
<option name="distributionType" value="DEFAULT_WRAPPED" /> | |||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | |||
<option name="modules"> | |||
<set> | |||
<option value="$PROJECT_DIR$" /> | |||
<option value="$PROJECT_DIR$/app" /> | |||
</set> | |||
</option> | |||
<option name="resolveModulePerSourceSet" value="false" /> | |||
</GradleProjectSettings> | |||
</option> | |||
</component> | |||
</project> |
@ -0,0 +1,34 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="NullableNotNullManager"> | |||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | |||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | |||
<option name="myNullables"> | |||
<value> | |||
<list size="5"> | |||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> | |||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> | |||
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> | |||
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | |||
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | |||
</list> | |||
</value> | |||
</option> | |||
<option name="myNotNulls"> | |||
<value> | |||
<list size="4"> | |||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> | |||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> | |||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> | |||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> | |||
</list> | |||
</value> | |||
</option> | |||
</component> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/build/classes" /> | |||
</component> | |||
<component name="ProjectType"> | |||
<option name="id" value="Android" /> | |||
</component> | |||
</project> |
@ -0,0 +1,12 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="RunConfigurationProducerService"> | |||
<option name="ignoredProducers"> | |||
<set> | |||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | |||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | |||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | |||
</set> | |||
</option> | |||
</component> | |||
</project> |
@ -0,0 +1,17 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>FoodCloud</name> | |||
<comment>Project FoodCloud created by Buildship.</comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | |||
</natures> | |||
</projectDescription> |
@ -0,0 +1,2 @@ | |||
connection.project.dir= | |||
eclipse.preferences.version=1 |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10/"/> | |||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/> | |||
<classpathentry kind="output" path="bin/default"/> | |||
</classpath> |
@ -0,0 +1 @@ | |||
/build |
@ -0,0 +1,23 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<projectDescription> | |||
<name>app</name> | |||
<comment>Project app created by Buildship.</comment> | |||
<projects> | |||
</projects> | |||
<buildSpec> | |||
<buildCommand> | |||
<name>org.eclipse.jdt.core.javabuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
<buildCommand> | |||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name> | |||
<arguments> | |||
</arguments> | |||
</buildCommand> | |||
</buildSpec> | |||
<natures> | |||
<nature>org.eclipse.jdt.core.javanature</nature> | |||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature> | |||
</natures> | |||
</projectDescription> |
@ -0,0 +1,2 @@ | |||
connection.project.dir=.. | |||
eclipse.preferences.version=1 |
@ -0,0 +1,34 @@ | |||
apply plugin: 'com.android.application' | |||
android { | |||
compileSdkVersion 27 | |||
defaultConfig { | |||
applicationId "gq.yigit.foodcloud" | |||
minSdkVersion 24 | |||
targetSdkVersion 27 | |||
versionCode 1 | |||
versionName "1.0" | |||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |||
} | |||
buildTypes { | |||
release { | |||
minifyEnabled false | |||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |||
} | |||
} | |||
} | |||
dependencies { | |||
implementation fileTree(include: ['*.jar'], dir: 'libs') | |||
implementation 'com.google.firebase:firebase-database:16.0.1' | |||
implementation 'com.android.support:appcompat-v7:27.1.1' | |||
implementation 'com.android.support.constraint:constraint-layout:1.1.0' | |||
implementation 'com.google.firebase:firebase-auth:16.0.1' | |||
implementation 'com.android.support:wear:27.1.1' | |||
testImplementation 'junit:junit:4.12' | |||
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |||
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' | |||
} | |||
apply plugin: 'com.google.gms.google-services' |
@ -0,0 +1,51 @@ | |||
{ | |||
"project_info": { | |||
"project_number": "554038090297", | |||
"firebase_url": "https://foodcloud-f6eb1.firebaseio.com", | |||
"project_id": "foodcloud-f6eb1", | |||
"storage_bucket": "foodcloud-f6eb1.appspot.com" | |||
}, | |||
"client": [ | |||
{ | |||
"client_info": { | |||
"mobilesdk_app_id": "1:554038090297:android:88c7b9f7692bb439", | |||
"android_client_info": { | |||
"package_name": "gq.yigit.foodcloud" | |||
} | |||
}, | |||
"oauth_client": [ | |||
{ | |||
"client_id": "554038090297-ur5brtr21n2p50hkuiprgbct2l6q76e5.apps.googleusercontent.com", | |||
"client_type": 3 | |||
}, | |||
{ | |||
"client_id": "554038090297-ur5brtr21n2p50hkuiprgbct2l6q76e5.apps.googleusercontent.com", | |||
"client_type": 3 | |||
} | |||
], | |||
"api_key": [ | |||
{ | |||
"current_key": "AIzaSyBELWHmzgjrtJdUQZiITbnfSQpQgcZt7-Y" | |||
} | |||
], | |||
"services": { | |||
"analytics_service": { | |||
"status": 1 | |||
}, | |||
"appinvite_service": { | |||
"status": 2, | |||
"other_platform_oauth_client": [ | |||
{ | |||
"client_id": "554038090297-ur5brtr21n2p50hkuiprgbct2l6q76e5.apps.googleusercontent.com", | |||
"client_type": 3 | |||
} | |||
] | |||
}, | |||
"ads_service": { | |||
"status": 2 | |||
} | |||
} | |||
} | |||
], | |||
"configuration_version": "1" | |||
} |
@ -0,0 +1,21 @@ | |||
# Add project specific ProGuard rules here. | |||
# You can control the set of applied configuration files using the | |||
# proguardFiles setting in build.gradle. | |||
# | |||
# For more details, see | |||
# http://developer.android.com/guide/developing/tools/proguard.html | |||
# If your project uses WebView with JS, uncomment the following | |||
# and specify the fully qualified class name to the JavaScript interface | |||
# class: | |||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | |||
# public *; | |||
#} | |||
# Uncomment this to preserve the line number information for | |||
# debugging stack traces. | |||
#-keepattributes SourceFile,LineNumberTable | |||
# If you keep the line number information, uncomment this to | |||
# hide the original source file name. | |||
#-renamesourcefileattribute SourceFile |
@ -0,0 +1,26 @@ | |||
package gq.yigit.foodcloud; | |||
import android.content.Context; | |||
import android.support.test.InstrumentationRegistry; | |||
import android.support.test.runner.AndroidJUnit4; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
import static org.junit.Assert.*; | |||
/** | |||
* Instrumented test, which will execute on an Android device. | |||
* | |||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |||
*/ | |||
@RunWith(AndroidJUnit4.class) | |||
public class ExampleInstrumentedTest { | |||
@Test | |||
public void useAppContext() { | |||
// Context of the app under test. | |||
Context appContext = InstrumentationRegistry.getTargetContext(); | |||
assertEquals("gq.yigit.foodcloud", appContext.getPackageName()); | |||
} | |||
} |
@ -0,0 +1,32 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
package="gq.yigit.foodcloud"> | |||
<uses-permission android:name="android.permission.INTERNET" /> | |||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | |||
<application | |||
android:allowBackup="true" | |||
android:hardwareAccelerated="false" | |||
android:largeHeap="true" | |||
android:icon="@mipmap/icon" | |||
android:label="@string/app_name" | |||
android:roundIcon="@mipmap/ic_launcher_round" | |||
android:supportsRtl="true" | |||
android:theme="@style/AppTheme"> | |||
<activity android:name=".MainActivity"> | |||
<intent-filter> | |||
<action android:name="android.intent.action.MAIN" /> | |||
<category android:name="android.intent.category.LAUNCHER" /> | |||
</intent-filter> | |||
</activity> | |||
<activity android:name=".ProductInfo" /> | |||
Set to true if your app is Standalone, that is, it does not require the handheld | |||
app to run. | |||
--> | |||
<activity android:name=".GetInfo" /> | |||
<activity android:name=".LearnMore"></activity> | |||
</application> | |||
</manifest> |
@ -0,0 +1,285 @@ | |||
package com.google.zxing.integration.android; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import android.app.Activity; | |||
import android.app.AlertDialog; | |||
import android.content.ActivityNotFoundException; | |||
import android.content.DialogInterface; | |||
import android.content.Intent; | |||
import android.content.pm.PackageManager; | |||
import android.content.pm.ResolveInfo; | |||
import android.net.Uri; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
public class IntentIntegrator { | |||
public static final int REQUEST_CODE = 0x0000c0de; // Only use bottom 16 bits | |||
private static final String TAG = IntentIntegrator.class.getSimpleName(); | |||
public static final String DEFAULT_TITLE = "Install Barcode Scanner?"; | |||
public static final String DEFAULT_MESSAGE = | |||
"This application requires Barcode Scanner. Would you like to install it?"; | |||
public static final String DEFAULT_YES = "Yes"; | |||
public static final String DEFAULT_NO = "No"; | |||
private static final String BS_PACKAGE = "com.google.zxing.client.android"; | |||
private static final String BSPLUS_PACKAGE = "com.srowen.bs.android"; | |||
// supported barcode formats | |||
public static final Collection<String> PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14"); | |||
public static final Collection<String> ONE_D_CODE_TYPES = | |||
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128", | |||
"ITF", "RSS_14", "RSS_EXPANDED"); | |||
public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE"); | |||
public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX"); | |||
public static final Collection<String> ALL_CODE_TYPES = null; | |||
public static final List<String> TARGET_BARCODE_SCANNER_ONLY = Collections.singletonList(BS_PACKAGE); | |||
public static final List<String> TARGET_ALL_KNOWN = list( | |||
BS_PACKAGE, // Barcode Scanner | |||
BSPLUS_PACKAGE, // Barcode Scanner+ | |||
BSPLUS_PACKAGE + ".simple" // Barcode Scanner+ Simple | |||
// What else supports this intent? | |||
); | |||
private final Activity activity; | |||
private String title; | |||
private String message; | |||
private String buttonYes; | |||
private String buttonNo; | |||
private List<String> targetApplications; | |||
private final Map<String,Object> moreExtras; | |||
public IntentIntegrator(Activity activity) { | |||
this.activity = activity; | |||
title = DEFAULT_TITLE; | |||
message = DEFAULT_MESSAGE; | |||
buttonYes = DEFAULT_YES; | |||
buttonNo = DEFAULT_NO; | |||
targetApplications = TARGET_ALL_KNOWN; | |||
moreExtras = new HashMap<String,Object>(3); | |||
} | |||
public String getTitle() { | |||
return title; | |||
} | |||
public void setTitle(String title) { | |||
this.title = title; | |||
} | |||
public void setTitleByID(int titleID) { | |||
title = activity.getString(titleID); | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
public void setMessage(String message) { | |||
this.message = message; | |||
} | |||
public void setMessageByID(int messageID) { | |||
message = activity.getString(messageID); | |||
} | |||
public String getButtonYes() { | |||
return buttonYes; | |||
} | |||
public void setButtonYes(String buttonYes) { | |||
this.buttonYes = buttonYes; | |||
} | |||
public void setButtonYesByID(int buttonYesID) { | |||
buttonYes = activity.getString(buttonYesID); | |||
} | |||
public String getButtonNo() { | |||
return buttonNo; | |||
} | |||
public void setButtonNo(String buttonNo) { | |||
this.buttonNo = buttonNo; | |||
} | |||
public void setButtonNoByID(int buttonNoID) { | |||
buttonNo = activity.getString(buttonNoID); | |||
} | |||
public Collection<String> getTargetApplications() { | |||
return targetApplications; | |||
} | |||
public final void setTargetApplications(List<String> targetApplications) { | |||
if (targetApplications.isEmpty()) { | |||
throw new IllegalArgumentException("No target applications"); | |||
} | |||
this.targetApplications = targetApplications; | |||
} | |||
public void setSingleTargetApplication(String targetApplication) { | |||
this.targetApplications = Collections.singletonList(targetApplication); | |||
} | |||
public Map<String,?> getMoreExtras() { | |||
return moreExtras; | |||
} | |||
public final void addExtra(String key, Object value) { | |||
moreExtras.put(key, value); | |||
} | |||
public final AlertDialog initiateScan() { | |||
return initiateScan(ALL_CODE_TYPES); | |||
} | |||
public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) { | |||
Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); | |||
intentScan.addCategory(Intent.CATEGORY_DEFAULT); | |||
// check which types of codes to scan for | |||
if (desiredBarcodeFormats != null) { | |||
// set the desired barcode types | |||
StringBuilder joinedByComma = new StringBuilder(); | |||
for (String format : desiredBarcodeFormats) { | |||
if (joinedByComma.length() > 0) { | |||
joinedByComma.append(','); | |||
} | |||
joinedByComma.append(format); | |||
} | |||
intentScan.putExtra("SCAN_FORMATS", joinedByComma.toString()); | |||
} | |||
String targetAppPackage = findTargetAppPackage(intentScan); | |||
if (targetAppPackage == null) { | |||
return showDownloadDialog(); | |||
} | |||
intentScan.setPackage(targetAppPackage); | |||
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
intentScan.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); | |||
attachMoreExtras(intentScan); | |||
startActivityForResult(intentScan, REQUEST_CODE); | |||
return null; | |||
} | |||
protected void startActivityForResult(Intent intent, int code) { | |||
activity.startActivityForResult(intent, code); | |||
} | |||
private String findTargetAppPackage(Intent intent) { | |||
PackageManager pm = activity.getPackageManager(); | |||
List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |||
if (availableApps != null) { | |||
for (ResolveInfo availableApp : availableApps) { | |||
String packageName = availableApp.activityInfo.packageName; | |||
if (targetApplications.contains(packageName)) { | |||
return packageName; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
private AlertDialog showDownloadDialog() { | |||
AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); | |||
downloadDialog.setTitle(title); | |||
downloadDialog.setMessage(message); | |||
downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() { | |||
@Override | |||
public void onClick(DialogInterface dialogInterface, int i) { | |||
String packageName = targetApplications.get(0); | |||
Uri uri = Uri.parse("market://details?id=" + packageName); | |||
Intent intent = new Intent(Intent.ACTION_VIEW, uri); | |||
try { | |||
activity.startActivity(intent); | |||
} catch (ActivityNotFoundException anfe) { | |||
// Hmm, market is not installed | |||
Log.w(TAG, "Google Play is not installed; cannot install " + packageName); | |||
} | |||
} | |||
}); | |||
downloadDialog.setNegativeButton(buttonNo, new DialogInterface.OnClickListener() { | |||
@Override | |||
public void onClick(DialogInterface dialogInterface, int i) {} | |||
}); | |||
return downloadDialog.show(); | |||
} | |||
public static IntentResult parseActivityResult(int requestCode, int resultCode, Intent intent) { | |||
if (requestCode == REQUEST_CODE) { | |||
if (resultCode == Activity.RESULT_OK) { | |||
String contents = intent.getStringExtra("SCAN_RESULT"); | |||
String formatName = intent.getStringExtra("SCAN_RESULT_FORMAT"); | |||
byte[] rawBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTES"); | |||
int intentOrientation = intent.getIntExtra("SCAN_RESULT_ORIENTATION", Integer.MIN_VALUE); | |||
Integer orientation = intentOrientation == Integer.MIN_VALUE ? null : intentOrientation; | |||
String errorCorrectionLevel = intent.getStringExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL"); | |||
return new IntentResult(contents, | |||
formatName, | |||
rawBytes, | |||
orientation, | |||
errorCorrectionLevel); | |||
} | |||
return new IntentResult(); | |||
} | |||
return null; | |||
} | |||
public final AlertDialog shareText(CharSequence text, CharSequence type) { | |||
Intent intent = new Intent(); | |||
intent.addCategory(Intent.CATEGORY_DEFAULT); | |||
intent.setAction(BS_PACKAGE + ".ENCODE"); | |||
intent.putExtra("ENCODE_TYPE", type); | |||
intent.putExtra("ENCODE_DATA", text); | |||
String targetAppPackage = findTargetAppPackage(intent); | |||
if (targetAppPackage == null) { | |||
return showDownloadDialog(); | |||
} | |||
intent.setPackage(targetAppPackage); | |||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); | |||
attachMoreExtras(intent); | |||
activity.startActivity(intent); | |||
return null; | |||
} | |||
private static List<String> list(String... values) { | |||
return Collections.unmodifiableList(Arrays.asList(values)); | |||
} | |||
private void attachMoreExtras(Intent intent) { | |||
for (Map.Entry<String,Object> entry : moreExtras.entrySet()) { | |||
String key = entry.getKey(); | |||
Object value = entry.getValue(); | |||
// Kind of hacky | |||
if (value instanceof Integer) { | |||
intent.putExtra(key, (Integer) value); | |||
} else if (value instanceof Long) { | |||
intent.putExtra(key, (Long) value); | |||
} else if (value instanceof Boolean) { | |||
intent.putExtra(key, (Boolean) value); | |||
} else if (value instanceof Double) { | |||
intent.putExtra(key, (Double) value); | |||
} else if (value instanceof Float) { | |||
intent.putExtra(key, (Float) value); | |||
} else if (value instanceof Bundle) { | |||
intent.putExtra(key, (Bundle) value); | |||
} else { | |||
intent.putExtra(key, value.toString()); | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,67 @@ | |||
package com.google.zxing.integration.android; | |||
public final class IntentResult { | |||
private final String contents; | |||
private final String formatName; | |||
private final byte[] rawBytes; | |||
private final Integer orientation; | |||
private final String errorCorrectionLevel; | |||
IntentResult() { | |||
this(null, null, null, null, null); | |||
} | |||
IntentResult(String contents, | |||
String formatName, | |||
byte[] rawBytes, | |||
Integer orientation, | |||
String errorCorrectionLevel) { | |||
this.contents = contents; | |||
this.formatName = formatName; | |||
this.rawBytes = rawBytes; | |||
this.orientation = orientation; | |||
this.errorCorrectionLevel = errorCorrectionLevel; | |||
} | |||
public String getContents() { | |||
return contents; | |||
} | |||
public String getFormatName() { | |||
return formatName; | |||
} | |||
public byte[] getRawBytes() { | |||
return rawBytes; | |||
} | |||
public Integer getOrientation() { | |||
return orientation; | |||
} | |||
public String getErrorCorrectionLevel() { | |||
return errorCorrectionLevel; | |||
} | |||
@Override | |||
public String toString() { | |||
StringBuilder dialogText = new StringBuilder(100); | |||
dialogText.append("Format: ").append(formatName).append('\n'); | |||
dialogText.append("Contents: ").append(contents).append('\n'); | |||
int rawBytesLength = rawBytes == null ? 0 : rawBytes.length; | |||
dialogText.append("Raw bytes: (").append(rawBytesLength).append(" bytes)\n"); | |||
dialogText.append("Orientation: ").append(orientation).append('\n'); | |||
dialogText.append("EC level: ").append(errorCorrectionLevel).append('\n'); | |||
return dialogText.toString(); | |||
} | |||
} |
@ -0,0 +1,16 @@ | |||
package gq.yigit.foodcloud; | |||
import android.support.v7.app.AppCompatActivity; | |||
import android.os.Bundle; | |||
import android.webkit.WebView; | |||
public class GetInfo extends AppCompatActivity { | |||
@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/"); | |||
} | |||
} |
@ -0,0 +1,99 @@ | |||
package gq.yigit.foodcloud; | |||
import android.content.Intent; | |||
import android.support.v7.app.AppCompatActivity; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.View; | |||
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; | |||
public class LearnMore extends AppCompatActivity implements View.OnClickListener { | |||
private static final String TAG = "MainActivity"; | |||
public String prod_loc_more; | |||
public ImageView factory; | |||
public ImageView farm; | |||
public ImageView packaging; | |||
public ImageView trans1; | |||
public ImageView trans2; | |||
public ImageView factory_cond; | |||
public ImageView farm_cond; | |||
public ImageView packaging_cond; | |||
public ImageView trans1_cond; | |||
public ImageView trans2_cond; | |||
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) { | |||
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); | |||
factory = (ImageView) findViewById(R.id.factory); | |||
factory.setOnClickListener(this); | |||
farm = (ImageView) findViewById(R.id.farm); | |||
farm.setOnClickListener(this); | |||
packaging = (ImageView) findViewById(R.id.packaging); | |||
packaging.setOnClickListener(this); | |||
trans1 = (ImageView) findViewById(R.id.trans1); | |||
trans1.setOnClickListener(this); | |||
trans2 = (ImageView) findViewById(R.id.trans2); | |||
trans2.setOnClickListener(this); | |||
back_to_main = (Button) findViewById(R.id.go_back_to_main); | |||
back_to_main.setOnClickListener(this); | |||
} | |||
public void onClick(View v){ | |||
if(v.getId() == R.id.go_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()); | |||
} | |||
}); | |||
} | |||
} |
@ -0,0 +1,61 @@ | |||
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.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 { | |||
int cnt = 0; | |||
private Button scanBtn; | |||
private Button infoBtn; | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_main); | |||
scanBtn = (Button)findViewById(R.id.scan_button); | |||
scanBtn.setOnClickListener(this); | |||
infoBtn = (Button)findViewById(R.id.info_button); | |||
infoBtn.setOnClickListener(this); | |||
} | |||
public void onClick(View v){ | |||
if (v.getId() == R.id.scan_button) { | |||
IntentIntegrator scanIntegrator = new IntentIntegrator(this); | |||
scanIntegrator.initiateScan(); | |||
} | |||
if (v.getId() == R.id.info_button) { | |||
startActivity(new Intent(MainActivity.this, GetInfo.class)); | |||
} | |||
} | |||
public void onActivityResult(int requestCode, int resultCode, Intent intent) { | |||
IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); | |||
if (scanningResult != null) { | |||
String scanContent = scanningResult.getContents(); | |||
Intent i = new Intent(MainActivity.this, ProductInfo.class); | |||
i.putExtra("key",scanContent); | |||
startActivity(i); | |||
} | |||
else{ | |||
Toast toast = Toast.makeText(getApplicationContext(), | |||
"No scan data received!", Toast.LENGTH_SHORT); | |||
toast.show(); | |||
} | |||
} | |||
} |
@ -0,0 +1,157 @@ | |||
package gq.yigit.foodcloud; | |||
import android.content.Intent; | |||
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.firebase.database.*; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import java.util.ArrayList; | |||
import android.view.View.OnClickListener; | |||
public class ProductInfo extends AppCompatActivity implements OnClickListener { | |||
private static final String TAG = "MainActivity"; | |||
private TextView Name; | |||
private TextView Cal; | |||
private TextView Cooked; | |||
private TextView Nutrients; | |||
private TextView BBD; | |||
private TextView Processed; | |||
private TextView Problematic; | |||
private TextView Allergens; | |||
private String name; | |||
private String cal; | |||
private String cooked; | |||
private ArrayList nutrients; | |||
private String bbd; | |||
private String processed; | |||
private String problematic; | |||
private ArrayList allergens; | |||
public ArrayList Prods; | |||
public Map<String, Object> someMap; | |||
public HashMap<String, Object> Prod; | |||
private Button scanBtn; | |||
private Button jrnyBtn; | |||
public String prod_loc; | |||
public String allergens_print = new String(); | |||
public String nutrients_print = new String(); | |||
@Override | |||
protected void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.activity_product_info); | |||
} | |||
@Override | |||
public void onClick(View v){ | |||
if (v.getId() == R.id.button) { | |||
Intent i = new Intent(ProductInfo.this, MainActivity.class); | |||
startActivity(i); | |||
}if (v.getId() == R.id.journey) { | |||
Intent i = new Intent(ProductInfo.this, LearnMore.class); | |||
i.putExtra("key", prod_loc); | |||
startActivity(i); | |||
} | |||
} | |||
public void onStart(){ | |||
super.onStart(); | |||
setContentView(R.layout.activity_product_info); | |||
Map<String, String> map = new HashMap<String, String>(); | |||
FirebaseDatabase database = FirebaseDatabase.getInstance(); | |||
DatabaseReference myRef = database.getReference(); | |||
scanBtn = (Button)findViewById(R.id.button); | |||
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"); | |||
//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("Products"); | |||
al1.remove(0); | |||
Prods = al1; | |||
Prod = (HashMap<String, Object>)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(); | |||
Name = (TextView) findViewById(R.id.name); | |||
Name.setText("Name : " + name); | |||
Cal = (TextView) findViewById(R.id.Calories); | |||
Cal.setText("Calories : " + cal); | |||
Allergens = (TextView) findViewById(R.id.allergens); | |||
allergens_print = ""; | |||
if(allergens.isEmpty()) { | |||
Allergens.setText("Allergens : None"); | |||
}else{ | |||
for(int i = 0; i < allergens.size();i++) { | |||
allergens_print = allergens_print + allergens.get(i); | |||
if(i != allergens.size() -1){ | |||
allergens_print = allergens_print + " , "; | |||
} | |||
} | |||
Allergens.setText("Allergens : " + allergens_print); | |||
} | |||
Nutrients = (TextView) findViewById(R.id.nutrients); | |||
nutrients_print = ""; | |||
if(nutrients.isEmpty()) { | |||
Nutrients.setText("Nutrients : None"); | |||
}else{ | |||
for(int i = 0; i < nutrients.size();i++) { | |||
nutrients_print = nutrients_print + nutrients.get(i); | |||
if(i != nutrients.size() -1){ | |||
nutrients_print = nutrients_print + " , "; | |||
} | |||
} | |||
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); | |||
Processed = (TextView) findViewById(R.id.Process); | |||
Processed.setText("Process : " + processed); | |||
Problematic = (TextView) findViewById(R.id.Problems); | |||
Problematic.setText("Problemed : " + problematic); | |||
} | |||
@Override | |||
public void onCancelled(DatabaseError error) { | |||
// Failed to read value | |||
Log.w(TAG, "Failed to read value.", error.toException()); | |||
} | |||
}); | |||
} | |||
} |
@ -0,0 +1,34 @@ | |||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:aapt="http://schemas.android.com/aapt" | |||
android:width="108dp" | |||
android:height="108dp" | |||
android:viewportHeight="108" | |||
android:viewportWidth="108"> | |||
<path | |||
android:fillType="evenOdd" | |||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" | |||
android:strokeColor="#00000000" | |||
android:strokeWidth="1"> | |||
<aapt:attr name="android:fillColor"> | |||
<gradient | |||
android:endX="78.5885" | |||
android:endY="90.9159" | |||
android:startX="48.7653" | |||
android:startY="61.0927" | |||
android:type="linear"> | |||
<item | |||
android:color="#44000000" | |||
android:offset="0.0" /> | |||
<item | |||
android:color="#00000000" | |||
android:offset="1.0" /> | |||
</gradient> | |||
</aapt:attr> | |||
</path> | |||
<path | |||
android:fillColor="#FFFFFF" | |||
android:fillType="nonZero" | |||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" | |||
android:strokeColor="#00000000" | |||
android:strokeWidth="1" /> | |||
</vector> |
@ -0,0 +1,74 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<vector | |||
android:height="108dp" | |||
android:width="108dp" | |||
android:viewportHeight="108" | |||
android:viewportWidth="108" | |||
xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<path android:fillColor="#26A69A" | |||
android:pathData="M0,0h108v108h-108z"/> | |||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89" | |||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/> | |||
</vector> |
@ -0,0 +1,33 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".GetInfo" | |||
tools:layout_editor_absoluteY="81dp"> | |||
<WebView | |||
android:id="@+id/info" | |||
android:layout_width="0dp" | |||
android:layout_height="0dp" | |||
android:layout_marginBottom="28dp" | |||
android:layout_marginEnd="8dp" | |||
android:layout_marginStart="8dp" | |||
android:layout_marginTop="8dp" | |||
app:layout_constraintBottom_toTopOf="@+id/back_to_main" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<Button | |||
android:id="@+id/back_to_main" | |||
android:layout_width="236dp" | |||
android:layout_height="53dp" | |||
android:layout_marginBottom="21dp" | |||
android:text="back to main menu" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toBottomOf="@+id/info" /> | |||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,228 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".LearnMore" | |||
tools:layout_editor_absoluteY="81dp"> | |||
<ImageView | |||
android:id="@+id/trans2_cond" | |||
android:layout_width="51dp" | |||
android:layout_height="45dp" | |||
android:layout_marginEnd="8dp" | |||
android:layout_marginStart="8dp" | |||
android:layout_marginTop="48dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/trans2" | |||
app:layout_constraintEnd_toEndOf="@+id/trans2" | |||
app:layout_constraintHorizontal_bias="1.0" | |||
app:layout_constraintStart_toStartOf="@+id/trans2" | |||
app:layout_constraintTop_toTopOf="@+id/trans2" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/check" /> | |||
<ImageView | |||
android:id="@+id/imageView16" | |||
android:layout_width="64dp" | |||
android:layout_height="112dp" | |||
android:layout_marginEnd="128dp" | |||
android:layout_marginTop="40dp" | |||
android:rotation="70" | |||
app:layout_constraintBottom_toBottomOf="@+id/trans2" | |||
app:layout_constraintEnd_toEndOf="@+id/trans2" | |||
app:layout_constraintHorizontal_bias="1.0" | |||
app:layout_constraintStart_toStartOf="@+id/trans2" | |||
app:layout_constraintTop_toTopOf="@+id/trans2" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/arrow_left" /> | |||
<ImageView | |||
android:id="@+id/packaging_cond" | |||
android:layout_width="51dp" | |||
android:layout_height="45dp" | |||
android:layout_marginStart="64dp" | |||
android:layout_marginTop="68dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/packaging" | |||
app:layout_constraintEnd_toEndOf="@+id/packaging" | |||
app:layout_constraintStart_toStartOf="@+id/packaging" | |||
app:layout_constraintTop_toTopOf="@+id/packaging" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/check" /> | |||
<ImageView | |||
android:id="@+id/trans2" | |||
android:layout_width="151dp" | |||
android:layout_height="83dp" | |||
android:layout_marginEnd="36dp" | |||
android:layout_marginTop="48dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/imageView13" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintTop_toTopOf="@+id/imageView13" | |||
app:layout_constraintVertical_bias="0.13" | |||
app:srcCompat="@mipmap/truck" /> | |||
<ImageView | |||
android:id="@+id/imageView13" | |||
android:layout_width="184dp" | |||
android:layout_height="62dp" | |||
android:layout_marginStart="64dp" | |||
android:rotation="30" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="@+id/factory" | |||
app:layout_constraintHorizontal_bias="0.0" | |||
app:layout_constraintStart_toStartOf="@+id/factory" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:layout_constraintVertical_bias="0.481" | |||
app:srcCompat="@mipmap/arrow_right" /> | |||
<ImageView | |||
android:id="@+id/factory_cond" | |||
android:layout_width="51dp" | |||
android:layout_height="45dp" | |||
android:layout_marginBottom="8dp" | |||
android:layout_marginStart="64dp" | |||
android:layout_marginTop="96dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/factory" | |||
app:layout_constraintEnd_toEndOf="@+id/factory" | |||
app:layout_constraintHorizontal_bias="0.0" | |||
app:layout_constraintStart_toStartOf="@+id/factory" | |||
app:layout_constraintTop_toTopOf="@+id/factory" | |||
app:srcCompat="@mipmap/check" /> | |||
<ImageView | |||
android:id="@+id/trans1_cond" | |||
android:layout_width="51dp" | |||
android:layout_height="45dp" | |||
android:layout_marginEnd="4dp" | |||
android:layout_marginStart="8dp" | |||
android:layout_marginTop="44dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/trans1" | |||
app:layout_constraintEnd_toEndOf="@+id/trans1" | |||
app:layout_constraintHorizontal_bias="0.954" | |||
app:layout_constraintStart_toStartOf="@+id/trans1" | |||
app:layout_constraintTop_toTopOf="@+id/trans1" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/check" /> | |||
<ImageView | |||
android:id="@+id/farm" | |||
android:layout_width="116dp" | |||
android:layout_height="108dp" | |||
android:layout_marginBottom="8dp" | |||
android:layout_marginEnd="8dp" | |||
android:layout_marginStart="16dp" | |||
android:layout_marginTop="8dp" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintHorizontal_bias="0.0" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:layout_constraintVertical_bias="0.02" | |||
app:srcCompat="@mipmap/farm" /> | |||
<ImageView | |||
android:id="@+id/farm_cond" | |||
android:layout_width="51dp" | |||
android:layout_height="46dp" | |||
android:layout_marginStart="76dp" | |||
android:layout_marginTop="76dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/farm" | |||
app:layout_constraintEnd_toEndOf="@+id/farm" | |||
app:layout_constraintHorizontal_bias="0.0" | |||
app:layout_constraintStart_toStartOf="@+id/farm" | |||
app:layout_constraintTop_toTopOf="@+id/farm" | |||
app:layout_constraintVertical_bias="0.285" | |||
app:srcCompat="@mipmap/check" /> | |||
<ImageView | |||
android:id="@+id/trans1" | |||
android:layout_width="151dp" | |||
android:layout_height="83dp" | |||
android:layout_marginStart="200dp" | |||
android:layout_marginTop="72dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/farm" | |||
app:layout_constraintEnd_toEndOf="@+id/farm" | |||
app:layout_constraintHorizontal_bias="0.08" | |||
app:layout_constraintStart_toStartOf="@+id/farm" | |||
app:layout_constraintTop_toTopOf="@+id/farm" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/truck" /> | |||
<ImageView | |||
android:id="@+id/imageView7" | |||
android:layout_width="196dp" | |||
android:layout_height="65dp" | |||
android:layout_marginBottom="8dp" | |||
android:layout_marginStart="76dp" | |||
android:layout_marginTop="20dp" | |||
android:rotation="30" | |||
app:layout_constraintBottom_toBottomOf="@+id/farm" | |||
app:layout_constraintEnd_toEndOf="@+id/farm" | |||
app:layout_constraintHorizontal_bias="0.0" | |||
app:layout_constraintStart_toStartOf="@+id/farm" | |||
app:layout_constraintTop_toTopOf="@+id/farm" | |||
app:layout_constraintVertical_bias="1.0" | |||
app:srcCompat="@mipmap/arrow_right" /> | |||
<ImageView | |||
android:id="@+id/imageView10" | |||
android:layout_width="64dp" | |||
android:layout_height="112dp" | |||
android:layout_marginEnd="76dp" | |||
android:layout_marginStart="8dp" | |||
android:layout_marginTop="72dp" | |||
android:rotation="70" | |||
app:layout_constraintBottom_toBottomOf="@+id/imageView7" | |||
app:layout_constraintEnd_toEndOf="@+id/imageView7" | |||
app:layout_constraintHorizontal_bias="0.895" | |||
app:layout_constraintStart_toStartOf="@+id/imageView7" | |||
app:layout_constraintTop_toTopOf="@+id/imageView7" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/arrow_left" /> | |||
<ImageView | |||
android:id="@+id/factory" | |||
android:layout_width="85dp" | |||
android:layout_height="142dp" | |||
android:layout_marginEnd="8dp" | |||
android:layout_marginStart="28dp" | |||
android:layout_marginTop="124dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/farm" | |||
app:layout_constraintEnd_toEndOf="@+id/farm" | |||
app:layout_constraintHorizontal_bias="1.0" | |||
app:layout_constraintStart_toStartOf="@+id/farm" | |||
app:layout_constraintTop_toTopOf="@+id/farm" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/factory" /> | |||
<ImageView | |||
android:id="@+id/packaging" | |||
android:layout_width="103dp" | |||
android:layout_height="103dp" | |||
android:layout_marginEnd="64dp" | |||
android:layout_marginTop="52dp" | |||
app:layout_constraintBottom_toBottomOf="@+id/imageView16" | |||
app:layout_constraintEnd_toEndOf="@+id/imageView16" | |||
app:layout_constraintHorizontal_bias="1.0" | |||
app:layout_constraintStart_toStartOf="@+id/imageView16" | |||
app:layout_constraintTop_toTopOf="@+id/imageView16" | |||
app:layout_constraintVertical_bias="0.0" | |||
app:srcCompat="@mipmap/packaging" /> | |||
<Button | |||
android:id="@+id/go_back_to_main" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginBottom="8dp" | |||
android:layout_marginEnd="8dp" | |||
android:layout_marginStart="200dp" | |||
android:layout_marginTop="420dp" | |||
android:text="back to main menu" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:layout_constraintVertical_bias="0.771" /> | |||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,42 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".MainActivity" | |||
tools:layout_editor_absoluteY="81dp"> | |||
<Button | |||
android:id="@+id/info_button" | |||
android:layout_width="297dp" | |||
android:layout_height="159dp" | |||
android:layout_centerHorizontal="true" | |||
android:layout_marginBottom="24dp" | |||
android:text="Get Info" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" /> | |||
<Button | |||
android:id="@+id/scan_button" | |||
android:layout_width="296dp" | |||
android:layout_height="159dp" | |||
android:layout_centerHorizontal="true" | |||
android:layout_marginTop="28dp" | |||
android:text="@string/scan" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<ImageView | |||
android:id="@+id/imageView" | |||
android:layout_width="279dp" | |||
android:layout_height="158dp" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" | |||
app:srcCompat="@mipmap/icon" /> | |||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,185 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
tools:context=".ProductInfo"> | |||
<Button | |||
android:id="@+id/journey" | |||
android:layout_width="179dp" | |||
android:layout_height="90dp" | |||
android:layout_marginBottom="40dp" | |||
android:layout_marginEnd="10dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="Learn More" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintHorizontal_bias="1.0" | |||
app:layout_constraintStart_toStartOf="parent" /> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="16dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/allergens" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="64dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/Calories" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="116dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/cooked" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="168dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/nutrients" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="228dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/BBD" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="288dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/Process" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="348dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<TextView | |||
android:id="@+id/Problems" | |||
android:layout_width="300dp" | |||
android:layout_height="31dp" | |||
android:layout_marginEnd="68dp" | |||
android:layout_marginStart="68dp" | |||
android:layout_marginTop="408dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintStart_toStartOf="parent" | |||
app:layout_constraintTop_toTopOf="parent" /> | |||
<Button | |||
android:id="@+id/button" | |||
android:layout_width="175dp" | |||
android:layout_height="90dp" | |||
android:layout_marginBottom="40dp" | |||
android:layout_marginStart="10dp" | |||
android:lineSpacingExtra="10sp" | |||
android:text="Back to main menu" | |||
android:textColor="@android:color/black" | |||
android:textSize="18sp" | |||
android:typeface="sans" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintHorizontal_bias="0.033" | |||
app:layout_constraintStart_toStartOf="parent" /> | |||
<android.support.constraint.Guideline | |||
android:id="@+id/guideline" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:orientation="horizontal" | |||
app:layout_constraintGuide_begin="20dp" /> | |||
<android.support.constraint.Guideline | |||
android:id="@+id/guideline2" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical" | |||
app:layout_constraintGuide_begin="20dp" /> | |||
</android.support.constraint.ConstraintLayout> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<background android:drawable="@drawable/ic_launcher_background"/> | |||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> | |||
</adaptive-icon> |
@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<background android:drawable="@drawable/ic_launcher_background"/> | |||
<foreground android:drawable="@drawable/ic_launcher_foreground"/> | |||
</adaptive-icon> |
@ -0,0 +1,3 @@ | |||
<resources> | |||
<string name="hello_world">Hello Round World!</string> | |||
</resources> |
@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<resources> | |||
<color name="colorPrimary">#3F51B5</color> | |||
<color name="colorPrimaryDark">#303F9F</color> | |||
<color name="colorAccent">#FF4081</color> | |||
</resources> |
@ -0,0 +1,15 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<resources> | |||
<!-- | |||
Because the window insets on round devices are larger than 15dp, this padding only applies | |||
to square screens. | |||
--> | |||
<dimen name="box_inset_layout_padding">0dp</dimen> | |||
<!-- | |||
This padding applies to both square and round screens. The total padding between the buttons | |||
and the window insets is box_inset_layout_padding (above variable) on square screens and | |||
inner_frame_layout_padding (below variable) on round screens. | |||
--> | |||
<dimen name="inner_frame_layout_padding">5dp</dimen> | |||
</resources> |
@ -0,0 +1,10 @@ | |||
<resources> | |||
<string name="app_name">FoodCloud</string>s | |||
<string name="scan">Scan</string> | |||
<string name="title_activity_info_page">InfoPage</string> | |||
<!-- | |||
This string is used for square devices and overridden by hello_world in | |||
values-round/strings.xml for round devices. | |||
--> | |||
<string name="hello_world">Hello Square World!</string> | |||
</resources> |
@ -0,0 +1,11 @@ | |||
<resources> | |||
<!-- Base application theme. --> | |||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |||
<!-- Customize your theme here. --> | |||
<item name="colorPrimary">@color/colorPrimary</item> | |||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |||
<item name="colorAccent">@color/colorAccent</item> | |||
</style> | |||
</resources> |
@ -0,0 +1,17 @@ | |||
package gq.yigit.foodcloud; | |||
import org.junit.Test; | |||
import static org.junit.Assert.*; | |||
/** | |||
* Example local unit test, which will execute on the development machine (host). | |||
* | |||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | |||
*/ | |||
public class ExampleUnitTest { | |||
@Test | |||
public void addition_isCorrect() { | |||
assertEquals(4, 2 + 2); | |||
} | |||
} |
@ -0,0 +1,27 @@ | |||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |||
buildscript { | |||
repositories { | |||
google() | |||
jcenter() | |||
} | |||
dependencies { | |||
classpath 'com.android.tools.build:gradle:3.1.0' | |||
classpath 'com.google.gms:google-services:4.0.0' | |||
// NOTE: Do not place your application dependencies here; they belong | |||
// in the individual module build.gradle files | |||
} | |||
} | |||
allprojects { | |||
repositories { | |||
google() | |||
jcenter() | |||
} | |||
} | |||
task clean(type: Delete) { | |||
delete rootProject.buildDir | |||
} |
@ -0,0 +1,19 @@ | |||
# Project-wide Gradle settings. | |||
# IDE (e.g. Android Studio) users: | |||
# Gradle settings configured through the IDE *will override* | |||
# any settings specified in this file. | |||
# For more details on how to configure your build environment visit | |||
# http://www.gradle.org/docs/current/userguide/build_environment.html | |||
# Specifies the JVM arguments used for the daemon process. | |||
# The setting is particularly useful for tweaking memory settings. | |||
org.gradle.jvmargs=-Xmx1536m | |||
android.enableAapt2=true | |||
# When configured, Gradle will run in incubating parallel mode. | |||
# This option should only be used with decoupled projects. More details, visit | |||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | |||
# org.gradle.parallel=true |
@ -0,0 +1,6 @@ | |||
#Thu May 31 22:02:24 EET 2018 | |||
distributionBase=GRADLE_USER_HOME | |||
distributionPath=wrapper/dists | |||
zipStoreBase=GRADLE_USER_HOME | |||
zipStorePath=wrapper/dists | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip |
@ -0,0 +1,172 @@ | |||
#!/usr/bin/env sh | |||
############################################################################## | |||
## | |||
## Gradle start up script for UN*X | |||
## | |||
############################################################################## | |||
# Attempt to set APP_HOME | |||
# Resolve links: $0 may be a link | |||
PRG="$0" | |||
# Need this for relative symlinks. | |||
while [ -h "$PRG" ] ; do | |||
ls=`ls -ld "$PRG"` | |||
link=`expr "$ls" : '.*-> \(.*\)$'` | |||
if expr "$link" : '/.*' > /dev/null; then | |||
PRG="$link" | |||
else | |||
PRG=`dirname "$PRG"`"/$link" | |||
fi | |||
done | |||
SAVED="`pwd`" | |||
cd "`dirname \"$PRG\"`/" >/dev/null | |||
APP_HOME="`pwd -P`" | |||
cd "$SAVED" >/dev/null | |||
APP_NAME="Gradle" | |||
APP_BASE_NAME=`basename "$0"` | |||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |||
DEFAULT_JVM_OPTS="" | |||
# Use the maximum available, or set MAX_FD != -1 to use that value. | |||
MAX_FD="maximum" | |||
warn () { | |||
echo "$*" | |||
} | |||
die () { | |||
echo | |||
echo "$*" | |||
echo | |||
exit 1 | |||
} | |||
# OS specific support (must be 'true' or 'false'). | |||
cygwin=false | |||
msys=false | |||
darwin=false | |||
nonstop=false | |||
case "`uname`" in | |||
CYGWIN* ) | |||
cygwin=true | |||
;; | |||
Darwin* ) | |||
darwin=true | |||
;; | |||
MINGW* ) | |||
msys=true | |||
;; | |||
NONSTOP* ) | |||
nonstop=true | |||
;; | |||
esac | |||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | |||
# Determine the Java command to use to start the JVM. | |||
if [ -n "$JAVA_HOME" ] ; then | |||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | |||
# IBM's JDK on AIX uses strange locations for the executables | |||
JAVACMD="$JAVA_HOME/jre/sh/java" | |||
else | |||
JAVACMD="$JAVA_HOME/bin/java" | |||
fi | |||
if [ ! -x "$JAVACMD" ] ; then | |||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | |||
Please set the JAVA_HOME variable in your environment to match the | |||
location of your Java installation." | |||
fi | |||
else | |||
JAVACMD="java" | |||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |||
Please set the JAVA_HOME variable in your environment to match the | |||
location of your Java installation." | |||
fi | |||
# Increase the maximum file descriptors if we can. | |||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | |||
MAX_FD_LIMIT=`ulimit -H -n` | |||
if [ $? -eq 0 ] ; then | |||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | |||
MAX_FD="$MAX_FD_LIMIT" | |||
fi | |||
ulimit -n $MAX_FD | |||
if [ $? -ne 0 ] ; then | |||
warn "Could not set maximum file descriptor limit: $MAX_FD" | |||
fi | |||
else | |||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | |||
fi | |||
fi | |||
# For Darwin, add options to specify how the application appears in the dock | |||
if $darwin; then | |||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | |||
fi | |||
# For Cygwin, switch paths to Windows format before running java | |||
if $cygwin ; then | |||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` | |||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | |||
JAVACMD=`cygpath --unix "$JAVACMD"` | |||
# We build the pattern for arguments to be converted via cygpath | |||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | |||
SEP="" | |||
for dir in $ROOTDIRSRAW ; do | |||
ROOTDIRS="$ROOTDIRS$SEP$dir" | |||
SEP="|" | |||
done | |||
OURCYGPATTERN="(^($ROOTDIRS))" | |||
# Add a user-defined pattern to the cygpath arguments | |||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then | |||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | |||
fi | |||
# Now convert the arguments - kludge to limit ourselves to /bin/sh | |||
i=0 | |||
for arg in "$@" ; do | |||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | |||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | |||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | |||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | |||
else | |||
eval `echo args$i`="\"$arg\"" | |||
fi | |||
i=$((i+1)) | |||
done | |||
case $i in | |||
(0) set -- ;; | |||
(1) set -- "$args0" ;; | |||
(2) set -- "$args0" "$args1" ;; | |||
(3) set -- "$args0" "$args1" "$args2" ;; | |||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; | |||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | |||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | |||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | |||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | |||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | |||
esac | |||
fi | |||
# Escape application args | |||
save () { | |||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | |||
echo " " | |||
} | |||
APP_ARGS=$(save "$@") | |||
# Collect all arguments for the java command, following the shell quoting and substitution rules | |||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | |||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong | |||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then | |||
cd "$(dirname "$0")" | |||
fi | |||
exec "$JAVACMD" "$@" |
@ -0,0 +1,84 @@ | |||
@if "%DEBUG%" == "" @echo off | |||
@rem ########################################################################## | |||
@rem | |||
@rem Gradle startup script for Windows | |||
@rem | |||
@rem ########################################################################## | |||
@rem Set local scope for the variables with windows NT shell | |||
if "%OS%"=="Windows_NT" setlocal | |||
set DIRNAME=%~dp0 | |||
if "%DIRNAME%" == "" set DIRNAME=. | |||
set APP_BASE_NAME=%~n0 | |||
set APP_HOME=%DIRNAME% | |||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | |||
set DEFAULT_JVM_OPTS= | |||
@rem Find java.exe | |||
if defined JAVA_HOME goto findJavaFromJavaHome | |||
set JAVA_EXE=java.exe | |||
%JAVA_EXE% -version >NUL 2>&1 | |||
if "%ERRORLEVEL%" == "0" goto init | |||
echo. | |||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | |||
echo. | |||
echo Please set the JAVA_HOME variable in your environment to match the | |||
echo location of your Java installation. | |||
goto fail | |||
:findJavaFromJavaHome | |||
set JAVA_HOME=%JAVA_HOME:"=% | |||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | |||
if exist "%JAVA_EXE%" goto init | |||
echo. | |||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | |||
echo. | |||
echo Please set the JAVA_HOME variable in your environment to match the | |||
echo location of your Java installation. | |||
goto fail | |||
:init | |||
@rem Get command-line arguments, handling Windows variants | |||
if not "%OS%" == "Windows_NT" goto win9xME_args | |||
:win9xME_args | |||
@rem Slurp the command line arguments. | |||
set CMD_LINE_ARGS= | |||
set _SKIP=2 | |||
:win9xME_args_slurp | |||
if "x%~1" == "x" goto execute | |||
set CMD_LINE_ARGS=%* | |||
:execute | |||
@rem Setup the command line | |||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | |||
@rem Execute Gradle | |||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | |||
:end | |||
@rem End local scope for the variables with windows NT shell | |||
if "%ERRORLEVEL%"=="0" goto mainEnd | |||
:fail | |||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | |||
rem the _cmd.exe /c_ return code! | |||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | |||
exit /b 1 | |||
:mainEnd | |||
if "%OS%"=="Windows_NT" endlocal | |||
:omega |
@ -0,0 +1 @@ | |||
include ':app' |