From efbbe7124bd8b02239f3eda80ab566905d5ef8a6 Mon Sep 17 00:00:00 2001 From: RemoMeijer Date: Tue, 12 Jan 2021 13:52:02 +0100 Subject: [PATCH] Route detail added --- app/src/main/assets/routes.json | 4 +-- .../fragments/LocationDetailFragment.java | 4 +-- .../fragments/RouteDetailFragment.java | 13 ++++++-- .../res/layout/fragment_location_detail.xml | 1 + .../main/res/layout/fragment_route_detail.xml | 30 ++++++++++++------- app/src/main/res/values-nl/strings.xml | 4 +++ app/src/main/res/values/strings.xml | 3 ++ 7 files changed, 41 insertions(+), 18 deletions(-) diff --git a/app/src/main/assets/routes.json b/app/src/main/assets/routes.json index 5619f4f..ddf291a 100644 --- a/app/src/main/assets/routes.json +++ b/app/src/main/assets/routes.json @@ -1,6 +1,6 @@ [ { - "name": "Evenementen Route", + "name": "Event Route", "locations": [ { "name": "Escaping Breda: Escape Room Games Boschstraat 114", @@ -39,7 +39,7 @@ "imageURL": "escaping_room" }, { - "name": "Hongerige Route", + "name": "Hungry Route", "locations": [ { "name":"Subway Karnemelkstraat 10 A, 1", diff --git a/app/src/main/java/com/a1/nextlocation/fragments/LocationDetailFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/LocationDetailFragment.java index 3d025c1..88b9eb2 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/LocationDetailFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/LocationDetailFragment.java @@ -54,7 +54,8 @@ public class LocationDetailFragment extends Fragment { currentDistanceToLocation = Location.getDistance(Data.INSTANCE.getLocation().getLatitude(), Data.INSTANCE.getLocation().getLongitude(), this.location.getLat(), this.location.getLong()); } - String detailText = ""; + //Adds distance text from the current distance of the user to the opened location + String detailText; if(getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)){ if(currentDistanceToLocation > 1609) detailText = location.getDescription() + String.format("%.3f",currentDistanceToLocation * 0.000621371192) + "mi"; @@ -66,7 +67,6 @@ public class LocationDetailFragment extends Fragment { else detailText = location.getDescription() + currentDistanceToLocation + "m"; } - this.detailText = view.findViewById(R.id.detail_location_text); this.detailText.setText(detailText); diff --git a/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java index 921329a..c3f36b0 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java @@ -3,6 +3,7 @@ package com.a1.nextlocation.fragments; import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; +import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -44,7 +45,7 @@ public class RouteDetailFragment extends Fragment { } - @SuppressLint("SetTextI18n") + @SuppressLint({"SetTextI18n", "DefaultLocale"}) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_route_detail, container, false); @@ -60,8 +61,14 @@ public class RouteDetailFragment extends Fragment { TextView routeName = view.findViewById(R.id.route_title); routeName.setText(this.route.getName()); - TextView routeDetailText = view.findViewById(R.id.reoute_detail_tekst); - routeDetailText.setText(this.route.getDescription()); + TextView routeDetailText = view.findViewById(R.id.route_detail_tekst); + StringBuilder locations = new StringBuilder(); + for(Location location : this.route.getLocations()){ + locations.append("
•").append(location.getName()); + } + String detailText = this.route.getDescription() + "

" + getResources().getString(R.string.following_locations) + "" + locations + "

" + getResources().getString(R.string.start_location) + ": " + route.getLocations().get(0).getName() + "
" + "" + getResources().getString(R.string.end_location) + ": " + route.getLocations().get(route.getLocations().size()-1).getName(); + routeDetailText.setText(Html.fromHtml(detailText)); + TextView totalDistance = view.findViewById(R.id.total_distance); String distance_tekst = getResources().getString(R.string.total_distance_route); diff --git a/app/src/main/res/layout/fragment_location_detail.xml b/app/src/main/res/layout/fragment_location_detail.xml index a89a336..3a68b38 100644 --- a/app/src/main/res/layout/fragment_location_detail.xml +++ b/app/src/main/res/layout/fragment_location_detail.xml @@ -46,6 +46,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/secondaryColour" + android:layout_marginHorizontal="20dp" android:text="" /> diff --git a/app/src/main/res/layout/fragment_route_detail.xml b/app/src/main/res/layout/fragment_route_detail.xml index 3eb21d2..bc35974 100644 --- a/app/src/main/res/layout/fragment_route_detail.xml +++ b/app/src/main/res/layout/fragment_route_detail.xml @@ -37,19 +37,27 @@ android:id="@+id/route_detail_image" app:layout_constraintTop_toBottomOf="@id/route_detail_back_button" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintBottom_toTopOf="@id/reoute_detail_tekst" /> + app:layout_constraintEnd_toEndOf="parent"/> - + app:layout_constraintEnd_toEndOf="parent" + > + + + +