33 Commits

Author SHA1 Message Date
SemvdH
04552932d9 Merge pull request #5 from SemvdH/develop
Develop
2021-01-14 11:55:22 +01:00
Sem van der Hoeven
7c0b57aa01 hehe 2021-01-14 11:13:23 +01:00
Robin Koedood
eae347844a Totale route tijd 2021-01-14 11:03:54 +01:00
Robin Koedood
9a746a1351 Radius big 2021-01-14 11:00:50 +01:00
Sem van der Hoeven
ad4583640c fixie 2021-01-14 10:52:39 +01:00
Sem van der Hoeven
d0ce399627 Merge branch 'develop' of https://github.com/SemvdH/Next-Location into develop 2021-01-14 10:49:04 +01:00
Sem van der Hoeven
f7691d62fe added visited locations in route 2021-01-14 10:48:52 +01:00
Robin Koedood
55b5b058f1 Icon bigger 2021-01-14 10:39:24 +01:00
Robin Koedood
e8ea9f7982 Toast vertaald 2021-01-14 10:36:49 +01:00
Sem van der Hoeven
018de5688e Merge branch 'develop' of https://github.com/SemvdH/Next-Location into develop 2021-01-14 10:28:19 +01:00
Sem van der Hoeven
53ea394ef5 fixed locatiooooons 2021-01-14 10:28:11 +01:00
Bart
9dbbb80594 fixed navbar update on backbutton clicked 2021-01-14 10:23:20 +01:00
Sem van der Hoeven
391c0729e4 Merge branch 'develop' of https://github.com/SemvdH/Next-Location into develop 2021-01-14 10:16:25 +01:00
Sem van der Hoeven
24a4d344d7 added location marker for visited 2021-01-14 10:16:09 +01:00
Bart
e19c15428d Edited refresh, no more visible reloading navbar 2021-01-14 10:03:47 +01:00
Sem van der Hoeven
158ddac964 Merge branch 'develop' of https://github.com/SemvdH/Next-Location into develop 2021-01-12 16:40:31 +01:00
Sem van der Hoeven
43c3060f1e color change 2021-01-12 16:40:24 +01:00
RemoMeijer
de11e59db1 Fixed total distance bug 2021-01-12 16:34:27 +01:00
Robin Koedood
036278f829 Merge remote-tracking branch 'origin/develop' into develop 2021-01-12 15:30:42 +01:00
Robin Koedood
8dc6414464 Merge remote-tracking branch 'origin/develop' into develop 2021-01-12 15:30:37 +01:00
Robin Koedood
231bef098d added extra route 2021-01-12 15:30:33 +01:00
Sem van der Hoeven
638198450e add extra distance check 2021-01-12 15:30:30 +01:00
Sem van der Hoeven
57edff604e Merge branch 'develop' into ButtonFix 2021-01-12 15:28:49 +01:00
Sem van der Hoeven
04defe4643 0,0 fix 2021-01-12 15:28:26 +01:00
RemoMeijer
02c2981d58 Fixed button 2021-01-12 15:27:46 +01:00
Bipin
209e3f3681 Merge branch 'CosmeticFixes' into develop 2021-01-12 15:11:18 +01:00
Bart
27a7feb05a Merge branch 'saveTimeMA8' into develop 2021-01-12 15:04:05 +01:00
Bart
6edcd7b74f Total time walked gets saved and loaded 2021-01-12 15:03:46 +01:00
RemoMeijer
5587c318d0 Fixed start route button 2021-01-12 15:02:12 +01:00
Sem van der Hoeven
9e2144bd08 Merge branch 'develop' into routeFragmentDetail 2021-01-12 14:57:28 +01:00
RemoMeijer
d80f23ff82 fixed colours 2021-01-12 14:55:59 +01:00
RemoMeijer
a7495d24ad Route displays expected time 2021-01-12 14:43:07 +01:00
RemoMeijer
5162dab0ff Fixed colors 2021-01-12 14:18:17 +01:00
20 changed files with 261 additions and 55 deletions

View File

@@ -88,5 +88,40 @@
"totalTime": 342342,
"description": "Met deze route bezoekt u alle snackbars en restaurants in het centrum van Breda!",
"imageURL": "kees_kroket"
},
{
"name": "Historische Route",
"locations": [
{
"name":"Koningin Wilhelmina Paviljoen Kraanstraat 4b",
"coordinates":"51.59040026960037, 4.775767751364238",
"description":"Koningin Wilhelmina Paviljoen is een bouwwerk in Breda Centrum in Breda. Het behoort tot de Koninklijke Militaire Academie (KMA) en bezit de status van rijksmonument. Het staat aan het Kasteelplein 15, vlak voor het Kasteel van Breda. Het ligt met de voorgevel aan de westkant van de oprijlaan van het kasteel, met de lange rechterzijgevel aan de kasteelgracht en de lange linkerzijgevel aan de Cingelstraat.\n\nAdres:\tKraanstraat 4b\nOpeningstijden:\tdi 11:00-16:00\nTelefoon:\t-\nAfstand tot: ",
"imageUrl":"koningin_wilhelimna_paviljoen",
"iconUrl": "building_icon"
},
{
"name":"Hercules en de Nemeïsche leeuw",
"coordinates":"51.59120082440261, 4.777904512729459",
"description":"Het beeld toont Hercules met de huid van de Nemeïsche leeuw. Herakles of Hercules is een figuur uit de Griekse mythologie. Hij was een Griekse heros en werd beroemd om de 12 moeilijke werken die hij uitvoerde in opdracht van koning Eurystheus. Het beeld maakt onderdeel uit van 17 anderen zandstenen beelden die Willem III tussen 1670 en 1686 kocht. De beelden stonden verdeeld over grasperken in het Valkenberg park.\nHercules is het enige originele beeld dat overgebleven is.\n\nAdres:\t4811 XJ Breda\nOpeningstijden:\t-\nTelefoon:\t14 076\nAfstand tot: ",
"imageUrl":"hercules_park_valkenburg",
"iconUrl": "statue_icon"
},
{
"name":"Nassau-Baroniemonument - 1905 - Pierre Cuypers Delpratsingel 1",
"coordinates":"51.59249639550226, 4.779742259785807",
"description":"Het Baroniemonument of Nassau-Baroniemonument is een beeld van de Nederlandse architect Pierre Cuypers. Het staat in het Park Valkenberg in Breda. Het monument werd geplaatst ter herinnering aan de 500-jarige band (1904) tussen Breda en het huis Oranje-Nassau. In 1404 werd Engelbrecht I van Nassau-Siegen gehuldigd als heer van Breda.\n\nAdres:\tDelpratsingel 1\nOpeningstijden:\t-\nTelefoon:\t14 076\nAfstand tot: ",
"imageUrl":"nassau_baroniemonument",
"iconUrl": "statue_icon"
},
{
"name":"De Belcrum Watertoren (1935) Speelhuislaan 158",
"coordinates":"51.60052702557225, 4.7689948674496145",
"description":"De watertoren in de Belcrum in Breda is een industrieel monument uit het interbellum. De toren is de thuisbasis voor SOAB adviseurs voor woning en leefomgeving en onderstreept de missie van ons bureau. De toren hoort bij de Belcrum. Als landmark en als onderdak voor activiteiten. Zo vierden de Belcrummers hun 400 jaar bestaan in de toren en worden lunches met rondleiding op hoog niveau georganiseerd. Kijken en proeven.\n\nAdres:\tSpeelhuislaan 158\nOpeningstijden:\t08:30-18:00\nTelefoon:\t076 521 3080\nAfstand tot: ",
"imageUrl":"belcrum_watertoren",
"iconUrl": "building_icon"
}
],
"description": "Met deze route kan je de historische punten ontdekken in het centrum van Breda",
"imageURL": "hercules_park_valkenburg"
}
]

View File

@@ -33,8 +33,6 @@
"imageUrl": "het_klooster_breda"
}
],
"totalDistance": 1073.0,
"totalTime": 342342,
"description": "This route will show you different and fun events scattered all around Breda! Try the escape rooms, an event at the dome or a fun party at MEZZ! With this route you walk past them all!",
"imageURL": "escaping_room"
},
@@ -84,9 +82,41 @@
"imageUrl": "de_boter_hal"
}
],
"totalDistance": 955.0,
"totalTime": 342342,
"description": "With this route you can visit all snackbars and restaurants in the centre of Breda!",
"imageURL": "kees_kroket"
},
{
"name": "Historical Route",
"locations": [
{
"name":"Koningin Wilhelmina Paviljoen Kraanstraat 4b",
"coordinates":"51.59040026960037, 4.775767751364238",
"description":"Queen Wilhelmina Pavilion is a building in Breda Center in Breda. It belongs to the Royal Military Academy (KMA) and has the status of a national monument. It is located at Kasteelplein 15, just in front of Breda Castle. the west side of the driveway of the castle, with the long right side wall on the castle moat and the long left side wall on the Cingelstraat.\n\nAdress:\tKraanstraat 4b\nOpening hours:\tdi 11:00-16:00\nPhone:\t-\nDistance to: ",
"imageUrl":"koningin_wilhelimna_paviljoen",
"iconUrl": "building_icon"
},
{
"name":"Hercules en de Nemeïsche leeuw",
"coordinates":"51.59120082440261, 4.777904512729459",
"description":"The statue shows Hercules with the skin of the Nemean lion. Heracles or Hercules is a figure from Greek mythology. He was a Greek hero and became famous for the 12 difficult works he performed at the behest of King Eurystheus. The statue is part of the 17 other sandstone statues that Willem III bought between 1670 and 1686. The statues were spread over lawns in the Valkenberg park.\nHercules is the only original statue that remains.\n\nAdress:\t4811 XJ Breda\nOpening hours:\t-\nPhone:\t14 076\nDistance to: ",
"imageUrl":"hercules_park_valkenburg",
"iconUrl": "statue_icon"
},{
"name":"Nassau-Baroniemonument - 1905 - Pierre Cuypers Delpratsingel 1",
"coordinates":"51.59249639550226, 4.779742259785807",
"description":"The Baroniemonument or Nassau-Baroniemonument is a statue of the Dutch architect Pierre Cuypers. It is located in Park Valkenberg in Breda. The monument was placed in memorial of the 500-year bond (1904) between Breda and the Oranje-Nassau house. In 1404 Engelbrecht I of Nassau-Siegen was honored as lord of Breda.\n\nAdress:\tDelpratsingel 1\nOpening hours:\t-\nPhone:\t14 076\nDistance to: ",
"imageUrl":"nassau_baroniemonument",
"iconUrl": "statue_icon"
},
{
"name":"De Belcrum Watertoren (1935) Speelhuislaan 158",
"coordinates":"51.60052702557225, 4.7689948674496145",
"description":"The water tower in the Belcrum in Breda is an industrial monument from the interwar period. The tower is the home base for SOAB advisers for housing and living environments and underlines the mission of our office. The tower is part of the Belcrum. As a landmark and as a shelter for activities. For example, the Belcrummers celebrated their 400th anniversary in the tower, and lunches with a guided tour are organized at a high level. Watch and taste.\n\nAdress:\tSpeelhuislaan 158\nOpening hours:\t08:30-18:00\nPhone:\t076 521 3080\nDistance to: ",
"imageUrl":"belcrum_watertoren",
"iconUrl": "building_icon"
}
],
"description": "With this route you can visit some historic points in the centre of Breda!",
"imageURL": "hercules_park_valkenburg"
}
]

View File

