4 Commits

Author SHA1 Message Date
Sem van der Hoeven
9b93ddaec5 stuff 2021-01-04 15:44:47 +01:00
Sem van der Hoeven
5e218f3b99 added getting directions for whole route 2021-01-04 15:20:24 +01:00
Sem van der Hoeven
96f32ccdbc added deserialization of the api response 2021-01-04 13:50:50 +01:00
Sem van der Hoeven
d433565fef added parsing of directions response 2021-01-04 11:42:34 +01:00
31 changed files with 1028 additions and 438 deletions

View File

@@ -26,6 +26,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
@@ -47,6 +50,9 @@ dependencies {
//osm
implementation 'org.osmdroid:osmdroid-android:6.1.8'
//osm bonus pack
implementation 'com.github.MKergall:osmbonuspack:6.6.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

View File

@@ -1,10 +1,6 @@
[
{
"code": "KROKET10",
"reward": "Gratis 2e kroket bij Kees Kroket™"
},
{
"code": "654",
"reward": ",juygly"
"code": "2345",
"reward": "fdasfasdf"
}
]

View File

@@ -3,7 +3,7 @@
"name": "rondje stad",
"locations": [
{
"name": "KesCrOkÊt breeda",
"name": "kees kroket",
"coordinates": "2.4654645,6.2342323",
"description": "lekkere patatjes"
}

View File

@@ -13,6 +13,7 @@ import com.a1.nextlocation.fragments.HomeFragment;
import com.a1.nextlocation.fragments.RouteFragment;
import com.a1.nextlocation.fragments.SettingsFragment;
import com.a1.nextlocation.fragments.StatisticFragment;
import com.a1.nextlocation.network.ApiHandler;
import com.a1.nextlocation.recyclerview.CouponListManager;
import com.a1.nextlocation.recyclerview.LocationListManager;
import com.a1.nextlocation.recyclerview.RouteListManager;

View File

@@ -1,15 +1,12 @@
package com.a1.nextlocation.data;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.osmdroid.util.GeoPoint;
public class Location implements Parcelable {
public class Location {
@NonNull
private String name;
@@ -35,25 +32,6 @@ public class Location implements Parcelable {
this(name,getStringFromCoordinates(latCoord,longCoord),description,imageUrl);
}
protected Location(Parcel in) {
name = in.readString();
coordinates = in.readString();
description = in.readString();
imageUrl = in.readString();
}
public static final Creator<Location> CREATOR = new Creator<Location>() {
@Override
public Location createFromParcel(Parcel in) {
return new Location(in);
}
@Override
public Location[] newArray(int size) {
return new Location[size];
}
};
@NotNull
public String getName() {
return name;
@@ -112,16 +90,4 @@ public class Location implements Parcelable {
return new GeoPoint(this.getLat(),this.getLong());
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(name);
parcel.writeString(coordinates);
parcel.writeString(description);
parcel.writeString(imageUrl);
}
}

View File

@@ -1,8 +1,5 @@
package com.a1.nextlocation.data;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.NonNull;
import org.jetbrains.annotations.NotNull;
@@ -10,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class Route implements Parcelable {
public class Route {
@NonNull
@@ -32,25 +29,6 @@ public class Route implements Parcelable {
}
protected Route(Parcel in) {
this.name = in.readString();
this.locations = in.createTypedArrayList(Location.CREATOR);
this.totalDistance = in.readFloat();
this.totalTime = in.readInt();
}
public static final Creator<Route> CREATOR = new Creator<Route>() {
@Override
public Route createFromParcel(Parcel in) {
return new Route(in);
}
@Override
public Route[] newArray(int size) {
return new Route[size];
}
};
public void addLocation(Location location) {
this.locations.add(location);
}
@@ -91,16 +69,4 @@ public class Route implements Parcelable {
this.totalTime = totalTime;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(name);
parcel.writeTypedList(locations);
parcel.writeFloat(totalDistance);
parcel.writeInt(totalTime);
}
}

View File

@@ -1,85 +1,26 @@
package com.a1.nextlocation.fragments;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Coupon;
import com.a1.nextlocation.recyclerview.CouponAdapter;
import com.a1.nextlocation.recyclerview.CouponListManager;
import java.util.List;
public class CouponFragment extends Fragment {
private RecyclerView couponRecyclerView;
private RecyclerView.LayoutManager layoutManager;
private List<Coupon> couponList;
private CouponAdapter couponAdapter;
private ImageButton imageButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_coupon, container, false);
this.couponRecyclerView = view.findViewById(R.id.couponRecyclerView);
this.couponRecyclerView.setHasFixedSize(true);
this.layoutManager = new LinearLayoutManager(this.getContext());
this.imageButton = view.findViewById(R.id.couponBackButton);
this.imageButton.setOnClickListener(v -> {
StatisticFragment statisticFragment = new StatisticFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, statisticFragment).addToBackStack(null).commit();
});
CouponListManager.INSTANCE.setContext(this.getContext());
CouponListManager.INSTANCE.load();
this.couponList = CouponListManager.INSTANCE.getCouponList();
this.couponAdapter = new CouponAdapter(this.getContext(), this.couponList, clickedPosition -> showPopup(this.couponList.get(clickedPosition)));
this.couponRecyclerView.setLayoutManager(this.layoutManager);
this.couponRecyclerView.setAdapter(this.couponAdapter);
return view;
}
private void showPopup(Coupon coupon) {
AlertDialog.Builder activateBuilder = new AlertDialog.Builder(getContext());
AlertDialog.Builder couponCodeBuilder = new AlertDialog.Builder(getContext());
// TODO: use string resources instead of hardcoded strings
activateBuilder.setMessage("Weet je zeker dat je deze coupon wilt activeren?");
activateBuilder.setCancelable(true);
// TODO: use string resources instead of hardcoded strings
activateBuilder.setPositiveButton("activeren", (dialog, which) -> {
// TODO: use string resources instead of hardcoded strings
dialog.cancel();
couponCodeBuilder.setMessage("Code: " + coupon.getCode());
couponCodeBuilder.setPositiveButton("Klaar", (dialog1, which1) -> {
dialog.cancel();
});
AlertDialog couponCodePopup = couponCodeBuilder.create();
couponCodePopup.show();
});
// TODO: use string resources instead of hardcoded strings
activateBuilder.setNegativeButton("annuleren", (dialog, which) -> dialog.cancel());
AlertDialog couponPopup = activateBuilder.create();
couponPopup.show();
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_coupon, container, false);
}
}

View File

@@ -13,14 +13,12 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
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.Route;
@@ -44,7 +42,6 @@ import java.util.ArrayList;
public class HomeFragment extends Fragment {
private final String userAgent = "com.ai.nextlocation.fragments";
private ImageButton imageButton;
private MapView mapView;
private final int REQUEST_PERMISSIONS_REQUEST_CODE = 1;
private final String TAG = HomeFragment.class.getCanonicalName();
@@ -63,16 +60,10 @@ public class HomeFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false);
View view = inflater.inflate(R.layout.fragment_home, container, false);
this.imageButton = view.findViewById(R.id.location_list_button);
this.imageButton.setOnClickListener(v -> {
LocationFragment locationFragment = new LocationFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
});
return view;
}
@Override
@@ -119,8 +110,6 @@ public class HomeFragment extends Fragment {
mapView.getOverlays().add(customOverlay);
// add the zoom controller
IMapController mapController = mapView.getController();
mapController.setZoom(15.0);

View File

@@ -3,19 +3,15 @@ package com.a1.nextlocation.fragments;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import com.a1.nextlocation.R;
public class LocationDetailFragment extends Fragment {
private ImageButton imageButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -25,15 +21,7 @@ public class LocationDetailFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_location_detail, container, false);
//
// this.imageButton = view.findViewById(R.id.detail_location_back_button);
// this.imageButton.setOnClickListener(v -> {
// LocationFragment locationFragment = new LocationFragment();
// ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
// });
return view;
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_location_detail, container, false);
}
}

