Commit 6cd9fbc3 authored by Ishankha K.C's avatar Ishankha K.C

Merge branch 'feature/chamod_dev' into 'master'

Feature/chamod dev

See merge request !2
parents 5619cc28 52101e08
......@@ -3,20 +3,7 @@
<component name="deploymentTargetDropDown">
<value>
<entry key="app">
<State>
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="adb-AYAV6R3925006878-kh1m4J._adb-tls-connect._tcp" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-05-18T11:27:38.975164100Z" />
</State>
<State />
</entry>
</value>
</component>
......
......@@ -5,7 +5,7 @@
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="gradleJvm" value="jbr-17" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
......
......@@ -2,7 +2,7 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,retrofit2.Response,errorBody" />
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,retrofit2.Response,errorBody|body" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -43,6 +43,10 @@ dependencies {
implementation(libs.retrofit2)
implementation(libs.convertor.gson)
implementation(libs.jackson.databind)
implementation(libs.ucrop)
implementation(libs.swiperefreshlayout)
implementation(libs.converter.jackson)
implementation(libs.jackson.datatype.jsr310)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
......
......@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<application
android:allowBackup="true"
......@@ -16,6 +17,13 @@
android:supportsRtl="true"
android:theme="@style/Theme.BabyCare"
tools:targetApi="31">
<activity
android:name=".activities.BabyDashboardActivity"
android:exported="false" />
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="fullSensor"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<activity
android:name=".activities.UserProfileActivity"
android:exported="false" />
......
......@@ -7,26 +7,15 @@ import android.content.Intent;
import android.os.Bundle;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.kaluwa.enterprises.babycare.activities.DashboardActivity;
import com.kaluwa.enterprises.babycare.activities.auth.LoginActivity;
import com.kaluwa.enterprises.babycare.config.TokenSaver;
import com.kaluwa.enterprises.babycare.databinding.ActivityMainBinding;
import com.kaluwa.enterprises.babycare.dto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.Toast;
......
......@@ -9,6 +9,7 @@ import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
......@@ -22,6 +23,8 @@ import com.kaluwa.enterprises.babycare.activities.auth.LoginActivity;
public class DashboardActivity extends AppCompatActivity {
LinearLayout btn1, btn2, btn3, btn4, btn5, btn6;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -29,6 +32,33 @@ public class DashboardActivity extends AppCompatActivity {
// define actionbar
defineActionbar();
btn1 = findViewById(R.id.btn_camera);
btn2 = findViewById(R.id.btn_vocal);
btn3 = findViewById(R.id.btn_notifications);
btn4 = findViewById(R.id.btn_device_controls);
btn5 = findViewById(R.id.btn_about_baby);
btn6 = findViewById(R.id.btn_settings);
btn1.setOnClickListener(v -> {
});
btn2.setOnClickListener(v -> {
});
btn3.setOnClickListener(v -> {
});
btn4.setOnClickListener(v -> {
});
btn5.setOnClickListener(v -> {
Intent intent = new Intent(this, BabyDashboardActivity.class);
startActivity(intent);
});
btn6.setOnClickListener(v -> {
});
}
private void defineActionbar() {
......
package com.kaluwa.enterprises.babycare.activities.auth;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.setToken;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger;
import static com.kaluwa.enterprises.babycare.utils.Utils.emailAddressValidation;
......@@ -16,29 +15,19 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.ybq.android.spinkit.SpinKitView;
import com.google.gson.Gson;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.activities.DashboardActivity;
import com.kaluwa.enterprises.babycare.activities.UserProfileActivity;
import com.kaluwa.enterprises.babycare.config.ApiConfig;
import com.kaluwa.enterprises.babycare.dto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.LoginRequest;
import com.kaluwa.enterprises.babycare.dto.UserDto;
import com.kaluwa.enterprises.babycare.error.ErrorDto;
import com.kaluwa.enterprises.babycare.service.AuthApiService;
import java.io.IOException;
import java.util.Objects;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......
package com.kaluwa.enterprises.babycare.adapter;
import static com.kaluwa.enterprises.babycare.utils.Utils.babyAgeCalculate;
import static com.kaluwa.enterprises.babycare.utils.Utils.calculateAge;
import static com.kaluwa.enterprises.babycare.utils.Utils.convertByteArrayToBitmap;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.imageview.ShapeableImageView;
import com.kaluwa.enterprises.babycare.R;
import com.kaluwa.enterprises.babycare.activities.UserProfileActivity;
import com.kaluwa.enterprises.babycare.dialogs.EditBabyDialog;
import com.kaluwa.enterprises.babycare.dto.BabyDto;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.List;
public class BabyDashboardAdapter extends RecyclerView.Adapter<BabyDashboardAdapter.BabyDashboardItemHolder> {
private final static String TAG = "BabyDashboardAdapter";
private Context context;
private List<BabyDto> babyList;
public BabyDashboardAdapter(Context context, List<BabyDto> babyList) {
this.context = context;
this.babyList = babyList;
}
@NonNull
@Override
public BabyDashboardAdapter.BabyDashboardItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.baby_rv_item, parent, false);
return new BabyDashboardAdapter.BabyDashboardItemHolder(view);
}
@SuppressLint("SetTextI18n")
@Override
public void onBindViewHolder(@NonNull BabyDashboardAdapter.BabyDashboardItemHolder holder, int position) {
BabyDto babyDto = babyList.get(position);
String firstname = babyDto.getFirstName();
String lastname = babyDto.getLastName();
LocalDate dob = babyDto.getDob();
String sex = babyDto.getSex();
String notes = babyDto.getNotes();
Boolean isActive = babyDto.getIsActive();
InputStream imageData = babyDto.getImageData();
if (lastname != null) {
holder.tvBabyName.setText(firstname + " " + lastname);
} else {
holder.tvBabyName.setText(firstname);
}
String age = babyAgeCalculate(dob);
holder.tvBabyAge.setText(age != null ? age : "Not Available");
holder.tvBabySex.setText(sex);
if (!TextUtils.isEmpty(notes)) {
holder.tvBabyDDespContent.setText(notes);
} else {
holder.tvBabyDDespTitle.setText("Status >");
holder.tvBabyDDespContent.setTextColor(isActive ? context.getResources().getColor(R.color.success_green) : context.getResources().getColor(R.color.cancel_red));
holder.tvBabyDDespContent.setText(isActive ? "Active" : "Inactive");
}
if (imageData != null) {
try {
Bitmap bitmap = convertByteArrayToBitmap(imageData);
holder.ivBabyImage.setImageBitmap(bitmap);
} catch (Exception e) {
Log.e(TAG, "Error occurred: " + e.getMessage());
Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
// Handle item click
holder.clBabyItem.setOnClickListener(v -> {
// Open the EditBabyDialog with the selected BabyDto
EditBabyDialog editBabyDialog = new EditBabyDialog(babyDto);
// Assuming context is an activity, cast it to FragmentActivity to get supportFragmentManager
editBabyDialog.show(((FragmentActivity) context).getSupportFragmentManager(), "EDIT_BABY_DIALOG");
});
}
@Override
public int getItemCount() {
return babyList.size();
}
public static class BabyDashboardItemHolder extends RecyclerView.ViewHolder {
public ConstraintLayout clBabyItem;
public TextView tvBabyName, tvBabyAge, tvBabySex, tvBabyDDespTitle, tvBabyDDespContent;
public ShapeableImageView ivBabyImage;
public BabyDashboardItemHolder(@NonNull View view) {
super(view);
clBabyItem = view.findViewById(R.id.baby_item);
tvBabyName = view.findViewById(R.id.baby_item_name);
tvBabyAge = view.findViewById(R.id.baby_item_tv_age_content);
tvBabySex = view.findViewById(R.id.baby_item_tv_sex_content);
tvBabyDDespTitle = view.findViewById(R.id.baby_item_tv_desp_title);
tvBabyDDespContent = view.findViewById(R.id.baby_item_tv_desp_content);
ivBabyImage = view.findViewById(R.id.baby_item_iv_image);
}
}
}
......@@ -2,13 +2,18 @@ package com.kaluwa.enterprises.babycare.config;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.kaluwa.enterprises.babycare.service.AuthApiService;
import com.kaluwa.enterprises.babycare.service.BabyApiService;
import com.kaluwa.enterprises.babycare.service.UserApiService;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;
public class ApiConfig {
private static final String BASE_URL = "http://192.168.1.2:8080/api/v1/baby-care/";
......@@ -19,9 +24,14 @@ public class ApiConfig {
private ApiConfig() {
OkHttpClient authHttpClient = new OkHttpClient.Builder().build();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
retrofitAuth = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(JacksonConverterFactory.create(mapper))
.client(authHttpClient)
.build();
......@@ -36,7 +46,7 @@ public class ApiConfig {
.build();
retrofitOther = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addConverterFactory(JacksonConverterFactory.create(mapper))
.client(otherHttpClient)
.build();
}
......@@ -56,4 +66,9 @@ public class ApiConfig {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(UserApiService.class);
}
public BabyApiService getBabyApi(String JWTToken) {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(BabyApiService.class);
}
}
......@@ -5,7 +5,7 @@ import android.content.SharedPreferences;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kaluwa.enterprises.babycare.dto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
public class TokenSaver {
private final static String SHARED_PREF_NAME = "net.kaluwa.SHARED_PREF_NAME";
......
package com.kaluwa.enterprises.babycare.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.InputStream;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BabyDto {
private Long babyId;
private String firstName;
private String lastName;
private LocalDate dob;
private String sex;
private String status;
private Boolean isActive;
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 LocalDate firstSmileDate;
private LocalDate firstToothDate;
private LocalDate firstWordDate;
private LocalDate 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 Long documentId;
@JsonIgnore
private InputStream imageData;
@JsonIgnore
private boolean sys_validated;
}
package com.kaluwa.enterprises.babycare.dto;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -15,4 +17,5 @@ public class UserDto {
private String phone;
private String role;
private String status;
private LocalDate dob;
}
\ No newline at end of file
package com.kaluwa.enterprises.babycare.dto;
package com.kaluwa.enterprises.babycare.dto.responseDto;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package com.kaluwa.enterprises.babycare.dto.responseDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseDto {
private Long id;
private String message;
}
package com.kaluwa.enterprises.babycare.dto;
package com.kaluwa.enterprises.babycare.dto.responseDto;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.LoginRequest;
import com.kaluwa.enterprises.babycare.dto.RegisterRequest;
import com.kaluwa.enterprises.babycare.dto.UserDto;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.POST;
......
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.BabyDto;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface BabyApiService {
@GET("baby")
Call<List<BabyDto>> getAllBabies();
@POST("baby")
Call<BabyDto> addBaby(@Body BabyDto baby);
@PUT("baby/{babyId}")
Call<BabyDto> updateBaby(@Path("babyId") Long babyId, @Body BabyDto baby);
}
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.UserDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
public interface UserApiService {
......@@ -16,4 +21,11 @@ public interface UserApiService {
@PUT("user/{userId}")
Call<UserDto> updateUserById(@Path("userId") Long userId, @Body UserDto user);
@Multipart
@PUT("user/image/{userId}")
Call<ResponseDto> uploadUserImage(@Path("userId") Long userId, @Part MultipartBody.Part image);
@GET("user/image/{userId}")
Call<ResponseBody> getImage(@Path("userId") Long userId);
}
package com.kaluwa.enterprises.babycare.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import com.github.ybq.android.spinkit.SpinKitView;
import com.kaluwa.enterprises.babycare.R;
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;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class 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) {
overlay.setVisibility(View.VISIBLE);
......@@ -52,4 +73,170 @@ public class Utils {
}
}
public static void setUpDOBPicker(EditText editText, Context context) {
editText.setOnClickListener(v -> {
final Calendar calendar = Calendar.getInstance();
// Check if EditText is not empty and parse the date
if (!TextUtils.isEmpty(editText.getText().toString())) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
calendar.setTime(Objects.requireNonNull(sdf.parse(editText.getText().toString())));
} catch (ParseException e) {
e.printStackTrace();
}
}
int day = calendar.get(Calendar.DAY_OF_MONTH);
int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR);
// Calculate the date 18 years ago from today
Calendar maxDate = Calendar.getInstance();
maxDate.add(Calendar.YEAR, -18);
// Date Picker Dialog
DatePickerDialog datePicker = new DatePickerDialog(context, (view, selectedYear, selectedMonth, selectedDayOfMonth) -> {
editText.setText(selectedDayOfMonth + "/" + (selectedMonth + 1) + "/" + selectedYear);
}, year, month, day);
// Set the maximum date (18 years ago)
datePicker.getDatePicker().setMaxDate(maxDate.getTimeInMillis());
// Show the date picker
datePicker.show();
});
}
public static void setUpDatePicker(EditText editText, Context context) {
editText.setOnClickListener(v -> {
final Calendar calendar = Calendar.getInstance();
// Check if EditText is not empty and parse the date
if (!TextUtils.isEmpty(editText.getText().toString())) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
calendar.setTime(Objects.requireNonNull(sdf.parse(editText.getText().toString())));
} catch (ParseException e) {
e.printStackTrace();
}
}
int day = calendar.get(Calendar.DAY_OF_MONTH);
int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR);
// Date Picker Dialog
DatePickerDialog datePicker = new DatePickerDialog(context, (view, selectedYear, selectedMonth, selectedDayOfMonth) -> {
editText.setText(selectedDayOfMonth + "/" + (selectedMonth + 1) + "/" + selectedYear);
}, year, month, day);
// Show the date picker
datePicker.show();
});
}
@SuppressLint("NewApi")
public static LocalDate getLocalDate(Object dob) {
LocalDate localDate = null;
if (dob instanceof LocalDate) {
localDate = (LocalDate) dob;
} else if (dob instanceof List) {
// dob is a List, convert it to LocalDate
List dobList = (List) dob;
if (dobList.size() == 3) {
try {
int year = ((Double) dobList.get(0)).intValue();
int month = ((Double) dobList.get(1)).intValue();
int day = ((Double) dobList.get(2)).intValue();
localDate = LocalDate.of(year, month, day);
} catch (Exception e) {
e.printStackTrace();
}
} else {
Log.e(TAG, "Unsupported date format");
}
} else {
// Handle other unexpected types if necessary
Log.e(TAG, "Unsupported date format");
}
return localDate;
}
@SuppressLint("NewApi")
public static Double calculateAge(Object dobObj, String condition) {
LocalDate dob = getLocalDate(dobObj);
if (dob == null) {
Log.e(TAG, "Invalid date of birth");
return null;
}
LocalDate currentDate = LocalDate.now();
Period period = Period.between(dob, currentDate);
Double age = null;
if (condition.equalsIgnoreCase("byYears")) {
age = (double) period.getYears();
age = Math.round(age * 10.0) / 10.0;
} else if (condition.equalsIgnoreCase("byMonths")) {
age = period.getYears() * 12 + period.getMonths() + (period.getDays() / 30.0);
age = Math.round(age * 10.0) / 10.0;
} else {
Log.e(TAG, "Unsupported Condition");
}
return age;
}
@SuppressLint("NewApi")
public static String babyAgeCalculate(LocalDate dob) {
if (dob == null) {
Log.e(TAG, "Invalid date of birth");
return null;
}
LocalDate currentDate = LocalDate.now();
Period period = Period.between(dob, currentDate);
int totalMonths = period.getYears() * 12 + period.getMonths();
int totalDays = period.getDays();
if (totalMonths <= 12) {
return totalMonths + " months " + totalDays + " days";
} else {
int years = totalMonths / 12;
int remainingMonths = totalMonths % 12;
return years + " years " + remainingMonths + " months " + totalDays + " days";
}
}
public static Bitmap convertByteArrayToBitmap(InputStream stream) {
try {
return BitmapFactory.decodeStream(stream);
} catch (Exception e) {
Log.e(TAG, "Error decoding image byte array: " + e.getMessage());
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("[yyyy-MM-dd]");
return builder.toFormatter(Locale.ENGLISH);
}
}
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="300"
android:fromAlpha="0.0"
android:toAlpha="1.0"/>
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:duration="300"
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
<?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
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.BabyDashboardActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/appbar"/>
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/b_care_action_bar"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/background"
android:contentDescription="background-image"
android:scaleType="centerCrop"
android:alpha="0.4"/>
<RelativeLayout
android:id="@+id/rl_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rl_background"
android:backgroundTint="#62178F"
app:layout_constraintTop_toTopOf="@+id/background"
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
android:padding="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Baby Dash"
android:textAlignment="center"
android:textColor="@color/white"
android:textAllCaps="true"
android:fontFamily="@font/inknut_antiqua_regular"
android:textSize="20sp"
android:gravity="center"/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/baby_dash_rv"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/rl_header"
app:layout_constraintBottom_toBottomOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
app:layout_constraintStart_toStartOf="@id/background"
android:scrollbars="none"
android:paddingTop="6dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingBottom="6dp"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_baby_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:contentDescription="add_own_baby_details"
android:src="@drawable/ic_add_32"
app:backgroundTint="@color/purple"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:maxImageSize="38dp"/>
<TextView
android:id="@+id/no_content_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No content available"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textStyle="bold"
android:visibility="gone"/>
<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>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
......@@ -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"/>
......
......@@ -32,15 +32,17 @@
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintTop_toTopOf="@+id/background">
<ImageView
android:id="@+id/forground_img"
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/up_iv_profile_image"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:contentDescription="foreground-image"
android:src="@drawable/icon_alt_user_pic_32" />
android:contentDescription="user-profile-image"
android:src="@drawable/icon_alt_user_pic_32"
app:shapeAppearanceOverlay="@style/RoundImage"
android:scaleType="centerCrop"/>
</RelativeLayout>
......@@ -66,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"
......@@ -140,11 +142,13 @@
android:id="@+id/up_et_dob"
android:layout_width="match_parent"
android:layout_height="45dp"
android:inputType="text"
android:inputType="date"
android:background="@drawable/et_background"
android:padding="8dp"
android:fontFamily="@font/acme_regular"
android:textColor="@color/purple"/>
android:textColor="@color/purple"
android:hint="Select your Date of birth (dd/mm/yyyy)*"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
......@@ -176,13 +180,26 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/inknut_antiqua_regular"
android:text="Email Address"
android:textColor="@color/black"
android:textSize="15sp" />
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inknut_antiqua_regular"
android:text="Email Address"
android:textColor="@color/black"
android:textSize="15sp" />
<ImageView
android:id="@+id/up_im_email_verification_status"
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:contentDescription="Email Verification Status" />
</LinearLayout>
<EditText
android:id="@+id/up_et_email"
......
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="20dp"
app:cardElevation="8dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/baby_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp"
android:background="@color/white">
<TextView
android:id="@+id/baby_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Baby's Name"
android:fontFamily="@font/jeju_gothic_regular"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="@+id/title_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/baby_item_name">
<TextView
android:id="@+id/baby_item_tv_age_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/acme_regular"
android:text="Age >"
android:textSize="16sp" />
<TextView
android:id="@+id/baby_item_tv_sex_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/acme_regular"
android:text="Sex >"
android:textSize="16sp" />
<TextView
android:id="@+id/baby_item_tv_desp_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/acme_regular"
android:text="Description >"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/content_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="4dp"
android:orientation="vertical"
app:layout_constraintEnd_toStartOf="@+id/baby_item_iv_image"
app:layout_constraintStart_toEndOf="@+id/title_box"
app:layout_constraintTop_toBottomOf="@id/baby_item_name">
<TextView
android:id="@+id/baby_item_tv_age_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/acme_regular"
android:text="Value"
android:textColor="@color/purple"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/baby_item_tv_sex_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/acme_regular"
android:text="Value"
android:textColor="@color/purple"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/baby_item_tv_desp_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:fontFamily="@font/acme_regular"
android:maxLines="2"
android:text="Value"
android:textColor="@color/purple"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/baby_item_iv_image"
android:layout_width="120dp"
android:layout_height="120dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/foreground"
app:shapeAppearanceOverlay="@style/RoundImage"
android:scaleType="centerCrop"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
This diff is collapsed.
<?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
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RoundImage" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<style name="CustomDialogAnimation">
<!-- Define your custom enter animation here -->
<item name="android:windowEnterAnimation">@anim/fade_in</item>
<!-- You can add more animations like scale, translate, etc. -->
</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
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RoundImage" parent="ShapeAppearance.MaterialComponents.SmallComponent">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
<style name="CustomDialogAnimation">
<!-- Define your custom enter animation here -->
<item name="android:windowEnterAnimation">@anim/fade_in</item>
<!-- You can add more animations like scale, translate, etc. -->
</style>
</resources>
\ No newline at end of file
......@@ -2,5 +2,6 @@
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">192.168.1.2</domain>
<domain includeSubdomains="true">192.168.1.6</domain>
</domain-config>
</network-security-config>
......@@ -4,32 +4,38 @@ junit = "4.13.2"
junitVersion = "1.1.5"
espressoCore = "3.5.1"
appcompat = "1.6.1"
material = "1.12.0"
constraintlayout = "2.1.4"
navigationFragment = "2.7.7"
navigationUi = "2.7.7"
activity = "1.9.0"
androidSpinkit = "1.4.0"
projectLombok = "1.18.32"
retrofit2 = "2.9.0"
retrofit2Convertor = "2.9.0"
retrofit2 = "2.11.0"
jacksonDatabind = "2.17.1"
materialVersion = "1.13.0-alpha02"
swiperefreshlayout = "1.2.0-alpha01"
converterJackson = "2.11.0"
jacksonDatatypeJsr310 = "2.17.1"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment", version.ref = "navigationFragment" }
navigation-ui = { group = "androidx.navigation", name = "navigation-ui", version.ref = "navigationUi" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
android-spinkit = { group = "com.github.ybq", name = "Android-SpinKit", version.ref = "androidSpinkit" }
projectlombok = { group = "org.projectlombok", name = "lombok", version.ref = "projectLombok"}
retrofit2 = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit2" }
convertor-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit2Convertor" }
retrofit2 = { group = "com.squareup.retrofit2", name = "retrofit", version = "2.11.0" }
convertor-gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "retrofit2" }
jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jacksonDatabind" }
ucrop = { group = "com.github.yalantis", name = "ucrop", version = "2.2.9" }
swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefreshlayout", version.ref = "swiperefreshlayout" }
converter-jackson = { group = "com.squareup.retrofit2", name = "converter-jackson", version.ref = "converterJackson" }
jackson-datatype-jsr310 = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-jsr310", version.ref = "jacksonDatatypeJsr310" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
......
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