51 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
Bipin
d87adeec8d text sizes and colours 2021-01-12 15:10:54 +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
Robin Koedood
e57e6cdcda Merge remote-tracking branch 'origin/develop' into develop 2021-01-12 14:54:56 +01:00
Robin Koedood
37a803b3a6 HELP popup en setting recreate nu na een switch ding switchen q8) 2021-01-12 14:54:31 +01:00
Sem van der Hoeven
65e7b99c86 Merge branch 'develop' of https://github.com/SemvdH/Next-Location into develop 2021-01-12 14:47:18 +01:00
Sem van der Hoeven
5e2d49ac08 add getactivity 2021-01-12 14:47:09 +01:00
RemoMeijer
a7495d24ad Route displays expected time 2021-01-12 14:43:07 +01:00
Bart
428fa10433 Merge branch 'AAAAAAAAAAAAAAAAAAAAAAAAAAAA' into develop 2021-01-12 14:39:51 +01:00
Bipin
6d21ca16b8 last visual fixes for real this time promise 2021-01-12 14:35:18 +01:00
Bart
363899811a Added English help translation, ok-button moved to the bottom 2021-01-12 14:30:14 +01:00
Bipin
3880d7b4a2 Fixed last colour problems 2021-01-12 14:28:22 +01:00
RemoMeijer
5162dab0ff Fixed colors 2021-01-12 14:18:17 +01:00
Bipin
baf30b5dda smol colour edit 2021-01-12 14:16:52 +01:00
Bipin
70efd6b97c Merge branch 'fuckcolours' into develop 2021-01-12 14:05:10 +01:00
Bipin
7f56cbe30a Button be working now 2021-01-12 13:58:41 +01:00
Bipin
2f5b53e2b4 barFix 2021-01-12 12:13:29 +01:00
Robin Koedood
4c09192f9a YEP 2021-01-12 12:09:30 +01:00
Robin Koedood
8740362553 Auto stash before merge of "fuckcolours" and "origin/fuckcolours" 2021-01-12 12:05:27 +01:00
Bipin
0663dabca5 Some non-functional changes 2021-01-12 11:54:33 +01:00
Bipin
e7f152bc00 WAT MOOOOOOI 2021-01-12 11:00:44 +01:00
Bipin
f3dbb2b1d1 big bordfer 2021-01-12 10:44:59 +01:00
36 changed files with 588 additions and 138 deletions

View File

@@ -88,5 +88,40 @@
"totalTime": 342342, "totalTime": 342342,
"description": "Met deze route bezoekt u alle snackbars en restaurants in het centrum van Breda!", "description": "Met deze route bezoekt u alle snackbars en restaurants in het centrum van Breda!",
"imageURL": "kees_kroket" "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" "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!", "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" "imageURL": "escaping_room"
}, },
@@ -84,9 +82,41 @@
"imageUrl": "de_boter_hal" "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!", "description": "With this route you can visit all snackbars and restaurants in the centre of Breda!",
"imageURL": "kees_kroket" "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

