Commit e6f88f4f authored by Ishankha K.C's avatar Ishankha K.C

Merge branch 'feature/chamod_dev' into 'master'

connect document management api

See merge request !3
parents 1c4c583c c6a05d88
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-09-03T20:20:16.727982200Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=D:\Softwares\toolbox\.android\.android\avd\Pixel_XL_API_29.avd" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
...@@ -2,6 +2,8 @@ package com.kaluwa.enterprises.babycare.activities; ...@@ -2,6 +2,8 @@ package com.kaluwa.enterprises.babycare.activities;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken; import static com.kaluwa.enterprises.babycare.config.TokenSaver.clearToken;
import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken; import static com.kaluwa.enterprises.babycare.config.TokenSaver.getToken;
import static com.kaluwa.enterprises.babycare.constants.DocumentTypes.IMAGE;
import static com.kaluwa.enterprises.babycare.constants.TableNames.USERS;
import static com.kaluwa.enterprises.babycare.utils.Utils.animationChanger; 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.convertByteArrayToBitmap;
import static com.kaluwa.enterprises.babycare.utils.Utils.disableEditText; import static com.kaluwa.enterprises.babycare.utils.Utils.disableEditText;
...@@ -47,6 +49,7 @@ import com.kaluwa.enterprises.babycare.dto.UserDto; ...@@ -47,6 +49,7 @@ import com.kaluwa.enterprises.babycare.dto.UserDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto; import com.kaluwa.enterprises.babycare.dto.responseDto.AuthenticationDto;
import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto; import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto;
import com.kaluwa.enterprises.babycare.error.ErrorDto; import com.kaluwa.enterprises.babycare.error.ErrorDto;
import com.kaluwa.enterprises.babycare.service.DocumentApiService;
import com.kaluwa.enterprises.babycare.service.UserApiService; import com.kaluwa.enterprises.babycare.service.UserApiService;
import com.kaluwa.enterprises.babycare.utils.Utils; import com.kaluwa.enterprises.babycare.utils.Utils;
import com.yalantis.ucrop.UCrop; import com.yalantis.ucrop.UCrop;
...@@ -76,6 +79,7 @@ public class UserProfileActivity extends AppCompatActivity { ...@@ -76,6 +79,7 @@ public class UserProfileActivity extends AppCompatActivity {
private SpinKitView progressBar; private SpinKitView progressBar;
private View overlay; private View overlay;
private UserApiService userApiService; private UserApiService userApiService;
private DocumentApiService documentApiService;
private AuthenticationDto authDto; private AuthenticationDto authDto;
private ActivityResultLauncher<Intent> pickImageLauncher; private ActivityResultLauncher<Intent> pickImageLauncher;
private ActivityResultLauncher<Intent> cropImageLauncher; private ActivityResultLauncher<Intent> cropImageLauncher;
...@@ -96,6 +100,7 @@ public class UserProfileActivity extends AppCompatActivity { ...@@ -96,6 +100,7 @@ public class UserProfileActivity extends AppCompatActivity {
Toast.makeText(this, "Error getting token, Please refresh", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Error getting token, Please refresh", Toast.LENGTH_SHORT).show();
} }
userApiService = ApiConfig.getInstance().getUserApi(authDto.getTokenDto().getToken()); userApiService = ApiConfig.getInstance().getUserApi(authDto.getTokenDto().getToken());
documentApiService = ApiConfig.getInstance().getDocumentApi(authDto.getTokenDto().getToken());
// progress // progress
progressBar = findViewById(R.id.progress_bar); progressBar = findViewById(R.id.progress_bar);
...@@ -204,7 +209,7 @@ public class UserProfileActivity extends AppCompatActivity { ...@@ -204,7 +209,7 @@ public class UserProfileActivity extends AppCompatActivity {
RequestBody requestFile = RequestBody.create(MediaType.parse("image/jpeg"), compressedData); RequestBody requestFile = RequestBody.create(MediaType.parse("image/jpeg"), compressedData);
MultipartBody.Part body = MultipartBody.Part.createFormData("image", "image.jpg", requestFile); MultipartBody.Part body = MultipartBody.Part.createFormData("image", "image.jpg", requestFile);
Call<ResponseDto> call = userApiService.uploadUserImage(authDto.getUserId(), body); Call<ResponseDto> call = documentApiService.uploadUserImage(IMAGE, USERS, authDto.getUniqKey(), body);
call.enqueue(new Callback<ResponseDto>() { call.enqueue(new Callback<ResponseDto>() {
@Override @Override
public void onResponse(Call<ResponseDto> call, Response<ResponseDto> response) { public void onResponse(Call<ResponseDto> call, Response<ResponseDto> response) {
...@@ -243,7 +248,7 @@ public class UserProfileActivity extends AppCompatActivity { ...@@ -243,7 +248,7 @@ public class UserProfileActivity extends AppCompatActivity {
} }
private void loadUserProfileImage() { private void loadUserProfileImage() {
Call<ResponseBody> call = userApiService.getImage(authDto.getUserId()); Call<ResponseBody> call = documentApiService.getImage(USERS, authDto.getUniqKey());
call.enqueue(new Callback<ResponseBody>() { call.enqueue(new Callback<ResponseBody>() {
@Override @Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
......
...@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; ...@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.kaluwa.enterprises.babycare.service.AuthApiService; import com.kaluwa.enterprises.babycare.service.AuthApiService;
import com.kaluwa.enterprises.babycare.service.BabyApiService; import com.kaluwa.enterprises.babycare.service.BabyApiService;
import com.kaluwa.enterprises.babycare.service.DocumentApiService;
import com.kaluwa.enterprises.babycare.service.UserApiService; import com.kaluwa.enterprises.babycare.service.UserApiService;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
...@@ -16,7 +17,7 @@ import retrofit2.converter.gson.GsonConverterFactory; ...@@ -16,7 +17,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory; import retrofit2.converter.jackson.JacksonConverterFactory;
public class ApiConfig { public class ApiConfig {
private static final String BASE_URL = "http://192.168.63.103:8080/api/v1/baby-care/"; private static final String BASE_URL = "http://192.168.1.2:8080/api/v1/baby-care/";
private static ApiConfig instance; private static ApiConfig instance;
private static Retrofit retrofitAuth = null; private static Retrofit retrofitAuth = null;
private static Retrofit retrofitOther = null; private static Retrofit retrofitOther = null;
...@@ -71,4 +72,9 @@ public class ApiConfig { ...@@ -71,4 +72,9 @@ public class ApiConfig {
AUTH_TOKEN = JWTToken; AUTH_TOKEN = JWTToken;
return retrofitOther.create(BabyApiService.class); return retrofitOther.create(BabyApiService.class);
} }
public DocumentApiService getDocumentApi(String JWTToken) {
AUTH_TOKEN = JWTToken;
return retrofitOther.create(DocumentApiService.class);
}
} }
package com.kaluwa.enterprises.babycare.constants;
public class DocumentTypes {
public static final String PROFILE_IMAGE = "profile_image";
public static final String BABY_PROFILE_IMAGE = "baby_profile_image";
public static final String IMAGE = "image";
}
package com.kaluwa.enterprises.babycare.constants;
public class TableNames {
public static final String USERS = "users";
public static final String BABIES = "babies";
}
...@@ -240,7 +240,7 @@ public class AddBabyDialog extends AppCompatDialogFragment { ...@@ -240,7 +240,7 @@ public class AddBabyDialog extends AppCompatDialogFragment {
etSEmergRelation = view.findViewById(R.id.abv_et_s_emergency_relationship); etSEmergRelation = view.findViewById(R.id.abv_et_s_emergency_relationship);
etSEmergConNumber = view.findViewById(R.id.abv_et_s_emergency_con_number); etSEmergConNumber = view.findViewById(R.id.abv_et_s_emergency_con_number);
etNotes = view.findViewById(R.id.abv_et_notes); etNotes = view.findViewById(R.id.abv_et_notes);
ibPhoto = view.findViewById(R.id.abv_ib_photo); // ibPhoto = view.findViewById(R.id.abv_ib_photo);
switchStatus = view.findViewById(R.id.abv_switch_status); switchStatus = view.findViewById(R.id.abv_switch_status);
progressbar = view.findViewById(R.id.progress_bar); progressbar = view.findViewById(R.id.progress_bar);
......
...@@ -45,6 +45,7 @@ public class BabyDto { ...@@ -45,6 +45,7 @@ public class BabyDto {
private String secondaryEmergencyRelationship; private String secondaryEmergencyRelationship;
private String secondaryEmergencyContactNumber; private String secondaryEmergencyContactNumber;
private String notes; private String notes;
private String uniqKey;
private UserDto user; private UserDto user;
private Long userId; private Long userId;
private Long documentId; private Long documentId;
......
...@@ -17,5 +17,6 @@ public class UserDto { ...@@ -17,5 +17,6 @@ public class UserDto {
private String phone; private String phone;
private String role; private String role;
private String status; private String status;
private String uniqKey;
private LocalDate dob; private LocalDate dob;
} }
\ No newline at end of file
...@@ -15,5 +15,6 @@ public class AuthenticationDto { ...@@ -15,5 +15,6 @@ public class AuthenticationDto {
private String phone; private String phone;
private String role; private String role;
private String status; private String status;
private String uniqKey;
private TokenDto tokenDto; private TokenDto tokenDto;
} }
\ No newline at end of file
package com.kaluwa.enterprises.babycare.service;
import com.kaluwa.enterprises.babycare.dto.responseDto.ResponseDto;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
public interface DocumentApiService {
@Multipart
@PUT("document/{docType}/{table}/{uniqKey}")
Call<ResponseDto> uploadUserImage(@Path("docType") String docType, @Path("table") String table, @Path("uniqKey") String uniqKey, @Part MultipartBody.Part image);
@GET("document/{table}/{uniqKey}")
Call<ResponseBody> getImage(@Path("table") String table, @Path("uniqKey") String uniqKey);
}
...@@ -21,11 +21,4 @@ public interface UserApiService { ...@@ -21,11 +21,4 @@ public interface UserApiService {
@PUT("user/{userId}") @PUT("user/{userId}")
Call<UserDto> updateUserById(@Path("userId") Long userId, @Body UserDto user); 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);
} }
...@@ -77,22 +77,22 @@ ...@@ -77,22 +77,22 @@
android:textSize="16sp" android:textSize="16sp"
android:fontFamily="@font/kanit_regular"/> android:fontFamily="@font/kanit_regular"/>
<TextView <!-- <TextView-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:textSize="16sp" <!-- android:textSize="16sp"-->
android:text="Photo" <!-- android:text="Photo"-->
android:fontFamily="@font/kanit_regular" <!-- android:fontFamily="@font/kanit_regular"-->
android:paddingStart="5dp" <!-- android:paddingStart="5dp"-->
android:paddingEnd="2dp" <!-- android:paddingEnd="2dp"-->
android:paddingTop="6dp"/> <!-- android:paddingTop="6dp"/>-->
<ImageButton <!-- <ImageButton-->
android:id="@+id/abv_ib_photo" <!-- android:id="@+id/abv_ib_photo"-->
android:layout_width="120dp" <!-- android:layout_width="120dp"-->
android:layout_height="120dp" <!-- android:layout_height="120dp"-->
android:src="@drawable/ic_add_32" <!-- android:src="@drawable/ic_add_32"-->
android:contentDescription="baby_uploaded_photo"/> <!-- android:contentDescription="baby_uploaded_photo"/>-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -41,14 +41,17 @@ ...@@ -41,14 +41,17 @@
android:background="@drawable/borders" android:background="@drawable/borders"
android:padding="8dp"> android:padding="8dp">
<ImageButton <com.google.android.material.imageview.ShapeableImageView
android:id="@+id/ebv_ib_photo" android:id="@+id/ebv_ib_photo"
android:layout_width="wrap_content" android:layout_width="160dp"
android:layout_height="wrap_content" android:layout_height="160dp"
android:maxHeight="200dp" android:maxHeight="160dp"
android:src="@drawable/ic_add_32" android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:src="@drawable/foreground"
app:shapeAppearanceOverlay="@style/RoundImage"
android:scaleType="centerCrop"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerInside"
android:layout_gravity="center" android:layout_gravity="center"
android:contentDescription="baby_uploaded_photo"/> android:contentDescription="baby_uploaded_photo"/>
......
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