View File

@@ -3,65 +3,25 @@ package com.a1.nextlocation.fragments;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.recyclerview.CouponAdapter;
import com.a1.nextlocation.recyclerview.LocationAdapter;
import com.a1.nextlocation.recyclerview.LocationListManager;
import java.util.ArrayList;
import java.util.List;
public class LocationFragment extends Fragment {
private RecyclerView locationRecyclerView;
private LocationAdapter locationAdapter;
private RecyclerView.LayoutManager layoutManager;
private List<Location> locationList;
private ImageButton imageButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_location, container, false);
this.locationRecyclerView = view.findViewById(R.id.locationRecyclerView);
this.locationRecyclerView.setHasFixedSize(true);
this.layoutManager = new LinearLayoutManager(this.getContext());
this.imageButton = view.findViewById(R.id.locationBackButton);
this.imageButton.setOnClickListener(v -> {
HomeFragment homeFragment = new HomeFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
});
LocationListManager.INSTANCE.setContext(this.getContext());
LocationListManager.INSTANCE.load();
this.locationList = LocationListManager.INSTANCE.getLocationList();
this.locationAdapter = new LocationAdapter(this.getContext(), this.locationList, clickedPosition -> {
LocationDetailFragment locationDetailFragment = new LocationDetailFragment();
Bundle locationBundle = new Bundle();
locationBundle.putParcelable("location", this.locationList.get(clickedPosition));
locationDetailFragment.setArguments(locationBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationDetailFragment).addToBackStack(null).commit();
});
this.locationRecyclerView.setLayoutManager(this.layoutManager);
this.locationRecyclerView.setAdapter(this.locationAdapter);
return view;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_location, container, false);
}
}