@@ -9,6 +9,7 @@ import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@@ -129,9 +130,10 @@ public class MainActivity extends AppCompatActivity implements Refreshable {
*/ */
@Override @Override
public void refreshAndNavigateTo(int id) { public void refreshAndNavigateTo(int id) {
bottomNav.getMenu().clear(); this.setContentView(R.layout.activity_main);
bottomNav.inflateMenu(R.menu.navmenu); BottomNavigationView navigationView = (BottomNavigationView) this.findViewById(R.id.navigation_bar);
bottomNav.setSelectedItemId(id); navigationView.setSelectedItemId(id);
navigationView.setOnNavigationItemSelectedListener(navListener);
} }
private final View.OnClickListener onInfoClickListener = new View.OnClickListener() { 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.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.util.Log;
import com.a1.nextlocation.recyclerview.LocationListManager;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
/** /**
* singleton to keep track of different global data * singleton to keep track of different global data
*/ */
public enum Data { public enum Data {
INSTANCE; INSTANCE;
private final String TAG = Data.class.getCanonicalName();
private double distanceTraveled = 0; private double distanceTraveled = 0;
private int locationsVisited = 0; private int locationsVisited = 0;
private long totalTime = 0; private long totalTime = 0;
@@ -63,6 +68,9 @@ public enum Data {
public void addTimeWalked(long time) { public void addTimeWalked(long time) {
totalTime += time; totalTime += time;
editor.putLong("timeWalked", totalTime);
editor.apply();
} }
public double getDistanceTraveled() { public double getDistanceTraveled() {
@@ -99,14 +107,43 @@ public enum Data {
String json = context.getSharedPreferences("Data", Context.MODE_PRIVATE).getString("visitedNames", "[]"); String json = context.getSharedPreferences("Data", Context.MODE_PRIVATE).getString("visitedNames", "[]");
Type type = new TypeToken<ArrayList<String>>() {}.getType(); Type type = new TypeToken<ArrayList<String>>() {}.getType();
visitedNames = new Gson().fromJson(json, type); visitedNames = new Gson().fromJson(json, type);
Log.i(TAG, "loadAndGetVisitedNamesList: visited names: " + Arrays.toString(visitedNames.toArray()));
return visitedNames; return visitedNames;
} }
public void load(){ public void load(){
SharedPreferences prefs = context.getSharedPreferences("Data", Context.MODE_PRIVATE); SharedPreferences prefs = context.getSharedPreferences("Data", Context.MODE_PRIVATE);
this.editor = prefs.edit(); 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(); 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() { public android.location.Location getLocation() {

View File

@@ -81,7 +81,6 @@ public class Route implements Parcelable {
public int getTotalTime() { public int getTotalTime() {
return totalTime; return totalTime;
} }
@@ -113,4 +112,13 @@ public class Route implements Parcelable {
public void setDescription(String description) { public void setDescription(String description) {
this.description = 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); Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime);
} }
this.currentRoute = route; 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); setFollowingRoute(true);
startedTime = System.currentTimeMillis(); startedTime = System.currentTimeMillis();
} }

View File

@@ -53,7 +53,8 @@ public class CouponFragment extends Fragment {
this.backButton = view.findViewById(R.id.coupon_back_button); this.backButton = view.findViewById(R.id.coupon_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
StatisticFragment statisticFragment = new StatisticFragment(); StatisticFragment statisticFragment = new StatisticFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit();
}); });
this.couponRecyclerView.setLayoutManager(this.layoutManager); this.couponRecyclerView.setLayoutManager(this.layoutManager);

View File

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

View File

@@ -12,7 +12,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Data; import com.a1.nextlocation.data.Data;
@@ -50,20 +49,20 @@ public class LocationDetailFragment extends Fragment {
this.titelText.setText(location.getName()); this.titelText.setText(location.getName());
double currentDistanceToLocation = 0.0; double currentDistanceToLocation = 0.0;
if(Data.INSTANCE.getLocation() != null){ if (Data.INSTANCE.getLocation() != null) {
currentDistanceToLocation = Location.getDistance(Data.INSTANCE.getLocation().getLatitude(), Data.INSTANCE.getLocation().getLongitude(), this.location.getLat(), this.location.getLong()); currentDistanceToLocation = Location.getDistance(Data.INSTANCE.getLocation().getLatitude(), Data.INSTANCE.getLocation().getLongitude(), this.location.getLat(), this.location.getLong());
} }
//Adds distance text from the current distance of the user to the opened location //Adds distance text from the current distance of the user to the opened location
String detailText; String detailText;
if(getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)){ if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)) {
if(currentDistanceToLocation > 1609) if (currentDistanceToLocation > 1609)
detailText = location.getDescription() + String.format("%.3f",currentDistanceToLocation * 0.000621371192) + "mi"; detailText = location.getDescription() + String.format("%.3f", currentDistanceToLocation * 0.000621371192) + "mi";
else else
detailText = location.getDescription() + String.format("%.2f",currentDistanceToLocation * 1.0936133) + "yd"; detailText = location.getDescription() + String.format("%.2f", currentDistanceToLocation * 1.0936133) + "yd";
} else { } else {
if(currentDistanceToLocation > 1000) if (currentDistanceToLocation > 1000)
detailText = location.getDescription() + String.format("%.3f",currentDistanceToLocation / 1000) + "km"; detailText = location.getDescription() + String.format("%.3f", currentDistanceToLocation / 1000) + "km";
else else
detailText = location.getDescription() + currentDistanceToLocation + "m"; detailText = location.getDescription() + currentDistanceToLocation + "m";
} }
@@ -74,7 +73,8 @@ public class LocationDetailFragment extends Fragment {
this.backButton = view.findViewById(R.id.detail_location_back_button); this.backButton = view.findViewById(R.id.detail_location_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment(); LocationFragment locationFragment = new LocationFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
}); });
//Logs the location //Logs the location

View File

@@ -43,7 +43,8 @@ public class LocationFragment extends Fragment {
this.backButton = view.findViewById(R.id.location_back_button); this.backButton = view.findViewById(R.id.location_back_button);
this.backButton.setOnClickListener(v -> { this.backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
}); });
//Loads the location list //Loads the location list
@@ -58,7 +59,8 @@ public class LocationFragment extends Fragment {
//Gives the clicked location to the adapter //Gives the clicked location to the adapter
locationBundle.putParcelable("location", this.locationList.get(clickedPosition)); locationBundle.putParcelable("location", this.locationList.get(clickedPosition));
locationDetailFragment.setArguments(locationBundle); locationDetailFragment.setArguments(locationBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit();
}); });
this.locationRecyclerView.setLayoutManager(this.layoutManager); this.locationRecyclerView.setLayoutManager(this.layoutManager);

