diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/navi_app/Location.java b/app/src/main/java/com/example/navi_app/Location.java
index f62541e..69bfa26 100644
--- a/app/src/main/java/com/example/navi_app/Location.java
+++ b/app/src/main/java/com/example/navi_app/Location.java
@@ -13,7 +13,13 @@ public class Location implements Serializable {
public String name;
public ArrayList nodes = new ArrayList<>();
- public int computersAvadiable;
+ public String type;
+
+ public String computers;
+ public String workspace;
+ public String food;
+
+
private final String TAG = "LOCATION";
//Location System
@@ -22,11 +28,33 @@ public class Location implements Serializable {
public Location(JSONObject location, LocationSystem currentSystem) {
+ // INIT Current location system
this.currentSystem = currentSystem;
+ // Try INIT location from json
try {
this.name = location.getString("name");
+ this.type = location.getString("type");
+
+ JSONObject locationData = location.getJSONObject("data");
+
+ try{
+ this.computers = locationData.getString("computers");
+ }catch (JSONException e){
+ this.computers = "";
+ }
+ try{
+ this.workspace = locationData.getString("workspace");
+ }catch (JSONException e){
+ this.workspace = "";
+ }
+ try{
+ this.food = locationData.getString("food");
+ }catch (JSONException e){
+ this.food = "";
+ }
+
JSONArray nodesArray = location.getJSONArray("nodes");
for (int i=0; i < nodesArray.length(); i++)
@@ -36,9 +64,13 @@ public class Location implements Serializable {
nodes.add(new Node(nodeJSON, currentSystem));
}
Log.i(TAG, name);
-
} catch (JSONException e) {
e.printStackTrace();
+ this.name = "";
+ this.type = "";
+ this.computers = "";
+ this.workspace = "";
+ this.food = "";
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/navi_app/MainActivity.java b/app/src/main/java/com/example/navi_app/MainActivity.java
index a28493a..6f45262 100644
--- a/app/src/main/java/com/example/navi_app/MainActivity.java
+++ b/app/src/main/java/com/example/navi_app/MainActivity.java
@@ -128,7 +128,7 @@ public class MainActivity extends AppCompatActivity {
}
public void btn_login_Clicked(View view) {
- LocationSystem ls = new LocationSystem("https://gist.githubusercontent.com/dominicegginton/99dc73485e5a1937b2d0bfadd0fa8d0c/raw/7ae81355ff7ddd4339c01cd58f8d5c1262686463/coventryUniNaviData.json");
+ LocationSystem ls = new LocationSystem("https://gist.githubusercontent.com/dominicegginton/99dc73485e5a1937b2d0bfadd0fa8d0c/raw/366c0aa82a74cc03ec0a0f13cf6f1a146c82fa38/coventryUniNaviData.json");
// Create new intent to open new page
Intent intent = new Intent(getBaseContext(), menu.class);
intent.putExtra("location_system", ls);
diff --git a/app/src/main/java/com/example/navi_app/current_location.java b/app/src/main/java/com/example/navi_app/current_location.java
index 8eb64d7..eb5b738 100644
--- a/app/src/main/java/com/example/navi_app/current_location.java
+++ b/app/src/main/java/com/example/navi_app/current_location.java
@@ -11,6 +11,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Handler;
+import android.support.constraint.ConstraintLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
@@ -18,6 +19,7 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -36,7 +38,20 @@ public class current_location extends AppCompatActivity {
TextView txt_location_level;
TextView txt_location_building;
ProgressBar progress_spinner;
-
+
+ ConstraintLayout layout_location_data_type;
+ ImageView img_location_data_type;
+ TextView txt_location_data_type;
+ ConstraintLayout layout_location_data_computers;
+ ImageView img_location_data_computers;
+ TextView txt_location_data_computers;
+ ConstraintLayout layout_location_data_workspaces;
+ ImageView img_location_data_workspaces;
+ TextView txt_location_data_workspaces;
+ ConstraintLayout layout_location_data_food;
+ ImageView img_location_data_food;
+ TextView txt_location_data_food;
+
//Location System Objects
private LocationSystem ls;
@@ -66,6 +81,19 @@ public class current_location extends AppCompatActivity {
txt_location_building = (TextView) findViewById(R.id.txt_location_Building);
progress_spinner = (ProgressBar) findViewById(R.id.progress_spinner);
+ layout_location_data_type = (ConstraintLayout) findViewById(R.id.layout_location_data_type);
+ img_location_data_type = (ImageView) findViewById(R.id.img_location_data_type);
+ txt_location_data_type = (TextView) findViewById(R.id.txt_location_data_type);
+ layout_location_data_computers = (ConstraintLayout) findViewById(R.id.layout_location_data_computers);
+ img_location_data_computers = (ImageView) findViewById(R.id.img_location_data_computer);
+ txt_location_data_computers = (TextView) findViewById(R.id.txt_location_data_computers);
+ layout_location_data_workspaces = (ConstraintLayout) findViewById(R.id.layout_location_data_workspace);
+ img_location_data_workspaces = (ImageView) findViewById(R.id.img_location_data_workspaces);
+ txt_location_data_workspaces = (TextView) findViewById(R.id.txt_location_data_workspaces);
+ layout_location_data_food = (ConstraintLayout) findViewById(R.id.layout_location_data_food);
+ img_location_data_food = (ImageView) findViewById(R.id.img_location_data_food);
+ txt_location_data_food = (TextView) findViewById(R.id.txt_location_data_food);
+
// update Current Location
displayCurrentLocation();
}
@@ -175,6 +203,19 @@ public class current_location extends AppCompatActivity {
txt_location_name.setVisibility(View.GONE);
txt_location_level.setVisibility(View.GONE);
txt_location_building.setVisibility(View.GONE);
+
+ layout_location_data_type.setVisibility(View.GONE);
+ //img_location_data_type.setVisibility(View.GONE);
+ //txt_location_data_type.setVisibility(View.GONE);
+ layout_location_data_computers.setVisibility(View.GONE);
+ //img_location_data_computers.setVisibility(View.GONE);
+ //txt_location_data_computers.setVisibility(View.GONE);
+ layout_location_data_workspaces.setVisibility(View.GONE);
+ //img_location_data_workspaces.setVisibility(View.GONE);
+ //txt_location_data_workspaces.setVisibility(View.GONE);
+ layout_location_data_food.setVisibility(View.GONE);
+ //img_location_data_food.setVisibility(View.GONE);
+ //txt_location_data_food.setVisibility(View.GONE);
scan();
// Create new delay handler of 10 seconds
@@ -185,13 +226,49 @@ public class current_location extends AppCompatActivity {
// Get current location object
Location currentLocation = ls.getCurrentLocation(scannedNodes);
- // Check for null location
+ // Check for null locations
if (currentLocation != null) {
+ // End Spinner
+ progress_spinner.setVisibility(View.GONE);
// Output location details to UI
txt_location_building.setText(ls.getCurrentBuilding(currentLocation).name);
txt_location_level.setText(ls.getCurrentLevel(currentLocation).name);
txt_location_name.setText(currentLocation.name);
+ txt_location_name.setVisibility(View.VISIBLE);
+ txt_location_level.setVisibility(View.VISIBLE);
+ txt_location_building.setVisibility(View.VISIBLE);
+
+ txt_location_data_type.setText(currentLocation.type);
+ //txt_location_data_type.setVisibility(View.VISIBLE);
+ Log.i("computers", currentLocation.computers);
+ if(currentLocation.type.equals("Classroom") | currentLocation.type.equals("Lecture")) {
+ img_location_data_type.setImageResource(R.drawable.icon_presenter);
+ } else if (currentLocation.type.equals("Reception")) {
+ img_location_data_type.setImageResource(R.drawable.icon_reception);
+ } else if (currentLocation.type.equals("Walkway")) {
+ img_location_data_type.setImageResource(R.drawable.icon_path);
+ } else {
+ img_location_data_type.setImageResource(R.drawable.icon_building);
+ }
+ //img_location_data_type.setVisibility(View.VISIBLE);
+ layout_location_data_type.setVisibility(View.VISIBLE);
+
+ if(!currentLocation.computers.equals("")) {
+ txt_location_data_computers.setText(currentLocation.computers);
+ img_location_data_computers.setImageResource(R.drawable.icon_computer);
+ layout_location_data_computers.setVisibility(View.VISIBLE);
+ }
+ if(!currentLocation.workspace.equals("")) {
+ txt_location_data_workspaces.setText(currentLocation.workspace);
+ img_location_data_workspaces.setImageResource(R.drawable.icon_table);
+ layout_location_data_workspaces.setVisibility(View.VISIBLE);
+ }
+ if(!currentLocation.food.equals("")) {
+ txt_location_data_food.setText(currentLocation.food);
+ img_location_data_food.setImageResource(R.drawable.icon_food);
+ layout_location_data_food.setVisibility(View.VISIBLE);
+ }
// Log Nodes that belong to the location
String output = currentLocation.name + " - {";
@@ -202,10 +279,6 @@ public class current_location extends AppCompatActivity {
Log.i("Current Location", output);
- progress_spinner.setVisibility(View.GONE);
- txt_location_name.setVisibility(View.VISIBLE);
- txt_location_level.setVisibility(View.VISIBLE);
- txt_location_building.setVisibility(View.VISIBLE);
}else {
// cant get current location
// Create Alert Dialog
diff --git a/app/src/main/res/drawable-v24/icon_building.png b/app/src/main/res/drawable-v24/icon_building.png
new file mode 100644
index 0000000..e16f60c
Binary files /dev/null and b/app/src/main/res/drawable-v24/icon_building.png differ
diff --git a/app/src/main/res/drawable-v24/icon_path.png b/app/src/main/res/drawable-v24/icon_path.png
new file mode 100644
index 0000000..1a448fd
Binary files /dev/null and b/app/src/main/res/drawable-v24/icon_path.png differ
diff --git a/app/src/main/res/drawable-v24/icon_presenter.png b/app/src/main/res/drawable-v24/icon_presenter.png
new file mode 100644
index 0000000..17a7a0c
Binary files /dev/null and b/app/src/main/res/drawable-v24/icon_presenter.png differ
diff --git a/app/src/main/res/drawable-v24/icon_reception.png b/app/src/main/res/drawable-v24/icon_reception.png
new file mode 100644
index 0000000..5f5f779
Binary files /dev/null and b/app/src/main/res/drawable-v24/icon_reception.png differ
diff --git a/app/src/main/res/layout/activity_current_location.xml b/app/src/main/res/layout/activity_current_location.xml
index 4f889ed..fe878f5 100644
--- a/app/src/main/res/layout/activity_current_location.xml
+++ b/app/src/main/res/layout/activity_current_location.xml
@@ -117,58 +117,147 @@
app:layout_constraintTop_toTopOf="parent" />
-
-
-
+
+
+
+
+
+
+
-
-
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/layout_location_data_type">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+