.
This commit is contained in:
@@ -3,6 +3,8 @@ package com.app.simplitend.patient_dashboard;
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
@@ -32,6 +34,7 @@ import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
@@ -43,7 +46,9 @@ import com.google.maps.android.PolyUtil;
|
||||
import com.google.maps.model.DirectionsResult;
|
||||
import com.google.maps.model.DirectionsRoute;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DirectionToHomeActivity extends AppCompatActivity
|
||||
implements OnMapReadyCallback, LocationListener {
|
||||
@@ -239,8 +244,8 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
private void addMarkersToMap(DirectionsResult results, GoogleMap mMap) throws Exception {
|
||||
pat_cur_lat = results.routes[0].legs[0].startLocation.lat;
|
||||
pat_cur_lng = results.routes[0].legs[0].startLocation.lng;
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].startLocation.lat,results.routes[0].legs[0].startLocation.lng)).title("Your location"));
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].endLocation.lat,results.routes[0].legs[0].endLocation.lng)).title("Senior's location"));
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].startLocation.lat ,results.routes[0].legs[0].startLocation.lng)).title("Your location").icon(BitmapDescriptorFactory.fromResource(R.drawable.img_pat_curr_location)));
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].endLocation.lat ,results.routes[0].legs[0].endLocation.lng)).title("Home location").icon(BitmapDescriptorFactory.fromResource(R.drawable.img_home_marker)));
|
||||
}
|
||||
|
||||
private void positionCamera(DirectionsRoute route, GoogleMap mMap) throws Exception{
|
||||
@@ -310,6 +315,7 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
addMarkersToMap(directionsResult, mGoogleMap);
|
||||
positionCamera(directionsResult.routes[0], mGoogleMap);
|
||||
addPolyline(directionsResult, mGoogleMap);
|
||||
loadAddresses(directionsResult);
|
||||
|
||||
binding.progress.setVisibility(View.GONE);
|
||||
binding.progress.setEnabled(false);
|
||||
@@ -321,4 +327,89 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadAddresses(DirectionsResult directionsResult) {
|
||||
String your_loc = "";
|
||||
try {
|
||||
// fetching address from the lag lng
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
List<Address> addresses = geocoder.getFromLocation(directionsResult.routes[0].legs[0].startLocation.lat, directionsResult.routes[0].legs[0].startLocation.lng, 1);
|
||||
|
||||
if (addresses != null && addresses.size() > 0 && addresses.get(0) != null) {
|
||||
Address address = addresses.get(0);
|
||||
|
||||
if (address.getMaxAddressLineIndex() > 0 && address.getAddressLine(0) != null){
|
||||
your_loc = address.getAddressLine(0);
|
||||
}
|
||||
|
||||
if (your_loc != null && !your_loc.isEmpty()) your_loc += ", ";
|
||||
|
||||
if (address.getLocality() != null){
|
||||
your_loc += address.getLocality();
|
||||
}
|
||||
|
||||
if (your_loc != null && !your_loc.isEmpty()) your_loc += ", ";
|
||||
|
||||
if (address.getAdminArea() != null){
|
||||
your_loc += address.getAdminArea();
|
||||
}
|
||||
|
||||
if (your_loc != null && !your_loc.isEmpty()) your_loc += ", ";
|
||||
|
||||
if (address.getCountryName() != null){
|
||||
your_loc += address.getCountryName();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// do nothing as we couldn't load the location from the lat lng
|
||||
if (your_loc != null && your_loc.isEmpty()) your_loc = null;
|
||||
}
|
||||
|
||||
if (your_loc != null){
|
||||
binding.yourLoc.setText(your_loc);
|
||||
}
|
||||
|
||||
String home_loc = "";
|
||||
try {
|
||||
// fetching address from the lag lng
|
||||
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
|
||||
List<Address> addresses = geocoder.getFromLocation(directionsResult.routes[0].legs[0].endLocation.lat, directionsResult.routes[0].legs[0].endLocation.lng, 1);
|
||||
|
||||
if (addresses != null && addresses.size() > 0 && addresses.get(0) != null) {
|
||||
Address address = addresses.get(0);
|
||||
|
||||
if (address.getMaxAddressLineIndex() > 0 && address.getAddressLine(0) != null){
|
||||
home_loc = address.getAddressLine(0);
|
||||
}
|
||||
|
||||
if (home_loc != null && !home_loc.isEmpty()) home_loc += ", ";
|
||||
|
||||
if (address.getLocality() != null){
|
||||
home_loc += address.getLocality();
|
||||
}
|
||||
|
||||
if (home_loc != null && !home_loc.isEmpty()) home_loc += ", ";
|
||||
|
||||
if (address.getAdminArea() != null){
|
||||
home_loc += address.getAdminArea();
|
||||
}
|
||||
|
||||
if (home_loc != null && !home_loc.isEmpty()) home_loc += ", ";
|
||||
|
||||
if (address.getCountryName() != null){
|
||||
home_loc += address.getCountryName();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// do nothing as we couldn't load the location from the lat lng
|
||||
if (home_loc != null && home_loc.isEmpty()) home_loc = null;
|
||||
}
|
||||
|
||||
if (home_loc != null){
|
||||
binding.homeLoc.setText(home_loc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.app.simplitend.patient_dashboard;
|
||||
|
||||
import static android.content.Context.*;
|
||||
import static android.content.Context.ACTIVITY_SERVICE;
|
||||
import static com.app.simplitend.locationupdates.LocationService.LOCATION_INTERVAL_BASE_TIME;
|
||||
import static com.app.simplitend.locationupdates.LocationService.LOCATION_UPDATE_MIN_INTERVAL;
|
||||
import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_ID;
|
||||
import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_TAG;
|
||||
import static com.app.simplitend.patientgeofencing.PatientLocationUpdatesReceiver.LOCATION_REQUEST_TAG;
|
||||
import static com.app.simplitend.patientgeofencing.PatientLocationUpdatesReceiver.LOCATION_UPDATES_REQUEST_CODE;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
@@ -36,7 +34,6 @@ import com.app.simplitend.caregiverdashboard.mvvm.NotificationApiService;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.models.GeoFenceDetails;
|
||||
import com.app.simplitend.locationupdates.LocationService;
|
||||
import com.app.simplitend.patientgeofencing.GeoFenceHelper;
|
||||
import com.app.simplitend.patientgeofencing.PatientLocationUpdatesReceiver;
|
||||
import com.app.simplitend.patientprofile.PatientProfileAPIService;
|
||||
import com.app.simplitend.patientprofile.medreminder.mvvm.models.NearestActivity;
|
||||
import com.app.simplitend.patientprofile.medreminder.mvvm.models.NearestReminder;
|
||||
@@ -44,11 +41,9 @@ import com.app.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult;
|
||||
import com.app.simplitend.patientprofile.setuproutine.mvvm.RoutineDetails;
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.Geofence;
|
||||
import com.google.android.gms.location.GeofencingClient;
|
||||
import com.google.android.gms.location.GeofencingRequest;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
@@ -159,7 +154,9 @@ public class PatientMainViewModel extends ViewModel {
|
||||
AppUtil.updatePatientGeofence(activity, latLng.latitude+"", latLng.longitude+"",
|
||||
GEOFENCING_RADIUS+"", unit);
|
||||
})
|
||||
.addOnFailureListener(e -> Log.d(GEOFENCE_TAG, "onFailure: Geofence couldn't be added: " + e.getLocalizedMessage() + " " + latLng + " Radius: " + GEOFENCING_RADIUS));
|
||||
.addOnFailureListener(e -> {
|
||||
Log.d(GEOFENCE_TAG, "onFailure: Geofence couldn't be added: " + e.getLocalizedMessage() + " " + latLng + " Radius: " + GEOFENCING_RADIUS);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
|
||||
|
||||
String selected_time = sdf.format(cal.getTime());
|
||||
binding.getDate.setText(selected_time);
|
||||
@@ -389,6 +389,33 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
binding.getTime3.setError("Required");
|
||||
}
|
||||
|
||||
boolean timeOk = true;
|
||||
|
||||
// checking if times are equal
|
||||
if (binding.getTime2.getVisibility() == View.VISIBLE && binding.getTime3.getVisibility() == View.VISIBLE){
|
||||
// all three times are visible
|
||||
if (binding.getTime.getText().toString().equals(binding.getTime2.getText().toString())){
|
||||
// time 1 and 2 are same
|
||||
timeOk = false;
|
||||
}else if (binding.getTime.getText().toString().equals(binding.getTime3.getText().toString())){
|
||||
// time 1 and 3 are same
|
||||
timeOk = false;
|
||||
}else if (binding.getTime2.getText().toString().equals(binding.getTime3.getText().toString())){
|
||||
// time 2 and 3 are same
|
||||
timeOk = false;
|
||||
}
|
||||
}else if (binding.getTime2.getVisibility() == View.VISIBLE){
|
||||
// time 1 and 2 are visible
|
||||
if (binding.getTime.getText().toString().equals(binding.getTime2.getText().toString())){
|
||||
timeOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!timeOk){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Medications times cannot be same.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
if (binding.quantity.getText().toString().trim().isEmpty()) {
|
||||
allOkay = false;
|
||||
binding.quantity.setError("Required");
|
||||
@@ -522,8 +549,8 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh
|
||||
}
|
||||
|
||||
private String formatDate(String medication_refill_date) {
|
||||
String inputPattern = "yyyy-dd-MM";
|
||||
String outputPattern = "dd-MM-yyyy";
|
||||
String inputPattern = "yyyy-MM-dd";
|
||||
String outputPattern = "MM-dd-yyyy";
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern, Locale.getDefault());
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern, Locale.getDefault());
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import androidx.navigation.Navigation;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.TextUtils;
|
||||
import com.app.simplitend.databinding.CreateContactViewHolderBinding;
|
||||
import com.app.simplitend.databinding.CreateEditContactFragmentBinding;
|
||||
import com.app.simplitend.welcome.welcomepatient.fragments.contacts.mvvm.Contact;
|
||||
@@ -171,6 +172,8 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
}
|
||||
}));
|
||||
|
||||
binding.email.addTextChangedListener(TextUtils.LEADING_SPACE_WATCHER);
|
||||
|
||||
imageSelector = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||
@@ -312,6 +315,10 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
|
||||
}else if (mustBeeCaregiver && !Patterns.EMAIL_ADDRESS.matcher(binding.email.getText().toString()).matches()){
|
||||
allOkay = false;
|
||||
binding.email.setError("Invalid email");
|
||||
}else if (!mustBeeCaregiver && !binding.email.getText().toString().isEmpty() && !Patterns.EMAIL_ADDRESS.matcher(binding.email.getText().toString()).matches()){
|
||||
// optional email is not blank and invalid
|
||||
allOkay = false;
|
||||
binding.email.setError("Invalid email");
|
||||
}
|
||||
|
||||
// if (binding.countryCodes.getSelectedIndex() == -1 && allOkay) {
|
||||
|
||||
@@ -151,7 +151,11 @@ public class CreatePinFragment extends Fragment implements WelcomeContracts.Regi
|
||||
} else if (binding.confirmPin.getText() == null ||
|
||||
!binding.confirmPin.getText().toString().equals(binding.pin.getText().toString())) {
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Confirm pin doesn't match.", Toast.LENGTH_SHORT).show();
|
||||
if (binding.confirmPin.getText().toString().trim().isEmpty()){
|
||||
Toast.makeText(requireContext(), "Please enter confirm pin", Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
Toast.makeText(requireContext(), "Confirm pin doesn't match.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
|
||||
Reference in New Issue
Block a user