View File

@@ -14,7 +14,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Location; import com.a1.nextlocation.data.Location;
@@ -31,6 +30,7 @@ public class RouteDetailFragment extends Fragment {
private Route route; private Route route;
private Refreshable refreshable; private Refreshable refreshable;
private String time;
@Override @Override
public void onAttach(@NotNull Context context) { public void onAttach(@NotNull Context context) {
@@ -63,23 +63,24 @@ public class RouteDetailFragment extends Fragment {
TextView routeDetailText = view.findViewById(R.id.route_detail_tekst); TextView routeDetailText = view.findViewById(R.id.route_detail_tekst);
StringBuilder locations = new StringBuilder(); StringBuilder locations = new StringBuilder();
for(Location location : this.route.getLocations()){ for (Location location : this.route.getLocations()) {
locations.append("<br>•").append(location.getName()); locations.append("<br>•").append(location.getName());
} }
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(); 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)); routeDetailText.setText(Html.fromHtml(detailText));
//sets the text of the totaldistance
TextView totalDistance = view.findViewById(R.id.total_distance); 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); 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 //Initialises the back button
ImageButton backButton = view.findViewById(R.id.route_detail_back_button); ImageButton backButton = view.findViewById(R.id.route_detail_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
RouteFragment routeFragment = new RouteFragment(); RouteFragment routeFragment = new RouteFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
}); });
Button startButton = view.findViewById(R.id.start_route_button); Button startButton = view.findViewById(R.id.start_route_button);
@@ -96,9 +97,10 @@ public class RouteDetailFragment extends Fragment {
public void startRoute(View view) { public void startRoute(View view) {
ApiHandler.INSTANCE.getDirections(route); ApiHandler.INSTANCE.getDirections(route);
RouteHandler.INSTANCE.followRoute(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 // navigates to the HomeFragment and refreshes the BottomNavigation
refreshable.refreshAndNavigateTo(R.id.locations); 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); System.out.println("Total Distance: " + totalDistance);
calculateTime(totalDistance);
// if the imperialSwitch is checked, return feet, if not, return meters // if the imperialSwitch is checked, return feet, if not, return meters
if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false)) if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false))
return totalDistance * 1.0936133; return totalDistance * 1.0936133;
@@ -130,4 +133,15 @@ public class RouteDetailFragment extends Fragment {
return totalDistance; 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; package com.a1.nextlocation.fragments;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@@ -9,7 +10,6 @@ import android.widget.ImageButton;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@@ -18,12 +18,21 @@ import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.recyclerview.RouteAdapter; import com.a1.nextlocation.recyclerview.RouteAdapter;
import com.a1.nextlocation.recyclerview.RouteListManager; import com.a1.nextlocation.recyclerview.RouteListManager;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class RouteFragment extends Fragment { public class RouteFragment extends Fragment {
private static final String TAG = RouteFragment.class.getCanonicalName(); private static final String TAG = RouteFragment.class.getCanonicalName();
private List<Route> routeList; private List<Route> routeList;
private Refreshable refreshable;
@Override
public void onAttach(@NotNull Context context) {
super.onAttach(context);
refreshable = (Refreshable) context;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -49,13 +58,17 @@ public class RouteFragment extends Fragment {
Bundle routeBundle = new Bundle(); Bundle routeBundle = new Bundle();
routeBundle.putParcelable("route", this.routeList.get(clickedPosition)); routeBundle.putParcelable("route", this.routeList.get(clickedPosition));
routeDetailFragment.setArguments(routeBundle); routeDetailFragment.setArguments(routeBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit();
}); });
ImageButton backButton = view.findViewById(R.id.route_back_button); ImageButton backButton = view.findViewById(R.id.route_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); if (getActivity() != null) {
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
refreshable.refreshAndNavigateTo(R.id.map_view);
}
}); });
routeRecyclerView.setLayoutManager(layoutManager); routeRecyclerView.setLayoutManager(layoutManager);

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -13,12 +14,13 @@ import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import com.a1.nextlocation.R; import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Data;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -29,6 +31,7 @@ public class SettingsFragment extends Fragment {
private SharedPreferences.Editor editor; private SharedPreferences.Editor editor;
private SwitchCompat fontSwitch; private SwitchCompat fontSwitch;
private SwitchCompat imperialSwitch; private SwitchCompat imperialSwitch;
private SwitchCompat colorBlindMode;
private Refreshable refreshable; private Refreshable refreshable;
@Override @Override
@@ -42,6 +45,7 @@ public class SettingsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
editor = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).edit(); editor = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).edit();
} }
@Override @Override
@@ -61,8 +65,10 @@ public class SettingsFragment extends Fragment {
ImageView backButton = view.findViewById(R.id.settings_back_button); ImageView backButton = view.findViewById(R.id.settings_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); 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); SharedPreferences sharedPreferences = getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE);
@@ -82,29 +88,50 @@ public class SettingsFragment extends Fragment {
fontSwitch.setChecked(sharedPreferences.getBoolean("fontSwitch", false)); fontSwitch.setChecked(sharedPreferences.getBoolean("fontSwitch", false));
//Initial check to see what setting was last chosen //Initial check to see what setting was last chosen
if (fontSwitch.isChecked()){ if (fontSwitch.isChecked()) {
requireActivity().setTheme(R.style.Theme_NextLocationBig); requireActivity().setTheme(R.style.Theme_NextLocationBig);
}else if (!fontSwitch.isChecked()){ } else if (!fontSwitch.isChecked()) {
requireActivity().setTheme(R.style.Theme_NextLocation); requireActivity().setTheme(R.style.Theme_NextLocation);
} }
//Changes the font settings depending on the state of the toggle //Changes the font settings depending on the state of the toggle
fontSwitch.setOnClickListener(view1 -> { fontSwitch.setOnClickListener(view1 -> {
if(fontSwitch.isChecked()) if (fontSwitch.isChecked()) {
{
requireActivity().setTheme(R.style.Theme_NextLocationBig); requireActivity().setTheme(R.style.Theme_NextLocationBig);
editor.putBoolean("fontSwitch",true); getActivity().recreate();
editor.apply();
} }
if(!fontSwitch.isChecked()) if(!fontSwitch.isChecked())
{ {
requireActivity().setTheme(R.style.Theme_NextLocation); requireActivity().setTheme(R.style.Theme_NextLocation);
editor.putBoolean("fontSwitch",false); getActivity().recreate();
editor.apply();
} }
editor.putBoolean("fontSwitch", fontSwitch.isChecked());
editor.apply();
editor.commit(); editor.commit();
}); });
this.colorBlindMode = view.findViewById(R.id.colourblindSwitch);
this.colorBlindMode.setChecked(sharedPreferences.getBoolean("colorBlindModeSwitch", false));
this.colorBlindMode.setOnClickListener(view1 -> {
editor.putBoolean("colorBlindModeSwitch", colorBlindMode.isChecked());
editor.apply();
editor.commit();
if (colorBlindMode.isChecked()) {
requireActivity().setTheme(R.style.Theme_NextLocation);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
getActivity().recreate();
System.out.println("AAN");
} else if (!colorBlindMode.isChecked()) {
requireActivity().setTheme(R.style.Theme_NextLocation);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
getActivity().recreate();
System.out.println("UIT");
}
});
} }
private void initializeLanguageDropdown(View view) { private void initializeLanguageDropdown(View view) {

View File

@@ -19,10 +19,19 @@ import com.a1.nextlocation.data.Data;
import com.a1.nextlocation.recyclerview.CouponAdapter; import com.a1.nextlocation.recyclerview.CouponAdapter;
import com.a1.nextlocation.recyclerview.CouponListManager; import com.a1.nextlocation.recyclerview.CouponListManager;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class StatisticFragment extends Fragment { public class StatisticFragment extends Fragment {
private TextView distance; private TextView distance;
private Refreshable refreshable;
@Override
public void onAttach(@NotNull Context context) {
super.onAttach(context);
refreshable = (Refreshable) context;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -58,28 +67,32 @@ public class StatisticFragment extends Fragment {
ImageView backButton = view.findViewById(R.id.statistics_back_button); ImageView backButton = view.findViewById(R.id.statistics_back_button);
backButton.setOnClickListener(v -> { backButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment(); HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit(); 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 //Initialises the coupon button
ImageView couponButton = view.findViewById(R.id.coupon_button); ImageView couponButton = view.findViewById(R.id.coupon_button);
couponButton.setOnClickListener(v -> { couponButton.setOnClickListener(v -> {
CouponFragment couponFragment = new CouponFragment(); CouponFragment couponFragment = new CouponFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
}); });
//Makes the constraintlayout clickable and opens the same layout as the coupon button //Makes the constraintlayout clickable and opens the same layout as the coupon button
ConstraintLayout constraintLayout = view.findViewById(R.id.Box4); ConstraintLayout constraintLayout = view.findViewById(R.id.Box4);
constraintLayout.setOnClickListener(v -> { constraintLayout.setOnClickListener(v -> {
CouponFragment couponFragment = new CouponFragment(); CouponFragment couponFragment = new CouponFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit(); if (getActivity() != null)
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
}); });
return view; return view;
} }
private void initializeDistanceTextView(View view){ private void initializeDistanceTextView(View view){
distance = view.findViewById(R.id.statistics_km); 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)) if (getContext().getSharedPreferences("Settings", Context.MODE_PRIVATE).getBoolean("imperialSwitch", false))
distance.setText("" + String.format("%.1f",dist * 0.621371) + " mi"); distance.setText("" + String.format("%.1f",dist * 0.621371) + " mi");
else else

View File

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

View File

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

@@ -5,6 +5,15 @@
android:id="@+id/couponItem" android:id="@+id/couponItem"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@+id/name_box"
app:layout_constraintBottom_toBottomOf="@+id/name_box"
app:layout_constraintLeft_toLeftOf="@+id/name_box"
app:layout_constraintRight_toRightOf="@+id/name_box"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/name_box" android:id="@+id/name_box"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -14,10 +14,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="9dp" android:layout_margin="9dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:text="@string/statistics" android:text="@string/coupons"
android:textSize="20sp" android:textSize="30sp"
app:layout_constraintStart_toEndOf="@id/coupon_back_button" android:textColor="@color/secondaryColour"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/coupon_back_button"
app:layout_constraintBottom_toBottomOf="@id/coupon_back_button"/>
<ImageButton <ImageButton
android:id="@+id/coupon_back_button" android:id="@+id/coupon_back_button"
@@ -26,7 +29,6 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="@drawable/ic_back_button_24" android:background="@drawable/ic_back_button_24"
android:backgroundTint="@color/buttonColour"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />

View File

@@ -15,8 +15,9 @@
android:layout_margin="9dp" android:layout_margin="9dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:text="@string/locations" android:text="@string/locations"
android:textSize="20sp" android:textSize="30sp"
app:layout_constraintStart_toEndOf="@id/location_back_button" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageButton <ImageButton
@@ -26,7 +27,6 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="@drawable/ic_back_button_24" android:background="@drawable/ic_back_button_24"
android:backgroundTint="@color/buttonColour"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />

View File

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

View File

@@ -24,9 +24,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="9dp" android:layout_margin="9dp"
android:text="@string/routes" android:text="@string/routes"
android:textSize="20sp" android:textSize="30sp"
app:layout_constraintStart_toEndOf="@id/route_back_button" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/route_back_button"
app:layout_constraintBottom_toBottomOf="@id/route_back_button"/>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/route_recyclerview" android:id="@+id/route_recyclerview"

View File

@@ -13,7 +13,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/ic_back_button_24" android:background="@drawable/ic_back_button_24"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -22,7 +21,7 @@
android:id="@+id/route_title" android:id="@+id/route_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/white" android:textColor="@color/secondaryColour"
android:textSize="30sp" android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/route_detail_image" app:layout_constraintBottom_toTopOf="@+id/route_detail_image"
android:text="" android:text=""
@@ -31,19 +30,19 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="40dp"
android:id="@+id/route_detail_image" 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_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintTop_toBottomOf="@id/route_detail_back_button" />
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="200dp" android:layout_height="200dp"
android:layout_margin="20dp" android:layout_margin="20dp"
android:background="@color/secondaryColour" android:background="@color/primaryColour"
android:id="@+id/route_scroll_view" android:id="@+id/route_scroll_view"
app:layout_constraintTop_toBottomOf="@id/route_detail_image" app:layout_constraintTop_toBottomOf="@id/route_detail_image"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@@ -58,18 +57,16 @@
</ScrollView> </ScrollView>
<Button <Button
android:id="@+id/start_route_button" android:id="@+id/start_route_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="45dp"
android:backgroundTint="@color/secondaryColour" android:backgroundTint="@color/secondaryColour"
android:text="@string/start_route" android:text="@string/start_route"
android:textColor="@color/primaryColour" android:textColor="@color/primaryColour"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/total_distance" /> app:layout_constraintTop_toBottomOf="@id/total_distance" />
@@ -77,7 +74,6 @@
android:id="@+id/total_distance" android:id="@+id/total_distance"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@color/primaryColour" android:background="@color/primaryColour"
android:text="@string/total_distance" android:text="@string/total_distance"
android:textColor="@color/secondaryColour" android:textColor="@color/secondaryColour"

View File

@@ -6,7 +6,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/primaryColour" android:background="@color/primaryColour"
android:id="@+id/settingFragment" android:id="@+id/settingFragment"
tools:context=".fragments.SettingsFragment"> tools:context=".fragments.SettingsFragment"
android:theme="@style/Theme.Switches">
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/settings_back_button" android:id="@+id/settings_back_button"
@@ -14,8 +15,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:backgroundTint="@color/primaryColour" android:background="@drawable/ic_back_button_24"
android:src="@drawable/ic_back_button_24"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -31,6 +31,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/name_box"
app:layout_constraintBottom_toBottomOf="@id/name_box"
app:layout_constraintLeft_toLeftOf="@id/name_box"
app:layout_constraintRight_toRightOf="@id/name_box"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/name_box" android:id="@+id/name_box"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -41,7 +51,6 @@
app:layout_constraintTop_toBottomOf="@id/textView" app:layout_constraintTop_toBottomOf="@id/textView"
android:background="@color/primaryColour" android:background="@color/primaryColour"
android:layout_marginHorizontal="20dp" android:layout_marginHorizontal="20dp"
> >
<TextView <TextView
@@ -57,7 +66,7 @@
<View <View
android:id="@+id/Balk" android:id="@+id/Balk"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/secondaryColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -79,6 +88,16 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box2"
app:layout_constraintBottom_toBottomOf="@id/Box2"
app:layout_constraintLeft_toLeftOf="@id/Box2"
app:layout_constraintRight_toRightOf="@id/Box2"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box2" android:id="@+id/Box2"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -105,9 +124,9 @@
<View <View
android:id="@+id/Balk2" android:id="@+id/Balk2"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/buttonColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@@ -126,13 +145,22 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box3"
app:layout_constraintBottom_toBottomOf="@id/Box3"
app:layout_constraintLeft_toLeftOf="@id/Box3"
app:layout_constraintRight_toRightOf="@id/Box3"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box3" android:id="@+id/Box3"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="70dp" android:layout_height="70dp"
android:layout_marginHorizontal="20dp" android:layout_marginHorizontal="20dp"
android:background="@color/primaryColour" android:background="@color/primaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/Box4"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box2" app:layout_constraintTop_toBottomOf="@id/Box2"
@@ -151,9 +179,9 @@
<View <View
android:id="@+id/Balk3" android:id="@+id/Balk3"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/black" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@@ -168,6 +196,61 @@
app:layout_constraintStart_toStartOf="@id/Balk3" app:layout_constraintStart_toStartOf="@id/Balk3"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box4"
app:layout_constraintBottom_toBottomOf="@id/Box4"
app:layout_constraintLeft_toLeftOf="@id/Box4"
app:layout_constraintRight_toRightOf="@id/Box4"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box4"
android:layout_width="match_parent"
android:layout_height="70dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box3"
android:background="@color/primaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/colorblind"
android:textColor="@color/secondaryColour"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk4"
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/colourblindSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk4"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -20,6 +20,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/name_box"
app:layout_constraintBottom_toBottomOf="@id/name_box"
app:layout_constraintLeft_toLeftOf="@id/name_box"
app:layout_constraintRight_toRightOf="@id/name_box"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/name_box" android:id="@+id/name_box"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -46,7 +55,7 @@
<View <View
android:id="@+id/Balk" android:id="@+id/Balk"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/secondaryColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -69,6 +78,15 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box2"
app:layout_constraintBottom_toBottomOf="@id/Box2"
app:layout_constraintLeft_toLeftOf="@id/Box2"
app:layout_constraintRight_toRightOf="@id/Box2"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box2" android:id="@+id/Box2"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -95,7 +113,7 @@
<View <View
android:id="@+id/Balk2" android:id="@+id/Balk2"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/secondaryColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -118,6 +136,15 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box3"
app:layout_constraintBottom_toBottomOf="@id/Box3"
app:layout_constraintLeft_toLeftOf="@id/Box3"
app:layout_constraintRight_toRightOf="@id/Box3"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box3" android:id="@+id/Box3"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -142,7 +169,7 @@
<View <View
android:id="@+id/Balk3" android:id="@+id/Balk3"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/secondaryColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -165,6 +192,15 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<View
android:layout_width="0dp"
android:layout_height="74dp"
app:layout_constraintTop_toTopOf="@id/Box4"
app:layout_constraintBottom_toBottomOf="@id/Box4"
app:layout_constraintLeft_toLeftOf="@id/Box4"
app:layout_constraintRight_toRightOf="@id/Box4"
android:background="@color/secondaryColour"/>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box4" android:id="@+id/Box4"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -191,7 +227,7 @@
<View <View
android:id="@+id/Balk4" android:id="@+id/Balk4"
android:layout_width="1dp" android:layout_width="2dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/secondaryColour" android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@@ -231,8 +267,6 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@drawable/ic_back_button_24" android:background="@drawable/ic_back_button_24"
android:backgroundTint="@color/buttonColour"
android:src="@drawable/ic_back_button_24"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />

View File

@@ -22,24 +22,28 @@
android:paddingVertical="10dp"/> android:paddingVertical="10dp"/>
<ScrollView <ScrollView
app:layout_constraintStart_toStartOf="parent" android:id="@+id/scrollView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/helpPopTitle"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="450dp"> android:layout_height="400dp"
android:layout_marginHorizontal="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/helpPopTitle"
app:layout_constraintBottom_toTopOf="@id/help_ok_button"
>
<TextView <TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/helpPopTitle"
android:layout_width="280dp" android:layout_width="280dp"
android:layout_height="430dp" android:layout_height="430dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:text="@string/help_discription" android:text="@string/help_discription"
android:textColor="@color/secondaryColour" android:textColor="@color/secondaryColour"
android:layout_marginStart="10dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="10dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="10dp" app:layout_constraintTop_toBottomOf="@id/helpPopTitle" />
android:layout_marginBottom="10dp"/>
</ScrollView> </ScrollView>
@@ -48,11 +52,13 @@
android:id="@+id/help_ok_button" android:id="@+id/help_ok_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:backgroundTint="@color/buttonColour" android:backgroundTint="@color/buttonColour"
android:textColor="@color/primaryColour"
android:text="ok" android:text="ok"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/helpPopTitle" /> app:layout_constraintTop_toBottomOf="@id/scrollView2"
app:layout_constraintStart_toStartOf="parent" />

View File

@@ -8,6 +8,24 @@
android:id="@+id/locationItem" android:id="@+id/locationItem"
android:layout_margin="20dp"> android:layout_margin="20dp">
<View
android:layout_width="0dp"
android:layout_height="54dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="@color/secondaryColour"/>
<View
android:layout_width="0dp"
android:layout_height="46dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="@color/primaryColour"/>
<ImageView <ImageView
android:id="@+id/location_image" android:id="@+id/location_image"
android:layout_width="50dp" android:layout_width="50dp"

View File

@@ -8,6 +8,24 @@
android:id="@+id/routeItem" android:id="@+id/routeItem"
android:layout_margin="20dp"> android:layout_margin="20dp">
<View
android:layout_width="0dp"
android:layout_height="54dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="@color/secondaryColour"/>
<View
android:layout_width="0dp"
android:layout_height="46dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:background="@color/primaryColour"/>
<ImageView <ImageView
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="primaryColour">#FF115571</color>
<color name="secondaryColour">#FF31AFB4</color>
<color name="buttonColour">#FF14212D</color>
<color name="red">#FF0000</color>
</resources>

View File

@@ -2,15 +2,28 @@
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item> <item name="colorPrimary">@color/white</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item> <item name="colorSecondary">@color/secondaryColour</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorButtonNormal">@color/buttonColour</item>
<item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">16sp</item>
</style>
<style name="Theme.Switches" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorControlActivated">@color/secondaryColour</item>
<item name="colorSwitchThumbNormal">@color/buttonColourCB</item>
</style>
<style name="Theme.NextLocationBig" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/primaryColour</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/secondaryColour</item>
<!-- Customize your theme here. -->
<item name="colorButtonNormal">@color/buttonColour</item>
<item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">24sp</item>
</style> </style>
</resources> </resources>

View File

@@ -12,7 +12,7 @@
<string name="colorblind">Kleurenblind</string> <string name="colorblind">Kleurenblind</string>
<string name="total_distance">Totale afstand:</string> <string name="total_distance">Totale afstand:</string>
<string name="visited_locations">Bezochte locaties:</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_collected">Coupons gespaard:</string>
<string name="coupons">Coupons</string> <string name="coupons">Coupons</string>
<string name="start_route">Start Route</string> <string name="start_route">Start Route</string>
@@ -26,10 +26,13 @@
<string name="Dutch">Nederlands</string> <string name="Dutch">Nederlands</string>
<string name="Chinese">Chinees</string> <string name="Chinese">Chinees</string>
<string name="help">HELP</string> <string name="help">HELP</string>
<string name="help_discription">Onderaan het scherm zijn verschillende knoppen te zien. Deze knoppen hebben de volgende functies: \n\nLocaties: toont een lijst met alle locaties die bezocht kunnen worden. Elke locatie wordt kort beschreven. \n\nRoutes: Toont een lijst met alle routes die gelopen kunnen worden. Van elke route wordt een omschrijving gegeven. \n\nStatistieken: Toont persoonlijke statistieken. \n\nInstellingen: Hier kunnen app-instellingen worden aangepast naar eigen voorkeur. \n\nEen locatie ingedrukt houden laat extra informatie zien over de gekozen locatie</string> <string name="help_discription">Onderaan het scherm zijn verschillende knoppen te zien. Deze knoppen hebben de volgende functies: \n\nLocaties: toont een lijst met alle locaties die bezocht kunnen worden. Elke locatie wordt kort beschreven. \n\nRoutes: Toont een lijst met alle routes die gelopen kunnen worden. Van elke route wordt een omschrijving gegeven. \n\nStatistieken: Toont persoonlijke statistieken. \n\nInstellingen: Hier kunnen app-instellingen worden aangepast naar eigen voorkeur. \n\nEen locatie ingedrukt houden laat extra informatie zien over de gekozen locatie. \n\n\n</string>
<string name="end_location">Eind locatie</string> <string name="end_location">Eind locatie</string>
<string name="start_location">Start locatie</string> <string name="start_location">Start locatie</string>
<string name="following_locations">"Deze route bevat de volgende locaties: "</string> <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_title">Je bent dicht bij een locatie!</string>
<string name="notification_text">Je bent bijna bij %1$s</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> </resources>

View File

@@ -11,4 +11,7 @@
<color name="secondaryColour">#FF000000</color> <color name="secondaryColour">#FF000000</color>
<color name="buttonColour">#FF000000</color> <color name="buttonColour">#FF000000</color>
<color name="red">#FF0000</color> <color name="red">#FF0000</color>
<color name="primaryColourCB">#FF115571</color>
<color name="secondaryColourCB">#FF31AFB4</color>
<color name="buttonColourCB">#FF14212D</color>
</resources> </resources>

View File

@@ -10,7 +10,7 @@
<string name="colorblind">Colorblind</string> <string name="colorblind">Colorblind</string>
<string name="total_distance">Total distance:</string> <string name="total_distance">Total distance:</string>
<string name="visited_locations">Visited locations:</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_collected">Coupons collected:</string>
<string name="coupons">Coupons</string> <string name="coupons">Coupons</string>
<string name="start_route">Start Route</string> <string name="start_route">Start Route</string>
@@ -24,10 +24,13 @@
<string name="English">English</string> <string name="English">English</string>
<string name="Chinese">Chinese</string> <string name="Chinese">Chinese</string>
<string name="help">HELP</string> <string name="help">HELP</string>
<string name="help_discription">Hasn\'t been translated yet</string> <string name="help_discription">Various buttons can be seen at the bottom of the screen. These buttons have the following functions: \n\nLocations: displays a list of all locations that can be visited. Each location is briefly described. \n\nRoutes: Displays a list of all routes that can be walked. A description is given of each route. \n\nStats: Displays personal statistics. \n\nSettings: This is where app settings can be adjusted according to your preferences. \n\nHold down on a location to display additional information about the chosen location. \n\n\n</string>
<string name="notification_title">You\'re close to a location!</string> <string name="notification_title">You\'re close to a location!</string>
<string name="notification_text">You\'re almost at %1$s</string> <string name="notification_text">You\'re almost at %1$s</string>
<string name="following_locations">This route contains the following locations: </string> <string name="following_locations">This route contains the following locations: </string>
<string name="end_location">End location</string> <string name="end_location">End location</string>
<string name="start_location">Start 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> </resources>

View File

@@ -2,13 +2,19 @@
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <style name="Theme.NextLocation" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/primaryColour</item> <item name="colorPrimary">@color/black</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/secondaryColour</item> <item name="colorSecondary">@color/secondaryColour</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorButtonNormal">@color/buttonColour</item> <item name="colorButtonNormal">@color/buttonColour</item>
<item name="colorPrimaryDark">@color/secondaryColour</item> <item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">16sp</item> <item name="android:textSize">16sp</item>
<item name="android:textColor">@color/black</item>
</style>
<style name="Theme.Switches" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorControlActivated">@color/buttonColour</item>
<item name="colorSwitchThumbNormal">@color/primaryColour</item>
</style> </style>
<style name="Theme.NextLocationBig" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <style name="Theme.NextLocationBig" parent="Theme.MaterialComponents.DayNight.NoActionBar">
@@ -21,4 +27,7 @@
<item name="colorPrimaryDark">@color/secondaryColour</item> <item name="colorPrimaryDark">@color/secondaryColour</item>
<item name="android:textSize">24sp</item> <item name="android:textSize">24sp</item>
</style> </style>
</resources> </resources>

View File

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

View File

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