.
This commit is contained in:
@@ -76,6 +76,13 @@ dependencies {
|
||||
// mapview
|
||||
implementation 'com.google.android.gms:play-services-maps:18.1.0'
|
||||
|
||||
// directions api
|
||||
implementation 'com.google.maps:google-maps-services:2.2.0'
|
||||
implementation 'org.slf4j:slf4j-simple:1.7.25'
|
||||
|
||||
// for decoding direction results into polylines
|
||||
implementation 'com.google.maps.android:android-maps-utils:3.5.3'
|
||||
|
||||
// location
|
||||
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
||||
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<!-- permissions for app blocking-->
|
||||
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" /> <!-- permissions for app blocking -->
|
||||
<uses-permission
|
||||
android:name="android.permission.PACKAGE_USAGE_STATS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SECURE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
|
||||
<application
|
||||
@@ -28,13 +29,14 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.SimpliTend"
|
||||
tools:targetApi="31">
|
||||
|
||||
|
||||
<activity android:name=".caregiverdashboard.activities.deactivateacc.DeActivateAccountActivity"
|
||||
<activity
|
||||
android:name=".patient_dashboard.DirectionToHomeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".caregiverdashboard.activities.deactivateacc.DeActivateAccountActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
/>
|
||||
android:windowSoftInputMode="adjustResize" />
|
||||
<activity
|
||||
android:name=".caregiverdashboard.activities.CaregiverSettingsActivity"
|
||||
android:exported="false"
|
||||
@@ -107,7 +109,6 @@
|
||||
android:name=".welcome.activities.WelcomeActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -130,30 +131,26 @@
|
||||
android:name=".cg_subscription.CgSubscriptionActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait">
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="" />
|
||||
</activity>
|
||||
|
||||
<!-- // app blocking stuff-->
|
||||
<activity android:name=".appblocking.FUAActivity"/>
|
||||
|
||||
<activity android:name=".appblocking.BlockApp"/>
|
||||
</activity> <!-- // app blocking stuff -->
|
||||
<activity android:name=".appblocking.FUAActivity" />
|
||||
<activity android:name=".appblocking.BlockApp" />
|
||||
|
||||
<service
|
||||
android:name=".appblocking.TopAppDetectionService"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
|
||||
android:exported="false">
|
||||
android:exported="false"
|
||||
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||
<intent-filter>
|
||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.accessibilityservice"
|
||||
android:resource="@xml/accessibility_service_config" />
|
||||
</service>
|
||||
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.ssb.simplitend.fileProvider"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ssb.simplitend.caregiverdashboard.activities;
|
||||
|
||||
import static com.ssb.simplitend.apputils.RetrofitHelper.UPDATE_CONTACT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.ProgressDialog;
|
||||
@@ -276,7 +274,11 @@ public class EditProfileInfoActivity extends AppCompatActivity implements
|
||||
getString(R.string.yes),
|
||||
getString(R.string.no),
|
||||
yes -> {
|
||||
updateCareGiverData();
|
||||
if (isFromPatient){
|
||||
updatePatientData();
|
||||
}else{
|
||||
updateCareGiverData();
|
||||
}
|
||||
}, no -> {
|
||||
|
||||
});
|
||||
@@ -411,6 +413,53 @@ public class EditProfileInfoActivity extends AppCompatActivity implements
|
||||
|
||||
}
|
||||
|
||||
private void updatePatientData() {
|
||||
if (patientData == null) return;
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we update your data.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody user_first_name = RequestBody.create(binding.name.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("full_name", user_first_name);
|
||||
|
||||
String country_code;
|
||||
if (binding.countryCodes.getSelectedIndex() == -1 ||
|
||||
binding.countryCodes.getSelectedIndex() >= countryCodeList.size()){
|
||||
country_code = "+1";
|
||||
}else{
|
||||
country_code = countryCodeList.get(binding.countryCodes.getSelectedIndex());
|
||||
}
|
||||
RequestBody contact_number_part = RequestBody.create(country_code+binding.contactNumber.getText().toString(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("contact_number", contact_number_part);
|
||||
|
||||
RequestBody email_part = RequestBody.create(binding.email.getText().toString(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("email", email_part);
|
||||
|
||||
RequestBody dob_part = RequestBody.create(binding.dob.getText().toString(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("date_of_birth", dob_part);
|
||||
|
||||
MultipartBody.Part filePart = null;
|
||||
|
||||
if (selectedImageUri != null) {
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("image/jpeg"), new File(selectedImageUri.getPath()));
|
||||
filePart = MultipartBody.Part.createFormData("photo",
|
||||
"img_" + System.currentTimeMillis()
|
||||
, requestFile);
|
||||
}
|
||||
|
||||
RequestBody street_part = RequestBody.create(binding.street.getText().toString().trim(), MediaType.parse("text/plain;charset=utf-8"));
|
||||
body.put("street", street_part);
|
||||
|
||||
viewModel.updatePatientData(patientData.patientId,
|
||||
body, filePart, "Bearer " + AppUtil.getPatientToken(this),
|
||||
this);
|
||||
|
||||
}
|
||||
|
||||
private void setDOB(int year, int month, int dayOfMonth) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, year);
|
||||
@@ -686,8 +735,15 @@ public class EditProfileInfoActivity extends AppCompatActivity implements
|
||||
getString(R.string.changes_successful), R.raw.done_anim_primary,
|
||||
3600, v3 -> {
|
||||
// here v3 is null
|
||||
this.careGiverData.patientDetails = patient;
|
||||
CaregiverDataCache.setCareGiverData(careGiverData);
|
||||
if (!isFromPatient && this.careGiverData != null){
|
||||
this.careGiverData.patientDetails = patient;
|
||||
CaregiverDataCache.setCareGiverData(careGiverData);
|
||||
}else{
|
||||
if (this.patientData != null) patient.patientId = this.patientData.patientId;
|
||||
|
||||
PatientDataCache.setPatientData(patient);
|
||||
}
|
||||
|
||||
Toast.makeText(this, "Data updated.", Toast.LENGTH_SHORT).show();
|
||||
onBackPressed();
|
||||
});
|
||||
|
||||
@@ -63,16 +63,11 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
protected CaregiverDashFragmentBinding binding;
|
||||
|
||||
private CaregiverMainViewModel viewModel;
|
||||
|
||||
private ReminderViewModel reminderViewModel;
|
||||
private RoutineViewModel routineViewModel;
|
||||
|
||||
private CareGiverData careGiverData;
|
||||
|
||||
private PatientData patientData;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private GoogleMap mGoogleMap;
|
||||
|
||||
public CgDashBoardFragment(){
|
||||
@@ -89,11 +84,12 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// CaregiverDataCache.getCaregiverData(requireActivity(), (careGiverData1 -> {
|
||||
// this.careGiverData = careGiverData1;
|
||||
//
|
||||
// loadReminders();
|
||||
// }), true);
|
||||
CaregiverDataCache.getCaregiverData(requireActivity(), (careGiverData1 -> {
|
||||
this.careGiverData = careGiverData1;
|
||||
|
||||
loadReminders();
|
||||
loadActivities();
|
||||
}), true);
|
||||
|
||||
initViews();
|
||||
|
||||
@@ -113,16 +109,14 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
this.careGiverData = careGiverData1;
|
||||
|
||||
setDetails();
|
||||
loadReminders();
|
||||
loadActivities();
|
||||
}), true);
|
||||
}
|
||||
|
||||
private void loadActivities() {
|
||||
if (careGiverData == null) return;
|
||||
|
||||
binding.onGoingActivity.setText(getString(R.string.loading));
|
||||
binding.upcomingActivity.setText(getString(R.string.loading));
|
||||
binding.onGoingActivity.setText(viewModel.ongoingActivityText);
|
||||
binding.upcomingActivity.setText(viewModel.upcomingActivityText);
|
||||
|
||||
routineViewModel.getRoutines(careGiverData.patientId,
|
||||
"Bearer " + AppUtil.getCgToken(requireContext()),
|
||||
@@ -133,8 +127,8 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
private void loadReminders(){
|
||||
if (careGiverData == null) return;
|
||||
|
||||
binding.nearestReminder.setText(getString(R.string.loading));
|
||||
binding.dailyReminder.setText(getString(R.string.loading));
|
||||
binding.nearestReminder.setText(viewModel.upcomingReminderText);
|
||||
binding.dailyReminder.setText(viewModel.dailyReminderText);
|
||||
|
||||
reminderViewModel.getRemindersList(careGiverData.patientId,
|
||||
Calendar.getInstance().get(Calendar.DAY_OF_WEEK)-1,
|
||||
@@ -321,15 +315,23 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
@Override
|
||||
public void onGeofenceDetailsFetched(GeoFenceDetails geoFenceDetails) {
|
||||
progressDialog.dismiss();
|
||||
Intent intent = new Intent(requireActivity(), CgGeoFencingActivity.class);
|
||||
intent.putExtra(GEOFENCE_DETAILS_KEY, geoFenceDetails);
|
||||
startActivity(intent);
|
||||
try {
|
||||
Intent intent = new Intent(requireActivity(), CgGeoFencingActivity.class);
|
||||
intent.putExtra(GEOFENCE_DETAILS_KEY, geoFenceDetails);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGeofenceDetailsFetchFailed(Throwable throwable, String message) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
try {
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -339,18 +341,20 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
@Override
|
||||
public void onFetchRemindersListFailed(Throwable t, String message) {
|
||||
binding.nearestReminder.setText(getString(R.string.couldnt_load_data));
|
||||
binding.dailyReminder.setText(getString(R.string.couldnt_load_data));
|
||||
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
|
||||
public void nearestReminder(NearestReminder nearestReminder) {
|
||||
Log.d("aditya", "nearestReminder: " + nearestReminder);
|
||||
|
||||
// daily routine setting
|
||||
String daily_r_txt;
|
||||
|
||||
try {
|
||||
// daily routine setting
|
||||
String daily_r_txt;
|
||||
|
||||
if (nearestReminder.daily_reminder_time == null){
|
||||
daily_r_txt = "No daily reminders for today";
|
||||
@@ -361,11 +365,11 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
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;
|
||||
}
|
||||
}catch (Exception e){
|
||||
daily_r_txt = getString(R.string.couldnt_load_data);
|
||||
}
|
||||
|
||||
binding.dailyReminder.setText(daily_r_txt);
|
||||
binding.dailyReminder.setText(daily_r_txt);
|
||||
}catch (Exception e){
|
||||
binding.dailyReminder.setText(R.string.couldnt_load_data);
|
||||
}
|
||||
|
||||
// next reminder setting
|
||||
try {
|
||||
@@ -399,19 +403,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
StringBuilder reminder_txt = new StringBuilder("Remind " + nearestReminder.medication_name);
|
||||
|
||||
// if (h > 0){
|
||||
// reminder_txt.append(" in " ).append(h);
|
||||
//
|
||||
// if (h > 1) reminder_txt.append(" Hrs ");
|
||||
// else reminder_txt.append(" Hr ");
|
||||
// }
|
||||
//
|
||||
// if (m > 0){
|
||||
// reminder_txt.append(m).append(" Min");
|
||||
//
|
||||
// if (m > 1) reminder_txt.append("s"); // plural
|
||||
// }
|
||||
|
||||
if (time_diff > 3600){
|
||||
// time greater than 60 mins
|
||||
// thus, showing direct time
|
||||
@@ -435,8 +426,11 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
binding.nearestReminder.setText(getString(R.string.couldnt_load_data));
|
||||
binding.nearestReminder.setText(R.string.couldnt_load_data);
|
||||
}
|
||||
|
||||
viewModel.upcomingReminderText = binding.nearestReminder.getText().toString();
|
||||
viewModel.dailyReminderText = binding.dailyReminder.getText().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -446,8 +440,11 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
@Override
|
||||
public void onRoutinesFetchedFailed(Throwable t, String message) {
|
||||
binding.upcomingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
binding.onGoingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
binding.upcomingActivity.setText(R.string.couldnt_load_data);
|
||||
binding.onGoingActivity.setText(R.string.couldnt_load_data);
|
||||
|
||||
viewModel.ongoingActivityText = binding.onGoingActivity.getText().toString();
|
||||
viewModel.upcomingActivityText = binding.upcomingActivity.getText().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -489,19 +486,6 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
|
||||
StringBuilder up_activity_txt = new StringBuilder(nearestActivity.upcoming_activity_name);
|
||||
|
||||
// if (h > 0){
|
||||
// up_activity_txt.append(" in " ).append(h);
|
||||
//
|
||||
// if (h > 1) up_activity_txt.append(" Hrs ");
|
||||
// else up_activity_txt.append(" Hr ");
|
||||
// }
|
||||
//
|
||||
// if (m > 0){
|
||||
// up_activity_txt.append(m).append(" Min");
|
||||
//
|
||||
// if (m > 1) up_activity_txt.append("s"); // plural
|
||||
// }
|
||||
|
||||
if (time_diff > 3600){
|
||||
// time greater than 60 mins
|
||||
// thus, showing direct time
|
||||
@@ -525,7 +509,10 @@ public class CgDashBoardFragment extends Fragment implements
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
binding.upcomingActivity.setText(getString(R.string.couldnt_load_data));
|
||||
binding.upcomingActivity.setText(R.string.couldnt_load_data);
|
||||
}
|
||||
|
||||
viewModel.ongoingActivityText = binding.onGoingActivity.getText().toString();
|
||||
viewModel.upcomingActivityText = binding.upcomingActivity.getText().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,13 @@ public class CaregiverMainViewModel extends ViewModel {
|
||||
|
||||
private ArrayList<ArticleResult> articleResults;
|
||||
|
||||
public String ongoingActivityText, upcomingActivityText;
|
||||
public String upcomingReminderText, dailyReminderText;
|
||||
|
||||
public CaregiverMainViewModel(){
|
||||
this.cgHomeRepository = CgHomeRepository.getHomeRepository();
|
||||
this.ongoingActivityText = this.upcomingActivityText =
|
||||
this.upcomingReminderText = this.dailyReminderText = "Loading...";
|
||||
}
|
||||
|
||||
public void setArticleResults(ArrayList<ArticleResult> articleResults) {
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.ssb.simplitend.patient_dashboard;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresPermission;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||
import com.google.android.gms.location.LocationListener;
|
||||
import com.google.android.gms.location.LocationRequest;
|
||||
import com.google.android.gms.location.LocationServices;
|
||||
import com.google.android.gms.maps.CameraUpdate;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||
import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.LatLngBounds;
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
import com.google.android.gms.maps.model.PolylineOptions;
|
||||
import com.google.maps.DirectionsApi;
|
||||
import com.google.maps.GeoApiContext;
|
||||
import com.google.maps.android.PolyUtil;
|
||||
import com.google.maps.model.DirectionsResult;
|
||||
import com.google.maps.model.DirectionsRoute;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.ActivityDirectionToHomeBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DirectionToHomeActivity extends AppCompatActivity
|
||||
implements OnMapReadyCallback, LocationListener {
|
||||
|
||||
protected ActivityDirectionToHomeBinding binding;
|
||||
|
||||
private ActivityResultLauncher<String[]> locationPermissionLauncher;
|
||||
private ActivityResultLauncher<Intent> enableLocationIntent;
|
||||
private FusedLocationProviderClient fusedLocationProviderClient;
|
||||
|
||||
private LocationRequest locationRequest;
|
||||
private GoogleMap mGoogleMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityDirectionToHomeBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
getLocationPermission();
|
||||
|
||||
initViews();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (fusedLocationProviderClient != null) {
|
||||
fusedLocationProviderClient.removeLocationUpdates(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
|
||||
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.direction_map);
|
||||
if (mapFragment != null) {
|
||||
mapFragment.getMapAsync(this);
|
||||
} else {
|
||||
Toast.makeText(this, "Couldn't load map. Please try again.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
|
||||
locationRequest = new LocationRequest.Builder(LocationRequest.PRIORITY_HIGH_ACCURACY, 5000)
|
||||
.build();
|
||||
}
|
||||
|
||||
private void getLocationPermission() {
|
||||
enableLocationIntent = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
locationPermissionLauncher.launch(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION});
|
||||
return;
|
||||
}
|
||||
|
||||
drawRoutes();
|
||||
});
|
||||
|
||||
// launching request to location permissions
|
||||
locationPermissionLauncher = registerForActivityResult(new ActivityResultContracts
|
||||
.RequestMultiplePermissions(), result -> {
|
||||
|
||||
Boolean fineLocationGranted;
|
||||
|
||||
if (result.containsKey(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||
fineLocationGranted = result.get(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
} else {
|
||||
fineLocationGranted = false;
|
||||
}
|
||||
|
||||
Boolean coarseLocationGranted;
|
||||
|
||||
if (result.containsKey(Manifest.permission.ACCESS_COARSE_LOCATION)) {
|
||||
coarseLocationGranted = result.get(Manifest.permission.ACCESS_COARSE_LOCATION);
|
||||
} else {
|
||||
coarseLocationGranted = false;
|
||||
}
|
||||
|
||||
if ((fineLocationGranted != null && fineLocationGranted) || (coarseLocationGranted != null && coarseLocationGranted)) {
|
||||
// one of the location access granted.
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawRoutes();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@RequiresPermission(anyOf = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION})
|
||||
private void drawRoutes() {
|
||||
if (mGoogleMap == null) return;
|
||||
|
||||
mGoogleMap.setMyLocationEnabled(true);
|
||||
mGoogleMap.getUiSettings().setMyLocationButtonEnabled(true);
|
||||
|
||||
if (!isLocationProviderEnabled()) {
|
||||
AppUtil.showAlert(this,
|
||||
getString(R.string.GPS_ENABLE_REQUIRED),
|
||||
getString(R.string.GPS_ENABLE_MESSAGE),
|
||||
getString(R.string.SETTINGS),
|
||||
(dialog, which) -> {
|
||||
// Settings button click callback
|
||||
// Sending user to turn location on
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
enableLocationIntent.launch(intent);
|
||||
},
|
||||
getString(R.string.NOT_NOW),
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fusedLocationProviderClient.requestLocationUpdates(locationRequest, this, null);
|
||||
}
|
||||
|
||||
public boolean isLocationProviderEnabled() {
|
||||
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
return locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
}
|
||||
|
||||
private void addMarkersToMap(DirectionsResult results, GoogleMap mMap) throws Exception {
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].startLocation.lat,results.routes[0].legs[0].startLocation.lng)).title("Your location"));
|
||||
mMap.addMarker(new MarkerOptions().position(new com.google.android.gms.maps.model.LatLng(results.routes[0].legs[0].endLocation.lat,results.routes[0].legs[0].endLocation.lng)).title("Senior's location"));
|
||||
}
|
||||
|
||||
private void positionCamera(DirectionsRoute route, GoogleMap mMap) throws Exception{
|
||||
// LatLng center_latlng = computeCentroid(new com.google.android.gms.maps.model.LatLng(route.legs[0].startLocation.lat, route.legs[0].startLocation.lng),
|
||||
// new com.google.android.gms.maps.model.LatLng(route.legs[0].endLocation.lat, route.legs[0].endLocation.lng));
|
||||
// mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(center_latlng, 10.5f));
|
||||
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
builder.include(new com.google.android.gms.maps.model.LatLng(route.legs[0].startLocation.lat, route.legs[0].startLocation.lng));
|
||||
builder.include(new com.google.android.gms.maps.model.LatLng(route.legs[0].endLocation.lat, route.legs[0].endLocation.lng));
|
||||
LatLngBounds bounds = builder.build();
|
||||
int padding = ((getWindowManager().getDefaultDisplay().getWidth() * 10) / 100); // offset from edges of the map
|
||||
// in pixels
|
||||
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,
|
||||
padding);
|
||||
mMap.animateCamera(cu);
|
||||
}
|
||||
|
||||
private LatLng computeCentroid(LatLng... points) {
|
||||
double latitude = 0;
|
||||
double longitude = 0;
|
||||
int n = points.length;
|
||||
|
||||
for (LatLng point : points) {
|
||||
latitude += point.latitude;
|
||||
longitude += point.longitude;
|
||||
}
|
||||
|
||||
return new LatLng(latitude/n, longitude/n);
|
||||
}
|
||||
|
||||
private void addPolyline(DirectionsResult results, GoogleMap mMap) throws Exception{
|
||||
for (int i = 0; i < results.routes.length; i++) {
|
||||
List<com.google.android.gms.maps.model.LatLng> decodedPath = PolyUtil.decode(results.routes[i].overviewPolyline.getEncodedPath());
|
||||
mMap.addPolyline(new PolylineOptions()
|
||||
.addAll(decodedPath).color(R.color.color_primary).width(15));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(@NonNull GoogleMap googleMap) {
|
||||
this.mGoogleMap = googleMap;
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||
drawRoutes();
|
||||
} else {
|
||||
locationPermissionLauncher.launch(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@NonNull Location location) {
|
||||
if (fusedLocationProviderClient != null) {
|
||||
fusedLocationProviderClient.removeLocationUpdates(this);
|
||||
}
|
||||
|
||||
try {
|
||||
DirectionsResult directionsResult = DirectionsApi.newRequest(
|
||||
new GeoApiContext.Builder()
|
||||
.apiKey(getString(R.string.GOOGLE_MAPS_API_KEY))
|
||||
.build())
|
||||
.origin(new com.google.maps.model.LatLng(location.getLatitude(), location.getLongitude()))
|
||||
.destination(new com.google.maps.model.LatLng(28.42104670992253, 76.92862066485148))
|
||||
.alternatives(true)
|
||||
.await();
|
||||
|
||||
addMarkersToMap(directionsResult, mGoogleMap);
|
||||
positionCamera(directionsResult.routes[0], mGoogleMap);
|
||||
addPolyline(directionsResult, mGoogleMap);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "Couldn't load routes", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,14 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.appblocking.FUAActivity;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.PatientDataCache;
|
||||
import com.ssb.simplitend.databinding.PatientDashboardFragmentBinding;
|
||||
import com.ssb.simplitend.patient_dashboard.DirectionToHomeActivity;
|
||||
import com.ssb.simplitend.welcome.activities.WelcomeActivity;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
|
||||
|
||||
@@ -72,11 +75,25 @@ public class PatientDashboardFragment extends Fragment {
|
||||
|
||||
PatientDataCache.getPatientData(requireContext(), (patientData -> {
|
||||
this.patientData = patientData;
|
||||
|
||||
setDetails();
|
||||
}), true);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void setDetails() {
|
||||
if (patientData == null) return;
|
||||
|
||||
Glide.with(requireContext())
|
||||
.load(AppUtil.IMAGE_BASE_URL + patientData.profile_photo)
|
||||
.diskCacheStrategy(DiskCacheStrategy.DATA)
|
||||
.fitCenter()
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
.error(R.drawable.senior_img)
|
||||
.into(binding.profile);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
}
|
||||
|
||||
@@ -134,6 +151,11 @@ public class PatientDashboardFragment extends Fragment {
|
||||
Intent intent = new Intent(requireActivity(), FUAActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
binding.directions.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), DirectionToHomeActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTime() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import static com.ssb.simplitend.caregiverdashboard.activities.PatientProfileSho
|
||||
import static com.ssb.simplitend.caregiverdashboard.activities.PatientProfileShowerActivity.MED_REMINDER_F;
|
||||
import static com.ssb.simplitend.caregiverdashboard.activities.PatientProfileShowerActivity.WHICH_FRAGMENT;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -18,6 +19,10 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.appblocking.FUAActivity;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.PatientDataCache;
|
||||
import com.ssb.simplitend.caregiverdashboard.activities.EditProfileInfoActivity;
|
||||
import com.ssb.simplitend.caregiverdashboard.activities.PatientProfileShowerActivity;
|
||||
@@ -43,13 +48,17 @@ public class PatientProfileInfoFragment extends Fragment {
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
PatientDataCache.getPatientData(requireContext(), (patientData -> {
|
||||
this.patientData = patientData;
|
||||
|
||||
setPatientDetails();
|
||||
}), true);
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void setPatientDetails() {
|
||||
@@ -58,14 +67,14 @@ public class PatientProfileInfoFragment extends Fragment {
|
||||
return;
|
||||
};
|
||||
|
||||
// if (patientData.p != null) {
|
||||
// // image
|
||||
// Glide.with(this)
|
||||
// .load(AppUtil.IMAGE_BASE_URL + careGiverData.profile_photo)
|
||||
// .placeholder(android.R.color.darker_gray)
|
||||
// .error(R.drawable.ic_contact)
|
||||
// .into(binding.image);
|
||||
// }
|
||||
if (patientData.profile_photo != null) {
|
||||
// image
|
||||
Glide.with(this)
|
||||
.load(AppUtil.IMAGE_BASE_URL + patientData.profile_photo)
|
||||
.placeholder(android.R.color.darker_gray)
|
||||
.error(R.drawable.senior_img)
|
||||
.into(binding.image);
|
||||
}
|
||||
|
||||
binding.name.setText(patientData.first_name);
|
||||
binding.phoneNumber.setText(patientData.phone_number);
|
||||
@@ -73,6 +82,13 @@ public class PatientProfileInfoFragment extends Fragment {
|
||||
|
||||
private void clickEvents() {
|
||||
|
||||
binding.backBtn.setOnClickListener(v -> {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null){
|
||||
activity.onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
binding.medication.setOnClickListener(v -> {
|
||||
gotoProfileShower(MED_REMINDER_F);
|
||||
});
|
||||
@@ -89,6 +105,11 @@ public class PatientProfileInfoFragment extends Fragment {
|
||||
gotoProfileShower(ACTIVITY_F);
|
||||
});
|
||||
|
||||
binding.freqUsedApps.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), FUAActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
binding.editBtn.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireActivity(), EditProfileInfoActivity.class);
|
||||
intent.putExtra(IS_FROM_PATIENT, true);
|
||||
|
||||
@@ -339,7 +339,7 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
binding.search.setOnClickListener(v -> {
|
||||
|
||||
List<Place.Field> fields = Arrays.asList(Place.Field.ID
|
||||
,Place.Field.NAME,
|
||||
, Place.Field.NAME,
|
||||
Place.Field.LAT_LNG, Place.Field.ADDRESS);
|
||||
|
||||
Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields)
|
||||
@@ -462,7 +462,7 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
if (currentLocation != null) {
|
||||
addMarker(currentLocation, null);
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 14));
|
||||
}else{
|
||||
} else {
|
||||
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.75796541422796, -73.98557368665934), 14));
|
||||
}
|
||||
}
|
||||
@@ -490,11 +490,11 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
|
||||
binding.zipCode.setText(address.getPostalCode());
|
||||
|
||||
if (title != null){
|
||||
if (title != null) {
|
||||
if (marker != null) marker.setTitle(title);
|
||||
|
||||
binding.street.setText(title);
|
||||
}else if (address.getThoroughfare() == null || address.getThoroughfare().isEmpty()) {
|
||||
} else if (address.getThoroughfare() == null || address.getThoroughfare().isEmpty()) {
|
||||
binding.street.setText(null);
|
||||
} else {
|
||||
binding.street.setText(address.getThoroughfare());
|
||||
@@ -528,7 +528,7 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
binding.countrySpinner.clearSelectedItem();
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
binding.countrySpinner.clearSelectedItem();
|
||||
binding.street.setText(null);
|
||||
binding.stateSpinner.clearSelectedItem();
|
||||
@@ -565,6 +565,12 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
getString(R.string.NOT_NOW),
|
||||
(dialog, which) -> dialog.dismiss()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
getLocationPermission();
|
||||
return;
|
||||
}
|
||||
|
||||
fusedLocationProviderClient.requestLocationUpdates(locationRequest, this, null);
|
||||
|
||||
38
app/src/main/res/layout/activity_direction_to_home.xml
Normal file
38
app/src/main/res/layout/activity_direction_to_home.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
tools:context=".patient_dashboard.DirectionToHomeActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_btn"
|
||||
android:layout_width="35sp"
|
||||
android:layout_height="35sp"
|
||||
android:contentDescription="@string/back_button"
|
||||
android:padding="5dp"
|
||||
app:srcCompat="@drawable/ic_home_nav_up"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginHorizontal="15dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/direction_to_home"
|
||||
android:fontFamily="@font/nunito_medium"
|
||||
android:textSize="@dimen/_18ssp"
|
||||
android:textColor="@color/black"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="15dp"
|
||||
/>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/direction_map"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -250,6 +250,9 @@
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:enabled="false"
|
||||
|
||||
android:background="@drawable/edit_text_bg_2"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="10dp"
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
|
||||
android:src="@drawable/static_3"
|
||||
android:src="@drawable/senior_img"
|
||||
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
@@ -333,6 +333,7 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/apps"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5"
|
||||
@@ -349,7 +350,6 @@
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
@@ -381,6 +381,7 @@
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/directions"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="5"
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
<item>Miles</item>
|
||||
</string-array>
|
||||
|
||||
<!-- app blocking stuff-->
|
||||
<!-- app blocking stuff-->
|
||||
<string name="accessibility_service_description">accessibility_service_description</string>
|
||||
<string name="default_notification_channel_id">ForegroundServiceChannel</string>
|
||||
<string name="all_apps">All apps</string>
|
||||
@@ -412,5 +412,6 @@
|
||||
<string name="all_reminder_done">No reminders for today.</string>
|
||||
<string name="no_ongoing_activity">No ongoing activity</string>
|
||||
<string name="no_upcoming_activities">No upcoming activities</string>
|
||||
<string name="direction_to_home">Direction to home</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user