@@ -130,9 +130,10 @@ public class MainActivity extends AppCompatActivity implements Refreshable {
*/
@Override
public void refreshAndNavigateTo(int id) {
bottomNav.getMenu().clear();
bottomNav.inflateMenu(R.menu.navmenu);
bottomNav.setSelectedItemId(id);
this.setContentView(R.layout.activity_main);
BottomNavigationView navigationView = (BottomNavigationView) this.findViewById(R.id.navigation_bar);
navigationView.setSelectedItemId(id);
navigationView.setOnNavigationItemSelectedListener(navListener);
}
private final View.OnClickListener onInfoClickListener = new View.OnClickListener() {

View File

@@ -2,18 +2,23 @@ package com.a1.nextlocation.data;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.a1.nextlocation.recyclerview.LocationListManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
/**
* singleton to keep track of different global data
*/
public enum Data {
INSTANCE;
private final String TAG = Data.class.getCanonicalName();
private double distanceTraveled = 0;
private int locationsVisited = 0;
private long totalTime = 0;
@@ -63,6 +68,9 @@ public enum Data {
public void addTimeWalked(long time) {
totalTime += time;
editor.putLong("timeWalked", totalTime);
editor.apply();
}
public double getDistanceTraveled() {
@@ -99,14 +107,43 @@ public enum Data {
String json = context.getSharedPreferences("Data", Context.MODE_PRIVATE).getString("visitedNames", "[]");
Type type = new TypeToken<ArrayList<String>>() {}.getType();
visitedNames = new Gson().fromJson(json, type);
Log.i(TAG, "loadAndGetVisitedNamesList: visited names: " + Arrays.toString(visitedNames.toArray()));
return visitedNames;
}
public void load(){
SharedPreferences prefs = context.getSharedPreferences("Data", Context.MODE_PRIVATE);
this.editor = prefs.edit();
Data.INSTANCE.addDistance(Double.parseDouble(prefs.getString("distanceTraveled", "0")));
this.distanceTraveled = (Double.parseDouble(prefs.getString("distanceTraveled", "0")));
this.locationsVisited = loadAndGetVisitedNamesList().size();
syncLocationObjectsWithList();
this.totalTime = prefs.getLong("timeWalked", 0);
}
/**
* sync the visited boolean for location objects with the received list
*/
private void syncLocationObjectsWithList() {
for (Location l : LocationListManager.INSTANCE.getLocationList()) {
if (visitedNames.contains(l.getName())) l.setVisited(true);
}
}
/**
* clears the visited locations
*/
public void clearVisitedLocations() {
visitedNames.clear();
locationsVisited = 0;
for (Location l : LocationListManager.INSTANCE.getLocationList()) {
l.setVisited(false);
}
}
public boolean isVisited(Location location) {
return this.visitedNames.contains(location.getName());
}
public android.location.Location getLocation() {

View File

@@ -81,7 +81,6 @@ public class Route implements Parcelable {
public int getTotalTime() {
return totalTime;
}
@@ -113,4 +112,13 @@ public class Route implements Parcelable {
public void setDescription(String description) {
this.description = description;
}
public void setLocationVisited(Location location) {
for (Location l : this.locations) {
if (l.getName().equals(location.getName())) {
l.setVisited(true);
break;
}
}
}
}

View File

@@ -64,6 +64,14 @@ public enum RouteHandler {
Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime);
}
this.currentRoute = route;
// sync the visited locations with the route
for (Location l : this.currentRoute.getLocations()) {
if (Data.INSTANCE.isVisited(l)) {
this.currentRoute.setLocationVisited(l);
}
}
setFollowingRoute(true);
startedTime = System.currentTimeMillis();
}

View File

@@ -5,7 +5,6 @@ import android.Manifest;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.location.Location;
@@ -25,7 +24,6 @@ import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Data;
@@ -92,7 +90,7 @@ public class HomeFragment extends Fragment implements LocationListener {
this.imageButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment();
if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
});
// set up the route stop button
@@ -151,7 +149,7 @@ public class HomeFragment extends Fragment implements LocationListener {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initializer = new GeofenceInitalizer(requireContext(),requireActivity());
initializer = new GeofenceInitalizer(requireContext(), requireActivity());
initMap(view);
}
@@ -208,7 +206,7 @@ public class HomeFragment extends Fragment implements LocationListener {
if (currentLocation == null) currentLocation = location;
if (location != null) {
GeoPoint start = new GeoPoint(location.getLatitude(), location.getLongitude());
GeoPoint start = new GeoPoint(currentLocation.getLatitude(), currentLocation.getLongitude());
mapController.setCenter(start);
}
@@ -229,7 +227,6 @@ public class HomeFragment extends Fragment implements LocationListener {
}
/**
* displays the route that is currently being followed as a red line
*/
@@ -261,13 +258,22 @@ public class HomeFragment extends Fragment implements LocationListener {
initializer.removeGeoFences();
final ArrayList<OverlayItem> items = new ArrayList<>(locations.size());
// marker icon
Drawable marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24);
marker.setAlpha(255);
marker.setTint(getResources().getColor(R.color.secondaryColour));
// add all locations to the overlay itemss
for (com.a1.nextlocation.data.Location location : locations) {
OverlayItem item = new OverlayItem(location.getName(), location.getDescription(), location.convertToGeoPoint());
Drawable marker = null;
if (location.isVisited()) {
Log.d(TAG, "addLocations: location " + location.getName() + " is visited");
marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24);
marker.setAlpha(255);
marker.setTint(getResources().getColor(R.color.red));
} else {
Log.d(TAG, "addLocations: location " + location.getName() + " is not visited");
marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24_2);
marker.setAlpha(255);
marker.setTint(getResources().getColor(R.color.secondaryColour));
}
item.setMarker(marker);
items.add(item);
}
@@ -313,12 +319,14 @@ public class HomeFragment extends Fragment implements LocationListener {
mapView.getOverlays().add(allLocationsOverlay);
Log.d(TAG, "addLocations: successfully added locations");
mapView.invalidate();
addGeofences(locations);
}
/**
* adds the geofences for the currently active locations
*
* @param locations the locations to add geofences for
*/
private void addGeofences(List<com.a1.nextlocation.data.Location> locations) {
@@ -363,7 +371,7 @@ public class HomeFragment extends Fragment implements LocationListener {
if (currentLocation != null) {
double distance = currentLocation.distanceTo(location); // in meters
// can't walk 100 meters in a few seconds
if (distance < 100) {
if (distance < 100 && distance > 0.1) {
Data.INSTANCE.addDistance(distance);
Data.INSTANCE.setLocation(location);
}
@@ -395,9 +403,9 @@ public class HomeFragment extends Fragment implements LocationListener {
}
public void onLocationVisited(com.a1.nextlocation.data.Location location) {
location.setVisited(true);
Data.INSTANCE.visitLocation(location);
showNotification(location);
}
private void showNotification(com.a1.nextlocation.data.Location location) {
@@ -412,13 +420,13 @@ public class HomeFragment extends Fragment implements LocationListener {
mNotificationManager.createNotificationChannel(notificationChannel);
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(requireContext(),CHANNEL_ID)
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(requireContext(), CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(getString(R.string.notification_title))
.setContentText(getString(R.string.notification_text,location.getName()))
.setContentText(getString(R.string.notification_text, location.getName()))
.setAutoCancel(true);
mNotificationManager.notify(0,mBuilder.build());
mNotificationManager.notify(0, mBuilder.build());
}
// empty override methods for the LocationListener

View File

@@ -30,6 +30,7 @@ public class RouteDetailFragment extends Fragment {
private Route route;
private Refreshable refreshable;
private String time;
@Override
public void onAttach(@NotNull Context context) {
@@ -68,11 +69,11 @@ public class RouteDetailFragment extends Fragment {
String detailText = this.route.getDescription() + "<br><br><b>" + getResources().getString(R.string.following_locations) + "</b>" + locations + "<br><br><b>" + getResources().getString(R.string.start_location) + ": </b>" + route.getLocations().get(0).getName() + "<br>" + "<b>" + getResources().getString(R.string.end_location) + ": </b>" + route.getLocations().get(route.getLocations().size() - 1).getName();
routeDetailText.setText(Html.fromHtml(detailText));
//sets the text of the totaldistance
TextView totalDistance = view.findViewById(R.id.total_distance);
String distance_tekst = getResources().getString(R.string.total_distance_route);
//looks if imperial units or metric
boolean imperialChecked = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false);
totalDistance.setText(distance_tekst + " " + String.format("%.1f", calculateRoute(this.route.getLocations())) + (imperialChecked ? "yd" : "m"));
totalDistance.setText(getResources().getString(R.string.total_distance_route) + " " + String.format("%.1f", calculateRoute(this.route.getLocations())) + (imperialChecked ? "yd" : "m") + "\n" + getResources().getString(R.string.total_time) + " " + this.time);
//Initialises the back button
ImageButton backButton = view.findViewById(R.id.route_detail_back_button);
@@ -96,9 +97,10 @@ public class RouteDetailFragment extends Fragment {
public void startRoute(View view) {
ApiHandler.INSTANCE.getDirections(route);
RouteHandler.INSTANCE.followRoute(route);
Toast.makeText(requireContext(), "Route started!", Toast.LENGTH_SHORT).show();
Toast.makeText(requireContext(), R.string.route_started_toast, Toast.LENGTH_SHORT).show();
// navigates to the HomeFragment and refreshes the BottomNavigation
refreshable.refreshAndNavigateTo(R.id.locations);
requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).commit();
}
/**
@@ -123,6 +125,7 @@ public class RouteDetailFragment extends Fragment {
}
System.out.println("Total Distance: " + totalDistance);
calculateTime(totalDistance);
// if the imperialSwitch is checked, return feet, if not, return meters
if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false))
return totalDistance * 1.0936133;
@@ -130,4 +133,15 @@ public class RouteDetailFragment extends Fragment {
return totalDistance;
}
@SuppressLint("DefaultLocale")
public void calculateTime(double totalDistance){
double totalTimeInMinutes = ((totalDistance / 1000) / 5) * 60;
if(totalTimeInMinutes > 60) {
int hours = (int)(totalTimeInMinutes / 60);
int minutes = (int)(totalTimeInMinutes % 60);
this.time = hours + " " + getResources().getString(R.string.hour) + " " + minutes + " " + getResources().getString(R.string.minutes);
}
else this.time = (int)(((totalDistance / 1000) / 5) * 60) + " " + getResources().getString(R.string.minutes);
}
}

View File

@@ -1,5 +1,6 @@
package com.a1.nextlocation.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -17,12 +18,21 @@ import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.recyclerview.RouteAdapter;
import com.a1.nextlocation.recyclerview.RouteListManager;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class RouteFragment extends Fragment {
private static final String TAG = RouteFragment.class.getCanonicalName();
private List<Route> routeList;
private Refreshable refreshable;
@Override
public void onAttach(@NotNull Context context) {
super.onAttach(context);
refreshable = (Refreshable) context;
}
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -55,8 +65,10 @@ public class RouteFragment extends Fragment {
ImageButton backButton = view.findViewById(R.id.route_back_button);
backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment();
if (getActivity() != null)
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
refreshable.refreshAndNavigateTo(R.id.map_view);
}
});
routeRecyclerView.setLayoutManager(layoutManager);

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -19,6 +20,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Data;
import org.jetbrains.annotations.NotNull;
@@ -63,9 +65,10 @@ public class SettingsFragment extends Fragment {
ImageView backButton = view.findViewById(R.id.settings_back_button);
backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment();
if (getActivity() != null)
if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
});
refreshable.refreshAndNavigateTo(R.id.map_view);
}});
SharedPreferences sharedPreferences = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE);

View File

@@ -19,10 +19,19 @@ import com.a1.nextlocation.data.Data;
import com.a1.nextlocation.recyclerview.CouponAdapter;
import com.a1.nextlocation.recyclerview.CouponListManager;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class StatisticFragment extends Fragment {
private TextView distance;
private Refreshable refreshable;
@Override
public void onAttach(@NotNull Context context) {
super.onAttach(context);
refreshable = (Refreshable) context;
}
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -60,6 +69,7 @@ public class StatisticFragment extends Fragment {
HomeFragment homeFragment = new HomeFragment();
if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
refreshable.refreshAndNavigateTo(R.id.map_view);
});
//Initialises the coupon button
@@ -82,7 +92,7 @@ public class StatisticFragment extends Fragment {
private void initializeDistanceTextView(View view){
distance = view.findViewById(R.id.statistics_km);
double dist = Double.parseDouble(getContext().getSharedPreferences("Data", Context.MODE_PRIVATE).getString("distanceTraveled", "0")) /1000;
double dist = Data.INSTANCE.getDistanceTraveled() / 1000;
if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false))
distance.setText("" + String.format("%.1f",dist * 0.621371) + " mi");
else

View File

@@ -91,7 +91,7 @@ public class GeofenceInitalizer {
private void addGeofence(GeoPoint p, String name) {
if (!checkFineLocationPermission()) return;
Geofence geofence = geoFencingHelper.getGeofence(name, p, 45);
Geofence geofence = geoFencingHelper.getGeofence(name, p, 60);
GeofencingRequest geofencingRequest = geoFencingHelper.getGeoFencingRequest(geofence);
PendingIntent pendingIntent = geoFencingHelper.getPendingIntent();

View File

@@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:width="32dp"
android:height="32dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@color/secondaryColour"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
</vector>

View File

@@ -51,8 +51,6 @@
/>
</ScrollView>
<ImageButton
android:id="@+id/detail_location_back_button"
android:layout_width="wrap_content"

View File

@@ -13,7 +13,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/ic_back_button_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@@ -31,13 +30,13 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="40dp"
android:id="@+id/route_detail_image"
app:layout_constraintTop_toBottomOf="@id/route_detail_back_button"
android:layout_width="228dp"
android:layout_height="208dp"
android:layout_margin="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintTop_toBottomOf="@id/route_detail_back_button" />
<ScrollView
android:layout_width="match_parent"
@@ -58,18 +57,16 @@
</ScrollView>
<Button
android:id="@+id/start_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="45dp"
android:backgroundTint="@color/secondaryColour"
android:text="@string/start_route"
android:textColor="@color/primaryColour"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/total_distance" />
@@ -77,7 +74,6 @@
android:id="@+id/total_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@color/primaryColour"
android:text="@string/total_distance"
android:textColor="@color/secondaryColour"

View File

@@ -12,7 +12,7 @@
<string name="colorblind">Kleurenblind</string>
<string name="total_distance">Totale afstand:</string>
<string name="visited_locations">Bezochte locaties:</string>
<string name="total_time">Totale tijd:</string>
<string name="total_time">Totale route tijd:</string>
<string name="coupons_collected">Coupons gespaard:</string>
<string name="coupons">Coupons</string>
<string name="start_route">Start Route</string>
@@ -32,4 +32,7 @@
<string name="following_locations">"Deze route bevat de volgende locaties: "</string>
<string name="notification_title">Je bent dicht bij een locatie!</string>
<string name="notification_text">Je bent bijna bij %1$s</string>
<string name="hour">uur</string>
<string name="minutes">minuten</string>
<string name="route_started_toast">Route is gestart!</string>
</resources>

View File

@@ -10,7 +10,7 @@
<string name="colorblind">Colorblind</string>
<string name="total_distance">Total distance:</string>
<string name="visited_locations">Visited locations:</string>
<string name="total_time">Total time:</string>
<string name="total_time">Total route time:</string>
<string name="coupons_collected">Coupons collected:</string>
<string name="coupons">Coupons</string>
<string name="start_route">Start Route</string>
@@ -30,4 +30,7 @@
<string name="following_locations">This route contains the following locations: </string>
<string name="end_location">End location</string>
<string name="start_location">Start location</string>
<string name="hour">hour</string>
<string name="minutes">minutes</string>
<string name="route_started_toast">Route started!</string>
</resources>

View File

@@ -20,29 +20,53 @@ public class DataTest {
@Test
public void testDistance(){
data.addDistance(2356.234);
try {
data.addDistance(2356.234);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
double expected = 2356.234;
assertEquals(expected, data.getDistanceTraveled(), 0.01);
data.addDistance(234342.1);
try {
data.addDistance(2356.234);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getDistanceTraveled());
}
@Test
public void testTimeWalked(){
data.addTimeWalked(3456);
try {
data.addTimeWalked(3456);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
long expected = 3456;
assertEquals(expected, data.getTotalTime());
data.addTimeWalked(3445);
try {
data.addTimeWalked(3456);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getTotalTime());
}
@Test
public void testVisitedLocation(){
Location testLocation = new Location("test", "test", "test", "test");
data.visitLocation(testLocation);
try {
data.visitLocation(testLocation);
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
int expected = 1;
assertEquals(expected, data.getLocationsVisited());
data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
try {
data.visitLocation(new Location("TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE", "TESTFORFALSE"));
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNotEquals(expected, data.getLocationsVisited());
}

View File

@@ -1,5 +1,7 @@
package com.a1.nextlocation;
import android.util.Log;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.data.RouteHandler;
@@ -50,7 +52,11 @@ public class RouteHandlerTest {
assertEquals(expected, routeHandler.isFollowingRoute());
assertEquals(testRoute, routeHandler.getCurrentRoute());
routeHandler.finishRoute();
try {
routeHandler.finishRoute();
} catch (NullPointerException e) {
System.out.println("shared preferences not mocked");
}
assertNull(routeHandler.getCurrentRoute());
routeHandler.followRoute(new Route("FALSEROUTENAME"));