From f713bb75558da909c28db6aed63b87cf02cc1b55 Mon Sep 17 00:00:00 2001 From: 14Sandee Date: Mon, 6 Nov 2023 21:00:43 +0530 Subject: [PATCH] . --- .../simplitend/appblocking/FUAActivity.java | 18 +++ .../com/app/simplitend/apputils/AppUtil.java | 21 +++- .../fragments/CgDashBoardFragment.java | 49 ++------ .../mvvm/CaregiverMainViewModel.java | 110 +----------------- .../cg_geofencing/CgGeoFencingActivity.java | 103 +++++++++------- .../CgSubscriptionActivity.java | 2 +- .../PatientMainViewModel.java | 86 +++++++------- .../fragments/PatientDashboardFragment.java | 2 +- .../medreminder/AddReminderFragment.java | 82 +++++-------- .../medreminder/ReminderFragment.java | 5 +- .../medreminder/mvvm/ReminderAdapter.java | 15 +-- .../medreminder/mvvm/ReminderRepository.java | 2 +- .../mvvm/models/ReminderResult.java | 9 +- app/src/main/res/drawable/ic_dash_small.xml | 2 +- .../res/layout/activity_cg_geofencing.xml | 61 +++++++--- .../res/layout/activity_personal_info.xml | 4 +- .../main/res/layout/add_reminder_fragment.xml | 2 + .../main/res/layout/bottom_sheet_alert.xml | 2 +- .../res/layout/caregiver_dash_fragment.xml | 13 ++- .../main/res/layout/create_pin_fragment.xml | 12 +- app/src/main/res/layout/fua_edu_dialog.xml | 51 ++++++++ .../main/res/layout/geofence_bottom_sheet.xml | 40 +------ app/src/main/res/values/strings.xml | 30 +++-- 23 files changed, 341 insertions(+), 380 deletions(-) create mode 100644 app/src/main/res/layout/fua_edu_dialog.xml diff --git a/app/src/main/java/com/app/simplitend/appblocking/FUAActivity.java b/app/src/main/java/com/app/simplitend/appblocking/FUAActivity.java index 3b652a2..87c7f0f 100644 --- a/app/src/main/java/com/app/simplitend/appblocking/FUAActivity.java +++ b/app/src/main/java/com/app/simplitend/appblocking/FUAActivity.java @@ -1,6 +1,9 @@ package com.app.simplitend.appblocking; +import android.app.AlertDialog; +import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; @@ -17,6 +20,7 @@ import android.provider.Telephony; import android.text.TextUtils; import android.util.Log; import android.view.View; +import android.widget.CompoundButton; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -28,6 +32,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.app.simplitend.R; import com.app.simplitend.apputils.AppUtil; +import com.app.simplitend.databinding.FuaEduDialogBinding; import java.util.ArrayList; import java.util.Collections; @@ -68,6 +73,19 @@ public class FUAActivity extends AppCompatActivity { no_fua_txt = findViewById(R.id.no_fua_text); all_apps_title = findViewById(R.id.all_app_tile); fua_sub_title = findViewById(R.id.fua_sub_title); + + if (AppUtil.shouldShowFUADialog(this)){ + FuaEduDialogBinding dialogBinding = FuaEduDialogBinding.inflate(getLayoutInflater()); + Dialog fuaDialog = new Dialog(this, R.style.BottomSheetDialog); + fuaDialog.setContentView(dialogBinding.getRoot()); + + dialogBinding.checkBox.setOnCheckedChangeListener((compoundButton, b) -> { + AppUtil.setShouldShowFuaDialog(this, !b); + }); + + dialogBinding.close.setOnClickListener(v -> fuaDialog.dismiss()); + fuaDialog.show(); + } if (!isAccessibilityAppBlockingEnabled()) { openAccessibilityDialog(); diff --git a/app/src/main/java/com/app/simplitend/apputils/AppUtil.java b/app/src/main/java/com/app/simplitend/apputils/AppUtil.java index d1e9944..f8d580a 100644 --- a/app/src/main/java/com/app/simplitend/apputils/AppUtil.java +++ b/app/src/main/java/com/app/simplitend/apputils/AppUtil.java @@ -321,7 +321,7 @@ public abstract class AppUtil { setupBottomSheet(binding, R.drawable.img_medication_time, title, "Current location", - "Unknown", "Call patient", + "Unknown", "Call senior", v -> { CaregiverDataCache.getCaregiverData(context, (careGiverData -> { bsd.dismiss(); @@ -433,7 +433,7 @@ public abstract class AppUtil { setupBottomSheet(binding, R.drawable.img_directioin_requested, title, body, - null, "Call patient", + null, "Call senior", v -> { CaregiverDataCache.getCaregiverData(context, (careGiverData -> { bsd.dismiss(); @@ -460,7 +460,7 @@ public abstract class AppUtil { setupBottomSheet(binding, R.drawable.img_sos_requested, title, body, - null, "Call patient", + null, "Call senior", v -> { CaregiverDataCache.getCaregiverData(context, (careGiverData -> { bsd.dismiss(); @@ -579,6 +579,8 @@ public abstract class AppUtil { stop_accessibility_intent.setAction(TopAppDetectionService.STOP_ACCESSIBILITY_SERVICE); context.startService(stop_accessibility_intent); + setShouldShowFuaDialog(context, true); + // removing contact listing setWhiteListedContacts(context, null); @@ -691,6 +693,19 @@ public abstract class AppUtil { return sp.getBoolean(notification, true); } + private static final String FUA_DIALOG = "FUA_dialog"; + + public static void setShouldShowFuaDialog(Context context, boolean b){ + SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE); + SharedPreferences.Editor editor = sp.edit(); + editor.putBoolean(FUA_DIALOG, b); + editor.apply(); + } + public static boolean shouldShowFUADialog(Context context){ + SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE); + return sp.getBoolean(FUA_DIALOG, true); + } + // patient geofencing private static final String PATIENT_GEOFENCE_RADIUS = "patient_geofence_radius"; private static final String PATIENT_GEOFENCE_RADIUS_UNIT = "patient_geofence_radius_unit"; diff --git a/app/src/main/java/com/app/simplitend/caregiverdashboard/fragments/CgDashBoardFragment.java b/app/src/main/java/com/app/simplitend/caregiverdashboard/fragments/CgDashBoardFragment.java index 1c7f83e..7889dfe 100644 --- a/app/src/main/java/com/app/simplitend/caregiverdashboard/fragments/CgDashBoardFragment.java +++ b/app/src/main/java/com/app/simplitend/caregiverdashboard/fragments/CgDashBoardFragment.java @@ -160,7 +160,6 @@ public class CgDashBoardFragment extends Fragment implements if (careGiverData == null) return; binding.nearestReminder.setText(viewModel.upcomingReminderText); - binding.dailyReminder.setText(viewModel.dailyReminderText); reminderViewModel.getRemindersList(careGiverData.patientId, Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1, @@ -226,7 +225,6 @@ public class CgDashBoardFragment extends Fragment implements binding.upcomingActivity.setText(viewModel.upcomingActivityText); binding.onGoingActivity.setText(viewModel.ongoingActivityText); binding.nearestReminder.setText(viewModel.upcomingReminderText); - binding.dailyReminder.setText(viewModel.dailyReminderText); loadReminders(); loadActivities(); @@ -437,10 +435,8 @@ public class CgDashBoardFragment extends Fragment implements binding.refreshBtn.setVisibility(View.VISIBLE); binding.nearestReminder.setText(R.string.couldnt_load_data); - binding.dailyReminder.setText(R.string.couldnt_load_data); viewModel.upcomingReminderText = binding.nearestReminder.getText().toString(); - viewModel.dailyReminderText = binding.dailyReminder.getText().toString(); } @Override @@ -450,25 +446,6 @@ public class CgDashBoardFragment extends Fragment implements binding.refreshProgress.setVisibility(View.GONE); binding.refreshBtn.setVisibility(View.VISIBLE); - try { - // daily routine setting - String daily_r_txt; - - if (nearestReminder.daily_reminder_time == null){ - daily_r_txt = "No daily reminders for today"; - }else{ - SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); - SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault()); - - String daily_r_time = format_sdf.format(Objects.requireNonNull(input_sdf.parse(nearestReminder.daily_reminder_time))); - daily_r_txt = "Daily reminder at " + daily_r_time; - } - - binding.dailyReminder.setText(daily_r_txt); - }catch (Exception e){ - binding.dailyReminder.setText(R.string.couldnt_load_data); - } - // next reminder setting try { if (nearestReminder == null) throw new Exception(); @@ -476,7 +453,6 @@ public class CgDashBoardFragment extends Fragment implements if (nearestReminder.upcoming_time == null){ binding.nearestReminder.setText(R.string.all_reminder_done); viewModel.upcomingReminderText = binding.nearestReminder.getText().toString(); - viewModel.dailyReminderText = binding.dailyReminder.getText().toString(); return; } @@ -501,25 +477,15 @@ public class CgDashBoardFragment extends Fragment implements long m = (time_diff / 60) % 60; long h = (time_diff / (60 * 60)) % 24; - StringBuilder reminder_txt = new StringBuilder("Remind " + nearestReminder.medication_name); + StringBuilder reminder_txt = new StringBuilder(nearestReminder.medication_name); - if (time_diff > 3600){ - // time greater than 60 mins - // thus, showing direct time - SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault()); + SimpleDateFormat format_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault()); - try { - String time = format_sdf.format(upcoming_date); - reminder_txt.append(" at ").append(time); - } catch (Exception e) { - reminder_txt.append(" at ").append(nearestReminder.upcoming_time); - } - - }else{ - // show in minutes - reminder_txt.append(" in ").append(m).append(" min"); - - if (m > 1) reminder_txt.append("s"); // plural + try { + String time = format_sdf.format(upcoming_date); + reminder_txt.append(" at ").append(time); + } catch (Exception e) { + reminder_txt.append(" at ").append(nearestReminder.upcoming_time); } binding.nearestReminder.setText(reminder_txt); @@ -530,7 +496,6 @@ public class CgDashBoardFragment extends Fragment implements } viewModel.upcomingReminderText = binding.nearestReminder.getText().toString(); - viewModel.dailyReminderText = binding.dailyReminder.getText().toString(); } @Override diff --git a/app/src/main/java/com/app/simplitend/caregiverdashboard/mvvm/CaregiverMainViewModel.java b/app/src/main/java/com/app/simplitend/caregiverdashboard/mvvm/CaregiverMainViewModel.java index d2d60e3..1eb087a 100644 --- a/app/src/main/java/com/app/simplitend/caregiverdashboard/mvvm/CaregiverMainViewModel.java +++ b/app/src/main/java/com/app/simplitend/caregiverdashboard/mvvm/CaregiverMainViewModel.java @@ -19,7 +19,6 @@ import com.yarolegovich.slidingrootnav.SlidingRootNav; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; @@ -179,26 +178,13 @@ public class CaregiverMainViewModel extends ViewModel { NearestReminder nearestReminder = new NearestReminder(); - try { - for (ReminderResult reminder: reminderResultList){ - - if (reminder.all_days == 1){ - nearestReminder.daily_reminder_time = reminder.time1; - } - - String upcoming_time = selectNextReminder(reminder.time1, reminder.time2, reminder.time3); - - if (upcoming_time != null && smallestTime(upcoming_time, nearestReminder.upcoming_time)){ - // upcoming_time for this reminder is less than nearestReminder.upcoming_time - // thus, updating nearest reminder - - nearestReminder.upcoming_time = upcoming_time; - nearestReminder.reminder_id = reminder.id; - nearestReminder.medication_name = reminder.medicine_name; - } + for (ReminderResult reminder: reminderResultList){ + if (!alreadyPassed(reminder.medicine_time)){ + nearestReminder.upcoming_time = reminder.medicine_time; + nearestReminder.reminder_id = reminder.id; + nearestReminder.medication_name = reminder.medicine_name; + break; } - }catch (Exception e){ - // do nothing } // callback through main thread @@ -206,90 +192,6 @@ public class CaregiverMainViewModel extends ViewModel { }); } - private String selectNextReminder(@NonNull String time1, String time2, String time3) { - return selectNextReminder(time1, selectNextReminder(time2, time3)); - } - - private String selectNextReminder(String time1, String time2) { - if (time1 == null && time2 == null) return null; - if (time2 == null) { - // time 2 is null - // thus, checking if time1 has already passed current_time or not. - - if (alreadyPassed(time1)){ - // the time1 has already passed the current time - // thus, returning null - - return null; - }else{ - // the time1 is yet to come - - return time1; - } - } - if (time1 == null){ - // time1 is null - // thus, checking if time2 has already passed current_time or not. - - if (alreadyPassed(time2)){ - // the time1 has already passed the current time - // thus, returning null - - return null; - }else{ - // the time1 is yet to come - - return time2; - } - } - - // comparing this 2 times with current time - // first converting time string to calendar - SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); - - try { - Date date1 = input_sdf.parse(time1); - Date date2 = input_sdf.parse(time2); - - if (date2 == null || date1 == null) throw new Exception(); - - Calendar cur_cal = Calendar.getInstance(); - Date cur_date = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), cur_cal.get(Calendar.HOUR_OF_DAY), cur_cal.get(Calendar.MINUTE), date1.getSeconds()); - - // All three above dates are of same date 01 Jan 1970 - // but, of different times i.e. hh:mm:ss - - long t1 = date1.getTime(); - long t2 = date2.getTime(); - long c_t = cur_date.getTime(); - - if (t1 < c_t && t2 > c_t){ - // t1 time is passed and t2 time is yet to come for the same day - // thus, returning t2 - return time2; - }else if (t1 > c_t && t2 < c_t){ - // t1 is yet to come for this day, and t2 has already been passed - // thus, returning t1 - return time1; - }else if (t1 > c_t && t2 > c_t){ - // Both the times are greater than current time, yet to come - // In this case, we show the smallest time - - if (t1 < t2) return time1; - else return time2; - }else{ - // Last case would be both the times has passed the current time - // thus, returning null - - return null; - } - - }catch (Exception e){ - // if something goes wrong, returning the time1 - return null; - } - } - // check if the time has passed current time or not private boolean alreadyPassed(String time1) { SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); diff --git a/app/src/main/java/com/app/simplitend/cg_geofencing/CgGeoFencingActivity.java b/app/src/main/java/com/app/simplitend/cg_geofencing/CgGeoFencingActivity.java index 6534a62..1cdeb57 100644 --- a/app/src/main/java/com/app/simplitend/cg_geofencing/CgGeoFencingActivity.java +++ b/app/src/main/java/com/app/simplitend/cg_geofencing/CgGeoFencingActivity.java @@ -3,8 +3,10 @@ package com.app.simplitend.cg_geofencing; import static com.app.simplitend.patientgeofencing.PatientLocationUpdatesReceiver.LOCATION_REQUEST_TAG; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Color; @@ -118,15 +120,18 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead Toast.makeText(this, "Couldn't load Geofence.", Toast.LENGTH_SHORT).show(); geoFenceDetails = new GeoFenceDetails(); onBackPressed(); + return; } } else { onBackPressed(); + return; } viewModel = new ViewModelProvider(this).get(CaregiverMainViewModel.class); progressDialog = new ProgressDialog(this); geofence_bs_binding = GeofenceBottomSheetBinding.inflate(getLayoutInflater()); + geofence_bs_binding.unitSpinner.selectItemByIndex(1); isTrackingSenior = false; CaregiverDataCache.getCaregiverData(this, (careGiverData -> { @@ -183,7 +188,6 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead // running on main thread new Handler(Looper.getMainLooper()).post(()-> { pat_cur_latLng = new LatLng(result.getLatitude(), result.getLongitude()); - Toast.makeText(CgGeoFencingActivity.this, "Update", Toast.LENGTH_SHORT).show(); updateCurrentLocationPatientMarker(); updatePatientCurrentLocationDetails(); }); @@ -221,7 +225,11 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead } } - if (MILES.equals(geoFenceDetails.type)) { + if (geoFenceDetails.type == null){ + // default + geofence_bs_binding.unitSpinner.selectItemByIndex(1); + } + else if (MILES.equals(geoFenceDetails.type)) { geofence_bs_binding.unitSpinner.selectItemByIndex(1); radius = radius / 1609.34f; } else { @@ -236,7 +244,6 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead geofence_bs_binding.radius.setText("" + radius); } geofence_bs_binding.message.setText(geoFenceDetails.message); - geofence_bs_binding.location.setText(geoFenceDetails.location_name); } private void initViews() { @@ -256,6 +263,14 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead private void clickEvents() { binding.backBtn.setOnClickListener(v -> onBackPressed()); + binding.changeBtn.setOnClickListener(v -> { + if (binding.search.getVisibility() == View.VISIBLE){ + binding.search.setVisibility(View.GONE); + }else{ + binding.search.setVisibility(View.VISIBLE); + } + }); + binding.setGf.setOnClickListener(v -> { if (bottomSheetDialog != null) { bottomSheetDialog.show(); @@ -263,9 +278,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead }); geofence_bs_binding.save.setOnClickListener(v -> { - if (allOkay()) { - saveGeoFence(); - } + saveGeoFence(); }); binding.search.setOnClickListener(v -> { @@ -287,7 +300,13 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead binding.updateBtn.setOnClickListener(v -> { if (careGiverData != null) { - updatePatientAddress(); + AppUtil.showAlert(this, + "Update senior's geofence", + "Are you sure you want to update the location?\nSenior Geofence will be updated.", + getString(R.string.ok), ((dialogInterface, i) -> { + updatePatientAddress(); + }), + "Cancel", ((dialogInterface, i) -> {})); } else { Toast.makeText(this, "Cannot update address.", Toast.LENGTH_SHORT).show(); } @@ -326,19 +345,28 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead currL.setLongitude(pat_cur_latLng.longitude); double distance = homeL.distanceTo(currL); - distance /= 1000; // converting to KMs + distance /= 1609.34; // converting to Miles if (distance <= 0.015){ binding.distanceAwayTxt.setText(patientData.first_name + " is at Home"); }else{ - binding.distanceAwayTxt.setText(String.format(patientData.first_name + " is %.2f Kms away", distance)); + binding.distanceAwayTxt.setText(String.format(patientData.first_name + " is %.2f miles away", distance)); } } } catch (NumberFormatException e) { // do nothing + } - String address = patientData.address_line1; - binding.homeAddress.setText(address); + StringBuilder senior_address = new StringBuilder(patientData.address_line1); + if (senior_address.length() != 0){ + senior_address.append(", "); + } + + senior_address.append(patientData.city).append(", ") + .append(patientData.state).append(", ") + .append(patientData.country).append("."); + + binding.homeAddress.setText(senior_address); } private void updatePatientAddress() { @@ -380,24 +408,6 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead } } - private boolean allOkay() { - geofence_bs_binding.message.setError(null); - geofence_bs_binding.location.setError(null); - boolean allOkay = true; - - if (geofence_bs_binding.message.getText().toString().trim().isEmpty()) { - allOkay = false; - geofence_bs_binding.message.setError("Required"); - } - - if (geofence_bs_binding.location.getText().toString().trim().isEmpty()) { - allOkay = false; - geofence_bs_binding.location.setError("Required"); - } - - return allOkay; - } - private void saveGeoFence() { if (careGiverData == null) { Toast.makeText(this, "Couldn't add Fence.", Toast.LENGTH_SHORT).show(); @@ -415,21 +425,28 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead if (geofence_bs_binding.unitSpinner.getSelectedIndex() == 1) { // it is miles radius = radius * 1609.34f; // to meters + if (radius < 160.934 || radius > 8046.72) { + new AlertDialog.Builder(this) + .setMessage("Please select radius between\n0.1 mile - 5 mile") + .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> { + dialogInterface.dismiss(); + }).show(); + return; + } } else { // it is kms radius = radius * 1000; // to meters - } - - if (radius < 1000) { - Toast.makeText(this, "Radius should be minimum 1 KM.", Toast.LENGTH_SHORT).show(); - return; - } else if (radius > 10_000) { - Toast.makeText(this, "Radius should be maximum 10 KM.", Toast.LENGTH_SHORT).show(); - return; + if (radius < 100 || radius > 8000) { + new AlertDialog.Builder(this) + .setMessage("Please select radius between\n0.1 km - 8 km") + .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> { + dialogInterface.dismiss(); + }).show(); + return; + } } geoFenceDetails.message = geofence_bs_binding.message.getText().toString(); - geoFenceDetails.location_name = geofence_bs_binding.location.getText().toString(); geoFenceDetails.radius = "" + radius; geoFenceDetails.type = geofence_bs_binding.unitSpinner.getSelectedIndex() == 0 ? KMS : MILES; geoFenceDetails.patient_xid = "" + careGiverData.patientId; @@ -483,6 +500,12 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead updateCurrentLocationPatientMarker(); mMap.setOnMapClickListener(latLng1 -> { + if (binding.search.getVisibility() != View.VISIBLE){ + // search bar is not visible + // user is not intending to change the home location + return; + } + this.mHomeLatLng = latLng1; isTrackingSenior = false; @@ -530,7 +553,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead updateHomeMarker(home_lat_lng); addRadius(); - mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home_lat_lng, 13)); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(home_lat_lng, 14)); } catch (Exception e) { // near marine drive Toast.makeText(this, "Couldn't load home location", Toast.LENGTH_SHORT).show(); @@ -563,7 +586,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead if (home_loc_marker != null) home_loc_marker.remove(); home_loc_marker = mMap.addMarker(markerOptions); - mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(home_latLng, 13)); + mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(home_latLng, 14)); } private void registerMapSearchResultLauncher() { diff --git a/app/src/main/java/com/app/simplitend/cg_subscription/CgSubscriptionActivity.java b/app/src/main/java/com/app/simplitend/cg_subscription/CgSubscriptionActivity.java index 5b17894..af9528a 100644 --- a/app/src/main/java/com/app/simplitend/cg_subscription/CgSubscriptionActivity.java +++ b/app/src/main/java/com/app/simplitend/cg_subscription/CgSubscriptionActivity.java @@ -136,7 +136,7 @@ public class CgSubscriptionActivity extends AppCompatActivity if (current_subscription_plan_id != null){ AppUtil.showAlert(this, "Cancel subscription", - "Are you sure you want to cancel the current subscribed plan?\nThis will stop the recurring payments", + "Are you sure you want to cancel the current subscribed plan?\nThis will stop the recurring payments.\nYou will be able to use the app until current plan expires.", getString(R.string.no), ((dialogInterface, i) -> {}), getString(R.string.yes), diff --git a/app/src/main/java/com/app/simplitend/patient_dashboard/PatientMainViewModel.java b/app/src/main/java/com/app/simplitend/patient_dashboard/PatientMainViewModel.java index 75fcce8..5ca3f4e 100644 --- a/app/src/main/java/com/app/simplitend/patient_dashboard/PatientMainViewModel.java +++ b/app/src/main/java/com/app/simplitend/patient_dashboard/PatientMainViewModel.java @@ -252,49 +252,49 @@ public class PatientMainViewModel extends ViewModel { }); } - public synchronized void getNearestReminder(List reminderResultList, - @NonNull CaregiverMainViewModel.GetNearestResultCallback nearestResultCallback){ - - ExecutorService executor = Executors.newSingleThreadExecutor(); - Handler handler = new Handler(Looper.getMainLooper()); - - executor.execute(() -> { - // background thread work - - NearestReminder nearestReminder = new NearestReminder(); - - try { - for (ReminderResult reminder: reminderResultList){ - - if (reminder.all_days == 1){ - nearestReminder.daily_reminder_time = reminder.time1; - } - - String upcoming_time = selectNextReminder(reminder.time1, reminder.time2, reminder.time3); - - if (upcoming_time != null && smallestTime(upcoming_time, nearestReminder.upcoming_time)){ - // upcoming_time for this reminder is less than nearestReminder.upcoming_time - // thus, updating nearest reminder - - nearestReminder.upcoming_time = upcoming_time; - nearestReminder.reminder_id = reminder.id; - nearestReminder.medication_name = reminder.medicine_name; - nearestReminder.med_quantity = reminder.medication_quantity; - try { - nearestReminder.med_type = reminder.medication_type.get(0).title; - }catch (Exception e){ - nearestReminder.med_type = "units"; - } - } - } - }catch (Exception e){ - // do nothing - } - - // callback through main thread - handler.post(() -> nearestResultCallback.nearestReminder(nearestReminder)); - }); - } +// public synchronized void getNearestReminder(List reminderResultList, +// @NonNull CaregiverMainViewModel.GetNearestResultCallback nearestResultCallback){ +// +// ExecutorService executor = Executors.newSingleThreadExecutor(); +// Handler handler = new Handler(Looper.getMainLooper()); +// +// executor.execute(() -> { +// // background thread work +// +// NearestReminder nearestReminder = new NearestReminder(); +// +// try { +// for (ReminderResult reminder: reminderResultList){ +// +// if (reminder.all_days == 1){ +// nearestReminder.daily_reminder_time = reminder.time1; +// } +// +// String upcoming_time = selectNextReminder(reminder.time1, reminder.time2, reminder.time3); +// +// if (upcoming_time != null && smallestTime(upcoming_time, nearestReminder.upcoming_time)){ +// // upcoming_time for this reminder is less than nearestReminder.upcoming_time +// // thus, updating nearest reminder +// +// nearestReminder.upcoming_time = upcoming_time; +// nearestReminder.reminder_id = reminder.id; +// nearestReminder.medication_name = reminder.medicine_name; +// nearestReminder.med_quantity = reminder.medication_quantity; +// try { +// nearestReminder.med_type = reminder.medication_type.get(0).title; +// }catch (Exception e){ +// nearestReminder.med_type = "units"; +// } +// } +// } +// }catch (Exception e){ +// // do nothing +// } +// +// // callback through main thread +// handler.post(() -> nearestResultCallback.nearestReminder(nearestReminder)); +// }); +// } private String selectNextReminder(@NonNull String time1, String time2, String time3) { return selectNextReminder(time1, selectNextReminder(time2, time3)); diff --git a/app/src/main/java/com/app/simplitend/patient_dashboard/fragments/PatientDashboardFragment.java b/app/src/main/java/com/app/simplitend/patient_dashboard/fragments/PatientDashboardFragment.java index 8d2f022..4ec6020 100644 --- a/app/src/main/java/com/app/simplitend/patient_dashboard/fragments/PatientDashboardFragment.java +++ b/app/src/main/java/com/app/simplitend/patient_dashboard/fragments/PatientDashboardFragment.java @@ -449,7 +449,7 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac @Override public void onRemindersListFetched(List reminderResult) { - viewModel.getNearestReminder(reminderResult, this); +// viewModel.getNearestReminder(reminderResult, this); } @Override diff --git a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/AddReminderFragment.java b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/AddReminderFragment.java index 32bbf47..a07118b 100644 --- a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/AddReminderFragment.java +++ b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/AddReminderFragment.java @@ -21,7 +21,6 @@ import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import androidx.lifecycle.ViewModelProvider; -import com.skydoves.powerspinner.OnSpinnerItemSelectedListener; import com.app.simplitend.R; import com.app.simplitend.apputils.AppUtil; import com.app.simplitend.databinding.AddReminderFragmentBinding; @@ -32,13 +31,13 @@ import com.app.simplitend.patientprofile.medreminder.mvvm.models.FreqNMedTypeRes import com.app.simplitend.patientprofile.medreminder.mvvm.models.Frequency; import com.app.simplitend.patientprofile.medreminder.mvvm.models.MedicationType; import com.app.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult; +import com.skydoves.powerspinner.OnSpinnerItemSelectedListener; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.Locale; -import java.util.TimeZone; public class AddReminderFragment extends Fragment implements CompoundButton.OnCheckedChangeListener, ProfileContracts.FreqNMedTypesCallback, @@ -177,20 +176,18 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh reminderResult.dosage_unit = String.valueOf(dosageTypeList.get(0).id); } + ArrayList time_list = new ArrayList<>(); + // saving the actual format of time i.e. HH:mm:ss as hint // and saving the formatted time as text i.e. hh:mm a - reminderResult.time1 = binding.getTime.getHint().toString(); + time_list.add(binding.getTime.getHint().toString()); if (binding.getTime2.getVisibility() == View.VISIBLE){ - reminderResult.time2 = binding.getTime2.getHint().toString(); - }else{ - reminderResult.time2 = null; + time_list.add(binding.getTime2.getHint().toString()); } if (binding.getTime3.getVisibility() == View.VISIBLE){ - reminderResult.time3 = binding.getTime3.getHint().toString(); - }else{ - reminderResult.time3 = null; + time_list.add(binding.getTime3.getHint().toString()); } reminderResult.medication_quantity = binding.quantity.getText().toString(); @@ -213,8 +210,13 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh reminderResult.patientRemainderId = reminder.id; reminderResult.reminder_marked = reminder.reminder_marked; + + // to edit the reminder need to send medicine_time_list + reminderResult.medicine_time_list = new ArrayList<>(); + reminderResult.medicine_time_list.add(binding.getTime.getHint().toString()); } else { reminderResult.is_update = "0"; + reminderResult.medicine_time_list = time_list; } String token = "Bearer " + AppUtil.getPatientToken(requireContext()); @@ -446,6 +448,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh private void setLayoutDetails(ReminderResult reminder) { if (reminder != null) { + // removing medication frequency spinner + binding.frequencyView.setVisibility(View.GONE); + binding.frequencyTitleView.setVisibility(View.GONE); + // intent is to edit the reminder binding.title.setText(getString(R.string.edit_reminder)); @@ -455,51 +461,10 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh binding.getDate.setText(formatDate(reminder.medication_refill_date)); binding.instructions.setText(reminder.medication_instruction); - SimpleDateFormat input_sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()); - SimpleDateFormat output_sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault()); - - String refill_time_1, refill_time_2 = null, refill_time_3 = null; - - try { - Date date = input_sdf.parse(reminder.time1); - if (date == null) throw new Exception(); - refill_time_1 = output_sdf.format(date); - - if (reminder.time2 != null){ - binding.getTime2.setVisibility(View.VISIBLE); - Date date2 = input_sdf.parse(reminder.time2); - if (date2 == null) throw new Exception(); - refill_time_2 = output_sdf.format(date2); - }else{ - binding.getTime2.setVisibility(View.GONE); - } - - if (reminder.time3 != null){ - binding.getTime3.setVisibility(View.VISIBLE); - Date date3 = input_sdf.parse(reminder.time3); - if (date3 == null) throw new Exception(); - refill_time_3 = output_sdf.format(date3); - }else{ - binding.getTime3.setVisibility(View.GONE); - } - - } catch (Exception e) { - refill_time_1 = reminder.time1; - refill_time_2 = reminder.time2; - refill_time_3 = reminder.time3; - } - - binding.getTime.setText(refill_time_1); - binding.getTime.setHint(reminder.time1); - - if (reminder.time2 != null){ - binding.getTime2.setText(refill_time_2); - binding.getTime2.setHint(reminder.time2); - } - - if (reminder.time3 != null){ - binding.getTime3.setText(refill_time_3); - binding.getTime3.setHint(reminder.time3); + String medicine_time = AppUtil.formatDate("HH:mm:ss", "hh:mm a", reminder.medicine_time); + if (medicine_time != null){ + binding.getTime.setText(medicine_time); + binding.getTime.setHint(reminder.medicine_time); } for (int i = 0; i < frequencyList.size(); i++) { @@ -700,6 +665,15 @@ public class AddReminderFragment extends Fragment implements CompoundButton.OnCh timeText.setError(null); Calendar calendar = Calendar.getInstance(Locale.getDefault()); + // setting calendar to set time + try { + SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a", Locale.getDefault()); + Date date = sdf.parse(timeText.getText().toString()); + if (date == null) throw new Exception(); + calendar.setTime(date); + }catch (Exception e){ + // do nothing + } TimePickerDialog tpd = new TimePickerDialog(requireContext(), (TimePickerDialog.OnTimeSetListener) (view, hourOfDay, minute) -> { diff --git a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/ReminderFragment.java b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/ReminderFragment.java index 8af5e88..0f813f8 100644 --- a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/ReminderFragment.java +++ b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/ReminderFragment.java @@ -331,7 +331,6 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener. binding.noData.setVisibility(View.GONE); reminderAdapter.submitLIst(reminderResultList); - } else { binding.remindersRv.setVisibility(View.GONE); binding.noData.setVisibility(View.VISIBLE); @@ -542,6 +541,10 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener. reminderResult.medication_refill_date = refill_date; + // to edit the reminder need to send medicine_time_list + reminderResult.medicine_time_list = new ArrayList<>(); + reminderResult.medicine_time_list.add(reminderResult.medicine_time); + reminderViewModel.addReminder( AppUtil.getPatientUid(requireContext()), reminderResult, diff --git a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderAdapter.java b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderAdapter.java index 23d81e1..b02aedd 100644 --- a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderAdapter.java +++ b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderAdapter.java @@ -9,6 +9,7 @@ import androidx.appcompat.content.res.AppCompatResources; import androidx.recyclerview.widget.RecyclerView; import com.app.simplitend.R; +import com.app.simplitend.apputils.AppUtil; import com.app.simplitend.databinding.ReminderViewholderBinding; import com.app.simplitend.patientprofile.medreminder.mvvm.models.ReminderResult; @@ -108,20 +109,12 @@ public class ReminderAdapter extends RecyclerView.Adapter 0) { diff --git a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderRepository.java b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderRepository.java index 2251acd..024ab02 100644 --- a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderRepository.java +++ b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/ReminderRepository.java @@ -66,7 +66,7 @@ public class ReminderRepository { .enqueue(new Callback>() { @Override public void onResponse(Call> call, Response> response) { - if (response.isSuccessful() && response.body() != null && response.body().result != null){ + if (response.isSuccessful() && response.body() != null){ if (response.body().status != 200){ addReminderCallBack.onReminderAddFailed(new Exception(), response.body().message); return; diff --git a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/models/ReminderResult.java b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/models/ReminderResult.java index 299f990..7269853 100644 --- a/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/models/ReminderResult.java +++ b/app/src/main/java/com/app/simplitend/patientprofile/medreminder/mvvm/models/ReminderResult.java @@ -28,9 +28,8 @@ public class ReminderResult implements Serializable { public String fri; public String sat; public String sun; - public String time1; - public String time2; - public String time3; + public String medicine_time; + public ArrayList medicine_time_list; public String active; public String deleted_at; public String created_by; @@ -51,11 +50,11 @@ public class ReminderResult implements Serializable { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ReminderResult that = (ReminderResult) o; - return id == that.id && Objects.equals(patient_xid, that.patient_xid) && Objects.equals(medicine_name, that.medicine_name) && Objects.equals(dosage, that.dosage) && Objects.equals(dosage_unit, that.dosage_unit) && Objects.equals(medication_type_xid, that.medication_type_xid) && Objects.equals(medication_frequency_xid, that.medication_frequency_xid) && Objects.equals(reminder_everyday_flag, that.reminder_everyday_flag) && Objects.equals(reminder_weekday_flag, that.reminder_weekday_flag) && Objects.equals(reminder_time, that.reminder_time) && Objects.equals(medication_quantity, that.medication_quantity) && Objects.equals(medication_refill_date, that.medication_refill_date) && Objects.equals(medication_instruction, that.medication_instruction) && Objects.equals(mon, that.mon) && Objects.equals(tue, that.tue) && Objects.equals(wed, that.wed) && Objects.equals(thu, that.thu) && Objects.equals(fri, that.fri) && Objects.equals(sat, that.sat) && Objects.equals(sun, that.sun) && Objects.equals(time1, that.time1) && Objects.equals(time2, that.time2) && Objects.equals(time3, that.time3) && Objects.equals(active, that.active); + return id == that.id && Objects.equals(patient_xid, that.patient_xid) && Objects.equals(medicine_name, that.medicine_name) && Objects.equals(dosage, that.dosage) && Objects.equals(dosage_unit, that.dosage_unit) && Objects.equals(medication_type_xid, that.medication_type_xid) && Objects.equals(medication_frequency_xid, that.medication_frequency_xid) && Objects.equals(reminder_everyday_flag, that.reminder_everyday_flag) && Objects.equals(reminder_weekday_flag, that.reminder_weekday_flag) && Objects.equals(reminder_time, that.reminder_time) && Objects.equals(medication_quantity, that.medication_quantity) && Objects.equals(medication_refill_date, that.medication_refill_date) && Objects.equals(medication_instruction, that.medication_instruction) && Objects.equals(mon, that.mon) && Objects.equals(tue, that.tue) && Objects.equals(wed, that.wed) && Objects.equals(thu, that.thu) && Objects.equals(fri, that.fri) && Objects.equals(sat, that.sat) && Objects.equals(sun, that.sun) && Objects.equals(active, that.active); } @Override public int hashCode() { - return Objects.hash(id, patient_xid, medicine_name, dosage, dosage_unit, medication_type_xid, medication_frequency_xid, reminder_everyday_flag, reminder_weekday_flag, reminder_time, medication_quantity, medication_refill_date, medication_instruction, mon, tue, wed, thu, fri, sat, sun, time1, time2, time3, active); + return Objects.hash(id, patient_xid, medicine_name, dosage, dosage_unit, medication_type_xid, medication_frequency_xid, reminder_everyday_flag, reminder_weekday_flag, reminder_time, medication_quantity, medication_refill_date, medication_instruction, mon, tue, wed, thu, fri, sat, sun, active); } } diff --git a/app/src/main/res/drawable/ic_dash_small.xml b/app/src/main/res/drawable/ic_dash_small.xml index db9941b..56995c3 100644 --- a/app/src/main/res/drawable/ic_dash_small.xml +++ b/app/src/main/res/drawable/ic_dash_small.xml @@ -1,5 +1,5 @@ diff --git a/app/src/main/res/layout/activity_cg_geofencing.xml b/app/src/main/res/layout/activity_cg_geofencing.xml index 22ee6ad..033649c 100644 --- a/app/src/main/res/layout/activity_cg_geofencing.xml +++ b/app/src/main/res/layout/activity_cg_geofencing.xml @@ -56,6 +56,7 @@ @@ -115,6 +117,7 @@ + + @@ -152,16 +174,29 @@ android:layout_alignParentEnd="true" - android:layout_marginStart="8dp" - - android:layout_marginTop="8dp" - + android:layout_marginVertical="8dp" android:layout_marginEnd="8dp" - android:layout_marginBottom="8dp" + android:padding="3dp" app:srcCompat="@drawable/ic_setting" app:tint="@color/black" /> + + diff --git a/app/src/main/res/layout/activity_personal_info.xml b/app/src/main/res/layout/activity_personal_info.xml index 9479201..11e3d5b 100644 --- a/app/src/main/res/layout/activity_personal_info.xml +++ b/app/src/main/res/layout/activity_personal_info.xml @@ -55,7 +55,7 @@ @@ -300,11 +302,10 @@ android:orientation="horizontal"> @@ -330,7 +331,7 @@ android:orientation="horizontal"> diff --git a/app/src/main/res/layout/create_pin_fragment.xml b/app/src/main/res/layout/create_pin_fragment.xml index ba82ebc..5b04e29 100644 --- a/app/src/main/res/layout/create_pin_fragment.xml +++ b/app/src/main/res/layout/create_pin_fragment.xml @@ -35,7 +35,7 @@ android:layout_marginBottom="5dp" android:fontFamily="@font/nunito_medium" android:text="@string/create_a_pin" - android:textSize="@dimen/_24ssp" + android:textSize="@dimen/_18ssp" android:textColor="@color/black" /> @@ -84,7 +84,7 @@ android:layout_height="wrap_content" android:background="@drawable/edit_text_bg_2" - android:hint="@string/enter_your_pin" + android:hint="@string/set_4_digit_login_pin" android:paddingVertical="15sp" android:paddingHorizontal="10dp" android:fontFamily="@font/nunito_regular" @@ -114,7 +114,7 @@ android:layout_marginHorizontal="15dp" android:layout_marginTop="15dp" android:fontFamily="@font/nunito_medium" - android:textSize="@dimen/_18ssp" + android:textSize="@dimen/_16ssp" android:textColor="@color/black" /> @@ -142,7 +142,7 @@ android:layout_height="wrap_content" android:background="@drawable/edit_text_bg_2" - android:hint="@string/enter_your_pin" + android:hint="@string/confirm_your_pin" android:paddingVertical="15sp" android:paddingHorizontal="10dp" android:fontFamily="@font/nunito_regular" diff --git a/app/src/main/res/layout/fua_edu_dialog.xml b/app/src/main/res/layout/fua_edu_dialog.xml new file mode 100644 index 0000000..52c3589 --- /dev/null +++ b/app/src/main/res/layout/fua_edu_dialog.xml @@ -0,0 +1,51 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/geofence_bottom_sheet.xml b/app/src/main/res/layout/geofence_bottom_sheet.xml index 3a1ad0b..2a653ae 100644 --- a/app/src/main/res/layout/geofence_bottom_sheet.xml +++ b/app/src/main/res/layout/geofence_bottom_sheet.xml @@ -7,39 +7,6 @@ android:background="@drawable/top_round_corner" android:gravity="center_horizontal"> - - - - @@ -150,6 +117,11 @@ android:autofillHints="name" android:inputType="textCapSentences" + + android:digits="@string/allowed_alphabets_with_space" + android:singleLine="true" + + android:maxLength="255" /> For your security, Please change the temporary pin to a new pin New Pin Enter your new pin - Confirm your Pin + Re-enter your Pin Reset Pin Lets get started Enter your contact information @@ -67,9 +67,9 @@ Enter your state Enter your country Enter your zip code - Create a pin + Create a 4-digit pin Create a pin to securely store your personal data - Set 4 digit login pin + Enter 4-digit login pin Set pin Thank you ! Let\'s add your caregiver contact information @@ -298,8 +298,8 @@ OR Unlock with Fingerprint or FaceID Enter Login pin - Remote access to patient\'s profile and setting - Real time patient tracking + Remote access to senior\'s profile and setting + Real time senior tracking Real-time alerts and notifications Setup geo-fence zone Retry @@ -315,7 +315,7 @@ No contacts found. There are no contacts added in your contact directory. Please click on the "Create New Contact" button above. Geofencing - Set specific geographic areas and receive instant alerts when your loved one leaves the geofenced zone. + Add geofence and receive notification when senior’s smartphone leaves the area of the geofence Unknown location Couldn\'t load address Enter your location @@ -324,9 +324,9 @@ 0.00 Message Enter a message - Syncing patient information - We are currently syncing patient data. This may take a few seconds. - Patient profile + Syncing senior information + We are currently syncing senior data. This may take a few seconds. + Senior profile Contacts Medication Medical Records @@ -388,9 +388,9 @@ (Select default number) Reset Update - Patients Home Address + Senior\'s Home Address When updating a password, it\'s essential to create a strong, unique password. - Your credit card will be charged 24 hours before your subscription period expires. You can cancel your subscription at any time by visiting this page. + Your credit card will be charged 24 hours before your subscription period expires. You can cancel your subscription at any time by visiting Senior\'s profile and selecting subscription. contact.us@simplitent.com Instructions: You are about to change emergency number from this contact to 911. Please confirm @@ -471,5 +471,13 @@ Your subscription has been canceled. You will be able to use your application until the end of your current subscription. Your app will stop working at that point. ,.?/]]> Frequently used apps]]> + Change + Senior address: + Confirm your pin + First name* + Enter your first name + > Frequently used apps]]> + Don\'t show this + Next medication schedule: \ No newline at end of file