Develop #5

Merged
SemvdH merged 62 commits from develop into main 2021-01-14 10:55:23 +00:00
2 changed files with 24 additions and 10 deletions
Showing only changes of commit 24a4d344d7 - Show all commits

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;
@@ -151,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);
} }
@@ -229,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
*/ */
@@ -265,11 +262,16 @@ public class HomeFragment extends Fragment implements LocationListener {
// 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 = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24); Drawable marker = null;
marker.setAlpha(255);
if (location.isVisited() && Data.INSTANCE.isVisited(location)) { if (location.isVisited() && Data.INSTANCE.isVisited(location)) {
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)); marker.setTint(getResources().getColor(R.color.red));
} else { } 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)); marker.setTint(getResources().getColor(R.color.secondaryColour));
} }
item.setMarker(marker); item.setMarker(marker);
@@ -324,6 +326,7 @@ public class HomeFragment extends Fragment implements LocationListener {
/** /**
* 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) {
@@ -400,6 +403,7 @@ 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);
} }
@@ -416,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

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
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>