View File

@@ -7,16 +7,11 @@ import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Route;
public class RouteDetailFragment extends Fragment {
private Route route;
private TextView routeDetailText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -24,16 +19,9 @@ public class RouteDetailFragment extends Fragment {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_route_detail, container, false);
if(getArguments().getParcelable("route") != null) {
this.route = getArguments().getParcelable("route");
}
this.routeDetailText = view.findViewById(R.id.routeDetailText);
this.routeDetailText.setText(this.route.getName());
return view;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_route_detail, container, false);
}
}

View File

@@ -2,58 +2,53 @@ package com.a1.nextlocation.fragments;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.recyclerview.RouteAdapter;
import com.a1.nextlocation.recyclerview.RouteListManager;
import java.util.ArrayList;
import java.util.List;
import com.a1.nextlocation.json.DirectionsResult;
import com.a1.nextlocation.network.ApiHandler;
import com.a1.nextlocation.network.DirectionsListener;
public class RouteFragment extends Fragment {
private RecyclerView routeRecyclerView;
private RecyclerView.LayoutManager layoutManager;
private List<Route> routeList;
private RouteAdapter routeAdapter;
private static final String TAG = RouteFragment.class.getCanonicalName();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ApiHandler.INSTANCE.addListener(this::onDirectionsAvailable);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_route, container, false);
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_route, container, false);
}
this.routeRecyclerView = view.findViewById(R.id.routeRecyclerView);
this.routeRecyclerView.setHasFixedSize(true);
this.layoutManager = new LinearLayoutManager(this.getContext());
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RouteListManager.INSTANCE.setContext(this.getContext());
RouteListManager.INSTANCE.load();
this.routeList = RouteListManager.INSTANCE.getRouteList();
// ApiHandler.INSTANCE.getDirections(8.681436,49.41461,8.687872,49.420318);
Route r = new Route("test");
r.addLocation(new Location("test",8.681436,49.41461,"route",null));
r.addLocation(new Location("test",8.687872,49.420318,"route",null));
ApiHandler.INSTANCE.getDirections(r);
}
this.routeAdapter = new RouteAdapter(this.getContext(), this.routeList, clickedPosition -> {
RouteDetailFragment routeDetailFragment = new RouteDetailFragment();
Bundle routeBundle = new Bundle();
routeBundle.putParcelable("route", this.routeList.get(clickedPosition));
routeDetailFragment.setArguments(routeBundle);
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeDetailFragment).addToBackStack(null).commit();
});
this.routeRecyclerView.setLayoutManager(this.layoutManager);
this.routeRecyclerView.setAdapter(this.routeAdapter);
return view;
public void onDirectionsAvailable(DirectionsResult result) {
Log.d(TAG, "onDirectionsAvailable: got result! " + result);
}
}

