This commit is contained in:
2023-09-04 16:13:26 +05:30
parent 6cccbc6697
commit bc15d45173
17 changed files with 339 additions and 71 deletions

View File

@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\adity\.android\avd\Samsung_Z3_flip_API_34.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-08-31T15:38:52.039533500Z" />
<runningDeviceTargetsSelectedWithDialog>
<Target>
<type value="RUNNING_DEVICE_TARGET" />

View File

@@ -16,5 +16,7 @@ public class BlockApp extends AppCompatActivity {
}
@Override
public void onBackPressed() {}
public void onBackPressed() {
// super.onBackPressed();
}
}

View File

@@ -55,5 +55,8 @@ public class MySharedPref {
}
public void setArrayList(String key, Set<String> appList) {
prefsEditor.putStringSet(key, appList);
prefsEditor.apply();
}
}

View File

@@ -19,6 +19,7 @@ import androidx.annotation.RawRes;
import com.bumptech.glide.Glide;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.ssb.simplitend.R;
import com.ssb.simplitend.appblocking.MySharedPref;
import com.ssb.simplitend.databinding.DecisionBottomsheetBinding;
import com.ssb.simplitend.databinding.DoneBottomsheetBinding;
@@ -30,6 +31,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Set;
public abstract class AppUtil {
@@ -233,6 +235,16 @@ public abstract class AppUtil {
return sp.getBoolean(IS_PATIENT_LOGGED_IN, false);
}
public static void patientSignOut(Context context){
AppUtil.savePatientData(null, -1, context, false);
MySharedPref mySharedPref = new MySharedPref(context);
Set<String> appList = mySharedPref.getArrayList("APP_LIST");
if (appList != null) {
appList.clear();
mySharedPref.setArrayList("APP_LIST", appList);
}
}
public static void saveCgData(String token, int patient_id, Context context){
SharedPreferences sp = context.getSharedPreferences(CAREGIVER_DETAILS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();

View File

@@ -1,26 +1,152 @@
package com.ssb.simplitend.caregiverdashboard.activities;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.ssb.simplitend.R;
import com.ssb.simplitend.apputils.AppUtil;
import com.ssb.simplitend.apputils.CaregiverDataCache;
import com.ssb.simplitend.caregiverdashboard.mvvm.CaregiverMainViewModel;
import com.ssb.simplitend.caregiverdashboard.mvvm.CgHomeContracts;
import com.ssb.simplitend.databinding.CgChangePasswordFragmentBinding;
import com.ssb.simplitend.welcome.welcomecg.mvvm.CareGiverData;
public class CgChangePwdActivity extends AppCompatActivity {
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class CgChangePwdActivity extends AppCompatActivity implements CgHomeContracts.UpdateCgPasswordCallback {
private CgChangePasswordFragmentBinding binding;
private CaregiverMainViewModel viewModel;
private ProgressDialog progressDialog;
private CareGiverData careGiverData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = CgChangePasswordFragmentBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
viewModel = new ViewModelProvider(this).get(CaregiverMainViewModel.class);
progressDialog = new ProgressDialog(this);
// viewing old pwd view
binding.oldPwdTitle.setVisibility(View.VISIBLE);
binding.oldPwdView.setVisibility(View.VISIBLE);
binding.subTitle.setText(R.string.when_updating_a_password_it_s_essential_to_create_a_strong_unique_password);
initViews();
clickEvents();
CaregiverDataCache.getCaregiverData(this, (careGiverData1 -> {
this.careGiverData = careGiverData1;
}), true);
}
private void initViews() {
}
private void clickEvents() {
binding.resetPin.setOnClickListener(v -> {
if (careGiverData == null){
Toast.makeText(this, "Couldn't load data", Toast.LENGTH_SHORT).show();
return;
}
if (allOkay()){
AppUtil.closeKeyboard(this);
progressDialog.setTitle("Please wait...");
progressDialog.setMessage("while we update your password.");
progressDialog.setCancelable(false);
progressDialog.show();
try {
Map<String, RequestBody> body = new HashMap<>();
RequestBody new_password_body = RequestBody.create(Objects.requireNonNull(binding.password.getText()).toString(), MediaType.parse("text/plain"));
body.put("new_password", new_password_body);
RequestBody old_password_body = RequestBody.create(Objects.requireNonNull(binding.oldPassword.getText()).toString(), MediaType.parse("text/plain"));
body.put("old_password", old_password_body);
viewModel.updateCgPassword(careGiverData.caregiver_xid,
body, "Bearer " + AppUtil.getCgToken(this),
this);
}catch (Exception e){
Toast.makeText(this, "Please try again later.", Toast.LENGTH_SHORT).show();
}
}
});
}
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(this, "Password must be at least 8 characters.", Toast.LENGTH_SHORT).show();
} else if (password.contains(" ")) {
allOkay = false;
Toast.makeText(this, "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(this, "Password doesn't match the required criteria.", Toast.LENGTH_SHORT).show();
} else if (!binding.confirmPassword.getText().toString().equals(password)) {
allOkay = false;
Toast.makeText(this, "Confirm password doesn't match.", Toast.LENGTH_SHORT).show();
}
if (allOkay && binding.oldPassword.getText() != null){
String old_password = binding.oldPassword.getText().toString();
if (old_password.trim().isEmpty()){
allOkay = false;
Toast.makeText(this, "Old password cannot be empty.", Toast.LENGTH_SHORT).show();
}else if (old_password.equals(password)){
allOkay = false;
Toast.makeText(this, "New password cannot be same as old password.", Toast.LENGTH_SHORT).show();
}
}
}
return allOkay;
}
@Override
public void onPasswordUpdated(@NonNull CareGiverData patientData) {
progressDialog.dismiss();
Toast.makeText(this, "Password updated successfully.", Toast.LENGTH_SHORT).show();
finish();
}
@Override
public void onPasswordUpdateFailed(Throwable throwable, String message) {
progressDialog.dismiss();
AppUtil.showAlert(this,
getString(R.string.something_went_wrong),
message,
getString(R.string.ok),
((dialogInterface, i) -> {}),
null, null);
}
}

View File

@@ -74,4 +74,11 @@ public class CaregiverMainViewModel extends ViewModel {
cgHomeRepository.updatePatientAddress(pat_id, body, token, patientAddressCallback);
}
public void updateCgPassword(int cg_xid,
Map<String, RequestBody> body,
@NonNull String token,
@NonNull CgHomeContracts.UpdateCgPasswordCallback passwordCallback){
cgHomeRepository.updateCgPassword(cg_xid, body, token, passwordCallback);
}
}

