.
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg;
|
||||
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgForgotPwdResult;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.ConnectCgResult;
|
||||
import com.ssb.simplitend.welcome.welcomepatient.mvvm.models.CallResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
@@ -17,4 +23,23 @@ public interface WelcomeApiService {
|
||||
@POST("api/auth/caregiver-register")
|
||||
Call<CallResponse<CareGiverData>> registerCareGiver(@PartMap Map<String, RequestBody> body);
|
||||
|
||||
@POST("api/auth/caregiver-login")
|
||||
Call<CallResponse<CareGiverData>> loginCaregiver(@Body Map<String, String> body);
|
||||
|
||||
@POST("api/auth/patient-caregiver-connect")
|
||||
Call<CallResponse<Object>> verifyCgOTP(@Body Map<String, String> body);
|
||||
|
||||
@GET("api/auth/forgot-caregiver-password")
|
||||
Call<CallResponse<CgForgotPwdResult>> sendForgotCodeEmail(@Header("email") String email);
|
||||
|
||||
@POST("api/auth/verify-caregiver-otp")
|
||||
Call<CallResponse<String>> verifyForgotOTP(@Body Map<String, String> body);
|
||||
|
||||
@Multipart
|
||||
@POST("api/auth/change-caregiver-password")
|
||||
Call<CallResponse<CareGiverData>> changeCgPassword(@PartMap Map<String, RequestBody> body);
|
||||
|
||||
@POST("api/auth/patient-caregiver-connect")
|
||||
Call<CallResponse<ConnectCgResult>> connectCg(@Body Map<String, String> body);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg;
|
||||
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgForgotPwdResult;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.ConnectCgResult;
|
||||
|
||||
public interface WelcomeContracts {
|
||||
|
||||
@@ -12,4 +14,42 @@ public interface WelcomeContracts {
|
||||
|
||||
}
|
||||
|
||||
interface VerifyCgOTPCallback{
|
||||
void onOTPVerifies();
|
||||
|
||||
void onVerifyOTPFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface CgLoginCallback{
|
||||
void onLoginSuccess(CareGiverData careGiverData, String token);
|
||||
|
||||
void onLogInFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface ForgotPwdSentCodeCallback{
|
||||
void onEmailSentSuccess(CgForgotPwdResult result);
|
||||
|
||||
void onEmailSentFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface VerifyForgotOTP{
|
||||
void onOTPVerified();
|
||||
|
||||
void onOTPVerificationFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface ChangePasswordCallback{
|
||||
void onPasswordChanged(CareGiverData careGiverData);
|
||||
|
||||
void onPasswordChangeFailed(Throwable t, String message);
|
||||
}
|
||||
|
||||
interface ConnectCgCallback{
|
||||
|
||||
void onCgConnected(ConnectCgResult result);
|
||||
|
||||
void onCgConnectFailed(Throwable throwable, String message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,43 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.fragments;
|
||||
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgCheckEmailFragment.FORGOT_EMAIL;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.CgChangePasswordFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgWelcomeViewModel;
|
||||
|
||||
public class CgChangePwdFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class CgChangePwdFragment extends Fragment implements WelcomeContracts.ChangePasswordCallback {
|
||||
|
||||
protected CgChangePasswordFragmentBinding binding;
|
||||
|
||||
public CgChangePwdFragment(){
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
private CgWelcomeViewModel viewModel;
|
||||
|
||||
private String eEmail;
|
||||
|
||||
public CgChangePwdFragment() {
|
||||
// required
|
||||
}
|
||||
|
||||
@@ -24,6 +46,103 @@ public class CgChangePwdFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CgChangePasswordFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(CgWelcomeViewModel.class);
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.resetPin.setOnClickListener(v -> {
|
||||
if (allOkay()) {
|
||||
changePassword();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changePassword() {
|
||||
if (eEmail == null ||
|
||||
binding.password.getText() == null ||
|
||||
binding.confirmPassword.getText() == null) {
|
||||
Toast.makeText(requireContext(), "Something goes wrong, Try again.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we change your password.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, RequestBody> body = new HashMap<>();
|
||||
|
||||
RequestBody email_body = RequestBody.create(eEmail, MediaType.parse("text/plain"));
|
||||
body.put("email", email_body);
|
||||
|
||||
RequestBody password_body = RequestBody.create(binding.password.getText().toString(), MediaType.parse("text/plain"));
|
||||
body.put("password", password_body);
|
||||
|
||||
RequestBody c_password_body = RequestBody.create(binding.confirmPassword.getText().toString(), MediaType.parse("text/plain"));
|
||||
body.put("c_password", c_password_body);
|
||||
|
||||
viewModel.changeCgPassword(body, this);
|
||||
|
||||
}
|
||||
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.password.getText() != null && binding.confirmPassword.getText() != null) {
|
||||
String password = binding.password.getText().toString();
|
||||
|
||||
if (password.length() < 8) {
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password must be at least 8 characters.", Toast.LENGTH_SHORT).show();
|
||||
} else if (password.contains(" ")) {
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password should not contains white spaces.", Toast.LENGTH_SHORT).show();
|
||||
} else if (!password.matches("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^a-zA-Z0-9]).{8,}$")) {
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password doesn't match the required criteria.", Toast.LENGTH_SHORT).show();
|
||||
} else if (!binding.confirmPassword.getText().toString().equals(password)) {
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Confirm password doesn't match.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle == null ||
|
||||
bundle.getString(FORGOT_EMAIL, null) == null) {
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack();
|
||||
Toast.makeText(requireContext(), "Something went wrong.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
eEmail = bundle.getString(FORGOT_EMAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordChanged(CareGiverData careGiverData) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "Password changed successfully.", Toast.LENGTH_SHORT).show();
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.popBackStack(R.id.cgSignInFragment, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPasswordChangeFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "" + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.fragments;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.CgCheckEmailFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgForgotPwdResult;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgWelcomeViewModel;
|
||||
|
||||
public class CgCheckEmailFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CgCheckEmailFragment extends Fragment implements WelcomeContracts.ForgotPwdSentCodeCallback,
|
||||
WelcomeContracts.VerifyForgotOTP {
|
||||
|
||||
protected CgCheckEmailFragmentBinding binding;
|
||||
|
||||
public CgCheckEmailFragment(){
|
||||
public static final String FORGOT_EMAIL = "forgot_mail";
|
||||
public static final String CG_USER_XID = "cg_user_xid";
|
||||
|
||||
private String mEmail, mUserXid;
|
||||
|
||||
private CgWelcomeViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public CgCheckEmailFragment() {
|
||||
// required
|
||||
}
|
||||
|
||||
@@ -30,6 +49,8 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CgCheckEmailFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(CgWelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -37,15 +58,68 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle == null ||
|
||||
bundle.getString(FORGOT_EMAIL, null) == null ||
|
||||
bundle.getString(CG_USER_XID, null) == null) {
|
||||
// no data received
|
||||
Navigation.findNavController(binding.getRoot()).popBackStack();
|
||||
Toast.makeText(requireContext(), "Something went wrong.", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
mEmail = bundle.getString(FORGOT_EMAIL);
|
||||
mUserXid = bundle.getString(CG_USER_XID);
|
||||
|
||||
binding.emailAt.setVisibility(View.VISIBLE);
|
||||
binding.email.setText(mEmail);
|
||||
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.submit.setOnClickListener(view -> {
|
||||
Navigation.findNavController(view)
|
||||
.navigate(R.id.action_cgCheckEmailFragment_to_cgChangePwdFragment);
|
||||
if (checkOTPInputs()){
|
||||
verifyOTP();
|
||||
}else{
|
||||
Toast.makeText(requireContext(), "Enter OTP received on your email.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
binding.resendOtp.setOnClickListener(v -> {
|
||||
if (mEmail == null) return;
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we resend you an OTP.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
viewModel.sendForgotCodeEmail(mEmail, this);
|
||||
});
|
||||
}
|
||||
|
||||
private void verifyOTP() {
|
||||
progressDialog.setTitle("Please wait");
|
||||
progressDialog.setMessage("while we verify your OTP.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, String> body = new HashMap<>();
|
||||
|
||||
body.put("otp_code", getOTPFromInputs());
|
||||
|
||||
body.put("user_id", mUserXid);
|
||||
|
||||
viewModel.verifyForgotOTP(body, this);
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// showing gif
|
||||
Glide.with(binding.image)
|
||||
.asGif()
|
||||
@@ -57,6 +131,13 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
private String getOTPFromInputs() {
|
||||
return binding.otp1.getText().toString() +
|
||||
binding.otp2.getText().toString() +
|
||||
binding.otp3.getText().toString() +
|
||||
binding.otp4.getText().toString();
|
||||
}
|
||||
|
||||
/*
|
||||
setting text change listener for every edit text for otp
|
||||
*/
|
||||
@@ -77,7 +158,7 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp2.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
if (checkOTPInputs()) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
}
|
||||
@@ -102,7 +183,7 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp3.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
if (checkOTPInputs()) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
} else {
|
||||
@@ -129,7 +210,7 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!s.toString().trim().isEmpty()) {
|
||||
binding.otp4.requestFocus();
|
||||
if (checkOTPInputs()){
|
||||
if (checkOTPInputs()) {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
}
|
||||
} else {
|
||||
@@ -168,19 +249,67 @@ public class CgCheckEmailFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
public boolean checkOTPInputs(){
|
||||
public boolean checkOTPInputs() {
|
||||
|
||||
if (binding.otp3.getText().toString().trim().length() != 1){
|
||||
if (binding.otp3.getText().toString().trim().length() != 1) {
|
||||
return false;
|
||||
}else if (binding.otp2.getText().toString().trim().length() != 1){
|
||||
} else if (binding.otp2.getText().toString().trim().length() != 1) {
|
||||
return false;
|
||||
}else if (binding.otp3.getText().toString().trim().length() != 1){
|
||||
} else if (binding.otp3.getText().toString().trim().length() != 1) {
|
||||
return false;
|
||||
}else if (binding.otp4.getText().toString().trim().length() != 1){
|
||||
} else if (binding.otp4.getText().toString().trim().length() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// otp send callback
|
||||
@Override
|
||||
public void onEmailSentSuccess(CgForgotPwdResult result) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "OTP resent successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
clearInputs();
|
||||
}
|
||||
|
||||
private void clearInputs() {
|
||||
binding.otp1.setText(null);
|
||||
binding.otp2.setText(null);
|
||||
binding.otp3.setText(null);
|
||||
binding.otp4.setText(null);
|
||||
|
||||
binding.otp1.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmailSentFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "Couldn't resend OTP.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// verify otp callback
|
||||
|
||||
|
||||
@Override
|
||||
public void onOTPVerified() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FORGOT_EMAIL, mEmail);
|
||||
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "OTP verification successful.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_cgCheckEmailFragment_to_cgChangePwdFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPVerificationFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "" + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,28 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.ConnectCaregiverFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
|
||||
|
||||
public class CgConnectFragment extends Fragment {
|
||||
|
||||
protected ConnectCaregiverFragmentBinding binding;
|
||||
|
||||
public CgConnectFragment(){
|
||||
public static final String CAREGIVER_EMAIL = "cg_email";
|
||||
public static final String CAREGIVER_PASSWORD = "caregiver_pwd";
|
||||
|
||||
private String cg_email, cg_password;
|
||||
|
||||
public CgConnectFragment() {
|
||||
// required
|
||||
}
|
||||
|
||||
@@ -39,5 +47,30 @@ public class CgConnectFragment extends Fragment {
|
||||
.load(R.raw.email_sending_anim)
|
||||
.placeholder(R.drawable.forgot_pin_email_img)
|
||||
.into(binding.image);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Bundle bundle = getArguments();
|
||||
|
||||
if (bundle == null ||
|
||||
bundle.getString(CAREGIVER_EMAIL, null) == null ||
|
||||
bundle.getString(CAREGIVER_PASSWORD, null) == null) {
|
||||
// no data received
|
||||
// Thus, asking cg_user to sign in again
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.popBackStack(R.id.cgSignInFragment, false);
|
||||
|
||||
return;
|
||||
}else{
|
||||
cg_email = bundle.getString(CAREGIVER_EMAIL);
|
||||
cg_password = bundle.getString(CAREGIVER_PASSWORD);
|
||||
|
||||
binding.emailAddress.setText(cg_email);
|
||||
Toast.makeText(requireContext(), "" + cg_password, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,43 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.fragments;
|
||||
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgCheckEmailFragment.CG_USER_XID;
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgCheckEmailFragment.FORGOT_EMAIL;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.CgForgotPasswordBinding;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgForgotPwdResult;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgWelcomeViewModel;
|
||||
|
||||
public class CgForgotPasswordFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CgForgotPasswordFragment extends Fragment implements WelcomeContracts.ForgotPwdSentCodeCallback {
|
||||
|
||||
protected CgForgotPasswordBinding binding;
|
||||
|
||||
private CgWelcomeViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
String mEmail;
|
||||
|
||||
public CgForgotPasswordFragment(){
|
||||
// required
|
||||
}
|
||||
@@ -27,6 +47,8 @@ public class CgForgotPasswordFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CgForgotPasswordBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(CgWelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
@@ -37,14 +59,31 @@ public class CgForgotPasswordFragment extends Fragment {
|
||||
private void clickEvents() {
|
||||
|
||||
binding.submit.setOnClickListener(v -> {
|
||||
Navigation.findNavController(v)
|
||||
.navigate(R.id.action_cgForgotPasswordFragment_to_cgCheckEmailFragment);
|
||||
|
||||
if (!Patterns.EMAIL_ADDRESS.matcher(binding.emailAddress.getText().toString().trim()).matches()){
|
||||
binding.emailAddress.setError("Invalid email.");
|
||||
return;
|
||||
}
|
||||
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we send you an email with a code.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
mEmail = binding.emailAddress.getText().toString().trim();
|
||||
|
||||
viewModel.sendForgotCodeEmail(mEmail, this);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
|
||||
// showing gif
|
||||
Glide.with(binding.image)
|
||||
.asGif()
|
||||
@@ -54,4 +93,26 @@ public class CgForgotPasswordFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmailSentSuccess(CgForgotPwdResult result) {
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putString(FORGOT_EMAIL, mEmail);
|
||||
bundle.putString(CG_USER_XID, result.principal_xid);
|
||||
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "OTP sent successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_cgForgotPasswordFragment_to_cgCheckEmailFragment, bundle);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEmailSentFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
|
||||
Toast.makeText(requireContext(), "" + message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.fragments;
|
||||
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgConnectFragment.CAREGIVER_EMAIL;
|
||||
import static com.ssb.simplitend.welcome.welcomecg.fragments.CgConnectFragment.CAREGIVER_PASSWORD;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
@@ -27,6 +30,7 @@ import androidx.navigation.Navigation;
|
||||
import com.google.i18n.phonenumbers.NumberParseException;
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import com.google.i18n.phonenumbers.Phonenumber;
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.apputils.EditTextErrorRemover;
|
||||
import com.ssb.simplitend.databinding.CgRegisterFragmentBinding;
|
||||
@@ -62,6 +66,8 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
|
||||
private PopupWindow passwordWindow;
|
||||
|
||||
private String mPassword;
|
||||
|
||||
private Calendar dob_selected;
|
||||
|
||||
public CgRegisterFragment(){
|
||||
@@ -140,7 +146,7 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we verify your entered email.");
|
||||
progressDialog.setMessage("while we register you as a caregiver.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
@@ -166,7 +172,13 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
RequestBody email_body = RequestBody.create(binding.email.getText().toString().trim(), MediaType.parse("text/plain"));
|
||||
body.put("email", email_body);
|
||||
|
||||
RequestBody password_body = RequestBody.create(binding.password.getText().toString().trim(), MediaType.parse("text/plain"));
|
||||
if (binding.password.getText() == null){
|
||||
mPassword = "";
|
||||
}else{
|
||||
mPassword = binding.password.getText().toString();
|
||||
}
|
||||
|
||||
RequestBody password_body = RequestBody.create(mPassword, MediaType.parse("text/plain"));
|
||||
body.put("password", password_body);
|
||||
|
||||
viewModel.registerCareGiver(body, this);
|
||||
@@ -375,6 +387,25 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
if (allOkay && binding.password.getText() != null && binding.confirmPassword.getText() != null){
|
||||
String password = binding.password.getText().toString();
|
||||
|
||||
if (password.length() < 8){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password must be at least 8 characters.", Toast.LENGTH_SHORT).show();
|
||||
}else if (password.contains(" ")){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password should not contains white spaces.", Toast.LENGTH_SHORT).show();
|
||||
}else if (!password.matches("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^a-zA-Z0-9]).{8,}$")){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Password doesn't match the required criteria.", Toast.LENGTH_SHORT).show();
|
||||
passwordWindow.showAsDropDown(binding.pwdTitle);
|
||||
}else if (!binding.confirmPassword.getText().toString().equals(password)){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Confirm password doesn't match.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
if (!binding.tncCheck.isChecked() && allOkay) {
|
||||
AppUtil.showAlert(requireContext(),
|
||||
"Accept terms and conditions",
|
||||
@@ -387,18 +418,31 @@ public class CgRegisterFragment extends Fragment implements WelcomeContracts.Reg
|
||||
allOkay = false;
|
||||
}
|
||||
|
||||
// TODO: 02-08-2023 password check
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCareGiverRegistered(CareGiverData careGiverData) {
|
||||
Toast.makeText(requireContext(), "Caregiver registered successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CAREGIVER_EMAIL, careGiverData.email);
|
||||
bundle.putString(CAREGIVER_PASSWORD, mPassword);
|
||||
|
||||
progressDialog.dismiss();
|
||||
|
||||
Navigation.findNavController(binding.getRoot())
|
||||
.navigate(R.id.action_cgRegisterFragment_to_cgConnectFragment, bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegisterFailed(Throwable t, String message) {
|
||||
|
||||
progressDialog.dismiss();
|
||||
AppUtil.showAlert(requireContext(),
|
||||
getString(R.string.something_went_wrong),
|
||||
message,
|
||||
getString(R.string.ok),
|
||||
((dialogInterface, i) -> {}),
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,37 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.fragments;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ssb.simplitend.R;
|
||||
import com.ssb.simplitend.databinding.CgHowToSetUpFragmentBinding;
|
||||
import com.ssb.simplitend.apputils.AppUtil;
|
||||
import com.ssb.simplitend.databinding.CgSignInFragmentBinding;
|
||||
import com.ssb.simplitend.welcome.welcomecg.WelcomeContracts;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
|
||||
import com.ssb.simplitend.welcome.welcomecg.mvvm.CgWelcomeViewModel;
|
||||
|
||||
public class CgSignInFragment extends Fragment {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CgSignInFragment extends Fragment implements WelcomeContracts.CgLoginCallback {
|
||||
|
||||
// view binding
|
||||
protected CgSignInFragmentBinding binding;
|
||||
|
||||
private CgWelcomeViewModel viewModel;
|
||||
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
public CgSignInFragment(){
|
||||
// required empty const.
|
||||
}
|
||||
@@ -28,7 +41,47 @@ public class CgSignInFragment extends Fragment {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
binding = CgSignInFragmentBinding.inflate(inflater, container, false);
|
||||
|
||||
viewModel = new ViewModelProvider(requireActivity()).get(CgWelcomeViewModel.class);
|
||||
|
||||
initViews();
|
||||
|
||||
clickEvents();
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
progressDialog = new ProgressDialog(requireContext());
|
||||
}
|
||||
|
||||
private void clickEvents() {
|
||||
binding.signInBtn.setOnClickListener(v -> {
|
||||
AppUtil.closeKeyboard(requireActivity());
|
||||
|
||||
binding.email.setError(null);
|
||||
|
||||
if (allOkay()){
|
||||
|
||||
progressDialog.setTitle("Please wait...");
|
||||
progressDialog.setMessage("while we sign you in.");
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
Map<String, String> body = new HashMap<>();
|
||||
body.put("email", binding.email.getText().toString());
|
||||
|
||||
String password;
|
||||
if (binding.password.getText() == null) {
|
||||
password = "";
|
||||
}
|
||||
else{
|
||||
password = binding.password.getText().toString();
|
||||
}
|
||||
|
||||
body.put("password", password);
|
||||
|
||||
viewModel.loginCaregiver(body, this);
|
||||
}
|
||||
});
|
||||
|
||||
binding.registerBtn.setOnClickListener(v -> {
|
||||
@@ -39,7 +92,33 @@ public class CgSignInFragment extends Fragment {
|
||||
Navigation.findNavController(v)
|
||||
.navigate(R.id.action_cgSignInFragment_to_cgForgotPasswordFragment);
|
||||
});
|
||||
}
|
||||
|
||||
return binding.getRoot();
|
||||
private boolean allOkay() {
|
||||
boolean allOkay = true;
|
||||
|
||||
if (binding.email.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
binding.email.setError("Please enter email.");
|
||||
}
|
||||
|
||||
if (binding.password.getText() != null && binding.password.getText().toString().trim().isEmpty()){
|
||||
allOkay = false;
|
||||
Toast.makeText(requireContext(), "Please enter password.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
return allOkay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginSuccess(CareGiverData careGiverData, String token) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), "Log in success.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLogInFailed(Throwable t, String message) {
|
||||
progressDialog.dismiss();
|
||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.mvvm;
|
||||
|
||||
public class CgForgotPwdResult{
|
||||
public int id;
|
||||
public String principal_xid;
|
||||
public String contact_xid;
|
||||
public String availability_working_hours;
|
||||
public String availability_weekend_holiday;
|
||||
public String availability_overnight;
|
||||
public String is_suspended;
|
||||
public String is_archived;
|
||||
public String active;
|
||||
public String deleted_at;
|
||||
public String created_by;
|
||||
public String updated_by;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
|
||||
public CgForgotPwdResult(){}
|
||||
|
||||
}
|
||||
@@ -64,4 +64,165 @@ public class CgWelcomeRepository {
|
||||
|
||||
}
|
||||
|
||||
public void verifyCgOTP(Map<String, String> body,
|
||||
WelcomeContracts.VerifyCgOTPCallback verifyCgOTPCallback){
|
||||
|
||||
apiService.verifyCgOTP(body)
|
||||
.enqueue(new Callback<CallResponse<Object>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<Object>> call, Response<CallResponse<Object>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
verifyCgOTPCallback.onVerifyOTPFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
verifyCgOTPCallback.onOTPVerifies();
|
||||
}else{
|
||||
verifyCgOTPCallback.onVerifyOTPFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<Object>> call, Throwable t) {
|
||||
Log.e(TAG, "onFailure: ", t);
|
||||
verifyCgOTPCallback.onVerifyOTPFailed(t, "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loginCaregiver(Map<String, String> body,
|
||||
WelcomeContracts.CgLoginCallback loginCallback){
|
||||
|
||||
apiService.loginCaregiver(body)
|
||||
.enqueue(new Callback<CallResponse<CareGiverData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<CareGiverData>> call, Response<CallResponse<CareGiverData>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
loginCallback.onLogInFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
loginCallback.onLoginSuccess(response.body().result, response.body().token);
|
||||
}else{
|
||||
loginCallback.onLogInFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<CareGiverData>> call, Throwable t) {
|
||||
loginCallback.onLogInFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void sendForgotCodeEmail(String email,
|
||||
WelcomeContracts.ForgotPwdSentCodeCallback sentCodeCallback){
|
||||
apiService.sendForgotCodeEmail(email)
|
||||
.enqueue(new Callback<CallResponse<CgForgotPwdResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<CgForgotPwdResult>> call, Response<CallResponse<CgForgotPwdResult>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
sentCodeCallback.onEmailSentFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
sentCodeCallback.onEmailSentSuccess(response.body().result);
|
||||
}else{
|
||||
sentCodeCallback.onEmailSentFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<CgForgotPwdResult>> call, Throwable t) {
|
||||
sentCodeCallback.onEmailSentFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void verifyForgotOTP(Map<String, String> body,
|
||||
WelcomeContracts.VerifyForgotOTP forgotOTPCallback){
|
||||
|
||||
apiService.verifyForgotOTP(body)
|
||||
.enqueue(new Callback<CallResponse<String>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<String>> call, Response<CallResponse<String>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200){
|
||||
forgotOTPCallback.onOTPVerificationFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
forgotOTPCallback.onOTPVerified();
|
||||
}else{
|
||||
forgotOTPCallback.onOTPVerificationFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<String>> call, Throwable t) {
|
||||
forgotOTPCallback.onOTPVerificationFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void changeCgPassword(Map<String, RequestBody> body,
|
||||
WelcomeContracts.ChangePasswordCallback changePasswordCallback){
|
||||
|
||||
apiService.changeCgPassword(body)
|
||||
.enqueue(new Callback<CallResponse<CareGiverData>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<CareGiverData>> call, Response<CallResponse<CareGiverData>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
changePasswordCallback.onPasswordChangeFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
changePasswordCallback.onPasswordChanged(response.body().result);
|
||||
}else{
|
||||
changePasswordCallback.onPasswordChangeFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<CareGiverData>> call, Throwable t) {
|
||||
changePasswordCallback.onPasswordChangeFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void connectCg(Map<String, String> body,
|
||||
WelcomeContracts.ConnectCgCallback connectCgCallback){
|
||||
|
||||
apiService.connectCg(body)
|
||||
.enqueue(new Callback<CallResponse<ConnectCgResult>>() {
|
||||
@Override
|
||||
public void onResponse(Call<CallResponse<ConnectCgResult>> call, Response<CallResponse<ConnectCgResult>> response) {
|
||||
if (response.body() != null){
|
||||
if (response.body().status != 200 || response.body().result == null){
|
||||
connectCgCallback.onCgConnectFailed(new Exception(), response.body().message);
|
||||
return;
|
||||
}
|
||||
|
||||
connectCgCallback.onCgConnected(response.body().result);
|
||||
}else{
|
||||
connectCgCallback.onCgConnectFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<CallResponse<ConnectCgResult>> call, Throwable t) {
|
||||
connectCgCallback.onCgConnectFailed(new Exception(), "Please try again later.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,36 @@ public class CgWelcomeViewModel extends ViewModel {
|
||||
repository.registerCareGiver(body, registerCareGiverCallback);
|
||||
}
|
||||
|
||||
public void verifyCgOTP(Map<String, String> body,
|
||||
WelcomeContracts.VerifyCgOTPCallback verifyCgOTPCallback){
|
||||
repository.verifyCgOTP(body, verifyCgOTPCallback);
|
||||
}
|
||||
|
||||
public void loginCaregiver(Map<String, String> body,
|
||||
WelcomeContracts.CgLoginCallback loginCallback){
|
||||
repository.loginCaregiver(body, loginCallback);
|
||||
}
|
||||
|
||||
public void sendForgotCodeEmail(String email,
|
||||
WelcomeContracts.ForgotPwdSentCodeCallback sentCodeCallback){
|
||||
repository.sendForgotCodeEmail(email, sentCodeCallback);
|
||||
}
|
||||
|
||||
public void verifyForgotOTP(Map<String, String> body,
|
||||
WelcomeContracts.VerifyForgotOTP forgotOTPCallback){
|
||||
repository.verifyForgotOTP(body, forgotOTPCallback);
|
||||
}
|
||||
|
||||
public void changeCgPassword(Map<String, RequestBody> body,
|
||||
WelcomeContracts.ChangePasswordCallback changePasswordCallback){
|
||||
repository.changeCgPassword(body, changePasswordCallback);
|
||||
}
|
||||
|
||||
public void connectCg(Map<String, String> body,
|
||||
WelcomeContracts.ConnectCgCallback connectCgCallback){
|
||||
repository.connectCg(body, connectCgCallback);
|
||||
}
|
||||
|
||||
public ArrayList<String> loadCountryCodeDropDown(Context context) {
|
||||
|
||||
ArrayList<String> countryCodeList = new ArrayList<>();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ssb.simplitend.welcome.welcomecg.mvvm;
|
||||
|
||||
public class ConnectCgResult{
|
||||
public int id;
|
||||
public String patient_xid;
|
||||
public String care_giver_xid;
|
||||
public String link_code;
|
||||
public int is_connected;
|
||||
public String active;
|
||||
public String deleted_at;
|
||||
public String created_by;
|
||||
public String updated_by;
|
||||
public String created_at;
|
||||
public String updated_at;
|
||||
|
||||
public ConnectCgResult(){}
|
||||
}
|
||||
@@ -292,6 +292,15 @@ public class CheckMailFragment extends Fragment implements WelcomeContracts.Veri
|
||||
return encoded_email + "@" + arr[1];
|
||||
}
|
||||
|
||||
private void clearInputs() {
|
||||
binding.otp1.setText(null);
|
||||
binding.otp2.setText(null);
|
||||
binding.otp3.setText(null);
|
||||
binding.otp4.setText(null);
|
||||
|
||||
binding.otp1.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOTPVerified() {
|
||||
progressDialog.dismiss();
|
||||
@@ -320,6 +329,8 @@ public class CheckMailFragment extends Fragment implements WelcomeContracts.Veri
|
||||
|
||||
user_id = otpSentResponse.principal_xid;
|
||||
Toast.makeText(requireContext(), "OTP resent successfully.", Toast.LENGTH_SHORT).show();
|
||||
|
||||
clearInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -471,6 +471,8 @@ public class LocationFragment extends Fragment implements OnMapReadyCallback,
|
||||
binding.stateSpinner.selectItemByIndex(state_index);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
binding.countrySpinner.clearSelectedItem();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user