View File

@@ -2,51 +2,26 @@ package com.a1.nextlocation.fragments;
import android.os.Bundle;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Coupon;
import com.a1.nextlocation.recyclerview.CouponAdapter;
import com.a1.nextlocation.recyclerview.CouponListManager;
import java.util.List;
public class StatisticFragment extends Fragment {
private List<Coupon> couponList;
private ImageView imageButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_statistic, container, false);
this.couponList = CouponListManager.INSTANCE.getCouponList();
CouponAdapter adapter = new CouponAdapter(this.getContext(), this.couponList);
TextView couponNumber = view.findViewById(R.id.couponAmount);
couponNumber.setText(String.valueOf(adapter.getItemCount()));
ConstraintLayout constraintLayout = view.findViewById(R.id.Box4);
constraintLayout.setOnClickListener(v -> {
CouponFragment couponFragment = new CouponFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, couponFragment).addToBackStack(null).commit();
});
return view;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_statistic, container, false);
}
}

View File

@@ -0,0 +1,164 @@
package com.a1.nextlocation.json;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import org.json.JSONArray;
import org.osmdroid.util.GeoPoint;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
public class DirectionsResult {
private static final String TAG = DirectionsResult.class.getCanonicalName();
private List<DirectionsStep> steps = new ArrayList<>();
private double distance;
private double duration;
private double[][] wayPointCoordinates;
public List<DirectionsStep> getSteps() {
return steps;
}
public void setSteps(List<DirectionsStep> steps) {
this.steps = steps;
}
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public double getDuration() {
return duration;
}
public void setDuration(double duration) {
this.duration = duration;
}
public void addStep(DirectionsStep step) {
this.steps.add(step);
}
/**
* parses a given json string into this object. It gets all the waypoints and steps and combines them so that every step also has the correct coordinates associated with it
* @param json the json string to parse.
*/
public void parse(String json) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject feature = JsonParser.parseString(json).getAsJsonObject().get("features").getAsJsonArray().get(0).getAsJsonObject();
JsonObject properties = feature.get("properties").getAsJsonObject();
JsonArray wayPointCoordinates = feature.get("geometry").getAsJsonObject().getAsJsonArray("coordinates");
this.wayPointCoordinates = new double[wayPointCoordinates.size()][2];
// fill the way point coordinates list for later use
for (int i = 0; i < wayPointCoordinates.size(); i++) {
JsonElement j = wayPointCoordinates.get(i);
JsonArray arr = j.getAsJsonArray();
this.wayPointCoordinates[i][0] = arr.get(0).getAsDouble();
this.wayPointCoordinates[i][1] = arr.get(1).getAsDouble();
}
JsonArray segments = properties.getAsJsonArray("segments");
for (JsonElement element : segments) {
JsonObject segment = element.getAsJsonObject();
setDistance(segment.get("distance").getAsDouble());
setDuration(segment.get("duration").getAsDouble());
JsonArray steps = segment.getAsJsonArray("steps");
for (JsonElement j : steps) {
DirectionsStep step = gson.fromJson(j,DirectionsStep.class);
double lat;
double longl;
// kinda stinky but it works
for (int i = 0; i < 2; i++) {
lat = this.wayPointCoordinates[step.getWay_points().get(i)][0];
longl = this.wayPointCoordinates[step.getWay_points().get(i)][1];
step.getWaypoints()[i] = new GeoPoint(lat,longl);
}
addStep(step);
Log.d(TAG, "parse: added step" + step);
}
}
}
public void parseRoute(String json) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonArray routes = JsonParser.parseString(json).getAsJsonObject().getAsJsonArray("routes");
for (JsonElement element : routes) {
JsonObject route = element.getAsJsonObject();
JsonObject summary = route.getAsJsonObject("summary");
this.distance = summary.get("distance").getAsDouble();
this.duration = summary.get("duration").getAsDouble();
JsonPrimitive geometry = route.getAsJsonPrimitive("geometry");
JsonArray wayPointCoordinates = GeometryDecoder.decodeGeometry(geometry.getAsString(),false);
this.wayPointCoordinates = new double[wayPointCoordinates.size()][2];
// fill the way point coordinates list for later use
for (int i = 0; i < wayPointCoordinates.size(); i++) {
JsonElement j = wayPointCoordinates.get(i);
JsonArray arr = j.getAsJsonArray();
this.wayPointCoordinates[i][0] = arr.get(0).getAsDouble();
this.wayPointCoordinates[i][1] = arr.get(1).getAsDouble();
}
JsonArray segments = route.getAsJsonArray("segments");
for (JsonElement e : segments) {
JsonObject segment = e.getAsJsonObject();
setDistance(segment.get("distance").getAsDouble());
setDuration(segment.get("duration").getAsDouble());
JsonArray steps = segment.getAsJsonArray("steps");
for (JsonElement j : steps) {
DirectionsStep step = gson.fromJson(j,DirectionsStep.class);
double lat;
double longl;
// kinda stinky but it works
for (int i = 0; i < 2; i++) {
lat = this.wayPointCoordinates[step.getWay_points().get(i)][0];
longl = this.wayPointCoordinates[step.getWay_points().get(i)][1];
step.getWaypoints()[i] = new GeoPoint(lat,longl);
}
addStep(step);
Log.d(TAG, "parse: added step" + step);
}
}
}
}
}

View File

@@ -0,0 +1,72 @@
package com.a1.nextlocation.json;
import org.osmdroid.util.GeoPoint;
import java.util.ArrayList;
/**
* pojo class that holds the step object from the api response
*/
public class DirectionsStep {
private double distance;
private double duration;
private String instruction;
private String name;
/**
* these are the actual waypoints that the step refers to. The first is the beginning of the step, and the second is what it leads to.
* The second geopoint is always the first geopoint of the next step in the list of the {@link DirectionsResult} object.
*/
private GeoPoint[] waypoints = new GeoPoint[2];
/**
* this is a list of the waypoints that are in the response, it is called way_points so it can be automatically serialized with gson
*/
private ArrayList<Integer> way_points;
public double getDistance() {
return distance;
}
public void setDistance(double distance) {
this.distance = distance;
}
public double getDuration() {
return duration;
}
public void setDuration(double duration) {
this.duration = duration;
}
public String getInstruction() {
return instruction;
}
public void setInstruction(String instruction) {
this.instruction = instruction;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ArrayList<Integer> getWay_points() {
return way_points;
}
public void setWay_points(ArrayList<Integer> way_points) {
this.way_points = way_points;
}
public GeoPoint[] getWaypoints() {
return waypoints;
}
public void setWaypoints(GeoPoint[] waypoints) {
this.waypoints = waypoints;
}
}

View File

@@ -0,0 +1,63 @@
package com.a1.nextlocation.json;
import com.google.gson.JsonArray;
import org.json.JSONArray;
import org.json.JSONException;
/**
* source: https://github.com/GIScience/openrouteservice-docs#geometry-decoding
*/
public class GeometryDecoder {
public static JsonArray decodeGeometry(String encodedGeometry, boolean inclElevation) {
JsonArray geometry = new JsonArray();
int len = encodedGeometry.length();
int index = 0;
int lat = 0;
int lng = 0;
int ele = 0;
while (index < len) {
int result = 1;
int shift = 0;
int b;
do {
b = encodedGeometry.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lat += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
result = 1;
shift = 0;
do {
b = encodedGeometry.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
if(inclElevation){
result = 1;
shift = 0;
do {
b = encodedGeometry.charAt(index++) - 63 - 1;
result += b << shift;
shift += 5;
} while (b >= 0x1f);
ele += (result & 1) != 0 ? ~(result >> 1) : (result >> 1);
}
JsonArray location = new JsonArray();
location.add(lat / 1E5);
location.add(lng / 1E5);
if(inclElevation){
location.add((float) (ele / 100));
}
geometry.add(location);
}
return geometry;
}
}

View File

@@ -4,14 +4,20 @@ import android.util.Log;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.json.DirectionsResult;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public enum ApiHandler {
@@ -22,21 +28,22 @@ public enum ApiHandler {
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
private final String BASE_URL = "https://api.openrouteservice.org/v2/directions/";
private final String API_KEY = "5b3ce3597851110001cf6248d4eee2099f724255918adc71cc502b2a";
private final String DIRECTIONS_MODE = "foot_walking";
private final String DIRECTIONS_MODE = "foot-walking";
private List<DirectionsListener> listeners = new ArrayList<>();
private OkHttpClient client = new OkHttpClient();
public Route getDirections(Location startLocation, Location endLocation) {
return getDirections(startLocation.getCoordinates(),endLocation.getCoordinates());
public void getDirections(Location startLocation, Location endLocation) {
getDirections(startLocation.getCoordinates(),endLocation.getCoordinates());
}
public Route getDirections(double startLat, double startLong, double endLat, double endLong) {
return getDirections(startLat + "," + startLong, endLat + "," + endLong);
public void getDirections(double startLat, double startLong, double endLat, double endLong) {
getDirections(startLat + "," + startLong, endLat + "," + endLong);
}
public Route getDirections(String startLocation, String endLocation) {
public void getDirections(String startLocation, String endLocation) {
String requestUrl = BASE_URL + DIRECTIONS_MODE + "?api_key=" + API_KEY + "&start=" +startLocation + "&end=" + endLocation;
AtomicReference<Route> res = null;
Thread t = new Thread(() -> {
Request request = new Request.Builder().url(requestUrl).build();
@@ -45,6 +52,14 @@ public enum ApiHandler {
if (response.body() != null) {
String responseString = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "getDirections: got response: " + responseString);
DirectionsResult result = new DirectionsResult();
result.parse(responseString);
Log.d(TAG, "getDirections: " + result.getSteps().size());
for (DirectionsListener listener : listeners) {
listener.onDirectionsAvailable(result);
}
}
} catch (IOException e) {
@@ -54,12 +69,59 @@ public enum ApiHandler {
t.start();
try {
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
public void addListener(DirectionsListener listener) {
this.listeners.add(listener);
}
public void getDirections(Route route) {
// for (int i = 0; i < route.getLocations().size()-1; i+= 2) {
// Location start = route.getLocations().get(i);
// Location end = route.getLocations().get(i+1);
// getDirections(start,end);
// }
ArrayList<double[]> allCoords = new ArrayList<>();
for (Location location : route.getLocations()) {
allCoords.add(location.getCoordinatesAsDoubles());
}
return res.get();
String body = "{\"coordinates\":" + new Gson().toJson(allCoords) + "}";
String requestUrl = BASE_URL + DIRECTIONS_MODE + "?api_key=" + API_KEY;
Thread t = new Thread(() -> {
RequestBody requestBody = RequestBody.create(body,JSON);
Request request = new Request.Builder()
.url(requestUrl)
.post(requestBody)
.build();
try (Response response = client.newCall(request).execute()) {
if (response.body() != null) {
String responseString = Objects.requireNonNull(response.body()).string();
Log.d(TAG, "getDirections: got response: " + responseString);
DirectionsResult result = new DirectionsResult();
result.parseRoute(responseString);
Log.d(TAG, "getDirections: " + result.getSteps().size());
for (DirectionsListener listener : listeners) {
listener.onDirectionsAvailable(result);
}
}
} catch (IOException e) {
Log.d(TAG, "getDirections: caught exception: " + e.getLocalizedMessage());
}
});
t.start();
}

View File

@@ -0,0 +1,8 @@
package com.a1.nextlocation.network;
import com.a1.nextlocation.data.Route;
import com.a1.nextlocation.json.DirectionsResult;
public interface DirectionsListener {
void onDirectionsAvailable(DirectionsResult result);
}

View File

@@ -3,13 +3,10 @@ package com.a1.nextlocation.recyclerview;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Coupon;
import java.util.List;
@@ -26,49 +23,31 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
class CouponViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView couponCode;
private TextView couponReward;
public CouponViewHolder(@NonNull View itemView) {
super(itemView);
itemView.setOnClickListener(this);
}
public void setTextViewName(String text){
this.couponReward = itemView.findViewById(R.id.coupon_name);
this.couponReward.setText(text);
}
@Override
public void onClick(View v) {
public void onClick(View view) {
clickListener.onItemClick(getAdapterPosition());
}
}
public CouponAdapter(Context context, List<Coupon> coupon, OnItemClickListener listener){
this.appContext = context;
this.couponList = coupon;
this.clickListener = listener;
}
public CouponAdapter(Context context, List<Coupon> coupon) {
this.appContext = context;
this.couponList = coupon;
appContext = context;
couponList = coupon;
clickListener = listener;
}
@NonNull
@Override
public CouponViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.coupon_item, parent, false);
return new CouponViewHolder(itemView);
return null;
}
@Override
public void onBindViewHolder(@NonNull CouponViewHolder holder, int position) {
Coupon coupon = couponList.get(position);
holder.setTextViewName(coupon.getReward());
}
@Override
@@ -76,4 +55,7 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
return couponList.size();
}
}

View File

@@ -5,9 +5,11 @@ import android.util.Log;
import com.a1.nextlocation.data.Coupon;
import com.a1.nextlocation.data.FileIO;
import com.a1.nextlocation.data.Location;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CouponLoader implements Loader<List<Coupon>> {

View File

@@ -18,7 +18,7 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
private Context appContext;
private List<Location> locationList;
private OnItemClickListener clickListener;
private CouponAdapter.OnItemClickListener clickListener;
public interface OnItemClickListener {
void onItemClick(int clickedPosition);
@@ -31,7 +31,6 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
public LocationViewHolder(@NonNull View itemView) {
super(itemView);
this.locationName = itemView.findViewById(R.id.location_name);
itemView.setOnClickListener(this);
}
@Override
@@ -40,12 +39,11 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
}
public void setTextViewText(String text){
this.locationName = itemView.findViewById(R.id.location_name);
locationName.setText(text);
}
}
public LocationAdapter(Context context, List<Location> location, OnItemClickListener listener){
public LocationAdapter(Context context, List<Location> location, CouponAdapter.OnItemClickListener listener){
this.appContext = context;
this.locationList = location;
this.clickListener = listener;
@@ -54,8 +52,9 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
@NonNull
@Override
public LocationAdapter.LocationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.location_item, parent, false);
return new LocationViewHolder(itemView);
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_location, parent, false);
LocationViewHolder viewHolder = new LocationViewHolder(itemView);
return viewHolder;
}
@Override

View File

@@ -1,17 +1,12 @@
package com.a1.nextlocation.recyclerview;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.a1.nextlocation.R;
import com.a1.nextlocation.data.Location;
import com.a1.nextlocation.data.Route;
import java.util.List;
@@ -28,23 +23,14 @@ public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHol
class RouteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView routeName;
public RouteViewHolder(@NonNull View itemView) {
super(itemView);
this.routeName = itemView.findViewById(R.id.route_name);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View view) {
clickListener.onItemClick(getAdapterPosition());
}
public void setTextViewText(String text){
this.routeName = itemView.findViewById(R.id.route_name);
this.routeName.setText(text);
}
}
public RouteAdapter(Context context, List<Route> route, CouponAdapter.OnItemClickListener listener){
@@ -56,14 +42,12 @@ public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHol
@NonNull
@Override
public RouteAdapter.RouteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.route_item, parent, false);
return new RouteViewHolder(itemView);
return null;
}
@Override
public void onBindViewHolder(@NonNull RouteAdapter.RouteViewHolder holder, int position) {
Route route = routeList.get(position);
holder.setTextViewText(route.getName());
}
@Override

View File

@@ -0,0 +1,284 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/primaryColour"
tools:context=".fragments.CouponFragment">
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/primaryColour"
android:src="@drawable/ic_back_button_24"
app:layout_constraintBottom_toBottomOf="@+id/textView"
app:layout_constraintEnd_toStartOf="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/coupons"
android:textColor="@color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box1"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="@id/Box2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Code"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Waarde"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginHorizontal="20dp"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toTopOf="@id/Box3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FRISDRANKJE20"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk2"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Frisdrank"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk2"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box3"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginHorizontal="20dp"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toTopOf="@id/Box4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box2"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CHOCOMEL30"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk3"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Chocomel"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk3"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box4"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="@id/Box5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box3"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FRISTI200"
android:textColor="@color/black"
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="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2x Fristi"
android:textColor="@color/black"
android:textSize="20sp"
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
android:id="@+id/Box5"
android:layout_width="match_parent"
android:layout_height="50dp"
app:layout_constraintBottom_toTopOf="@id/ButtonActivate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box4"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OLA30"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk5"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Waterijsje"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk5"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/ButtonActivate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/buttonColour"
android:text="Activate"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -10,7 +10,7 @@
android:id="@+id/fragment_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/topBar"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/navbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@@ -34,6 +34,7 @@
android:id="@+id/topBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="50dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/fragment_layout"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box1"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/coupon_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Naam"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,39 +1,284 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/primaryColour"
tools:context=".fragments.LocationFragment">
tools:context=".fragments.CouponFragment">
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/primaryColour"
android:src="@drawable/ic_back_button_24"
app:layout_constraintBottom_toBottomOf="@+id/textView"
app:layout_constraintEnd_toStartOf="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView" />
<TextView
android:id="@+id/coupon_RV"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="9dp"
android:text="Statistics"
android:textSize="20sp"
app:layout_constraintStart_toEndOf="@id/couponBackButton"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/couponBackButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_back_button_24"
android:backgroundTint="@color/buttonColour"
android:text="Back"
android:layout_margin="10dp"
android:layout_marginTop="10dp"
android:text="@string/coupons"
android:textColor="@color/white"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/couponRecyclerView"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box1"
android:layout_width="match_parent"
android:layout_height="70dp"
app:layout_constraintBottom_toTopOf="@id/Box2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textView"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Code"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Waarde"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box2"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginHorizontal="20dp"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toTopOf="@id/Box3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FRISDRANKJE20"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk2"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Frisdrank"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk2"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box3"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginHorizontal="20dp"
android:background="@color/secondaryColour"
app:layout_constraintBottom_toTopOf="@id/Box4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box2"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CHOCOMEL30"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk3"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Chocomel"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk3"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/Box4"
android:layout_width="match_parent"
android:layout_height="70dp"
app:layout_constraintBottom_toTopOf="@id/Box5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box3"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FRISTI200"
android:textColor="@color/black"
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="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2x Fristi"
android:textColor="@color/black"
android:textSize="20sp"
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
android:id="@+id/Box5"
android:layout_width="match_parent"
android:layout_height="70dp"
app:layout_constraintBottom_toTopOf="@id/ButtonActivate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/Box4"
android:background="@color/secondaryColour"
android:layout_marginHorizontal="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OLA30"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/Balk5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/Balk5"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1x Waterijsje"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/Balk5"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/ButtonActivate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/buttonColour"
android:text="Activate"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/couponBackButton" />
app:layout_constraintTop_toBottomOf="@id/Box5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -10,23 +9,6 @@
<org.osmdroid.views.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</org.osmdroid.views.MapView>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/location_list_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:src="@drawable/ic_baseline_outlined_flag_24"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
android:layout_height="match_parent" />
</FrameLayout>

View File

@@ -14,11 +14,11 @@
android:layout_margin="9dp"
android:text="Locations"
android:textSize="20sp"
app:layout_constraintStart_toEndOf="@id/locationBackButton"
app:layout_constraintStart_toEndOf="@id/routeBackButton"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/locationBackButton"
android:id="@+id/routeBackButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_back_button_24"
@@ -31,7 +31,6 @@
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/locationRecyclerView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"

View File

@@ -28,7 +28,7 @@
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/routeRecyclerView"
android:id="@+id/routeListRV"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/primaryColour"

View File

@@ -7,6 +7,16 @@
android:background="@color/primaryColour"
tools:context=".fragments.StatisticFragment">
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/primaryColour"
android:src="@drawable/ic_back_button_24"
app:layout_constraintBottom_toBottomOf="@+id/textView"
app:layout_constraintEnd_toStartOf="@+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
@@ -201,7 +211,6 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/couponAmount"
android:text="GETAL"
android:textColor="@color/black"
android:textSize="20sp"

View File

@@ -17,7 +17,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/route_name"
android:id="@+id/routeName"
android:text="test text"
android:gravity="center"
android:textSize="20dp"