diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
index a68303d..468e843 100644
--- a/.idea/deploymentTargetDropDown.xml
+++ b/.idea/deploymentTargetDropDown.xml
@@ -7,12 +7,12 @@
-
+
-
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 863e986..e6c44dc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -18,18 +18,26 @@
android:theme="@style/Theme.SimpliTend"
tools:targetApi="31">
+ android:name=".caregiverdashboard.activities.PatientProfileShowerActivity"
+ android:exported="false"
+ android:screenOrientation="portrait"
+ />
+
-
-
+ android:name=".caregiverdashboard.activities.CgProfileProgressActivity"
+ android:exported="true"
+ android:screenOrientation="portrait"
+ >
+ android:exported="true"
+ android:screenOrientation="portrait"
+ android:windowSoftInputMode="adjustResize"
+ />
loadCountryCodeDropDown(Context context) {
+
+ ArrayList countryCodeList = new ArrayList<>();
+
+ try {
+
+ String countryCodeStr = readCountryCodes(context);
+ JSONArray jsonArray = new JSONArray(countryCodeStr);
+
+ for (int i = 0; i < jsonArray.length(); i++) {
+
+ JSONObject code = jsonArray.getJSONObject(i);
+
+ countryCodeList.add(code.getString("dial_code"));
+
+ }
+
+ } catch (Exception e) {
+
+ // if cannot load all country codes showing only india's dial code
+ countryCodeList.add("+91");
+ countryCodeList.add("+1");
+
+ Log.e(TAG, "loadCountryCodeDropDown: ", e);
+ }
+
+ return countryCodeList;
+ }
+
+ public static String readCountryCodes(Context context) throws IOException {
+ StringBuilder returnString = new StringBuilder();
+
+ InputStream fIn = context.getResources().openRawResource(R.raw.country_code);
+ InputStreamReader isr = new InputStreamReader(fIn);
+ BufferedReader input = new BufferedReader(isr);
+
+ String line = "";
+
+ while ((line = input.readLine()) != null) {
+ returnString.append(line);
+ }
+
+ try {
+ isr.close();
+
+ if (fIn != null) fIn.close();
+
+ input.close();
+
+ } catch (Exception e) {
+ Log.e(TAG, "readCountryCodes: ", e);
+ }
+
+ return returnString.toString();
+ }
+
+
+ // user data utils
public static void savePatientData(String token, int patient_uid, Context context, boolean isLoggedIn){
SharedPreferences sp = context.getSharedPreferences(PATIENT_DETAILS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
diff --git a/app/src/main/java/com/ssb/simplitend/apputils/CaregiverDataCache.java b/app/src/main/java/com/ssb/simplitend/apputils/CaregiverDataCache.java
index 724a171..10c577e 100644
--- a/app/src/main/java/com/ssb/simplitend/apputils/CaregiverDataCache.java
+++ b/app/src/main/java/com/ssb/simplitend/apputils/CaregiverDataCache.java
@@ -23,24 +23,26 @@ public abstract class CaregiverDataCache {
}
public static void getCaregiverData(Context context,
- @NonNull GetCaregiverDataCallBack callBack){
+ @NonNull GetCaregiverDataCallBack callBack,
+ boolean show_progress){
if (careGiverData != null && careGiverData.patientDetails != null){
callBack.careGiverData(careGiverData);
return;
}
- updateCaregiverData(context, callBack);
+ updateCaregiverData(context, callBack, show_progress);
}
private static void updateCaregiverData(Context context,
- @Nullable GetCaregiverDataCallBack callBack) {
+ @Nullable GetCaregiverDataCallBack callBack,
+ boolean show_progress) {
WelcomeApiService apiService = RetrofitHelper.getRetrofit().create(WelcomeApiService.class);
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setTitle("Please wait...");
progressDialog.setMessage("while we fetch details for you...");
progressDialog.setCancelable(false);
- progressDialog.show();
+ if (show_progress) progressDialog.show();
apiService.getCgUserData("Bearer " + AppUtil.getCgToken(context))
.enqueue(new Callback>() {
diff --git a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/CaregiverDashActivity.java b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CaregiverDashActivity.java
similarity index 98%
rename from app/src/main/java/com/ssb/simplitend/caregiverdashboard/CaregiverDashActivity.java
rename to app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CaregiverDashActivity.java
index 0086802..dbf5614 100644
--- a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/CaregiverDashActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CaregiverDashActivity.java
@@ -1,4 +1,4 @@
-package com.ssb.simplitend.caregiverdashboard;
+package com.ssb.simplitend.caregiverdashboard.activities;
import android.content.Intent;
import android.os.Bundle;
@@ -47,7 +47,7 @@ public class CaregiverDashActivity extends AppCompatActivity implements
this.careGiverData = careGiverData;
watchSubscription();
- });
+ }, true);
initViews();
diff --git a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/CgProfileProgressActivity.java b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CgProfileProgressActivity.java
similarity index 52%
rename from app/src/main/java/com/ssb/simplitend/caregiverdashboard/CgProfileProgressActivity.java
rename to app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CgProfileProgressActivity.java
index 4aaf016..4febda8 100644
--- a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/CgProfileProgressActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/CgProfileProgressActivity.java
@@ -1,17 +1,31 @@
-package com.ssb.simplitend.caregiverdashboard;
+package com.ssb.simplitend.caregiverdashboard.activities;
import android.content.Intent;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import android.os.Handler;
+import android.view.View;
import android.widget.Toast;
+import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.load.DataSource;
+import com.bumptech.glide.load.engine.GlideException;
+import com.bumptech.glide.load.resource.gif.GifDrawable;
+import com.bumptech.glide.request.RequestListener;
+import com.bumptech.glide.request.target.Target;
+import com.daimajia.androidanimations.library.Techniques;
+import com.daimajia.androidanimations.library.YoYo;
+import com.ssb.simplitend.R;
import com.ssb.simplitend.apputils.CaregiverDataCache;
+import com.ssb.simplitend.cg_geofencing.CgGeoFencingActivity;
import com.ssb.simplitend.databinding.ActivityCgProfileProgressBinding;
-import com.ssb.simplitend.welcome.welcomecg.fragments.CgAuthActivity;
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
-import static com.ssb.simplitend.caregiverdashboard.PatientProfileShowerActivity.*;
+import static com.ssb.simplitend.caregiverdashboard.activities.PatientProfileShowerActivity.*;
public class CgProfileProgressActivity extends AppCompatActivity {
@@ -26,13 +40,28 @@ public class CgProfileProgressActivity extends AppCompatActivity {
binding = ActivityCgProfileProgressBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
- CaregiverDataCache.getCaregiverData(this, (careGiverData1 -> {
- this.careGiverData = careGiverData1;
+ startAnimation();
- initViews();
+ new Handler().postDelayed(() -> {
+ CaregiverDataCache.getCaregiverData(this, (careGiverData1 -> {
+ this.careGiverData = careGiverData1;
- clickEvents();
- }));
+ binding.loadingView.setVisibility(View.GONE);
+ binding.profileProgressView.setVisibility(View.VISIBLE);
+
+ initViews();
+
+ clickEvents();
+ }), false);
+ }, 3000);
+
+ }
+
+ private void startAnimation() {
+ Glide.with(this)
+ .asGif()
+ .load(R.raw.ic_sync_data)
+ .into(binding.loadingAnim);
}
private void clickEvents() {
@@ -43,6 +72,16 @@ public class CgProfileProgressActivity extends AppCompatActivity {
finish();
});
+ binding.profileInfo.setOnClickListener(v -> {
+ Intent intent = new Intent(this, PatientProfileInfoActivity.class);
+ startActivity(intent);
+ });
+
+ binding.geoFencing.setOnClickListener(v -> {
+ Intent intent = new Intent(this, CgGeoFencingActivity.class);
+ startActivity(intent);
+ });
+
binding.medicReminder.setOnClickListener(v -> {
gotoProfileShower(MED_REMINDER_F);
});
diff --git a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileInfoActivity.java b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileInfoActivity.java
new file mode 100644
index 0000000..fc42778
--- /dev/null
+++ b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileInfoActivity.java
@@ -0,0 +1,421 @@
+package com.ssb.simplitend.caregiverdashboard.activities;
+
+import android.app.DatePickerDialog;
+import android.content.Context;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.InputFilter;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.google.i18n.phonenumbers.PhoneNumberUtil;
+import com.google.i18n.phonenumbers.Phonenumber;
+import com.skydoves.powerspinner.OnSpinnerItemSelectedListener;
+import com.ssb.simplitend.R;
+import com.ssb.simplitend.apputils.AppUtil;
+import com.ssb.simplitend.apputils.CaregiverDataCache;
+import com.ssb.simplitend.databinding.ActivityPersonalInfoBinding;
+import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Array;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+
+public class PatientProfileInfoActivity extends AppCompatActivity {
+
+ private static final String TAG = "PatientProfileInfoActiv";
+
+ // view binding
+ protected ActivityPersonalInfoBinding binding;
+
+ private DatePickerDialog datePickerDialog;
+
+ private ArrayList countryCodeList;
+
+ private PatientData patientData;
+
+ private ArrayList countryList;
+ private HashMap> country_N_states_map;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ binding = ActivityPersonalInfoBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+
+ initViews();
+
+ clickEvents();
+
+ CaregiverDataCache.getCaregiverData(this, (careGiverData -> {
+ this.patientData = careGiverData.patientDetails;
+
+ setDetails();
+ }), true);
+
+ binding.name.requestFocus();
+ }
+
+ private void setDetails() {
+ if (patientData == null) {
+ Toast.makeText(this, "Couldn't load patient data.", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ binding.name.setText(patientData.first_name);
+ binding.dob.setText(formatDateToMMddYYYY("yyyy-MM-dd", patientData.date_of_birth));
+ binding.contactNumber.setText(patientData.phone_number);
+ binding.email.setText(patientData.email);
+
+ binding.street.setText(patientData.address_line1);
+ binding.town.setText(patientData.city);
+ binding.zipCode.setText(patientData.post_code);
+
+ String country = patientData.country;
+ String state = patientData.state;
+ if (!countryList.contains(country)){
+ countryList.add(country);
+ ArrayList states = new ArrayList<>();
+ states.add(state);
+ country_N_states_map.put(country, states);
+ }
+
+ binding.countrySpinner.selectItemByIndex(countryList.indexOf(country));
+ try {
+ binding.stateSpinner.selectItemByIndex(country_N_states_map.get(country).indexOf(state));
+ } catch (Exception e) {
+ Toast.makeText(this, "Couldn't load state.", Toast.LENGTH_SHORT).show();
+ }
+
+
+ }
+
+ private void initViews() {
+
+ loadCountriesAndStates();
+
+ // date picker dialog
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 18);
+
+ datePickerDialog = new DatePickerDialog(this,
+ (datePicker, year, month, dayOfMonth) -> {
+ setDOB(year, month, dayOfMonth);
+
+ binding.contactNumber.requestFocus();
+
+ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+
+ }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
+ datePickerDialog.getDatePicker().setMaxDate(calendar.getTimeInMillis());
+
+ // creating this view model here as it contains the fetching code
+ countryCodeList = AppUtil.loadCountryCodeDropDown(this);
+
+ binding.countryCodes.setLifecycleOwner(this);
+ binding.countryCodes.setItems(countryCodeList);
+ if (!countryCodeList.contains("+1")) {
+ countryCodeList.add("+1");
+ }
+ binding.countryCodes.selectItemByIndex(countryCodeList.indexOf("+1"));
+ binding.countryCodes.setDismissWhenNotifiedItemSelected(true);
+ binding.countryCodes.setIsFocusable(true);
+
+ setPhoneNumberInputFilter();
+
+ setFocusManager();
+
+ inputFieldFocusManage();
+
+ }
+
+ private void clickEvents() {
+ binding.save.setOnClickListener(v -> {
+ onBackPressed();
+ });
+
+ binding.dob.setOnClickListener(v -> {
+ pickDate();
+ });
+
+ binding.backBtn.setOnClickListener(v -> {
+ onBackPressed();
+ });
+ }
+
+ private void setDOB(int year, int month, int dayOfMonth) {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, year);
+ cal.set(Calendar.MONTH, month);
+ cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
+
+ String selected_time = sdf.format(cal.getTime());
+ binding.dob.setText(selected_time);
+ }
+
+ // This adds textChangeListener to all the EditTexts available to remove error if available
+ private void setPhoneNumberInputFilter() {
+ // phone number formatting
+ // to deal with input pasting in the edit text
+ InputFilter phoneFilter = (charSequence, i, i1, spanned, i2, i3) -> {
+ String phone_number_str = charSequence.toString();
+
+ String country_code;
+
+ if (binding.countryCodes.getSelectedIndex() == -1) {
+ country_code = "+1";
+ } else {
+ country_code = countryCodeList.get(binding.countryCodes.getSelectedIndex());
+ }
+
+ try {
+ PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
+ Phonenumber.PhoneNumber phoneNumber = phoneNumberUtil.parse(charSequence, "US");
+
+ phone_number_str = String.valueOf(phoneNumber.getNationalNumber());
+ country_code = "+" + phoneNumber.getCountryCode();
+ } catch (Exception e) {
+ // nothing
+ }
+
+ if (!countryCodeList.contains(country_code)) {
+ countryCodeList.add(country_code);
+ }
+
+ binding.countryCodes.selectItemByIndex(countryCodeList.indexOf(country_code));
+
+ if (phone_number_str.length() > 10) {
+ // pasted number length is greater than 10
+ return phone_number_str.substring(0, 10);
+ }
+
+ String total_phone_number = binding.contactNumber.getText().toString() + phone_number_str;
+
+ if (total_phone_number.length() > 10) {
+ // max length should be 10
+ return "";
+ } else {
+ return phone_number_str;
+ }
+ };
+
+ binding.contactNumber.setFilters(new InputFilter[]{phoneFilter});
+
+ }
+
+ private void setFocusManager() {
+ binding.name.setOnEditorActionListener((textView, i, keyEvent) -> {
+ AppUtil.closeKeyboard(this);
+ binding.name.clearFocus();
+
+ pickDate();
+ return true;
+ });
+
+ binding.email.setOnEditorActionListener(((textView, i, keyEvent) -> {
+ AppUtil.closeKeyboard(this);
+ binding.email.clearFocus();
+
+ binding.countrySpinner.show();
+ return true;
+ }));
+ }
+
+ private void pickDate() {
+
+ if (datePickerDialog == null) return;
+
+ datePickerDialog.show();
+
+ }
+
+ public String formatDateToMMddYYYY(String inputFormat, String input_date) {
+ SimpleDateFormat out_sdf = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());
+ SimpleDateFormat in_sdf = new SimpleDateFormat(inputFormat, Locale.getDefault());
+
+ try {
+ Date date = in_sdf.parse(input_date);
+ input_date = out_sdf.format(date);
+
+ // setting it to datepickerdialog
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ if (datePickerDialog != null) {
+ datePickerDialog.getDatePicker().updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
+ }
+ } catch (Exception e) {
+ // do nothing
+ return input_date;
+ }
+
+ return input_date;
+ }
+
+ private void inputFieldFocusManage() {
+
+ binding.town.setOnEditorActionListener((textView, i, keyEvent) -> {
+ AppUtil.closeKeyboard(this);
+ binding.town.clearFocus();
+ binding.stateSpinner.show();
+ return true;
+ });
+
+ binding.zipCode.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ if (editable.toString().length() == 6){
+ binding.zipCode.clearFocus();
+ AppUtil.closeKeyboard(PatientProfileInfoActivity.this);
+ }
+ }
+ });
+
+ }
+
+ private void loadCountriesAndStates() {
+
+ countryList = new ArrayList<>();
+
+ country_N_states_map = new HashMap<>();
+
+ try {
+
+ String country_n_states_str = readCountryNStates(this);
+
+ JSONArray country_n_states = new JSONObject(country_n_states_str).getJSONArray("countries");
+
+ Log.d(TAG, "loadCountriesAndStates: " + country_n_states);
+
+ for (int i = 0; i < country_n_states.length(); i++) {
+
+ String country = country_n_states.getJSONObject(i).getString("country");
+ countryList.add(country);
+
+ JSONArray states = country_n_states.getJSONObject(i).getJSONArray("states");
+
+ ArrayList stateList = new ArrayList<>();
+
+ for (int j = 0; j < states.length(); j++) {
+ stateList.add(states.getString(j));
+ }
+
+ country_N_states_map.put(country, stateList);
+ }
+
+ } catch (Exception e) {
+
+ Log.e(TAG, "load country and states: ", e);
+ }
+
+ Log.d(TAG, "loadCountriesAndStates: " + countryList);
+
+ binding.stateSpinner.setLifecycleOwner(this);
+ binding.countrySpinner.setLifecycleOwner(this);
+
+ binding.countrySpinner.setItems(countryList);
+
+
+ // selecting United States country as by default
+// if (countryList.contains(UNITED_STATES)){
+// binding.countrySpinner.selectItemByIndex(countryList.indexOf(UNITED_STATES));
+//
+// if (country_N_states_map.containsKey(UNITED_STATES))
+// {
+// binding.stateSpinner.setItems(country_N_states_map.get(UNITED_STATES));
+// }
+// }
+
+ binding.stateSpinner.setDismissWhenNotifiedItemSelected(true);
+ binding.countrySpinner.setDismissWhenNotifiedItemSelected(true);
+
+ binding.stateSpinner.setIsFocusable(true);
+ binding.countrySpinner.setIsFocusable(true);
+
+ binding.countrySpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener) (i, s, i1, t1) -> {
+
+ binding.countrySpinner.setError(null);
+
+ ArrayList stateList;
+
+ if (country_N_states_map.containsKey(t1) && country_N_states_map.get(t1) != null) {
+ stateList = country_N_states_map.get(t1);
+ } else {
+ stateList = new ArrayList<>();
+ }
+
+ if (stateList != null) {
+ binding.stateSpinner.setItems(stateList);
+ binding.stateSpinner.clearSelectedItem();
+ }
+
+ binding.street.requestFocus();
+
+ getWindow()
+ .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ });
+
+ binding.stateSpinner.setOnSpinnerItemSelectedListener((OnSpinnerItemSelectedListener) (i, s, i1, t1) -> {
+ binding.stateSpinner.setError(null);
+ binding.zipCode.requestFocus();
+
+ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+
+ });
+
+ }
+
+ public String readCountryNStates(Context context) throws IOException {
+ StringBuilder returnString = new StringBuilder();
+
+ InputStream fIn = context.getResources().openRawResource(R.raw.country_n_states);
+ InputStreamReader isr = new InputStreamReader(fIn);
+ BufferedReader input = new BufferedReader(isr);
+
+ String line = "";
+
+ while ((line = input.readLine()) != null) {
+ returnString.append(line);
+ }
+
+ try {
+ isr.close();
+
+ if (fIn != null) fIn.close();
+
+ input.close();
+
+ } catch (Exception e) {
+ Log.e(TAG, "readCountryNStates: ", e);
+ }
+
+ return returnString.toString();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/PatientProfileShowerActivity.java b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileShowerActivity.java
similarity index 84%
rename from app/src/main/java/com/ssb/simplitend/caregiverdashboard/PatientProfileShowerActivity.java
rename to app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileShowerActivity.java
index 214ba33..1eecf75 100644
--- a/app/src/main/java/com/ssb/simplitend/caregiverdashboard/PatientProfileShowerActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/caregiverdashboard/activities/PatientProfileShowerActivity.java
@@ -1,4 +1,4 @@
-package com.ssb.simplitend.caregiverdashboard;
+package com.ssb.simplitend.caregiverdashboard.activities;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
@@ -48,7 +48,7 @@ public class PatientProfileShowerActivity extends AppCompatActivity {
return;
}
- addFragment(fragment);
+ addFragment(fragment, which_f);
}
@@ -74,9 +74,13 @@ public class PatientProfileShowerActivity extends AppCompatActivity {
return fragment;
}
- private void addFragment(Fragment fragment) {
- getSupportFragmentManager().beginTransaction()
- .add(R.id.fcv_profile_shower, fragment)
- .commitAllowingStateLoss();
+ private void addFragment(Fragment fragment, String tag) {
+ try {
+ getSupportFragmentManager().beginTransaction()
+ .add(R.id.fcv_profile_shower, fragment, tag)
+ .commitAllowingStateLoss();
+ } catch (Exception e) {
+ // user may be out of context
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/ssb/simplitend/cg_geofencing/CgGeoFencingActivity.java b/app/src/main/java/com/ssb/simplitend/cg_geofencing/CgGeoFencingActivity.java
index 89eb8d6..881dab1 100644
--- a/app/src/main/java/com/ssb/simplitend/cg_geofencing/CgGeoFencingActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/cg_geofencing/CgGeoFencingActivity.java
@@ -1,21 +1,244 @@
package com.ssb.simplitend.cg_geofencing;
+import androidx.activity.result.ActivityResultLauncher;
+import androidx.activity.result.contract.ActivityResultContracts;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Color;
import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+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.CameraPosition;
+import com.google.android.gms.maps.model.CircleOptions;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
+import com.google.android.libraries.places.api.Places;
+import com.google.android.libraries.places.api.model.Place;
+import com.google.android.libraries.places.widget.Autocomplete;
+import com.google.android.libraries.places.widget.model.AutocompleteActivityMode;
+import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.ssb.simplitend.R;
+import com.ssb.simplitend.apputils.CaregiverDataCache;
import com.ssb.simplitend.databinding.ActivityCgGeofencingBinding;
+import com.ssb.simplitend.databinding.GeofenceBottomSheetBinding;
+import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.PatientData;
-public class CgGeoFencingActivity extends AppCompatActivity {
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CgGeoFencingActivity extends AppCompatActivity implements OnMapReadyCallback {
// view binding
protected ActivityCgGeofencingBinding binding;
+ // bottom sheet binding
+ private BottomSheetDialog bottomSheetDialog;
+
+ private GeofenceBottomSheetBinding geofence_bs_binding;
+
+ private PatientData patientData;
+
+ private GoogleMap mMap;
+
+ private LatLng mLatLng;
+
+ private ActivityResultLauncher startAutocompleteMapSearch;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityCgGeofencingBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
+
+ geofence_bs_binding = GeofenceBottomSheetBinding.inflate(getLayoutInflater());
+
+ CaregiverDataCache.getCaregiverData(this, (careGiverData -> {
+ if (careGiverData == null) return;;
+
+ this.patientData = careGiverData.patientDetails;
+ }), true);
+
+ initViews();
+
+ clickEvents();
+
+ }
+
+ private void initViews() {
+ // Obtain the SupportMapFragment and get notified when the map is ready to be used.
+ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.geofence_map);
+ if (mapFragment != null) {
+ mapFragment.getMapAsync(this);
+ }else{
+ Toast.makeText(this, "Couldn't load map. Please try again.", Toast.LENGTH_SHORT).show();
+ }
+
+
+ bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
+ bottomSheetDialog.setContentView(geofence_bs_binding.getRoot());
+ bottomSheetDialog.setCancelable(true);
+
+ try {
+ geofence_bs_binding.unitSpinner.selectItemByIndex(0);
+ }catch (Exception e){
+ ArrayList arrayList = new ArrayList<>();
+ arrayList.add("Kms");
+ arrayList.add("Miles");
+ geofence_bs_binding.unitSpinner.setItems(arrayList);
+ geofence_bs_binding.unitSpinner.selectItemByIndex(0);
+ }
+
+ geofence_bs_binding.unitSpinner.setLifecycleOwner(this);
+ geofence_bs_binding.unitSpinner.setIsFocusable(true);
+
+ registerMapSearchResultLauncher();
+
+ }
+
+ private void clickEvents(){
+ binding.backBtn.setOnClickListener(v -> onBackPressed());
+
+ binding.setGf.setOnClickListener(v -> {
+ if (bottomSheetDialog != null){
+ bottomSheetDialog.show();
+ }
+ });
+
+ geofence_bs_binding.save.setOnClickListener(v -> {
+ Float radius = getRadius();
+
+ if (radius == null){
+ Toast.makeText(this, "Invalid radius", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ // convert to meters
+ if (geofence_bs_binding.unitSpinner.getSelectedIndex() == 1){
+ // it is miles
+ radius = radius * 1609.34f; // to meters
+ }else{
+ // it is kms
+ radius = radius * 1000; // to meters
+ }
+
+ if (radius < 100){
+ Toast.makeText(this, "Radius should be minimum 100 meters.", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ addMarker(mLatLng);
+ addCircle(radius);
+ });
+
+ binding.search.setOnClickListener(v -> {
+
+ List fields = Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG);
+
+ Intent intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields)
+ .build(this);
+
+ startAutocompleteMapSearch.launch(intent);
+ });
+ }
+
+ private void addCircle(float radius) {
+ if (mMap == null) return;
+
+ CircleOptions circleOptions = new CircleOptions();
+ circleOptions.center(mLatLng);
+ circleOptions.radius(radius);
+ circleOptions.strokeWidth(0);
+ circleOptions.fillColor(Color.argb(150, 167, 205, 242));
+
+ mMap.addCircle(circleOptions);
+ bottomSheetDialog.dismiss();
+ mMap.animateCamera(CameraUpdateFactory.zoomTo(13));
+
+ Toast.makeText(this, "Geofence added. Radius : " + radius + " meters.", Toast.LENGTH_SHORT).show();
+ }
+
+ private Float getRadius() {
+ Float radius = null;
+
+ try {
+ radius = Float.valueOf(geofence_bs_binding.radius.getText().toString());
+ }catch (Exception e){
+ // do nothing
+ }
+
+ return radius;
+ }
+
+ @Override
+ public void onMapReady(@NonNull GoogleMap googleMap) {
+ this.mMap = googleMap;
+
+ LatLng latLng;
+
+ // loading patient's location
+ try {
+ if (patientData == null) throw new Exception();
+
+ double lat = Double.parseDouble(patientData.lat);
+ double lng = Double.parseDouble(patientData.lng);
+
+ latLng = new LatLng(lat, lng);
+ }catch (Exception e){
+ // near marine drive
+ latLng = new LatLng(18.93294274664527, 72.82806102186441);
+ }
+
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));
+ addMarker(latLng);
+ }
+
+ private void addMarker(@NonNull LatLng latLng){
+ if (mMap == null || patientData == null) return;
+
+ this.mLatLng = latLng;
+
+ mMap.clear();
+
+ MarkerOptions markerOptions = new MarkerOptions()
+ .position(latLng)
+ .title(patientData.first_name + "");
+
+ mMap.addMarker(markerOptions);
+ mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));;
+ }
+
+ private void registerMapSearchResultLauncher() {
+
+ // initializing places
+
+ // Initialize the SDK
+ Places.initialize(this, getString(R.string.GOOGLE_MAPS_API_KEY));
+
+ startAutocompleteMapSearch = registerForActivityResult(
+ new ActivityResultContracts.StartActivityForResult(),
+ result -> {
+ if (result.getResultCode() == Activity.RESULT_OK) {
+ Intent intent = result.getData();
+ if (intent != null) {
+ Place place = Autocomplete.getPlaceFromIntent(intent);
+
+ if (place.getLatLng() == null) return;
+
+ addMarker(place.getLatLng());
+ }
+ }
+ });
+
+
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/ssb/simplitend/cg_subscription/CgSubscriptionActivity.java b/app/src/main/java/com/ssb/simplitend/cg_subscription/CgSubscriptionActivity.java
index 7642206..600d4b1 100644
--- a/app/src/main/java/com/ssb/simplitend/cg_subscription/CgSubscriptionActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/cg_subscription/CgSubscriptionActivity.java
@@ -13,9 +13,7 @@ import androidx.viewpager2.widget.ViewPager2;
import com.ssb.simplitend.R;
import com.ssb.simplitend.apputils.AppUtil;
import com.ssb.simplitend.apputils.CaregiverDataCache;
-import com.ssb.simplitend.caregiverdashboard.CaregiverDashActivity;
-import com.ssb.simplitend.caregiverdashboard.CgProfileProgressActivity;
-import com.ssb.simplitend.caregiverdashboard.PatientProfileShowerActivity;
+import com.ssb.simplitend.caregiverdashboard.activities.CgProfileProgressActivity;
import com.ssb.simplitend.cg_subscription.mvp.SubscriptionContracts;
import com.ssb.simplitend.cg_subscription.mvp.SubscriptionCredentials;
import com.ssb.simplitend.cg_subscription.mvp.SubscriptionPresenter;
@@ -63,7 +61,7 @@ public class CgSubscriptionActivity extends AppCompatActivity
CaregiverDataCache.getCaregiverData(this, (careGiverData -> {
this.careGiverData = careGiverData;
- }));
+ }), true);
initViews();
diff --git a/app/src/main/java/com/ssb/simplitend/patientprofile/medicalinfo/MedicalInfoFragment.java b/app/src/main/java/com/ssb/simplitend/patientprofile/medicalinfo/MedicalInfoFragment.java
index 3f6789a..a465943 100644
--- a/app/src/main/java/com/ssb/simplitend/patientprofile/medicalinfo/MedicalInfoFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/patientprofile/medicalinfo/MedicalInfoFragment.java
@@ -82,10 +82,14 @@ public class MedicalInfoFragment extends Fragment implements ProfileContracts.Ge
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .replace(R.id.fcv_profile_shower, AddMedicalInfoFragment.class, null)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, AddMedicalInfoFragment.class, null)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
}
);
@@ -103,10 +107,14 @@ public class MedicalInfoFragment extends Fragment implements ProfileContracts.Ge
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .replace(R.id.fcv_profile_shower, AddMedicalInfoFragment.class, bundle)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, AddMedicalInfoFragment.class, bundle)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
}
diff --git a/app/src/main/java/com/ssb/simplitend/patientprofile/medreminder/ReminderFragment.java b/app/src/main/java/com/ssb/simplitend/patientprofile/medreminder/ReminderFragment.java
index be1bbdc..9ae4a70 100644
--- a/app/src/main/java/com/ssb/simplitend/patientprofile/medreminder/ReminderFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/patientprofile/medreminder/ReminderFragment.java
@@ -112,10 +112,14 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .replace(R.id.fcv_profile_shower, AddReminderFragment.class, null)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, AddReminderFragment.class, null)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
}
);
@@ -426,10 +430,14 @@ public class ReminderFragment extends Fragment implements RecyclerTouchListener.
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .add(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .add(R.id.fcv_profile_shower, AddReminderFragment.class, bundle)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
}
diff --git a/app/src/main/java/com/ssb/simplitend/patientprofile/setuproutine/RoutineFragment.java b/app/src/main/java/com/ssb/simplitend/patientprofile/setuproutine/RoutineFragment.java
index 844070e..e2fc3db 100644
--- a/app/src/main/java/com/ssb/simplitend/patientprofile/setuproutine/RoutineFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/patientprofile/setuproutine/RoutineFragment.java
@@ -116,10 +116,14 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .replace(R.id.fcv_profile_shower, AddRoutineFragment.class, null)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, AddRoutineFragment.class, null)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
});
@@ -400,10 +404,14 @@ public class RoutineFragment extends Fragment implements RoutineAdapter.ClickLis
// there may be a IllegalStateException as this same fragment is used from another fragment
// and not through the nav graph
- getParentFragmentManager().beginTransaction()
- .add(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
- .addToBackStack("add_reminder")
- .commitAllowingStateLoss();
+ try {
+ getParentFragmentManager().beginTransaction()
+ .add(R.id.fcv_profile_shower, AddRoutineFragment.class, bundle)
+ .addToBackStack("add_reminder")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
}
}
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgAuthActivity.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgAuthActivity.java
index 9546439..ad55f4c 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgAuthActivity.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgAuthActivity.java
@@ -19,7 +19,7 @@ import androidx.core.content.ContextCompat;
import com.daimajia.androidanimations.library.Techniques;
import com.daimajia.androidanimations.library.YoYo;
import com.ssb.simplitend.apputils.AppUtil;
-import com.ssb.simplitend.caregiverdashboard.CaregiverDashActivity;
+import com.ssb.simplitend.caregiverdashboard.activities.CaregiverDashActivity;
import com.ssb.simplitend.databinding.CgAuthFragmentBinding;
public class CgAuthActivity extends AppCompatActivity {
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgSignInFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgSignInFragment.java
index 76c9c08..2402b5a 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgSignInFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomecg/fragments/CgSignInFragment.java
@@ -20,7 +20,7 @@ import androidx.navigation.Navigation;
import com.ssb.simplitend.R;
import com.ssb.simplitend.apputils.AppUtil;
import com.ssb.simplitend.apputils.CaregiverDataCache;
-import com.ssb.simplitend.caregiverdashboard.CaregiverDashActivity;
+import com.ssb.simplitend.caregiverdashboard.activities.CaregiverDashActivity;
import com.ssb.simplitend.databinding.CgSignInFragmentBinding;
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/AddContactFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/AddContactFragment.java
index a460c10..88d51f5 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/AddContactFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/AddContactFragment.java
@@ -3,6 +3,7 @@ package com.ssb.simplitend.welcome.welcomepatient.fragments.contacts;
import static com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.ContactInfoFragment.CONTACT_DATA_KEY;
import static com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.CreateContactFragment.TO_EDIT_KEY;
+import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -36,6 +37,8 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
// view binding
protected AddContactFragmentBinding binding;
+ public static final String CONTACT_INFO_F = "contact_info_f";
+
protected AddContactAdapter contactAdapter;
private ProgressDialog progressDialog;
@@ -91,7 +94,18 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
});
binding.nextBtn.setOnClickListener(v ->
- Navigation.findNavController(v).navigate(R.id.action_addContactFragment_to_profileProgressFragment));
+ {
+ try {
+ Navigation.findNavController(v).navigate(R.id.action_addContactFragment_to_profileProgressFragment);
+ }catch (Exception e){
+ // this fragment is not only opened by the welcome_nav_graph
+ // but, also by other fragments
+ Activity activity = getActivity();
+ if (activity != null){
+ activity.onBackPressed();
+ }
+ }
+ });
}
@@ -132,16 +146,40 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
"Add from contacts or manually?",
"Contacts",
((dialogInterface, i) -> {
- Navigation.findNavController(binding.getRoot())
- .navigate(R.id.action_addContactFragment_to_contactListFragment);
+ try {
+ Navigation.findNavController(binding.getRoot())
+ .navigate(R.id.action_addContactFragment_to_contactListFragment);
+ }catch (Exception e){
+ // this fragment is also opened by other context
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, ContactListFragment.class, null)
+ .addToBackStack("contact_list_f")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
}),
"Manually",
((dialogInterface, i) -> {
Bundle bundle = new Bundle();
bundle.putSerializable(TO_EDIT_KEY, false);
- Navigation.findNavController(binding.getRoot())
- .navigate(R.id.action_addContactFragment_to_createContactFragment, bundle);
+ try {
+ Navigation.findNavController(binding.getRoot())
+ .navigate(R.id.action_addContactFragment_to_createContactFragment, bundle);
+ }catch (Exception e){
+ // this fragment is also opened by other context
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, CreateContactFragment.class, bundle)
+ .addToBackStack("create_contact_f")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
})
);
@@ -150,8 +188,21 @@ public class AddContactFragment extends Fragment implements WelcomeContracts.Con
Bundle bundle = new Bundle();
bundle.putSerializable(CONTACT_DATA_KEY, contactData);
- Navigation.findNavController(binding.getRoot())
- .navigate(R.id.action_addContactFragment_to_contactInfoFragment, bundle);
+ try {
+ Navigation.findNavController(binding.getRoot())
+ .navigate(R.id.action_addContactFragment_to_contactInfoFragment, bundle);
+ }catch (Exception e){
+ // this fragment is also opened by other context
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, ContactInfoFragment.class, bundle)
+ .addToBackStack(CONTACT_INFO_F)
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
+
}
}
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactInfoFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactInfoFragment.java
index 6c138f5..59bec53 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactInfoFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactInfoFragment.java
@@ -3,6 +3,7 @@ package com.ssb.simplitend.welcome.welcomepatient.fragments.contacts;
import static com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.CreateContactFragment.CONTACT_KEY;
import static com.ssb.simplitend.welcome.welcomepatient.fragments.contacts.CreateContactFragment.TO_EDIT_KEY;
+import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
@@ -63,7 +64,10 @@ public class ContactInfoFragment extends Fragment implements WelcomeContracts.De
contactData = (ContactData) getArguments().getSerializable(CONTACT_DATA_KEY);
} else {
// no arguments received
- Navigation.findNavController(binding.getRoot()).popBackStack();
+ Activity activity = getActivity();
+ if (activity != null){
+ activity.onBackPressed();
+ }
return;
}
@@ -143,8 +147,19 @@ public class ContactInfoFragment extends Fragment implements WelcomeContracts.De
bundle.putBoolean(TO_EDIT_KEY, true);
bundle.putSerializable(CONTACT_KEY, contactData);
- Navigation.findNavController(v)
- .navigate(R.id.action_contactInfoFragment_to_createContactFragment, bundle);
+ try {
+ Navigation.findNavController(v)
+ .navigate(R.id.action_contactInfoFragment_to_createContactFragment, bundle);
+ }catch (Exception e){
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, CreateContactFragment.class, bundle)
+ .addToBackStack("create_contact_f")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
});
binding.callBtn.setOnClickListener(v -> {
@@ -167,7 +182,10 @@ public class ContactInfoFragment extends Fragment implements WelcomeContracts.De
public void onContactDelete() {
progressDialog.dismiss();
Toast.makeText(requireActivity(), "Contact deleted successfully.", Toast.LENGTH_SHORT).show();
- Navigation.findNavController(binding.getRoot()).popBackStack();
+ Activity activity = getActivity();
+ if (activity != null){
+ activity.onBackPressed();
+ }
}
@Override
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactListFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactListFragment.java
index 6c136ab..8c7b12a 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactListFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/ContactListFragment.java
@@ -87,7 +87,20 @@ public class ContactListFragment extends Fragment {
Bundle bundle = new Bundle();
bundle.putBoolean(CreateContactFragment.TO_EDIT_KEY, false);
bundle.putSerializable(CreateContactFragment.CONTACT_KEY, new ContactData(contact));
- Navigation.findNavController(binding.getRoot()).navigate(R.id.action_contactListFragment_to_createContactFragment, bundle);
+
+ try {
+ Navigation.findNavController(binding.getRoot()).navigate(R.id.action_contactListFragment_to_createContactFragment, bundle);
+ }catch (Exception e){
+ // this fragment is not only opened by the welcome_vav_graph
+ try {
+ getParentFragmentManager().beginTransaction()
+ .replace(R.id.fcv_profile_shower, CreateContactFragment.class, bundle)
+ .addToBackStack("create_contact_f")
+ .commitAllowingStateLoss();
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
}
);
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/CreateContactFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/CreateContactFragment.java
index 9832e2c..1d15781 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/CreateContactFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/contacts/CreateContactFragment.java
@@ -21,6 +21,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;
@@ -389,7 +390,16 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
if (bsd != null) bsd.dismiss();
Toast.makeText(requireActivity(), "Contact updated successFully.", Toast.LENGTH_SHORT).show();
- Navigation.findNavController(binding.getRoot()).popBackStack(R.id.addContactFragment, false);
+ try {
+ Navigation.findNavController(binding.getRoot()).popBackStack(R.id.addContactFragment, false);
+ }catch (Exception e){
+ // this fragment is not only opened by the welcome_nav_graph
+ try {
+ getParentFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ }catch (Exception e2){
+ // user may be out of context
+ }
+ }
}, 3600);
}
@@ -453,7 +463,12 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
Log.e(TAG, "onFailure: message : " + message + "\n", t);
progressDialog.dismiss();
- Navigation.findNavController(binding.getRoot()).popBackStack();
+
+ Activity activity = getActivity();
+ if (activity != null){
+ activity.onBackPressed();
+ }
+
Toast.makeText(requireContext(), "Couldn't load contact", Toast.LENGTH_SHORT).show();
}
@@ -463,7 +478,16 @@ public class CreateContactFragment extends Fragment implements WelcomeContracts.
Log.d(TAG, "onContactCreated: " + contact);
progressDialog.dismiss();
- Navigation.findNavController(binding.getRoot()).navigate(R.id.action_createContactFragment_to_addContactFragment);
+ try {
+ Navigation.findNavController(binding.getRoot()).navigate(R.id.action_createContactFragment_to_addContactFragment);
+ }catch (Exception e){
+ // this fragment is opened from outside of welcome_nav_graph
+ try {
+ getParentFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ } catch (Exception ex) {
+ // user may be out of context
+ }
+ }
}
@Override
diff --git a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java
index e1da65c..c2c98fc 100644
--- a/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java
+++ b/app/src/main/java/com/ssb/simplitend/welcome/welcomepatient/fragments/register/SplashFragment.java
@@ -19,7 +19,7 @@ import com.ssb.simplitend.R;
import com.ssb.simplitend.apputils.AppUtil;
import com.ssb.simplitend.apputils.RetrofitHelper;
import com.ssb.simplitend.apputils.CaregiverDataCache;
-import com.ssb.simplitend.caregiverdashboard.CaregiverDashActivity;
+import com.ssb.simplitend.caregiverdashboard.activities.CaregiverDashActivity;
import com.ssb.simplitend.databinding.SplashFragmentBinding;
import com.ssb.simplitend.patient_dashboard.DashBoardActivity;
import com.ssb.simplitend.patientprofile.PatientProfileAPIService;
diff --git a/app/src/main/res/drawable/ic_contacts.xml b/app/src/main/res/drawable/ic_contacts.xml
new file mode 100644
index 0000000..4f6b461
--- /dev/null
+++ b/app/src/main/res/drawable/ic_contacts.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_geofence.xml b/app/src/main/res/drawable/ic_geofence.xml
new file mode 100644
index 0000000..2c0c3cf
--- /dev/null
+++ b/app/src/main/res/drawable/ic_geofence.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/top_right_corners_round.xml b/app/src/main/res/drawable/top_right_corners_round.xml
new file mode 100644
index 0000000..111580a
--- /dev/null
+++ b/app/src/main/res/drawable/top_right_corners_round.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_cg_geofencing.xml b/app/src/main/res/layout/activity_cg_geofencing.xml
index 324a911..b24d861 100644
--- a/app/src/main/res/layout/activity_cg_geofencing.xml
+++ b/app/src/main/res/layout/activity_cg_geofencing.xml
@@ -144,16 +144,20 @@
/>
diff --git a/app/src/main/res/layout/activity_cg_profile_progress.xml b/app/src/main/res/layout/activity_cg_profile_progress.xml
index 199381b..4e5439a 100644
--- a/app/src/main/res/layout/activity_cg_profile_progress.xml
+++ b/app/src/main/res/layout/activity_cg_profile_progress.xml
@@ -1,458 +1,672 @@
-
+ android:layout_height="match_parent">
+
+
- toola:text="Aditya Gaikwad"
- android:fontFamily="@font/nunito_medium"
- android:textColor="@color/black"
- android:textSize="@dimen/_20ssp"
-
- android:layout_marginHorizontal="25dp"
- android:layout_marginTop="25dp"
- android:layout_marginBottom="15dp"
-
- android:maxLines="1"
- android:ellipsize="end"
-
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:text="@string/we_are_currently_syncing_patient_data_this_may_take_a_few_seconds"
+ android:textAlignment="center"
+ android:textSize="@dimen/_16ssp"
+ android:textColor="@color/black" />
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_patient_profile_shower.xml b/app/src/main/res/layout/activity_patient_profile_shower.xml
index aa0eeaf..404962a 100644
--- a/app/src/main/res/layout/activity_patient_profile_shower.xml
+++ b/app/src/main/res/layout/activity_patient_profile_shower.xml
@@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
- tools:context=".caregiverdashboard.PatientProfileShowerActivity">
+ tools:context=".caregiverdashboard.activities.PatientProfileShowerActivity">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/cg_onboard_fragment.xml b/app/src/main/res/layout/cg_onboard_fragment.xml
index 0d551cf..c96938a 100644
--- a/app/src/main/res/layout/cg_onboard_fragment.xml
+++ b/app/src/main/res/layout/cg_onboard_fragment.xml
@@ -1,7 +1,6 @@
-
-
-
-
- android:layout_marginStart="@dimen/_15sdp"
- android:layout_marginEnd="15dp"
- android:layout_marginBottom="@dimen/_5sdp"
- android:fontFamily="@font/nunito_semibold"
-
- android:textColor="@color/black"
- android:textSize="@dimen/_22ssp"
- app:layout_constraintBottom_toTopOf="@+id/sub_title"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- android:text="@string/reinventing_connected_ncaregiving" />
-
-
-
-
-
-
-
-
+ android:layout_marginBottom="@dimen/_10sdp"
-
+
+
+
+
+
+ android:textSize="@dimen/_18ssp"
+ app:layout_constraintBottom_toTopOf="@+id/relativeLayout2"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
-
+
+
+
+
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..3a1ad0b
--- /dev/null
+++ b/app/src/main/res/layout/geofence_bottom_sheet.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/navigation/welcome_nav_graph.xml b/app/src/main/res/navigation/welcome_nav_graph.xml
index 0d45f2a..c171d9b 100644
--- a/app/src/main/res/navigation/welcome_nav_graph.xml
+++ b/app/src/main/res/navigation/welcome_nav_graph.xml
@@ -2,7 +2,7 @@
+ app:startDestination="@id/splashFragment">
Set specific geographic areas and receive instant alerts when your loved one leaves the geofenced zone.
Destination 0.5m away
165 Hasley St. Newark, NJ 07102
+ Enter your location
+ Location
+ Radius
+ 0.00
+ Message
+ Enter a message
+ Syncing patient information
+ We are currently syncing patient data. This may take a few seconds.
+
+
+ - Kms
+ - Miles
+
\ No newline at end of file