View File

@@ -48,4 +48,9 @@ public interface CgDashboardApiService {
@Body Map<String, String> body,
@Header("Authorization") String token);
@Multipart
@POST("api/caregiver-password-update/{id}")
Call<CallResponse<CareGiverData>> updateCgPassword(@Path("id") int cg_xid,
@PartMap Map<String, RequestBody> body,
@Header("Authorization") String token);
}

View File

@@ -42,6 +42,11 @@ public interface CgHomeContracts {
void onPatientAddressUpdateFailed(Throwable throwable, String message);
}
interface UpdateCgPasswordCallback {
void onPasswordUpdated(@NonNull CareGiverData patientData);
void onPasswordUpdateFailed(Throwable throwable, String message);
}
}

View File

@@ -189,4 +189,33 @@ public class CgHomeRepository {
});
}
public void updateCgPassword(int cg_xid,
Map<String, RequestBody> body,
@NonNull String token,
@NonNull CgHomeContracts.UpdateCgPasswordCallback passwordCallback){
dash_apiService.updateCgPassword(cg_xid, body, token)
.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){
passwordCallback.onPasswordUpdateFailed(new Exception(), response.body().message);
return;
}
passwordCallback.onPasswordUpdated(response.body().result);
}else{
passwordCallback.onPasswordUpdateFailed(new Exception(), "Please try again later.");
}
}
@Override
public void onFailure(Call<CallResponse<CareGiverData>> call, Throwable t) {
passwordCallback.onPasswordUpdateFailed(new Exception(), "Please try again later.");
}
});
}
}

View File

