This commit is contained in:
14Sandee
2023-10-30 20:58:54 +05:30
parent eba28dd428
commit 44c788d5de
12 changed files with 206 additions and 34 deletions

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="RZCW41EJRPN" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-10-30T14:39:29.458770Z" />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />

View File

@@ -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);
}
}
}

View File

@@ -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);
});
}

View File

@@ -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());

View File

@@ -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) {

View File

@@ -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;

View File

@@ -122,37 +122,67 @@
android:background="@drawable/edit_text_bg_2"
>
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:text="@string/your_location"
android:fontFamily="@font/nunito_medium"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.Material3.TitleSmall"
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/img_pat_curr_location"
android:scaleType="fitXY"
/>
android:drawablePadding="15dp"
app:drawableStartCompat="@drawable/ic_plus" />
<TextView
android:id="@+id/your_loc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="@string/your_location"
android:fontFamily="@font/nunito_medium"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.Material3.TitleSmall" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_dotted_dash"
android:layout_marginStart="10dp"
android:layout_marginStart="11dp"
android:layout_marginVertical="5dp"/>
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:text="@string/home_address_txt"
android:fontFamily="@font/nunito_medium"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.Material3.TitleSmall"
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="@drawable/img_home_marker"
android:scaleType="fitXY"
/>
android:drawablePadding="15dp"
app:drawableStartCompat="@drawable/ic_plus" />
<TextView
android:id="@+id/home_loc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:text="@string/home_address_txt"
android:fontFamily="@font/nunito_medium"
android:textColor="@color/black"
android:textAppearance="@style/TextAppearance.Material3.TitleSmall" />
</LinearLayout>
</LinearLayout>

View File

@@ -89,7 +89,7 @@
android:layout_width="@dimen/_100sdp"
android:layout_height="@dimen/_100sdp"
android:contentDescription="@string/onboard_image"
android:src="@drawable/ic_contact" />
android:src="@drawable/senior_img" />
</com.google.android.material.card.MaterialCardView>

View File

@@ -76,6 +76,8 @@
android:maxLength="50"
android:digits="@string/allowed_alphabets_n_numbers_with_space"
/>
<TextView

View File

@@ -2,7 +2,8 @@
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:layout_width="match_parent"
@@ -21,7 +22,7 @@
android:background="@android:color/transparent"
app:title="Welcome Aditya"
tools:title="Welcome Aditya"
android:layout_marginEnd="40dp"

View File

@@ -367,6 +367,7 @@
android:textColorHint="@android:color/darker_gray"
android:maxLength="255"
/>
<LinearLayout

View File

@@ -416,7 +416,7 @@
<string name="home_address_txt">Home Address</string>
<string name="go">go</string>
<string name="call_and_message_your_loved_ones">Call and message your loved ones</string>
<string name="select_number_to_cal_or_message">Select number to cal or message</string>
<string name="select_number_to_cal_or_message">Select number to call or message</string>
<string name="call">Call</string>
<string name="no_frequently_used_apps">No frequently used apps added\nPlease select an app from below list to unlock.</string>
<string name="no_frequently_used_apps_set_up">No frequently used apps added\nGoto Profile -> Frequently used apps to setup this feature.</string>