This commit is contained in:
14Sandee
2023-11-16 21:20:41 +05:30
parent f13933685a
commit e242757aeb
11 changed files with 128 additions and 32 deletions

View File

@@ -6,13 +6,13 @@
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="RZCW41EJRPN" />
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_7_Pro_API_33.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-11-13T14:36:53.968997Z" />
<timeTargetWasSelectedWithDropDown value="2023-11-16T15:42:30.248939Z" />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />

View File

@@ -378,13 +378,22 @@ public abstract class AppUtil {
return;
}
title = patient_name + " is out of Geofence!";
String senior_address_gf = intent.getStringExtra(NOTIFICATION_SENIOR_ADDRESS_KEY);
title = patient_name + " is outside of geofence zone!";
String senior_distance = intent.getStringExtra(NOTIFICATION_SENIOR_ADDRESS_KEY);
try {
double distance = Double.parseDouble(senior_distance);
if (distance == 0) throw new Exception();
senior_distance = distance + " miles away from home";
}catch (Exception e){
senior_distance = "Unable to locate";
}
setupBottomSheet(binding,
R.drawable.img_medication_time,
title, "Current location",
senior_address_gf, "Call senior",
senior_distance, "Call senior",
v -> {
CaregiverDataCache.getCaregiverData(context, (careGiverData -> {
bsd.dismiss();
@@ -520,7 +529,8 @@ public abstract class AppUtil {
return;
}
title = patient_name + " contacted help";
title = patient_name + " called the emergency number";
body = "Please contact " + patient_name;
setupBottomSheet(binding,
R.drawable.img_sos_requested,

View File

@@ -2,9 +2,11 @@ package com.app.simplitend.apputils;
import static com.app.simplitend.locationupdates.LocationService.LOCATION_NOTIFICATION_CHANNEL_ID;
import android.app.ActivityManager;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -14,11 +16,15 @@ import android.provider.MediaStore;
import android.provider.Telephony;
import android.util.Log;
import androidx.annotation.NonNull;
import com.app.simplitend.patient_dashboard.chats.SocketHelper;
import com.onesignal.Continue;
import com.onesignal.OneSignal;
import com.onesignal.debug.LogLevel;
import com.app.simplitend.R;
import com.onesignal.notifications.INotificationClickEvent;
import com.onesignal.notifications.INotificationClickListener;
import com.stripe.android.PaymentConfiguration;
import java.util.List;
@@ -46,6 +52,11 @@ public class SimpliTendApp extends Application {
}
}));
// click listener to notification
OneSignal.getNotifications().addClickListener(iNotificationClickEvent -> {
});
// creating notification channel for location share location updates from patient side
// using a foreground service
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){

View File

@@ -343,6 +343,10 @@ public class CaregiverDashActivity extends AppCompatActivity implements
binding.toolbar.setNavigationIcon(AppCompatResources.getDrawable(this, R.drawable.ic_menu));
binding.toolbar.setNavigationIconTint(getResources().getColor(R.color.white));
} else if (selectedItem == MenuItem.CHATS) {
if (careGiverData.link_id == null){
CaregiverDataCache.setCareGiverData(null); // to fetch new data with link id
}
CaregiverDataCache.getCaregiverData(this, (careGiverData1 -> {
if (careGiverData1 != null && careGiverData1.patientDetails != null){
this.careGiverData = careGiverData1;

View File

@@ -6,7 +6,6 @@ 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;
@@ -257,7 +256,6 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
}
registerMapSearchResultLauncher();
}
private void clickEvents() {
@@ -283,6 +281,12 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
saveGeoFence();
});
geofence_bs_binding.cancelSetGf.setOnClickListener(v -> {
if (bottomSheetDialog != null){
bottomSheetDialog.dismiss();
}
});
binding.search.setOnClickListener(v -> {
List<Place.Field> fields = Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG);
@@ -359,6 +363,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
// do nothing
}
StringBuilder senior_address = new StringBuilder("");
if (patientData.address_line1 != null){
@@ -398,8 +403,21 @@ 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]);
}
}
}
body.put("town", (address.getSubLocality() != null ? address.getSubLocality() : address.getLocality()));
body.put("street", (address.getSubThoroughfare() != null ? address.getSubThoroughfare() : address.getThoroughfare()));
body.put("street", addressLine);
body.put("state", address.getAdminArea());
body.put("country", address.getCountryName());
body.put("zip_code", address.getPostalCode());
@@ -657,7 +675,7 @@ public class CgGeoFencingActivity extends AppCompatActivity implements OnMapRead
CaregiverDataCache.setCareGiverData(this.careGiverData);
progressDialog.dismiss();
updatePatientCurrentLocationDetails();
Toast.makeText(this, "Patient's location updated.", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Senior geofence updated successfully", Toast.LENGTH_SHORT).show();
}
@Override

