.
This commit is contained in:
@@ -20,6 +20,15 @@ import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.DecisionBottomsheetBinding;
|
||||
import com.ssb.simplitend.databinding.DoneBottomsheetBinding;
|
||||
|
||||
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.util.ArrayList;
|
||||
|
||||
public abstract class AppUtil {
|
||||
|
||||
private static final String TAG = "AppUtil";
|
||||
@@ -133,6 +142,65 @@ public abstract class AppUtil {
|
||||
alertBuilder.create().show(); // Showing alert dialog
|
||||
}
|
||||
|
||||
// fetches the country codes from the JSON file in raw directory
|
||||
public static ArrayList<String> loadCountryCodeDropDown(Context context) {
|
||||
|
||||
ArrayList<String> 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();
|
||||
|
||||
@@ -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<CallResponse<CareGiverData>>() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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<String> countryCodeList;
|
||||
|
||||
private PatientData patientData;
|
||||
|
||||
private ArrayList<String> countryList;
|
||||
private HashMap<String, ArrayList<String>> 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<String> 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<String> 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<String>) (i, s, i1, t1) -> {
|
||||
|
||||
binding.countrySpinner.setError(null);
|
||||
|
||||
ArrayList<String> 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<String>) (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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<Intent> 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<String> 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<Place.Field> 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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user