diff --git a/FoodCloud/.idea/caches/build_file_checksums.ser b/FoodCloud/.idea/caches/build_file_checksums.ser index 71eed71..3bd2d98 100644 Binary files a/FoodCloud/.idea/caches/build_file_checksums.ser and b/FoodCloud/.idea/caches/build_file_checksums.ser differ diff --git a/FoodCloud/app/src/main/AndroidManifest.xml b/FoodCloud/app/src/main/AndroidManifest.xml index aa8c554..af9bbff 100644 --- a/FoodCloud/app/src/main/AndroidManifest.xml +++ b/FoodCloud/app/src/main/AndroidManifest.xml @@ -36,7 +36,11 @@ - + + \ No newline at end of file diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java index f42ee61..761467d 100644 --- a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java +++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/LearnMore.java @@ -96,6 +96,14 @@ public class LearnMore extends AppCompatActivity implements View.OnClickListener Intent i = new Intent(LearnMore.this, PackagePop.class); i.putExtra("key", process.get("Packaging").toString()); startActivity(i); + } else if (v.getId() == R.id.trans1) { + Intent i = new Intent(LearnMore.this, PopTrans1.class); + i.putExtra("key", process.get("Transport1").toString()); + startActivity(i); + } else if (v.getId() == R.id.trans2) { + Intent i = new Intent(LearnMore.this, PopTrans2.class); + i.putExtra("key", process.get("Transport2").toString()); + startActivity(i); } }catch(JSONException e){ Log.d(TAG,"An error occured with json"); diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans1.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans1.java index d3f78f3..b2489f9 100644 --- a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans1.java +++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans1.java @@ -1,13 +1,79 @@ package gq.yigit.foodcloud; +import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.widget.ImageView; +import android.widget.TextView; -public class PopTrans1 extends AppCompatActivity { +import org.json.JSONException; +import org.json.JSONObject; +import static android.support.constraint.Constraints.TAG; + +public class PopTrans1 extends Activity { + public TextView duration; + public TextView from; + public TextView to; + public TextView stop; + public TextView cond; + public TextView safe_txt; + public ImageView safe_img; + public boolean safe; + public boolean stop_cond; + public boolean cond_cond; + public JSONObject json_trans1; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pop_trans1); + duration = (TextView)findViewById(R.id.duration); + from = (TextView)findViewById(R.id.from); + safe_txt = (TextView)findViewById(R.id.safe_txt); + to = (TextView)findViewById(R.id.to); + stop = (TextView)findViewById(R.id.stop); + cond = (TextView)findViewById(R.id.cond); + safe_img = (ImageView) findViewById(R.id.safe_img); + + Bundle extras = getIntent().getExtras(); + if (extras != null) { + try { + json_trans1 = new JSONObject(extras.getString("key")); + duration.setText(json_trans1.get("Duration").toString() + " hours"); + safe = (boolean)json_trans1.get("Problematic"); + to.setText(json_trans1.get("Moved to,from").toString().split("-")[1]); + from.setText(json_trans1.get("Moved to,from").toString().split("-")[0]); + stop_cond = (boolean)json_trans1.get("Stopped"); + cond_cond = (boolean)json_trans1.get("Condition"); + }catch(JSONException e){ + Log.d(TAG,"An error occured with json!"); + } + } + if(safe){ + safe_img.setImageResource(R.mipmap.warning); + safe_txt.setText("Warning, there was an error in the harvestment of this product. We recommend that you don't consume it!"); + }else{ + safe_img.setImageResource(R.mipmap.check); + safe_txt.setText("This product did not have any problems during harvesting. It is safe to consume!"); + } + if(stop_cond){ + stop.setText("Yes"); + }else{ + stop.setText("No"); + } + if(cond_cond){ + cond.setText("Yes"); + }else{ + cond.setText("No"); + } + + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm); + int width = dm.widthPixels; + int height = dm.heightPixels; + getWindow().setLayout((int)(width*0.8), (int)(height*0.72)); } } diff --git a/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans2.java b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans2.java new file mode 100644 index 0000000..f8a4e44 --- /dev/null +++ b/FoodCloud/app/src/main/java/gq/yigit/foodcloud/PopTrans2.java @@ -0,0 +1,79 @@ +package gq.yigit.foodcloud; + +import android.app.Activity; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.widget.ImageView; +import android.widget.TextView; + +import org.json.JSONException; +import org.json.JSONObject; + +import static android.support.constraint.Constraints.TAG; + +public class PopTrans2 extends Activity { + public TextView duration; + public TextView from; + public TextView to; + public TextView stop; + public TextView cond; + public TextView safe_txt; + public ImageView safe_img; + public boolean safe; + public boolean stop_cond; + public boolean cond_cond; + public JSONObject json_trans2; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_pop_trans2); + duration = (TextView)findViewById(R.id.duration); + from = (TextView)findViewById(R.id.from); + safe_txt = (TextView)findViewById(R.id.safe_txt); + to = (TextView)findViewById(R.id.to); + stop = (TextView)findViewById(R.id.stop); + cond = (TextView)findViewById(R.id.cond); + safe_img = (ImageView) findViewById(R.id.safe_img); + + Bundle extras = getIntent().getExtras(); + if (extras != null) { + try { + json_trans2 = new JSONObject(extras.getString("key")); + duration.setText(json_trans2.get("Duration").toString() + " hours"); + safe = (boolean)json_trans2.get("Problematic"); + to.setText(json_trans2.get("Moved to,from").toString().split("-")[1]); + from.setText(json_trans2.get("Moved to,from").toString().split("-")[0]); + stop_cond = (boolean)json_trans2.get("Stopped"); + cond_cond = (boolean)json_trans2.get("Condition"); + }catch(JSONException e){ + Log.d(TAG,"An error occured with json!"); + } + } + if(safe){ + safe_img.setImageResource(R.mipmap.warning); + safe_txt.setText("Warning, there was an error in the harvestment of this product. We recommend that you don't consume it!"); + }else{ + safe_img.setImageResource(R.mipmap.check); + safe_txt.setText("This product did not have any problems during harvesting. It is safe to consume!"); + } + if(stop_cond){ + stop.setText("Yes"); + }else{ + stop.setText("No"); + } + if(cond_cond){ + cond.setText("Yes"); + }else{ + cond.setText("No"); + } + + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm); + int width = dm.widthPixels; + int height = dm.heightPixels; + getWindow().setLayout((int)(width*0.8), (int)(height*0.72)); + } +} diff --git a/FoodCloud/app/src/main/res/layout/activity_pop_trans1.xml b/FoodCloud/app/src/main/res/layout/activity_pop_trans1.xml index c2d61ed..fd0e6dd 100644 --- a/FoodCloud/app/src/main/res/layout/activity_pop_trans1.xml +++ b/FoodCloud/app/src/main/res/layout/activity_pop_trans1.xml @@ -5,6 +5,185 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".PopTrans1" - android:background="@drawable/process_bg"> + android:background="@drawable/process_bg"> + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FoodCloud/app/src/main/res/layout/activity_pop_trans2.xml b/FoodCloud/app/src/main/res/layout/activity_pop_trans2.xml new file mode 100644 index 0000000..7e98f42 --- /dev/null +++ b/FoodCloud/app/src/main/res/layout/activity_pop_trans2.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file