@@ -108,7 +108,7 @@ public class PatientDashboardFragment extends Fragment {
// fake sign out
// TODO: 08-08-2023 remove this
AppUtil.savePatientData(null, -1, requireContext(), false);
AppUtil.patientSignOut(requireContext());
Intent intent = new Intent(requireActivity(), WelcomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

View File

@@ -146,11 +146,21 @@ public class RegisterCompleteFragment extends Fragment implements ProfileContrac
progressDialog.dismiss();
if (patientData.isCareGiverConnectedWithPatient == 1) {
gotoPatientDashBoard();
if (patientData.isCaregiverTakeSubscription == 1){
gotoPatientDashBoard();
}else{
AppUtil.showAlert(requireContext(),
"Ask Caregiver to Subscribe",
"Kindly ask CareGiver to complete SimpliTend subscription.",
"OK",
((dialogInterface, i) -> {
}), null, null);
}
} else {
AppUtil.showAlert(requireContext(),
"Ask Caregiver to register",
"Kindly ask CareGiver to complete registeration.",
"Kindly ask CareGiver to complete registration.",
"OK",
((dialogInterface, i) -> {

View File

@@ -6,8 +6,6 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -41,21 +39,29 @@ public class CgOnBoardFragment extends Fragment {
private void clickEvents() {
binding.nextBtn.setOnClickListener(v -> {
int current_item = binding.viewPager.getCurrentItem();
// binding.nextBtn.setOnClickListener(v -> {
// int current_item = binding.viewPager.getCurrentItem();
//
// if (current_item >= 0 && current_item < 2){
// binding.viewPager.setCurrentItem(current_item + 1, true);
// }
//
// });
//
// binding.getsStarted.setOnClickListener(v -> {
// Navigation.findNavController(v).navigate(R.id.action_cgOnBoardFragment_to_cgSignInFragment);
// });
//
// binding.skip.setOnClickListener(v -> {
// Navigation.findNavController(v).navigate(R.id.action_cgOnBoardFragment_to_cgSignInFragment);
// });
if (current_item >= 0 && current_item < 2){
binding.viewPager.setCurrentItem(current_item + 1, true);
}
});
binding.getsStarted.setOnClickListener(v -> {
binding.login.setOnClickListener(v -> {
Navigation.findNavController(v).navigate(R.id.action_cgOnBoardFragment_to_cgSignInFragment);
});
binding.skip.setOnClickListener(v -> {
Navigation.findNavController(v).navigate(R.id.action_cgOnBoardFragment_to_cgSignInFragment);
binding.registerBtn.setOnClickListener(v -> {
Navigation.findNavController(v).navigate(R.id.action_cgOnBoardFragment_to_cgHowToSetUpFragment);
});
}
@@ -75,15 +81,15 @@ public class CgOnBoardFragment extends Fragment {
public void onPageSelected(int position) {
super.onPageSelected(position);
if (position == 2){
binding.getsStarted.setVisibility(View.VISIBLE);
binding.nextBtn.setVisibility(View.GONE);
binding.skip.setVisibility(View.GONE);
}else {
binding.getsStarted.setVisibility(View.GONE);
binding.nextBtn.setVisibility(View.VISIBLE);
binding.skip.setVisibility(View.VISIBLE);
}
// if (position == 2){
// binding.getsStarted.setVisibility(View.VISIBLE);
// binding.nextBtn.setVisibility(View.GONE);
// binding.skip.setVisibility(View.GONE);
// }else {
// binding.getsStarted.setVisibility(View.GONE);
// binding.nextBtn.setVisibility(View.VISIBLE);
// binding.skip.setVisibility(View.VISIBLE);
// }
String title, subtitle;

View File

@@ -31,7 +31,8 @@ public class PatientData {
, isPatientReminderData
, isPatientRoutineData
, isPatientMedicalData
, isCareGiverConnectedWithPatient;
, isCareGiverConnectedWithPatient
, isCaregiverTakeSubscription;
public PatientData() {
}

View File

@@ -31,14 +31,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="25dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:fontFamily="@font/nunito_medium"
android:text="@string/change_your_password"
android:textAppearance="@style/TextAppearance.Material3.HeadlineLarge"
android:textSize="@dimen/_20ssp"
android:textColor="@color/black" />
<TextView
android:id="@+id/sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
@@ -46,7 +47,7 @@
android:layout_marginBottom="35dp"
android:fontFamily="@font/nunito_regular"
android:text="@string/for_your_security_please_change_the_temporary_password_to_a_new_password"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="@dimen/_16ssp"
android:textColor="@color/black" />
<TextView

View File

@@ -84,65 +84,110 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<RelativeLayout
<LinearLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginHorizontal="15dp"
android:layout_marginBottom="@dimen/_5sdp"
android:layout_marginBottom="@dimen/_10sdp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/next_btn"
android:layout_width="@dimen/_30sdp"
android:layout_height="@dimen/_30sdp"
<!-- <de.hdodenhof.circleimageview.CircleImageView-->
<!-- android:id="@+id/next_btn"-->
<!-- android:layout_width="@dimen/_30sdp"-->
<!-- android:layout_height="@dimen/_30sdp"-->
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_centerVertical="true"-->
android:src="@drawable/ic_next"
android:visibility="visible"
<!-- android:src="@drawable/ic_next"-->
<!-- android:visibility="visible"-->
app:civ_circle_background_color="@color/color_primary"
<!-- app:civ_circle_background_color="@color/color_primary"-->
<!-- />-->
<!-- <TextView-->
<!-- android:id="@+id/skip"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:fontFamily="@font/nunito_semibold"-->
<!-- android:text="@string/skip"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/_18ssp"-->
<!-- android:paddingVertical="@dimen/_10sdp"-->
<!-- />-->
<!-- <com.google.android.material.button.MaterialButton-->
<!-- android:id="@+id/gets_started"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:backgroundTint="@color/color_primary"-->
<!-- android:fontFamily="@font/nunito_regular"-->
<!-- android:paddingVertical="@dimen/_10sdp"-->
<!-- android:text="@string/get_started"-->
<!-- android:textAllCaps="false"-->
<!-- android:textAppearance="@style/TextAppearance.Material3.TitleMedium"-->
<!-- android:textColor="@color/white_bg"-->
<!-- android:visibility="gone"-->
<!-- app:cornerRadius="10dp" />-->
<TextView
android:id="@+id/register_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingVertical="@dimen/_10sdp"
android:background="@drawable/round_corners"
android:backgroundTint="@color/color_primary"
android:fontFamily="@font/nunito_regular"
android:gravity="center"
android:text="@string/register"
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="@dimen/_12ssp"
/>
<TextView
android:id="@+id/skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/login"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_centerVertical="true"
android:fontFamily="@font/nunito_semibold"
android:text="@string/skip"
android:paddingVertical="@dimen/_10sdp"
android:background="@drawable/login_btn_bg"
android:fontFamily="@font/nunito_regular"
android:gravity="center"
android:text="@string/login"
android:textAlignment="center"
android:textAllCaps="false"
android:textSize="@dimen/_12ssp"
android:textColor="@color/black"
android:textSize="@dimen/_18ssp"
android:layout_marginStart="-10dp"
android:paddingVertical="@dimen/_10sdp"
app:backgroundTint="#EEF5FC"/>
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/gets_started"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/color_primary"
android:fontFamily="@font/nunito_regular"
android:paddingVertical="@dimen/_10sdp"
android:text="@string/get_started"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.Material3.TitleMedium"
android:textColor="@color/white_bg"
android:visibility="gone"
app:cornerRadius="10dp" />
</RelativeLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -246,6 +246,9 @@
<action
android:id="@+id/action_cgOnBoardFragment_to_cgSignInFragment"
app:destination="@id/cgSignInFragment" />
<action
android:id="@+id/action_cgOnBoardFragment_to_cgHowToSetUpFragment"
app:destination="@id/cgHowToSetUpFragment" />
</fragment>
<fragment
android:id="@+id/cgHowToSetUpFragment"

View File

@@ -391,5 +391,6 @@
<string name="reset">Reset</string>
<string name="update">Update</string>
<string name="patients_home_address">Patients Home Address</string>
<string name="when_updating_a_password_it_s_essential_to_create_a_strong_unique_password">When updating a password, it\'s essential to create a strong, unique password.</string>
</resources>