Commit 644d4077 authored by Chamod Ishankha's avatar Chamod Ishankha

add baby dialog

parent 2858c3fb
......@@ -3,8 +3,11 @@ package com.kaluwa.enterprises.babycare.activities;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger;
import static com.kaluwa.enterprises.babycare.utils.Utils.loader;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
......@@ -13,17 +16,14 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
......@@ -35,6 +35,7 @@ import com.kaluwa.enterprises.babycare.MainActivity;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.adapter.BabyDashboardAdapter;
import com.kaluwa.enterprises.babycare.config.ApiConfig;
import com.kaluwa.enterprises.babycare.dialogs.AddBabyDialog;
import com.kaluwa.enterprises.babycare.dto.BabyDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.service.BabyApiService;
......@@ -44,7 +45,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
public class BabyDashboardActivity extends AppCompatActivity {
public class BabyDashboardActivity extends AppCompatActivity implements AddBabyDialog.BabyDialogInterface {
private final static String TAG = "BabyDashboardActivity";
private SwipeRefreshLayout swipeContainer;
......@@ -85,16 +86,16 @@ public class BabyDashboardActivity extends AppCompatActivity {
baby1.setFirstName("Chamod");
baby1.setLastName("Ishankha");
baby1.setDob(LocalDate.parse("2000/07/23", DateTimeFormatter.ofPattern("yyyy/MM/dd")));
baby1.setGender("Male");
baby1.setSex("Male");
baby1.setActive(true);
BabyDto baby2 = new BabyDto();
baby2.setFirstName("Yohani");
baby2.setLastName("Madusha");
baby2.setDob(LocalDate.parse("2000/11/01", DateTimeFormatter.ofPattern("yyyy/MM/dd")));
baby2.setGender("Female");
baby2.setSex("Female");
baby2.setActive(false);
baby2.setDescription("My little cute daughter, Love you my darling.");
baby2.setNotes("My little cute daughter, Love you my darling.");
babyDtoList.add(baby1);
babyDtoList.add(baby2);
......@@ -105,6 +106,15 @@ public class BabyDashboardActivity extends AppCompatActivity {
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
// add button enable
floatingAddButton.setOnClickListener(v -> {
openAddBabyDialog();
});
}
private void openAddBabyDialog() {
AddBabyDialog addbabyDialog = new AddBabyDialog();
addbabyDialog.show(getSupportFragmentManager(), "ADD_BABY_DIALOG");
}
......@@ -179,4 +189,19 @@ public class BabyDashboardActivity extends AppCompatActivity {
super.onBackPressed();
animationChanger(this);
}
@Override
public void parseValues(BabyDto dto, AlertDialog dialog, View overlay, SpinKitView progressbar) {
dto.setUserId(authDto.getUserId());
Button positiveBtn = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
Button negativeBtn = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
loader(overlay, progressbar, true);
positiveBtn.setEnabled(false);
negativeBtn.setEnabled(false);
// TODO
// make api caller
// make photo selector
// make dropdowns
}
}
\ No newline at end of file
package com.kaluwa.enterprises.babycare.activities;
import static com.kaluwa.enterprises.babycare.utils.Utils.DATE_FORMAT;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger;
import static com.kaluwa.enterprises.babycare.utils.Utils.convertByteArrayToBitmap;
import static com.kaluwa.enterprises.babycare.utils.Utils.disableEditText;
import static com.kaluwa.enterprises.babycare.utils.Utils.getDateTimeFormatter;
import static com.kaluwa.enterprises.babycare.utils.Utils.loader;
import static com.kaluwa.enterprises.babycare.utils.Utils.mobileNumberValidation;
import static com.kaluwa.enterprises.babycare.utils.Utils.setUpDOBPicker;
......@@ -24,7 +24,6 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
......@@ -44,8 +43,8 @@ import com.google.gson.Gson;
import com.kaluwa.enterprises.babycare.MainActivity;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.config.ApiConfig;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.UserDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto;
import com.kaluwa.enterprises.babycare.error.ErrorDto;
import com.kaluwa.enterprises.babycare.service.UserApiService;
......@@ -56,7 +55,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -81,6 +79,7 @@ public class UserProfileActivity extends AppCompatActivity {
private AuthenticationDto authDto;
private ActivityResultLauncher<Intent> pickImageLauncher;
private ActivityResultLauncher<Intent> cropImageLauncher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -93,7 +92,7 @@ public class UserProfileActivity extends AppCompatActivity {
try {
authDto = getToken(getApplicationContext());
} catch (JsonProcessingException e) {
Log.e(TAG, "Error: "+e.getMessage());
Log.e(TAG, "Error: " + e.getMessage());
Toast.makeText(this, "Error getting token, Please refresh", Toast.LENGTH_SHORT).show();
}
userApiService = ApiConfig.getInstance().getUserApi(authDto.getTokenDto().getToken());
......@@ -186,7 +185,7 @@ public class UserProfileActivity extends AppCompatActivity {
} else if (result.getResultCode() == UCrop.RESULT_ERROR) {
final Throwable cropError = UCrop.getError(result.getData());
// Handle the error
Toast.makeText(this, "Something went wrong: "+cropError.getMessage(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Something went wrong: " + cropError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
......@@ -228,7 +227,7 @@ public class UserProfileActivity extends AppCompatActivity {
Toast.makeText(UserProfileActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: "+e.getMessage());
Log.e(TAG, "else-error: " + e.getMessage());
Toast.makeText(UserProfileActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressBar, false);
......@@ -278,7 +277,7 @@ public class UserProfileActivity extends AppCompatActivity {
Toast.makeText(UserProfileActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: "+e.getMessage());
Log.e(TAG, "else-error: " + e.getMessage());
Toast.makeText(UserProfileActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressBar, false);
......@@ -343,7 +342,7 @@ public class UserProfileActivity extends AppCompatActivity {
Toast.makeText(UserProfileActivity.this, "An unexpected error occurred", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e(TAG, "else-error: "+e.getMessage());
Log.e(TAG, "else-error: " + e.getMessage());
Toast.makeText(UserProfileActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
loader(overlay, progressBar, false);
......@@ -385,7 +384,7 @@ public class UserProfileActivity extends AppCompatActivity {
userDto.setLastName(lastName);
userDto.setPhone(mobileNumber);
if (!TextUtils.isEmpty(etDob.getText().toString())) {
LocalDate dob = LocalDate.parse(etDob.getText().toString(), DateTimeFormatter.ofPattern(DATE_FORMAT));
LocalDate dob = LocalDate.parse(etDob.getText().toString(), getDateTimeFormatter());
userDto.setDob(dob.toString());
}
}
......@@ -404,14 +403,14 @@ public class UserProfileActivity extends AppCompatActivity {
UserDto user = response.body();
etFirstName.setText(user.getFirstName());
etLastName.setText(user.getLastName());
etType.setText(!Objects.equals(user.getRole(), "USER") ? user.getRole():"PARENT");
etType.setText(!Objects.equals(user.getRole(), "USER") ? user.getRole() : "PARENT");
etEmail.setText(user.getEmail());
ivVerifiedStatus.setImageDrawable(user.getStatus().equals("NEW")?getDrawable(R.drawable.ico_unverified) : getDrawable(R.drawable.ico_verified));
ivVerifiedStatus.setImageDrawable(user.getStatus().equals("NEW") ? getDrawable(R.drawable.ico_unverified) : getDrawable(R.drawable.ico_verified));
etMobile.setText(user.getPhone());
if (user.getDob() != null) {
LocalDate localDate = Utils.getLocalDate(user.getDob());
if (localDate != null) {
etDob.setText(localDate.format(DateTimeFormatter.ofPattern(DATE_FORMAT)));
etDob.setText(localDate.format(getDateTimeFormatter()));
}
}
loader(overlay, progressBar, false);
......
......@@ -52,9 +52,9 @@ public class BabyDashboardAdapter extends RecyclerView.Adapter<BabyDashboardAdap
holder.tvBabyName.setText(babyDto.getFirstName() + " " + babyDto.getLastName());
Double age = calculateAge(babyDto.getDob(), "byMonths");
holder.tvBabyAge.setText(age != null ? age + " months" : "Not Available");
holder.tvBabySex.setText(babyDto.getGender());
if (!TextUtils.isEmpty(babyDto.getDescription())) {
holder.tvBabyDDespContent.setText(babyDto.getDescription());
holder.tvBabySex.setText(babyDto.getSex());
if (!TextUtils.isEmpty(babyDto.getNotes())) {
holder.tvBabyDDespContent.setText(babyDto.getNotes());
} else {
holder.tvBabyDDespTitle.setText("Status >");
holder.tvBabyDDespContent.setTextColor(babyDto.isActive() ? context.getResources().getColor(R.color.success_green) : context.getResources().getColor(R.color.cancel_red));
......
package com.kaluwa.enterprises.babycare.dialogs;
import static com.kaluwa.enterprises.babycare.utils.Utils.dpToPx;
import static com.kaluwa.enterprises.babycare.utils.Utils.getDateTimeFormatter;
import static com.kaluwa.enterprises.babycare.utils.Utils.setUpDatePicker;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.appcompat.widget.SwitchCompat;
import com.github.ybq.android.spinkit.SpinKitView;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.dto.BabyDto;
import java.time.LocalDate;
public class AddBabyDialog extends AppCompatDialogFragment {
BabyDialogInterface babyDialogInterface;
private EditText etFirstname, etLastname, dateDob, etSex, etWeight, etHeight, etBloodType, etEyeColor, etHairColor, etAllergies, etMediConditions, etMedication, etVaccinateRecs, etDocName, etDocContact, etHealthInsuranceInfo, dateFirstSmile, dateFirstTooth, dateFirstWord, dateFirstStep, etFavFoods, etDisFoods, etPEmergConName, etPEmergRelation, etPEmergConNumber, etSEmergConName, etSEmergRelation, etSEmergConNumber, etNotes;
private ImageButton ibPhoto;
private SwitchCompat switchStatus;
private View overlay;
private SpinKitView progressbar;
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.add_baby_view_layout, null);
builder
.setView(view)
.setNegativeButton("Cancel", (dialog, which) -> {
dialog.dismiss();
})
.setPositiveButton("Save", null);
TextView title = new TextView(getContext());
// You Can Customise your Title here
title.setText("Add Your Baby's Information");
title.setBackgroundColor(getResources().getColor(R.color.purple));
title.setPadding(10, 10, 10, 10);
title.setGravity(Gravity.CENTER);
title.setTextColor(Color.WHITE);
title.setTextSize(20);
builder.setCustomTitle(title);
// find views by id
findViews(view);
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
// Set button colors after the dialog is shown
dialog.setOnShowListener(dialogInterface -> {
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setTextColor(getResources().getColor(R.color.success_green));
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(getResources().getColor(R.color.line_outline));
positiveButton.setOnClickListener(v -> {
applyBabyDto(dialog);
});
// Get the display metrics
DisplayMetrics displayMetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenHeight = displayMetrics.heightPixels;
// Convert 30dp to pixels
int margin = dpToPx(getContext(), 100);
// Calculate the available height
int availableHeight = screenHeight - (2 * margin);
// Set the dialog height
WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes();
layoutParams.height = availableHeight;
dialog.getWindow().setAttributes(layoutParams);
});
return dialog;
}
private void applyBabyDto(AlertDialog dialog) {
BabyDto babyDto = validateObjects();
if (babyDto.isSys_validated()) {
babyDialogInterface.parseValues(babyDto, dialog, overlay, progressbar);
}
}
@SuppressLint("NewApi")
private BabyDto validateObjects() {
BabyDto baby = new BabyDto();
baby.setSys_validated(false);
String firstname, lastname, dob, sex, weight, height, bType, eyeColor, hairColor, allergies, medicalConditions, medications, vaccinateRecs, docName, docContact, healthInsuInfo, firstSmile, firstTooth, firstWord, firstStep, favFoods, disFoods, pEmergeConName, pEmergeRelationship, pEmergeContact, sEmergeConName, sEmergeRelationship, sEmergeContact, notes;
firstname = etFirstname.getText().toString();
lastname = etLastname.getText().toString();
dob = dateDob.getText().toString();
sex = etSex.getText().toString();
weight = etWeight.getText().toString();
height = etHeight.getText().toString();
bType = etBloodType.getText().toString();
eyeColor = etEyeColor.getText().toString();
hairColor = etHairColor.getText().toString();
allergies = etAllergies.getText().toString();
medicalConditions = etMediConditions.getText().toString();
medications = etMedication.getText().toString();
vaccinateRecs = etVaccinateRecs.getText().toString();
docName = etDocName.getText().toString();
docContact = etDocContact.getText().toString();
healthInsuInfo = etHealthInsuranceInfo.getText().toString();
firstSmile = dateFirstSmile.getText().toString();
firstTooth = dateFirstTooth.getText().toString();
firstWord = dateFirstWord.getText().toString();
firstStep = dateFirstStep.getText().toString();
favFoods = etFavFoods.getText().toString();
disFoods = etDisFoods.getText().toString();
pEmergeConName = etPEmergConName.getText().toString();
pEmergeRelationship = etPEmergRelation.getText().toString();
pEmergeContact = etPEmergConNumber.getText().toString();
sEmergeConName = etSEmergConName.getText().toString();
sEmergeRelationship = etSEmergRelation.getText().toString();
sEmergeContact = etSEmergConNumber.getText().toString();
notes = etNotes.getText().toString();
if (TextUtils.isEmpty(firstname)) {
etFirstname.setError("First name is required.");
etFirstname.requestFocus();
} else if (TextUtils.isEmpty(dob)) {
dateDob.setError("Date of birth is required.");
dateDob.requestFocus();
} else if (TextUtils.isEmpty(sex)) {
etSex.setError("Gender is required.");
etSex.requestFocus();
} else {
baby.setFirstName(firstname);
baby.setLastName(lastname);
baby.setDob(LocalDate.parse(dob, getDateTimeFormatter()));
baby.setSex(sex);
baby.setPhotoData(null);
baby.setActive(switchStatus.isChecked());
if (!TextUtils.isEmpty(weight)) {
baby.setWeight(Float.parseFloat(weight));
}
if (!TextUtils.isEmpty(height)) {
baby.setHeight(Float.parseFloat(height));
}
baby.setBloodType(bType);
baby.setEyeColor(eyeColor);
baby.setHairColor(hairColor);
baby.setAllergies(allergies);
baby.setMedicalConditions(medicalConditions);
baby.setMedications(medications);
baby.setVaccinateRecords(vaccinateRecs);
baby.setDocName(docName);
baby.setDocContactNumber(docContact);
baby.setHealthInsuranceInfo(healthInsuInfo);
if (!TextUtils.isEmpty(firstSmile)) {
baby.setFirstSmileDate(LocalDate.parse(firstSmile, getDateTimeFormatter()));
}
if (!TextUtils.isEmpty(firstTooth)) {
baby.setFirstToothDate(LocalDate.parse(firstTooth, getDateTimeFormatter()));
}
if (!TextUtils.isEmpty(firstWord)) {
baby.setFirstWordDate(LocalDate.parse(firstWord, getDateTimeFormatter()));
}
if (!TextUtils.isEmpty(firstStep)) {
baby.setFirstStepDate(LocalDate.parse(firstStep, getDateTimeFormatter()));
}
baby.setFavFoods(favFoods);
baby.setFoodsDislikes(disFoods);
baby.setPrimaryEmergencyContactName(pEmergeConName);
baby.setPrimaryEmergencyRelationship(pEmergeRelationship);
baby.setPrimaryEmergencyContactNumber(pEmergeContact);
baby.setSecondaryEmergencyContactName(sEmergeConName);
baby.setSecondaryEmergencyRelationship(sEmergeRelationship);
baby.setSecondaryEmergencyContactNumber(sEmergeContact);
baby.setNotes(notes);
baby.setSys_validated(true);
}
return baby;
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
babyDialogInterface = (BabyDialogInterface) context;
}
private void findViews(View view) {
etFirstname = view.findViewById(R.id.abv_et_first_name);
etLastname = view.findViewById(R.id.abv_et_last_name);
dateDob = view.findViewById(R.id.abv_et_dob);
etSex = view.findViewById(R.id.abv_et_sex);
etWeight = view.findViewById(R.id.abv_et_weight);
etHeight = view.findViewById(R.id.abv_et_height);
etBloodType = view.findViewById(R.id.abv_dd_blood_type);
etEyeColor = view.findViewById(R.id.abv_et_eye_colour);
etHairColor = view.findViewById(R.id.abv_et_hair_colour);
etAllergies = view.findViewById(R.id.abv_et_allergies);
etMediConditions = view.findViewById(R.id.abv_et_medical_conditions);
etMedication = view.findViewById(R.id.abv_et_medications);
etVaccinateRecs = view.findViewById(R.id.abv_et_vaccination_recs);
etDocName = view.findViewById(R.id.abv_et_doc_name);
etDocContact = view.findViewById(R.id.abv_et_doc_contact);
etHealthInsuranceInfo = view.findViewById(R.id.abv_et_health_insurance_info);
dateFirstSmile = view.findViewById(R.id.abv_et_first_smile);
dateFirstTooth = view.findViewById(R.id.abv_et_first_tooth);
dateFirstWord = view.findViewById(R.id.abv_et_first_word);
dateFirstStep = view.findViewById(R.id.abv_et_first_step);
etFavFoods = view.findViewById(R.id.abv_et_favourite_foods);
etDisFoods = view.findViewById(R.id.abv_et_food_dislikes);
etPEmergConName = view.findViewById(R.id.abv_et_p_emergency_con_name);
etPEmergRelation = view.findViewById(R.id.abv_et_p_emergency_relationship);
etPEmergConNumber = view.findViewById(R.id.abv_et_p_emergency_con_number);
etSEmergConName = view.findViewById(R.id.abv_et_s_emergency_con_name);
etSEmergRelation = view.findViewById(R.id.abv_et_s_emergency_relationship);
etSEmergConNumber = view.findViewById(R.id.abv_et_s_emergency_con_number);
etNotes = view.findViewById(R.id.abv_et_notes);
ibPhoto = view.findViewById(R.id.abv_ib_photo);
switchStatus = view.findViewById(R.id.abv_switch_status);
progressbar = view.findViewById(R.id.progress_bar);
overlay = view.findViewById(R.id.overlay);
setUpDatePicker(dateDob, getContext());
setUpDatePicker(dateFirstSmile, getContext());
setUpDatePicker(dateFirstTooth, getContext());
setUpDatePicker(dateFirstWord, getContext());
setUpDatePicker(dateFirstStep, getContext());
}
public interface BabyDialogInterface {
void parseValues(BabyDto dto, AlertDialog dialog, View overlay, SpinKitView progressbar);
}
}
......@@ -13,12 +13,39 @@ public class BabyDto {
private String firstName;
private String lastName;
private Object dob;
private String gender;
private String description;
private String sex;
private String status;
private boolean isActive;
private byte[] photoData;
private float weight;
private float height;
private String bloodType;
private String eyeColor;
private String hairColor;
private String allergies;
private String medicalConditions;
private String medications;
private String vaccinateRecords;
private String docName;
private String docContactNumber;
private String healthInsuranceInfo;
private Object firstSmileDate;
private Object firstToothDate;
private Object firstWordDate;
private Object firstStepDate;
private String favFoods;
private String foodsDislikes;
private String primaryEmergencyContactName;
private String primaryEmergencyRelationship;
private String primaryEmergencyContactNumber;
private String secondaryEmergencyContactName;
private String secondaryEmergencyRelationship;
private String secondaryEmergencyContactNumber;
private String notes;
private UserDto user;
private Long userId;
private InputStream imageData;
private boolean sys_validated;
}
......@@ -10,17 +10,17 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.github.ybq.android.spinkit.SpinKitView;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.activities.UserProfileActivity;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
......@@ -28,13 +28,11 @@ import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.ResponseBody;
public class Utils {
private static final String TAG = "Utils";
public static final String DATE_FORMAT = "dd/M/yyyy";
public static final int PICK_IMAGE_REQUEST = 1;
private static final String TAG = "Utils";
public static void loader(View overlay, SpinKitView spinKitView, boolean status) {
if (status) {
......@@ -199,4 +197,21 @@ public class Utils {
throw new RuntimeException("Error decoding image byte array");
}
}
public static int dpToPx(Context context, int dp) {
float density = context.getResources().getDisplayMetrics().density;
return Math.round(dp * density);
}
@SuppressLint("NewApi")
public static DateTimeFormatter getDateTimeFormatter() {
DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder()
.parseCaseInsensitive().parseLenient()
.appendPattern("[d/M/yyyy]")
.appendPattern("[dd MMM yyyy]")
.appendPattern("[dd/MM/yyyy]")
.appendPattern("[dd/M/yyyy]");
return builder.toFormatter(Locale.ENGLISH);
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/purple"/>
</shape>
</item>
</selector>
\ No newline at end of file
......@@ -77,7 +77,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:text="@string/email_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -102,7 +102,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password"
android:text="@string/password_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......
......@@ -77,7 +77,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="First Name"
android:text="@string/first_name_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -100,7 +100,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Last Name"
android:text="@string/last_name_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -123,7 +123,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mobile Number"
android:text="@string/mobile_number_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -146,7 +146,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Email"
android:text="@string/email_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -170,7 +170,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Password"
android:text="@string/password_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......@@ -195,7 +195,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Confirm Password"
android:text="@string/confirm_password_req"
android:textSize="15sp"
android:textColor="@color/black"
android:fontFamily="@font/adamina_regular"/>
......
......@@ -68,13 +68,13 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:fontFamily="@font/inknut_antiqua_regular"
android:textSize="20sp"
android:layout_marginTop="6dp"
android:fontFamily="@font/inknut_antiqua_regular"
android:text="Profile Details"
android:textAlignment="center"
android:textColor="@color/purple"
android:textStyle="bold"/>
android:textSize="20sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Basic Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/first_name_req"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_last_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/last_name_label"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_dob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/birth_date_req"
android:inputType="date"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:focusable="false" />
<EditText
android:id="@+id/abv_et_sex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/sex"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="Photo"
android:fontFamily="@font/kanit_regular"
android:paddingStart="5dp"
android:paddingEnd="2dp"
android:paddingTop="6dp"/>
<ImageButton
android:id="@+id/abv_ib_photo"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/ic_add_32"
android:contentDescription="baby_uploaded_photo"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/abv_switch_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enabled status"
android:layout_marginStart="15dp"
android:fontFamily="@font/kanit_regular"
android:textSize="16sp"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Physical Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_weight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Weight (kg)"
android:inputType="numberDecimal"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Height (feet)"
android:inputType="numberDecimal"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_dd_blood_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Blood type"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:contentDescription="dropdown"/>
<EditText
android:id="@+id/abv_et_eye_colour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Eye colour"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_hair_colour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hair colour"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Health Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_allergies"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Allergies"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_medical_conditions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Medical Conditions"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_medications"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Medications"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_vaccination_recs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Vaccination Records (rec1 / rec2 / rec3)"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_doc_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Doctor/Pediatrician Name"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_doc_contact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Doctor/Pediatrician Contact Information"
android:inputType="phone"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_health_insurance_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Health Insurance Information"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="3"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Development Milestones"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_first_smile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First smile"
android:inputType="date"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:focusable="false"/>
<EditText
android:id="@+id/abv_et_first_tooth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First tooth"
android:inputType="date"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:focusable="false"/>
<EditText
android:id="@+id/abv_et_first_word"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First word"
android:inputType="date"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:focusable="false"/>
<EditText
android:id="@+id/abv_et_first_step"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First step"
android:inputType="date"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"
android:focusable="false"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dietary Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_favourite_foods"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Favourite foods"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="3"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_food_dislikes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Food dislikes"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="3"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Emergency Contact Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_p_emergency_con_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Primary emergency contact name"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_p_emergency_relationship"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Primary emergency relationship"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_p_emergency_con_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Primary emergency contact phone number"
android:inputType="phone"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_s_emergency_con_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Secondary emergency contact name"
android:inputType="textPersonName"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
<EditText
android:id="@+id/abv_et_s_emergency_relationship"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Secondary emergency relationship"
android:inputType="text"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
<EditText
android:id="@+id/abv_et_s_emergency_con_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Secondary emergency contact phone number"
android:inputType="phone"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Additional Information"
android:textColor="@color/purple"
android:textStyle="bold"
android:fontFamily="@font/jeju_gothic_regular"
android:textSize="18sp"
android:paddingTop="12dp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dark_purple"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="4dp"
android:background="@drawable/borders"
android:padding="8dp">
<EditText
android:id="@+id/abv_et_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Notes"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="5"
android:textSize="16sp"
android:fontFamily="@font/kanit_regular" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:id="@+id/overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99D5C5DF"
android:visibility="gone"
android:clickable="true"
android:focusable="true"/>
<com.github.ybq.android.spinkit.SpinKitView
android:id="@+id/progress_bar"
style="@style/SpinKitView.Large.DoubleBounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:SpinKit_Color="@color/purple"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="first_name_req">First name<font color="#FF0000"> *</font></string>
<string name="email_req">Email<font color="#FF0000"> *</font></string>
<string name="password_req">Password<font color="#FF0000"> *</font></string>
<string name="last_name_req">Last name<font color="#FF0000"> *</font></string>
<string name="mobile_number_req">Mobile number<font color="#FF0000"> *</font></string>
<string name="confirm_password_req">Confirm password<font color="#FF0000"> *</font></string>
<string name="last_name_label">Last name</string>
<string name="birth_date_req">Birth date<font color="#FF0000"> *</font></string>
<string name="sex">Sex<font color="#FF0000"> *</font></string>
</resources>
\ No newline at end of file
......@@ -4,4 +4,14 @@
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<!-- Custom AlertDialog theme -->
<style name="CustomAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="buttonBarStyle">@style/CustomButtonBar</item>
</style>
<!-- Custom button bar style -->
<style name="CustomButtonBar" parent="Widget.AppCompat.ButtonBar.AlertDialog">
<item name="android:background">?attr/colorPrimary</item> <!-- Change this to your desired color -->
</style>
</resources>
\ No newline at end of file
......@@ -11,4 +11,13 @@
<string name="login"><u>Login</u></string>
<string name="edit_btn_value">Edit</string>
<string name="update_btn_value">Update</string>
<string name="first_name_req">First name<font color="#FF0000"> *</font></string>
<string name="email_req">Email<font color="#FF0000"> *</font></string>
<string name="password_req">Password<font color="#FF0000"> *</font></string>
<string name="last_name_req">Last name<font color="#FF0000"> *</font></string>
<string name="mobile_number_req">Mobile number<font color="#FF0000"> *</font></string>
<string name="confirm_password_req">Confirm password<font color="#FF0000"> *</font></string>
<string name="last_name_label">Last name</string>
<string name="birth_date_req">Birth date<font color="#FF0000"> *</font></string>
<string name="sex">Sex<font color="#FF0000"> *</font></string>
</resources>
\ No newline at end of file
......@@ -4,4 +4,14 @@
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<!-- Custom AlertDialog theme -->
<style name="CustomAlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="buttonBarStyle">@style/CustomButtonBar</item>
</style>
<!-- Custom button bar style -->
<style name="CustomButtonBar" parent="Widget.AppCompat.ButtonBar.AlertDialog">
<item name="android:background">?attr/colorPrimary</item> <!-- Change this to your desired color -->
</style>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment