Compare commits
11 Commits
CosmeticFi
...
ButtonFix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57edff604e | ||
|
|
04defe4643 | ||
|
|
02c2981d58 | ||
|
|
209e3f3681 | ||
|
|
27a7feb05a | ||
|
|
6edcd7b74f | ||
|
|
5587c318d0 | ||
|
|
9e2144bd08 | ||
|
|
d80f23ff82 | ||
|
|
a7495d24ad | ||
|
|
5162dab0ff |
@@ -63,6 +63,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() {
|
||||||
@@ -105,8 +108,9 @@ public enum Data {
|
|||||||
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.addDistance(Double.parseDouble(prefs.getString("distanceTraveled", "0")));
|
||||||
this.locationsVisited = loadAndGetVisitedNamesList().size();
|
this.locationsVisited = loadAndGetVisitedNamesList().size();
|
||||||
|
this.totalTime = prefs.getLong("timeWalked", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public android.location.Location getLocation() {
|
public android.location.Location getLocation() {
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ public class Route implements Parcelable {
|
|||||||
|
|
||||||
|
|
||||||
public int getTotalTime() {
|
public int getTotalTime() {
|
||||||
|
|
||||||
return totalTime;
|
return totalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,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) {
|
||||||
@@ -68,11 +69,11 @@ public class RouteDetailFragment extends Fragment {
|
|||||||
String detailText = this.route.getDescription() + "<br><br><b>" + getResources().getString(R.string.following_locations) + "</b>" + locations + "<br><br><b>" + getResources().getString(R.string.start_location) + ": </b>" + route.getLocations().get(0).getName() + "<br>" + "<b>" + getResources().getString(R.string.end_location) + ": </b>" + route.getLocations().get(route.getLocations().size() - 1).getName();
|
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);
|
||||||
@@ -123,6 +124,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 +132,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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -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" />
|
||||||
@@ -31,13 +30,13 @@
|
|||||||
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"
|
||||||
@@ -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"
|
||||||
|
|||||||
@@ -32,4 +32,6 @@
|
|||||||
<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>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -30,4 +30,6 @@
|
|||||||
<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>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user