View File

@@ -51,6 +51,7 @@ 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() {

View File

@@ -32,6 +32,7 @@ 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;
@@ -216,6 +217,10 @@ public class PatientDashboardFragment extends Fragment implements ProfileContrac
});
binding.chats.setOnClickListener(v -> {
if (patientData.link_id == null){
PatientDataCache.setPatientData(null); // to fetch new data with link id
}
PatientDataCache.getPatientData(requireContext(), (patientData1 -> {
if (patientData1 != null){
this.patientData = patientData1;

View File

@@ -19,6 +19,7 @@ import static com.app.simplitend.locationupdates.LocationService.LOCATION_UPDATE
import static com.app.simplitend.patientgeofencing.GeoFenceHelper.GEOFENCE_TAG;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import retrofit2.Call;
@@ -41,13 +42,29 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
int transition_type = geofencingEvent.getGeofenceTransition();
Location location = geofencingEvent.getTriggeringLocation();
String senior_address = null;
if (location != null){
senior_address = AppUtil.getCompleteAddress(context, location.getLatitude(), location.getLongitude());
}
// String senior_address = null;
// if (location != null){
// senior_address = AppUtil.getCompleteAddress(context, location.getLatitude(), location.getLongitude());
// }
//
// if (senior_address == null) {
// senior_address = "Unable to locate";
// }
if (senior_address == null) {
senior_address = "Unable to locate";
double distance;
try {
String[] homeLatLng = AppUtil.getPatientLatLng(context);
Location homeLocation = new Location("homeLatLng");
homeLocation.setLatitude(Double.parseDouble(homeLatLng[0]));
homeLocation.setLongitude(Double.parseDouble(homeLatLng[1]));
if (location == null) throw new Exception();
distance = homeLocation.distanceTo(location);
distance /= 1609; // converting to miles
}catch (Exception e){
distance = 0;
}
switch (transition_type) {
@@ -64,7 +81,7 @@ public class GeoFenceBroadcastReceiver extends BroadcastReceiver {
break;
case Geofence.GEOFENCE_TRANSITION_EXIT:
Log.d(GEOFENCE_TAG, "onReceive: EXIT");
notifyOutOfGeofence(context, senior_address);
notifyOutOfGeofence(context, String.format(Locale.getDefault(),"%.2f", distance));
break;
}
}

View File

@@ -136,7 +136,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
if (to_edit) {
setLayoutDetails(getString(R.string.edit_contact), getString(R.string.change_photo), getString(R.string.save));
} else {
setLayoutDetails(getString(R.string.create_contact), getString(R.string.add_photo), getString(R.string.create_contact));
setLayoutDetails(getString(R.string.create_contact), getString(R.string.add_photo), getString(R.string.save));
}
if (bundle.getSerializable(CONTACT_KEY) != null) {
@@ -383,7 +383,7 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
binding.caregiverCheck.setChecked(true);
// setting up title
setLayoutDetails(getString(R.string.create_caregiver_contact), getString(R.string.add_photo), getString(R.string.create_contact));
setLayoutDetails(getString(R.string.create_caregiver_contact), getString(R.string.add_photo), getString(R.string.save));
addContactView("", true);
}

View File

@@ -483,7 +483,7 @@
android:layout_weight="1"
android:layout_height="wrap_content"
android:backgroundTint="@color/color_primary"
tools:text="@string/create_contact"
android:text="@string/save"
android:textColor="@color/white_bg"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
android:textAllCaps="false"

View File

@@ -124,21 +124,51 @@
android:maxLength="255"
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/save"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="15dp"
android:text="@string/save"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
android:textAllCaps="false"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/white_bg"
android:paddingVertical="15dp"
app:backgroundTint="@color/color_primary"
app:cornerRadius="15dp"
android:weightSum="2">
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/cancel_set_gf"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
android:textAllCaps="false"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/black"
android:paddingVertical="15dp"
app:backgroundTint="@color/white"
app:cornerRadius="15dp"
app:strokeColor="@color/color_accent"
app:strokeWidth="0.5dp"
android:layout_marginEnd="5dp"
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/save"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/update"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
android:textAllCaps="false"
android:fontFamily="@font/nunito_regular"
android:textColor="@color/white_bg"
android:paddingVertical="15dp"
app:backgroundTint="@color/color_primary"
app:cornerRadius="15dp"
android:layout_marginStart="5dp"
/>
</LinearLayout>
</LinearLayout>