,
This commit is contained in:
2
.idea/deploymentTargetDropDown.xml
generated
2
.idea/deploymentTargetDropDown.xml
generated
@@ -12,7 +12,7 @@
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-11-16T15:42:30.248939Z" />
|
||||
<timeTargetWasSelectedWithDropDown value="2023-11-17T15:19:06.042756Z" />
|
||||
<targetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
|
||||
@@ -96,6 +96,7 @@ public abstract class AppUtil {
|
||||
public static final String CG_REGISTRATION_COMPLETE = "cg_registration_complete";
|
||||
|
||||
public static final String PATIENT_UID = "patient_uid";
|
||||
|
||||
public static final String IS_PATIENT_LOGGED_IN = "patient_logged_in";
|
||||
|
||||
public static final String WHITE_LISTED_CONTACTS = "white_listed_contacts";
|
||||
@@ -502,12 +503,21 @@ public abstract class AppUtil {
|
||||
|
||||
title = patient_name + " requested for directions to home";
|
||||
body = "Current location:";
|
||||
String senior_address = intent.getStringExtra(NOTIFICATION_SENIOR_ADDRESS_KEY);
|
||||
String doh_distance = intent.getStringExtra(NOTIFICATION_SENIOR_ADDRESS_KEY);
|
||||
|
||||
try {
|
||||
double distance = Double.parseDouble(doh_distance);
|
||||
if (distance == 0) throw new Exception();
|
||||
|
||||
doh_distance = distance + " miles away from home";
|
||||
}catch (Exception e){
|
||||
doh_distance = "Unable to locate";
|
||||
}
|
||||
|
||||
setupBottomSheet(binding,
|
||||
R.drawable.img_directioin_requested,
|
||||
title, body,
|
||||
senior_address, "Call senior",
|
||||
doh_distance, "Call senior",
|
||||
v -> {
|
||||
CaregiverDataCache.getCaregiverData(context, (careGiverData -> {
|
||||
bsd.dismiss();
|
||||
@@ -681,7 +691,8 @@ public abstract class AppUtil {
|
||||
setWhiteListedContacts(context, null);
|
||||
|
||||
// geofence details clear
|
||||
updatePatientGeofence(context, null, null, null, null);
|
||||
updatePatientGeofence(context, null, null, null, null, null);
|
||||
updatePatientGeofenceChatsCred(context, -1, -1);
|
||||
|
||||
// removing geofence of same tag
|
||||
removeGeofence(context);
|
||||
@@ -807,8 +818,42 @@ public abstract class AppUtil {
|
||||
private static final String PATIENT_GEOFENCE_RADIUS_UNIT = "patient_geofence_radius_unit";
|
||||
private static final String PATIENT_GEOFENCE_LATITUDE = "patient_geofence_latitude";
|
||||
private static final String PATIENT_GEOFENCE_LONGITUDE = "patient_geofence_longitude";
|
||||
private static final String PATIENT_GEOFENCE_MESSAGE = "patient_geofence_message";
|
||||
|
||||
public static void updatePatientGeofence(Context context, String lat, String lng, String radius, String radius_unit) {
|
||||
private static final String PATIENT_GEOFENCE_CG_ID = "pg_cg_uid";
|
||||
private static final String PATIENT_GEOFENCE_CHANNEL_ID = "pg_channel_uid";
|
||||
|
||||
public static void updatePatientGeofenceChatsCred(Context context,
|
||||
int cg_id,
|
||||
int channel_id){
|
||||
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
|
||||
editor.putInt(PATIENT_GEOFENCE_CG_ID, cg_id);
|
||||
editor.putInt(PATIENT_GEOFENCE_CHANNEL_ID, channel_id);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
// return array of size 3
|
||||
// index content
|
||||
// 0 -> patient_id
|
||||
// 1 -> caregiver_id
|
||||
// 2 -> channel_id
|
||||
@NonNull
|
||||
public static int[] getPatientGeofenceChatCred(Context context){
|
||||
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
|
||||
return new int[]{sp.getInt(PATIENT_UID, -1),
|
||||
sp.getInt(PATIENT_GEOFENCE_CG_ID, -1),
|
||||
sp.getInt(PATIENT_GEOFENCE_CHANNEL_ID, -1)};
|
||||
}
|
||||
|
||||
public static void updatePatientGeofence(Context context,
|
||||
String lat,
|
||||
String lng,
|
||||
String radius,
|
||||
String radius_unit,
|
||||
String message) {
|
||||
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
|
||||
@@ -816,6 +861,7 @@ public abstract class AppUtil {
|
||||
editor.putString(PATIENT_GEOFENCE_LONGITUDE, lng);
|
||||
editor.putString(PATIENT_GEOFENCE_RADIUS, radius);
|
||||
editor.putString(PATIENT_GEOFENCE_RADIUS_UNIT, radius_unit);
|
||||
editor.putString(PATIENT_GEOFENCE_MESSAGE, message);
|
||||
|
||||
editor.apply();
|
||||
Log.d(GEOFENCE_TAG, "updatePatientGeofence: UPDATED");
|
||||
@@ -836,6 +882,11 @@ public abstract class AppUtil {
|
||||
return sp.getString(PATIENT_GEOFENCE_RADIUS_UNIT, null);
|
||||
}
|
||||
|
||||
public static String getPatientGeofenceMessage(Context context) {
|
||||
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
|
||||
return sp.getString(PATIENT_GEOFENCE_MESSAGE, null);
|
||||
}
|
||||
|
||||
public static void setWhiteListedContacts(Context context, List<ContactData> contactList){
|
||||
Set<String> contactSet;
|
||||
|
||||
|
||||
@@ -82,12 +82,18 @@ public class NotificationService implements INotificationServiceExtension {
|
||||
double lat = extras.getDouble("lat");
|
||||
double lng = extras.getDouble("lng");
|
||||
double radius = extras.getDouble("radius");
|
||||
String message;
|
||||
try {
|
||||
message = extras.getString("message");
|
||||
} catch (JSONException e) {
|
||||
message = null;
|
||||
}
|
||||
|
||||
Log.d(GEOFENCE_TAG, "DATA RECEIVED WITH NOTIFICATION : Lat/Lng: " + lat + "," + lng + " Radius: " + radius);
|
||||
|
||||
if (radius >= 0){
|
||||
addGeoFence(new LatLng(lat, lng),
|
||||
radius, iNotificationReceivedEvent.getContext());
|
||||
radius, message, iNotificationReceivedEvent.getContext());
|
||||
}
|
||||
}catch (Exception e){
|
||||
Log.e(GEOFENCE_TAG, "COULDN'T CREATE GEOFENCE: " + e);
|
||||
@@ -100,7 +106,7 @@ public class NotificationService implements INotificationServiceExtension {
|
||||
}
|
||||
|
||||
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
private void addGeoFence(@NonNull LatLng latLng, double GEOFENCING_RADIUS , Context context) {
|
||||
private void addGeoFence(@NonNull LatLng latLng, double GEOFENCING_RADIUS, String message, Context context) {
|
||||
AppUtil.removeGeofence(context);
|
||||
|
||||
GeoFenceHelper geoFenceHelper = new GeoFenceHelper(context);
|
||||
@@ -123,7 +129,7 @@ public class NotificationService implements INotificationServiceExtension {
|
||||
.addOnSuccessListener(aVoid -> {
|
||||
Log.d(GEOFENCE_TAG, "Geofence added successfully.");
|
||||
AppUtil.updatePatientGeofence(context, latLng.latitude+"", latLng.longitude+"",
|
||||
GEOFENCING_RADIUS+"", "kms");
|
||||
GEOFENCING_RADIUS+"", "kms", message);
|
||||
})
|
||||
.addOnFailureListener(e -> Log.d(GEOFENCE_TAG, "onFailure: Geofence couldn't be added: " + e.getLocalizedMessage() + " " + latLng + " Radius: " + GEOFENCING_RADIUS));
|
||||
|
||||
|
||||
@@ -11,8 +11,13 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
public abstract class RetrofitHelper {
|
||||
|
||||
// urls
|
||||
|
||||
// Testing BASE URL
|
||||
private static final String BASE_URL = "https://simplitend.betadelivery.com/";
|
||||
|
||||
// Staging BASE URL
|
||||
// private static final String BASE_URL = "https://simplitendapp.betadelivery.com/";
|
||||
|
||||
public static final String CREATE_CONTACT = "api/contact-create";
|
||||
|
||||
public static final String UPDATE_CONTACT = "api/patient-contact-update/";
|
||||
|
||||
@@ -40,8 +40,8 @@ public class CaregiverMainViewModel extends ViewModel {
|
||||
public String ongoingActivityText, upcomingActivityText;
|
||||
public String upcomingReminderText, dailyReminderText;
|
||||
|
||||
public List<ReminderResult> remindersList;
|
||||
public List<RoutineDetails> activityList;
|
||||
public static List<ReminderResult> remindersList;
|
||||
public static List<RoutineDetails> activityList;
|
||||
|
||||
public CaregiverMainViewModel(){
|
||||
this.cgHomeRepository = CgHomeRepository.getHomeRepository();
|
||||
|
||||
@@ -164,7 +164,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (careGiverData != null) {
|
||||
SocketHelper.getInstance().removeLocationUpdateListener(careGiverData.patientId+"");
|
||||
SocketHelper.getInstance().removeLocationUpdateListener(careGiverData.patientId + "");
|
||||
}
|
||||
|
||||
SocketHelper.getInstance().closeConnection();
|
||||
@@ -172,20 +172,20 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
private void establishSocketConnection() {
|
||||
CaregiverDataCache.getCaregiverData(this, (careGiverData1 -> {
|
||||
if (careGiverData1 != null){
|
||||
if (careGiverData1 != null) {
|
||||
this.careGiverData = careGiverData1;
|
||||
|
||||
SocketHelper socketHelper = SocketHelper.getInstance();
|
||||
socketHelper.establishConnection(null);
|
||||
|
||||
Log.d(LOCATION_REQUEST_TAG, "CG STARTED LISTENING TO LOCATION UPDATES");
|
||||
socketHelper.getLocationUpdates(careGiverData1.patientId+"", new SocketHelper.Callback<Location>() {
|
||||
socketHelper.getLocationUpdates(careGiverData1.patientId + "", new SocketHelper.Callback<Location>() {
|
||||
@Override
|
||||
public void onMessageReceived(Location result) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "LOCATION RECEIVED: " + result);
|
||||
if (result != null){
|
||||
if (result != null) {
|
||||
// running on main thread
|
||||
new Handler(Looper.getMainLooper()).post(()-> {
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
pat_cur_latLng = new LatLng(result.getLatitude(), result.getLongitude());
|
||||
updateCurrentLocationPatientMarker();
|
||||
updatePatientCurrentLocationDetails();
|
||||
@@ -224,11 +224,10 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
}
|
||||
}
|
||||
|
||||
if (geoFenceDetails.type == null){
|
||||
if (geoFenceDetails.type == null) {
|
||||
// default
|
||||
geofence_bs_binding.unitSpinner.selectItemByIndex(1);
|
||||
}
|
||||
else if (MILES.equals(geoFenceDetails.type)) {
|
||||
} else if (MILES.equals(geoFenceDetails.type)) {
|
||||
geofence_bs_binding.unitSpinner.selectItemByIndex(1);
|
||||
radius = radius / 1609.34f;
|
||||
} else {
|
||||
@@ -262,10 +261,10 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
binding.backBtn.setOnClickListener(v -> onBackPressed());
|
||||
|
||||
binding.changeBtn.setOnClickListener(v -> {
|
||||
if (binding.search.getVisibility() == View.VISIBLE){
|
||||
if (binding.search.getVisibility() == View.VISIBLE) {
|
||||
binding.search.setVisibility(View.GONE);
|
||||
binding.changeBtn.setText(getString(R.string.change));
|
||||
}else{
|
||||
} else {
|
||||
binding.changeBtn.setText(getString(R.string.close_));
|
||||
binding.search.setVisibility(View.VISIBLE);
|
||||
}
|
||||
@@ -282,7 +281,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
});
|
||||
|
||||
geofence_bs_binding.cancelSetGf.setOnClickListener(v -> {
|
||||
if (bottomSheetDialog != null){
|
||||
if (bottomSheetDialog != null) {
|
||||
bottomSheetDialog.dismiss();
|
||||
}
|
||||
});
|
||||
@@ -313,21 +312,22 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
getString(R.string.ok), ((dialogInterface, i) -> {
|
||||
updatePatientAddress();
|
||||
}),
|
||||
"Cancel", ((dialogInterface, i) -> {}));
|
||||
"Cancel", ((dialogInterface, i) -> {
|
||||
}));
|
||||
} else {
|
||||
Toast.makeText(this, "Cannot update address.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
binding.homeLocationBtn.setOnClickListener(v -> {
|
||||
if (mMap != null && home_loc_marker != null){
|
||||
if (mMap != null && home_loc_marker != null) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(home_loc_marker.getPosition(), 16));
|
||||
isTrackingSenior = false;
|
||||
}
|
||||
});
|
||||
|
||||
binding.cgLocationBtn.setOnClickListener(v -> {
|
||||
if (mMap != null && curr_loc_marker != null){
|
||||
if (mMap != null && curr_loc_marker != null) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(curr_loc_marker.getPosition(), 16));
|
||||
isTrackingSenior = true;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
if (patientData == null) return;
|
||||
|
||||
try {
|
||||
if (pat_cur_latLng != null){
|
||||
if (pat_cur_latLng != null) {
|
||||
// calculating distance
|
||||
LatLng homeLatLng = new LatLng(Double.parseDouble(patientData.lat),
|
||||
Double.parseDouble(patientData.lng));
|
||||
@@ -353,9 +353,9 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
double distance = homeL.distanceTo(currL);
|
||||
distance /= 1609.34; // converting to Miles
|
||||
if (distance <= 0.015){
|
||||
if (distance <= 0.015) {
|
||||
binding.distanceAwayTxt.setText(patientData.first_name + " is at Home");
|
||||
}else{
|
||||
} else {
|
||||
binding.distanceAwayTxt.setText(String.format(patientData.first_name + " is %.2f miles away", distance));
|
||||
}
|
||||
}
|
||||
@@ -366,19 +366,19 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
StringBuilder senior_address = new StringBuilder("");
|
||||
|
||||
if (patientData.address_line1 != null){
|
||||
if (patientData.address_line1 != null) {
|
||||
senior_address.append(patientData.address_line1).append(", ");
|
||||
}
|
||||
|
||||
if (patientData.city != null){
|
||||
if (patientData.city != null) {
|
||||
senior_address.append(patientData.city).append(", ");
|
||||
}
|
||||
|
||||
if (patientData.state != null){
|
||||
if (patientData.state != null) {
|
||||
senior_address.append(patientData.state).append(", ");
|
||||
}
|
||||
|
||||
if (patientData.country != null){
|
||||
if (patientData.country != null) {
|
||||
senior_address.append(patientData.country).append(".");
|
||||
}
|
||||
|
||||
@@ -403,19 +403,18 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
|
||||
Map<String, String> body = new HashMap<>();
|
||||
|
||||
String addressLine;
|
||||
addressLine = (address.getThoroughfare() != null ? address.getThoroughfare() : address.getSubThoroughfare());
|
||||
|
||||
if (addressLine == null || addressLine.isEmpty()){
|
||||
addressLine = "";
|
||||
if (address.getMaxAddressLineIndex() >= 0 && address.getAddressLine(0) != null){
|
||||
String[] addressLines = address.getAddressLine(0).split(",");
|
||||
for (int i = 0; i < Math.min(2, addressLines.length); i++) {
|
||||
addressLine = addressLine.concat(addressLines[i]);
|
||||
}
|
||||
String addressLine = "";
|
||||
if (address.getMaxAddressLineIndex() >= 0 && address.getAddressLine(0) != null) {
|
||||
String[] addressLines = address.getAddressLine(0).split(",");
|
||||
for (int i = 0; i < Math.min(1, addressLines.length); i++) {
|
||||
addressLine = addressLine.concat(addressLines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (addressLine.isEmpty()){
|
||||
addressLine = (address.getThoroughfare() != null ? address.getThoroughfare() : address.getSubThoroughfare());
|
||||
}
|
||||
|
||||
body.put("town", (address.getSubLocality() != null ? address.getSubLocality() : address.getLocality()));
|
||||
body.put("street", addressLine);
|
||||
body.put("state", address.getAdminArea());
|
||||
@@ -529,7 +528,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
updateCurrentLocationPatientMarker();
|
||||
|
||||
mMap.setOnMapClickListener(latLng1 -> {
|
||||
if (binding.search.getVisibility() != View.VISIBLE){
|
||||
if (binding.search.getVisibility() != View.VISIBLE) {
|
||||
// search bar is not visible
|
||||
// user is not intending to change the home location
|
||||
return;
|
||||
@@ -548,7 +547,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
}
|
||||
|
||||
private void updateCurrentLocationPatientMarker() {
|
||||
if (pat_cur_latLng != null){
|
||||
if (pat_cur_latLng != null) {
|
||||
String name;
|
||||
if (patientData != null) name = patientData.first_name;
|
||||
else name = "Senior's location";
|
||||
@@ -562,7 +561,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
if (curr_loc_marker != null) curr_loc_marker.remove();
|
||||
curr_loc_marker = mMap.addMarker(options);
|
||||
|
||||
if (isTrackingSenior){
|
||||
if (isTrackingSenior) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLng(pat_cur_latLng));
|
||||
}
|
||||
}
|
||||
@@ -621,7 +620,6 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
|
||||
private void registerMapSearchResultLauncher() {
|
||||
|
||||
// initializing places
|
||||
|
||||
// Initialize the SDK
|
||||
Places.initialize(this, getString(R.string.GOOGLE_MAPS_API_KEY));
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ public class DefaultLocationClient implements LocationClient{
|
||||
}
|
||||
|
||||
locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, interval)
|
||||
.setMinUpdateIntervalMillis(2000) // get fasted updates if available every 2 sec
|
||||
.build();
|
||||
|
||||
locationCallback = new LocationCallback() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.patient_dashboard.chats.SocketHelper;
|
||||
import com.app.simplitend.patientgeofencing.PatientLocationUpdatesReceiver;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
|
||||
@@ -35,6 +36,8 @@ public class LocationService extends Service implements LocationClient.DefaultLo
|
||||
super.onCreate();
|
||||
locationClient = new DefaultLocationClient(this,
|
||||
LocationServices.getFusedLocationProviderClient(this));
|
||||
|
||||
SocketHelper.getInstance().establishConnection(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,9 +63,12 @@ public class LocationService extends Service implements LocationClient.DefaultLo
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
removeLocationUpdates();
|
||||
SocketHelper.getInstance().closeConnection();
|
||||
}
|
||||
|
||||
private void startLocationUpdates(int minInterval){
|
||||
SocketHelper.getInstance().establishConnection(null);
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this, LOCATION_NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle("SimpliTend is sharing your current location")
|
||||
.setSmallIcon(R.mipmap.ic_launcher_round)
|
||||
@@ -89,6 +95,7 @@ public class LocationService extends Service implements LocationClient.DefaultLo
|
||||
stopForeground(true);
|
||||
stopSelf();
|
||||
removeLocationUpdates();
|
||||
SocketHelper.getInstance().closeConnection();
|
||||
}
|
||||
|
||||
public void removeLocationUpdates(){
|
||||
|
||||
@@ -48,7 +48,6 @@ 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;
|
||||
|
||||
@@ -123,13 +122,30 @@ public class DirectionToHomeActivity extends AppCompatActivity
|
||||
|
||||
startActivity(intent);
|
||||
|
||||
String current_address = AppUtil.getCompleteAddress(this, pat_lat, pat_lng);
|
||||
if (current_address == null){
|
||||
current_address = "Unable to locate";
|
||||
// String current_address = AppUtil.getCompleteAddress(this, pat_lat, pat_lng);
|
||||
// if (current_address == null){
|
||||
// current_address = "Unable to locate";
|
||||
// }
|
||||
|
||||
double distance;
|
||||
try {
|
||||
|
||||
Location homeLocation = new Location("homeLatLng");
|
||||
homeLocation.setLatitude(pat_lat);
|
||||
homeLocation.setLongitude(pat_lng);
|
||||
|
||||
Location currLocation = new Location("currentLocation");
|
||||
currLocation.setLatitude(pat_cur_lat);
|
||||
currLocation.setLongitude(pat_cur_lng);
|
||||
|
||||
distance = homeLocation.distanceTo(currLocation);
|
||||
distance /= 1609; // converting to miles
|
||||
}catch (Exception e){
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
viewModel.notifyRequestedDirections(AppUtil.getPatientUid(this)+"",
|
||||
current_address,
|
||||
String.format(Locale.getDefault(),"%.2f", distance),
|
||||
AppUtil.getPatientToken(this));
|
||||
});
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class PatientMainViewModel extends ViewModel {
|
||||
return;
|
||||
}
|
||||
|
||||
addGeoFence(latLng, radius, activity, geoFenceDetails.type);
|
||||
addGeoFence(latLng, radius, activity, geoFenceDetails.type, geoFenceDetails.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class PatientMainViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
private void addGeoFence(@NonNull LatLng latLng, float GEOFENCING_RADIUS , Activity activity, String unit) {
|
||||
private void addGeoFence(@NonNull LatLng latLng, float GEOFENCING_RADIUS , Activity activity, String unit, String message) {
|
||||
AppUtil.removeGeofence(activity);
|
||||
|
||||
GeoFenceHelper geoFenceHelper = new GeoFenceHelper(activity);
|
||||
@@ -157,7 +157,7 @@ public class PatientMainViewModel extends ViewModel {
|
||||
.addOnSuccessListener(aVoid -> {
|
||||
Log.d(GEOFENCE_TAG, "Geofence added successfully. " + latLng + " Radius: " + GEOFENCING_RADIUS + " meters");
|
||||
AppUtil.updatePatientGeofence(activity, latLng.latitude+"", latLng.longitude+"",
|
||||
GEOFENCING_RADIUS+"", unit);
|
||||
GEOFENCING_RADIUS+"", unit, message);
|
||||
})
|
||||
.addOnFailureListener(e -> {
|
||||
Log.d(GEOFENCE_TAG, "onFailure: Geofence couldn't be added: " + e.getLocalizedMessage() + " " + latLng + " Radius: " + GEOFENCING_RADIUS);
|
||||
|
||||
@@ -110,12 +110,12 @@ public class ChatFragment extends Fragment implements SocketHelper.Callback<Mess
|
||||
|
||||
@Override
|
||||
public void onConnectionError(Exception e) {
|
||||
|
||||
Log.d(TAG, "onConnectionError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
|
||||
Log.d(TAG, "onDisconnected: ");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ public class SocketHelper {
|
||||
@Override
|
||||
public void call(Object... args) {
|
||||
try {
|
||||
Log.d("aditya_testing", "call: " + args);
|
||||
if (args.length >= 4) {
|
||||
String received_sender_id = (String) args[1];
|
||||
String message_txt = (String) args[2];
|
||||
|
||||
@@ -32,7 +32,6 @@ import androidx.navigation.Navigation;
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.appblocking.FUAActivity;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.CaregiverDataCache;
|
||||
import com.app.simplitend.apputils.Constants;
|
||||
import com.app.simplitend.apputils.PatientDataCache;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
@@ -139,6 +138,36 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
|
||||
this.patientData = patientData;
|
||||
|
||||
setDetails();
|
||||
|
||||
// updating chats credentials to send message when geofence is triggered when patient is out of geofence
|
||||
// to send message to patient on behalf of caregiver
|
||||
|
||||
if (patientData != null && patientData.link_id == null){
|
||||
PatientDataCache.setPatientData(null); // to load new fresh data
|
||||
}
|
||||
|
||||
try {
|
||||
PatientDataCache.getPatientData(requireContext(), (patientData1 -> {
|
||||
try {
|
||||
if (patientData != null){
|
||||
int cg_id = Integer.parseInt(patientData.caregiverId);
|
||||
int channel_id = Integer.parseInt(patientData.link_id);
|
||||
|
||||
AppUtil.updatePatientGeofenceChatsCred(
|
||||
requireContext(),
|
||||
cg_id,
|
||||
channel_id
|
||||
);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
// do nothing
|
||||
}
|
||||
}), false);
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}), true);
|
||||
|
||||
PatientDataCache.getContactList(requireContext(), "Bearer " + AppUtil.getPatientToken(requireContext()),
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
package com.app.simplitend.patientgeofencing;
|
||||
|
||||
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_TAG;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import com.app.simplitend.locationupdates.LocationService;
|
||||
import com.google.android.gms.location.Geofence;
|
||||
import com.google.android.gms.location.GeofencingEvent;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.apputils.RetrofitHelper;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.NotificationApiService;
|
||||
import com.app.simplitend.locationupdates.LocationService;
|
||||
import com.app.simplitend.patient_dashboard.chats.SocketHelper;
|
||||
import com.app.simplitend.patient_dashboard.chats.mvvm.Message;
|
||||
import com.app.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
|
||||
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_TAG;
|
||||
import com.google.android.gms.location.Geofence;
|
||||
import com.google.android.gms.location.GeofencingEvent;
|
||||
import com.onesignal.OneSignal;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -31,14 +37,12 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
|
||||
|
||||
|
||||
if (geofencingEvent == null || geofencingEvent.hasError()) {
|
||||
Log.d(GEOFENCE_TAG, "onReceive: Couldn't add geofence");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(GEOFENCE_TAG, "onReceive: " + intent.getExtras());
|
||||
|
||||
int transition_type = geofencingEvent.getGeofenceTransition();
|
||||
Location location = geofencingEvent.getTriggeringLocation();
|
||||
|
||||
@@ -63,7 +67,7 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
distance = homeLocation.distanceTo(location);
|
||||
distance /= 1609; // converting to miles
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
distance = 0;
|
||||
}
|
||||
|
||||
@@ -75,17 +79,104 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
|
||||
Log.d(GEOFENCE_TAG, "onReceive: ENTER");
|
||||
Intent locationServiceIntent = new Intent(context, LocationService.class);
|
||||
locationServiceIntent.setAction(LocationService.ACTION_START_LOCATION_UPDATES);
|
||||
locationServiceIntent.putExtra(LOCATION_UPDATE_MIN_INTERVAL, LOCATION_INTERVAL_BASE_TIME
|
||||
);
|
||||
locationServiceIntent.putExtra(LOCATION_UPDATE_MIN_INTERVAL, LOCATION_INTERVAL_BASE_TIME);
|
||||
context.startService(locationServiceIntent);
|
||||
break;
|
||||
case Geofence.GEOFENCE_TRANSITION_EXIT:
|
||||
Log.d(GEOFENCE_TAG, "onReceive: EXIT");
|
||||
notifyOutOfGeofence(context, String.format(Locale.getDefault(),"%.2f", distance));
|
||||
notifyOutOfGeofence(context, String.format(Locale.getDefault(), "%.2f", distance));
|
||||
|
||||
notifyPatient(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyPatient(Context context) {
|
||||
Log.d(GEOFENCE_TAG, "notifyPatient: SENDING MESSAGE TO SENIOR PHONE FROM CAREGIVER PHONE");
|
||||
|
||||
String message = AppUtil.getPatientGeofenceMessage(context);
|
||||
if (message == null || message.trim().isEmpty()) {
|
||||
message = "You are too far from home";
|
||||
}
|
||||
|
||||
int[] chatsCred = AppUtil.getPatientGeofenceChatCred(context);
|
||||
if (chatsCred[0] == -1 || chatsCred[1] == -1 || chatsCred[2] == -1) {
|
||||
Log.d(GEOFENCE_TAG, "notifyPatient: CANNOT SEND MESSAGE AS EITHER PAT_ID, CG_ID OR CHANNEL_ID IS NOT AVAILABLE");
|
||||
return;
|
||||
}
|
||||
|
||||
// sending message
|
||||
new SendMessageTask(message, chatsCred[0], chatsCred[1], chatsCred[2]).execute();
|
||||
}
|
||||
|
||||
public static class SendMessageTask extends AsyncTask<Void, Void, Void> {
|
||||
@NonNull
|
||||
private final String message;
|
||||
private final int patientId, cg_id, channel_id;
|
||||
|
||||
public SendMessageTask(@NonNull String message, int patientId, int cg_id, int channel_id) {
|
||||
this.patientId = patientId;
|
||||
this.cg_id = cg_id;
|
||||
this.channel_id = channel_id;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
SocketHelper socketHelper = SocketHelper.getInstance();
|
||||
|
||||
socketHelper.getMessage(new SocketHelper.Callback<Message>() {
|
||||
@Override
|
||||
public void onMessageReceived(Message result) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: MESSAGE SENT");
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageSentSuccessfully() {
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: MESSAGE NOT SENT " + e);
|
||||
socketHelper.stopMessages(channel_id + "");
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
}, cg_id + "", channel_id + "", patientId + "", null);
|
||||
|
||||
if (socketHelper.isConnected()) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: ALREADY CONNECTED TO SOCKET");
|
||||
socketHelper.sendMessage(message, cg_id + "", patientId + "", channel_id + "");
|
||||
} else {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: CONNECTING TO SOCKET");
|
||||
|
||||
socketHelper.establishConnection(new SocketHelper.SockCallBack() {
|
||||
@Override
|
||||
public void onSocketConnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTED");
|
||||
socketHelper.sendMessage(message, cg_id + "", patientId + "", channel_id + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionError(Exception e) {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET CONNECTION ERROR " + e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.d(GEOFENCE_TAG, "doInBackground: SOCKET DISCONNECTED");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyOutOfGeofence(Context context, String senior_address) {
|
||||
Log.d(GEOFENCE_TAG, "Sending notification to patient");
|
||||
Log.d(GEOFENCE_TAG, "Current location: " + senior_address);
|
||||
@@ -95,27 +186,26 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
|
||||
body.put("patient_id", AppUtil.getPatientUid(context) + "");
|
||||
body.put("address", senior_address);
|
||||
|
||||
apiService.notifyOutOfGeoFence(body, "Bearer " + AppUtil.getPatientToken(context))
|
||||
.enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.code() == 200){
|
||||
Log.d(GEOFENCE_TAG, "OUT OF GEOFENCE NOTIFICATION SENT SUCCESSFULLY.");
|
||||
}else{
|
||||
Log.d(GEOFENCE_TAG, "Couldn't notify patient " + response.message());
|
||||
}
|
||||
}
|
||||
apiService.notifyOutOfGeoFence(body, "Bearer " + AppUtil.getPatientToken(context)).enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.code() == 200) {
|
||||
Log.d(GEOFENCE_TAG, "OUT OF GEOFENCE NOTIFICATION SENT SUCCESSFULLY.");
|
||||
} else {
|
||||
Log.d(GEOFENCE_TAG, "Couldn't notify patient " + response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<Object>> call, Throwable t) {
|
||||
Log.d(GEOFENCE_TAG, "Couldn't notify patient due to " + t);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<Object>> call, Throwable t) {
|
||||
Log.d(GEOFENCE_TAG, "Couldn't notify patient due to " + t);
|
||||
}
|
||||
});
|
||||
|
||||
// getting faster location updates as patient is out of geofence
|
||||
Intent intent = new Intent(context, LocationService.class);
|
||||
intent.setAction(LocationService.ACTION_START_LOCATION_UPDATES);
|
||||
intent.putExtra(LOCATION_UPDATE_MIN_INTERVAL, 10 * 1000); // every 10 seconds
|
||||
intent.putExtra(LOCATION_UPDATE_MIN_INTERVAL, 5 * 1000); // every 5 seconds
|
||||
context.startService(intent);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.app.simplitend.patientgeofencing;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.Address;
|
||||
import android.location.Location;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
@@ -39,13 +40,13 @@ public class PatientLocationUpdatesReceiver extends BroadcastReceiver {
|
||||
|
||||
int patient_id = AppUtil.getPatientUid(context);
|
||||
String token = AppUtil.getPatientToken(context);
|
||||
if (patient_id != -1 && token != null){
|
||||
if (patient_id != -1 && token != null) {
|
||||
updateRemoteCurrLocation(location, patient_id,
|
||||
"Bearer " + token);
|
||||
}else{
|
||||
Log.e(LOCATION_REQUEST_TAG, "CANNOT UPDATE REMOTE LOCATION AS PATIENT_ID OR TOKEN IS -1 OR NULL RESP." );
|
||||
} else {
|
||||
Log.e(LOCATION_REQUEST_TAG, "CANNOT UPDATE REMOTE LOCATION AS PATIENT_ID OR TOKEN IS -1 OR NULL RESP.");
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Log.e(LOCATION_REQUEST_TAG, "LOCATION RECEIVED IS NULL");
|
||||
}
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public class PatientLocationUpdatesReceiver extends BroadcastReceiver {
|
||||
PatientProfileAPIService apiService = RetrofitHelper.getRetrofit().create(PatientProfileAPIService.class);
|
||||
|
||||
Map<String, String> body = new HashMap<>();
|
||||
body.put("patient_id", patient_id+"");
|
||||
body.put("patient_id", patient_id + "");
|
||||
body.put("lat", location.getLatitude() + "");
|
||||
body.put("lng", location.getLongitude() + "");
|
||||
|
||||
@@ -63,13 +64,13 @@ public class PatientLocationUpdatesReceiver extends BroadcastReceiver {
|
||||
.enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.code() == 200 && response.body().error_code == 0){
|
||||
if (response.body() != null) {
|
||||
if (response.code() == 200 && response.body().error_code == 0) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "LOCATION REMOTE UPDATED.");
|
||||
}else{
|
||||
} else {
|
||||
Log.e(LOCATION_REQUEST_TAG, "LOCATION REMOTE UPDATE FAILED" + response.body().message);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Log.e(LOCATION_REQUEST_TAG, "LOCATION REMOTE UPDATE FAILED" + response.message());
|
||||
}
|
||||
}
|
||||
@@ -83,11 +84,11 @@ public class PatientLocationUpdatesReceiver extends BroadcastReceiver {
|
||||
new UpdateRemoteLocationTask(patient_id + "").execute(location);
|
||||
}
|
||||
|
||||
public static class UpdateRemoteLocationTask extends AsyncTask<Location, Void, Void>{
|
||||
public static class UpdateRemoteLocationTask extends AsyncTask<Location, Void, Void> {
|
||||
@NonNull
|
||||
private final String patientId;
|
||||
|
||||
public UpdateRemoteLocationTask(@NonNull String patientId){
|
||||
public UpdateRemoteLocationTask(@NonNull String patientId) {
|
||||
this.patientId = patientId;
|
||||
}
|
||||
|
||||
@@ -95,53 +96,44 @@ public class PatientLocationUpdatesReceiver extends BroadcastReceiver {
|
||||
protected Void doInBackground(Location... locations) {
|
||||
SocketHelper socketHelper = SocketHelper.getInstance();
|
||||
|
||||
if (socketHelper.isConnected()){
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: ALREADY CONNECTED TO SOCKET");
|
||||
socketHelper.getLocationUpdates(patientId, null);
|
||||
socketHelper.sendLocationUpdates(locations[0], patientId);
|
||||
}else{
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: CONNECTING TO SOCKET");
|
||||
socketHelper.getLocationUpdates(patientId, new SocketHelper.Callback<Location>() {
|
||||
@Override
|
||||
public void onMessageReceived(Location result) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "LOCATION SENT " + result);
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: CONNECTING TO SOCKET");
|
||||
|
||||
@Override
|
||||
public void onMessageSentSuccessfully() {
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
socketHelper.getLocationUpdates(patientId, new SocketHelper.Callback<Location>() {
|
||||
@Override
|
||||
public void onMessageReceived(Location result) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "LOCATION SENT " + result);
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
Log.e(LOCATION_REQUEST_TAG, "LOCATION SENDING PROBLEM", e);
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
socketHelper.closeConnection();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onMessageSentSuccessfully() {
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
}
|
||||
|
||||
socketHelper.establishConnection(new SocketHelper.SockCallBack() {
|
||||
@Override
|
||||
public void onSocketConnected() {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET CONNECTED");
|
||||
socketHelper.sendLocationUpdates(locations[0], patientId);
|
||||
}
|
||||
@Override
|
||||
public void onError(Exception e) {
|
||||
Log.e(LOCATION_REQUEST_TAG, "LOCATION SENDING PROBLEM", e);
|
||||
socketHelper.removeLocationUpdateListener(patientId);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onConnectionError(Exception e) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET CONNECTION ERROR");
|
||||
}
|
||||
socketHelper.establishConnection(new SocketHelper.SockCallBack() {
|
||||
@Override
|
||||
public void onSocketConnected() {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET CONNECTED");
|
||||
socketHelper.sendLocationUpdates(locations[0], patientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET DISCONNECTED");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onConnectionError(Exception e) {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET CONNECTION ERROR" + e);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.d(LOCATION_REQUEST_TAG, "doInBackground: SOCKET DISCONNECTED");
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
import com.app.simplitend.databinding.RemindersFragmentBinding;
|
||||
import com.app.simplitend.patientprofile.ProfileContracts;
|
||||
import com.app.simplitend.patientprofile.medreminder.mvvm.ReminderAdapter;
|
||||
@@ -327,6 +328,13 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
|
||||
|
||||
if (reminderResultList != null && reminderResultList.size() > 0) {
|
||||
// reminders are present
|
||||
|
||||
// updating global list of reminders
|
||||
if (reminderViewModel.selected_dow == 0){
|
||||
// only updating global list of reminders with current day's reminder list
|
||||
CaregiverMainViewModel.remindersList = reminderResultList;
|
||||
}
|
||||
|
||||
binding.remindersRv.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ReminderAdapter extends RecyclerView.Adapter<ReminderAdapter.Remind
|
||||
quantity = reminder.medication_quantity + " spoon";
|
||||
break;
|
||||
case "Cup":
|
||||
binding.medImg.setImageResource(R.drawable.ic_cup);
|
||||
binding.medImg.setImageResource(R.drawable.ic_med_cup);
|
||||
quantity = reminder.medication_quantity + " cup";
|
||||
break;
|
||||
case "Syringe":
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.app.simplitend.R;
|
||||
import com.app.simplitend.apputils.AppUtil;
|
||||
import com.app.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
|
||||
import com.app.simplitend.databinding.RoutineFragmentBinding;
|
||||
import com.app.simplitend.patientprofile.ProfileContracts;
|
||||
import com.app.simplitend.patientprofile.medreminder.WeekDayViewHolder;
|
||||
@@ -341,6 +342,12 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
|
||||
|
||||
if (routineList != null && routineList.size() > 0) {
|
||||
// reminders are present
|
||||
|
||||
// updating global list of activities for today's day
|
||||
if (routineViewModel.selected_dow == 0) {
|
||||
CaregiverMainViewModel.activityList = routineList;
|
||||
}
|
||||
|
||||
binding.routineRv.setVisibility(View.VISIBLE);
|
||||
binding.noData.setVisibility(View.GONE);
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ public class SignInFragment extends Fragment implements WelcomeContracts.Registe
|
||||
public void onResponse(PatientData patientResult, String token) {
|
||||
// caching user data
|
||||
PatientDataCache.setPatientData(patientResult);
|
||||
|
||||
AppUtil.savePatientData(token, patientResult.patientId, requireContext(), true);
|
||||
|
||||
progressDialog.dismiss();
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable/ic_med_cup.png
Normal file
BIN
app/src/main/res/drawable/ic_med_cup.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Reference in New Issue
Block a user