ProgressiveActivity Module Screens design
OtherHseActivity Module Screen designmaster
parent
6dc0aa4617
commit
8e4f0844c5
|
@ -1,16 +1,167 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.HSETrainingForms;
|
package com.utopiaindustries.hseobservationsapp.activities.HSETrainingForms;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.media.ExifInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||||
|
|
||||||
public class HseOneActivity extends AppCompatActivity {
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||||
|
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||||
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
|
public class HseOneActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
|
||||||
|
EasyPermissions.RationaleCallbacks{
|
||||||
|
|
||||||
|
RecyclerView trainingPicRecyclerView;
|
||||||
|
PTWImageAdapter imagePaperAdapter;
|
||||||
|
String paperFilePath = "no_pic";
|
||||||
|
ArrayList<DocumentTypeImageModel> PaperImageList = new ArrayList<>();
|
||||||
|
String docTypeId = "";
|
||||||
|
String docTypeTitle = "";
|
||||||
|
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||||
|
private static final int GALLERY_REQUEST = 201;
|
||||||
|
ImageView imgUpload, imgBack;
|
||||||
|
Button btnNext;
|
||||||
|
|
||||||
|
// Activity Result Launcher for Gallery
|
||||||
|
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
|
Uri selectedImage = result.getData().getData();
|
||||||
|
|
||||||
|
uriToByteArrayAsync(
|
||||||
|
this,
|
||||||
|
selectedImage,
|
||||||
|
100, // Target size in KB
|
||||||
|
compressedImage -> {
|
||||||
|
// Handle the compressed image here, e.g., display it
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
compressedImage
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
// Handle any errors
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(this, "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activity Result Launcher for Paper Camera
|
||||||
|
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
|
||||||
|
if (result.getResultCode() == RESULT_OK) {
|
||||||
|
|
||||||
|
File imageFile = new File(paperFilePath);
|
||||||
|
if (imageFile.exists()) {
|
||||||
|
|
||||||
|
Bitmap originalBitmap = fixImageRotation(paperFilePath);
|
||||||
|
|
||||||
|
//Bitmap timestampedBitmap = addTimestampToImage(originalBitmap);
|
||||||
|
|
||||||
|
bitmapToByteArrayAsync(
|
||||||
|
originalBitmap,
|
||||||
|
100, // Target size in KB
|
||||||
|
imageBytes -> {
|
||||||
|
this.runOnUiThread(() -> {
|
||||||
|
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
imageBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Image file not found!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -22,5 +173,365 @@ public class HseOneActivity extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
imgUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
alertForPictures(HseOneActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
imgBack.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnNext.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(HseOneActivity.this, HseTwoActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
imgUpload = findViewById(R.id.img_upload);
|
||||||
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
btnNext = findViewById(R.id.btn_next);
|
||||||
|
|
||||||
|
trainingPicRecyclerView = findViewById(R.id.tPicturesRecyclerView);
|
||||||
|
|
||||||
|
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
|
||||||
|
trainingPicRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
trainingPicRecyclerView.setAdapter(imagePaperAdapter);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bitmapToByteArrayAsync(
|
||||||
|
Bitmap bitmap,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IllegalArgumentException("Bitmap cannot be null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void uriToByteArrayAsync(
|
||||||
|
Context context,
|
||||||
|
Uri uri,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
|
||||||
|
// Load the image as a Bitmap without scaling
|
||||||
|
Bitmap bitmap;
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IOException("Failed to decode image from URI.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap fixImageRotation(String imagePath) {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
||||||
|
try {
|
||||||
|
ExifInterface exif = new ExifInterface(imagePath);
|
||||||
|
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
|
||||||
|
|
||||||
|
int rotationAngle = 0;
|
||||||
|
switch (orientation) {
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||||
|
rotationAngle = 90;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||||
|
rotationAngle = 180;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||||
|
rotationAngle = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotationAngle != 0) {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.postRotate(rotationAngle);
|
||||||
|
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void alertForPictures(Context con) {
|
||||||
|
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
TextView dialogCameraBtn, dialogGalleryBtn;
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||||
|
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_image, viewGroup, false);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setView(view1);
|
||||||
|
|
||||||
|
dialogCameraBtn = view1.findViewById(R.id.dialog_camera_btn);
|
||||||
|
dialogGalleryBtn = view1.findViewById(R.id.dialog_gallery_btn);
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
dialogCameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogGalleryBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(GALLERY_REQUEST)
|
||||||
|
public void openGallery() {
|
||||||
|
if (hasGalleryPermission()) {
|
||||||
|
// Have permission, do the thing!
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
|
// Start the Intent
|
||||||
|
//startActivityForResult(galleryIntent, GALLERY_REQUEST);
|
||||||
|
imagePickerLauncher.launch(galleryIntent);
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
|
||||||
|
}
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_gallery), GALLERY_REQUEST, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
||||||
|
public void openCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
getPackageName(),
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
paperCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_PAPER, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@AfterPermissionGranted(CAMERA_REQUEST_ITEM)
|
||||||
|
public void openItemCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile("Item");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
"com.utopia.inventorymanagement",
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
itemCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_ITEM, perms);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
@NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
// EasyPermissions handles the request result.
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
|
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
|
||||||
|
new AppSettingsDialog.Builder(this).build().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCameraPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log.e("perms: ",""+perms);
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasGalleryPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
// Create an image file name
|
||||||
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||||
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||||
|
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
|
File image = File.createTempFile(
|
||||||
|
imageFileName, //prefix
|
||||||
|
".jpg", //suffix
|
||||||
|
storageDir //directory
|
||||||
|
);
|
||||||
|
|
||||||
|
paperFilePath = image.getAbsolutePath();
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleAccepted(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleDenied(int requestCode) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.HSETrainingForms;
|
package com.utopiaindustries.hseobservationsapp.activities.HSETrainingForms;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -9,9 +13,13 @@ import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||||
|
|
||||||
public class HseTwoActivity extends AppCompatActivity {
|
public class HseTwoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -22,5 +30,24 @@ public class HseTwoActivity extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(HseTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(HseTwoActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -9,9 +13,13 @@ import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationThreeActivity;
|
||||||
|
|
||||||
public class InjuryFormFour extends AppCompatActivity {
|
public class InjuryFormFour extends AppCompatActivity {
|
||||||
|
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -22,5 +30,24 @@ public class InjuryFormFour extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(InjuryFormFour.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(InjuryFormFour.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,10 @@ package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
||||||
|
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -26,6 +28,7 @@ public class InjuryFormOne extends AppCompatActivity {
|
||||||
private Calendar calendar;
|
private Calendar calendar;
|
||||||
TextView txtDate;
|
TextView txtDate;
|
||||||
private ImageView imgCalendar;
|
private ImageView imgCalendar;
|
||||||
|
Button btnNext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -46,6 +49,14 @@ public class InjuryFormOne extends AppCompatActivity {
|
||||||
showDatePickerDialog(InjuryFormOne.this);
|
showDatePickerDialog(InjuryFormOne.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnNext.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(InjuryFormOne.this, InjuryFormTwo.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeLayouts() {
|
private void initializeLayouts() {
|
||||||
|
@ -56,6 +67,7 @@ public class InjuryFormOne extends AppCompatActivity {
|
||||||
day = calendar.get(Calendar.DAY_OF_MONTH);
|
day = calendar.get(Calendar.DAY_OF_MONTH);
|
||||||
txtDate = findViewById(R.id.txt_date);
|
txtDate = findViewById(R.id.txt_date);
|
||||||
imgCalendar = findViewById(R.id.img_calendar);
|
imgCalendar = findViewById(R.id.img_calendar);
|
||||||
|
btnNext = findViewById(R.id.btn_next);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,167 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.media.ExifInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||||
|
|
||||||
public class InjuryFormThree extends AppCompatActivity {
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||||
|
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||||
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
|
public class InjuryFormThree extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
|
||||||
|
EasyPermissions.RationaleCallbacks{
|
||||||
|
|
||||||
|
RecyclerView picturesRecyclerView;
|
||||||
|
PTWImageAdapter imagePaperAdapter;
|
||||||
|
String paperFilePath = "no_pic";
|
||||||
|
ArrayList<DocumentTypeImageModel> PaperImageList = new ArrayList<>();
|
||||||
|
String docTypeId = "";
|
||||||
|
String docTypeTitle = "";
|
||||||
|
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||||
|
private static final int GALLERY_REQUEST = 201;
|
||||||
|
ImageView imgUpload, imgBack;
|
||||||
|
Button btnNext;
|
||||||
|
|
||||||
|
// Activity Result Launcher for Gallery
|
||||||
|
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
|
Uri selectedImage = result.getData().getData();
|
||||||
|
|
||||||
|
uriToByteArrayAsync(
|
||||||
|
this,
|
||||||
|
selectedImage,
|
||||||
|
100, // Target size in KB
|
||||||
|
compressedImage -> {
|
||||||
|
// Handle the compressed image here, e.g., display it
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
compressedImage
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
// Handle any errors
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(this, "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activity Result Launcher for Paper Camera
|
||||||
|
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
|
||||||
|
if (result.getResultCode() == RESULT_OK) {
|
||||||
|
|
||||||
|
File imageFile = new File(paperFilePath);
|
||||||
|
if (imageFile.exists()) {
|
||||||
|
|
||||||
|
Bitmap originalBitmap = fixImageRotation(paperFilePath);
|
||||||
|
|
||||||
|
//Bitmap timestampedBitmap = addTimestampToImage(originalBitmap);
|
||||||
|
|
||||||
|
bitmapToByteArrayAsync(
|
||||||
|
originalBitmap,
|
||||||
|
100, // Target size in KB
|
||||||
|
imageBytes -> {
|
||||||
|
this.runOnUiThread(() -> {
|
||||||
|
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
imageBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Image file not found!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -22,5 +173,365 @@ public class InjuryFormThree extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
imgUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
alertForPictures(InjuryFormThree.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
imgBack.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnNext.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(InjuryFormThree.this, InjuryFormFour.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
imgUpload = findViewById(R.id.img_upload);
|
||||||
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
btnNext = findViewById(R.id.btn_next);
|
||||||
|
|
||||||
|
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
|
||||||
|
|
||||||
|
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
|
||||||
|
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
picturesRecyclerView.setAdapter(imagePaperAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void alertForPictures(Context con) {
|
||||||
|
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
TextView dialogCameraBtn, dialogGalleryBtn;
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||||
|
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_image, viewGroup, false);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setView(view1);
|
||||||
|
|
||||||
|
dialogCameraBtn = view1.findViewById(R.id.dialog_camera_btn);
|
||||||
|
dialogGalleryBtn = view1.findViewById(R.id.dialog_gallery_btn);
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
dialogCameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogGalleryBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(GALLERY_REQUEST)
|
||||||
|
public void openGallery() {
|
||||||
|
if (hasGalleryPermission()) {
|
||||||
|
// Have permission, do the thing!
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
|
// Start the Intent
|
||||||
|
//startActivityForResult(galleryIntent, GALLERY_REQUEST);
|
||||||
|
imagePickerLauncher.launch(galleryIntent);
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
|
||||||
|
}
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_gallery), GALLERY_REQUEST, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
||||||
|
public void openCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
getPackageName(),
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
paperCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_PAPER, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@AfterPermissionGranted(CAMERA_REQUEST_ITEM)
|
||||||
|
public void openItemCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile("Item");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
"com.utopia.inventorymanagement",
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
itemCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_ITEM, perms);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
@NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
// EasyPermissions handles the request result.
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
|
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
|
||||||
|
new AppSettingsDialog.Builder(this).build().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCameraPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log.e("perms: ",""+perms);
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasGalleryPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap fixImageRotation(String imagePath) {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
||||||
|
try {
|
||||||
|
ExifInterface exif = new ExifInterface(imagePath);
|
||||||
|
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
|
||||||
|
|
||||||
|
int rotationAngle = 0;
|
||||||
|
switch (orientation) {
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||||
|
rotationAngle = 90;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||||
|
rotationAngle = 180;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||||
|
rotationAngle = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotationAngle != 0) {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.postRotate(rotationAngle);
|
||||||
|
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
// Create an image file name
|
||||||
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||||
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||||
|
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
|
File image = File.createTempFile(
|
||||||
|
imageFileName, //prefix
|
||||||
|
".jpg", //suffix
|
||||||
|
storageDir //directory
|
||||||
|
);
|
||||||
|
|
||||||
|
paperFilePath = image.getAbsolutePath();
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleAccepted(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleDenied(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bitmapToByteArrayAsync(
|
||||||
|
Bitmap bitmap,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IllegalArgumentException("Bitmap cannot be null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void uriToByteArrayAsync(
|
||||||
|
Context context,
|
||||||
|
Uri uri,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
|
||||||
|
// Load the image as a Bitmap without scaling
|
||||||
|
Bitmap bitmap;
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IOException("Failed to decode image from URI.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -12,6 +15,8 @@ import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
|
||||||
public class InjuryFormTwo extends AppCompatActivity {
|
public class InjuryFormTwo extends AppCompatActivity {
|
||||||
|
|
||||||
|
Button btnNext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -22,5 +27,20 @@ public class InjuryFormTwo extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
btnNext.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(InjuryFormTwo.this, InjuryFormThree.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
btnNext = findViewById(R.id.btn_next);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,8 @@ import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationClassAdapter;
|
import com.utopiaindustries.hseobservationsapp.adapters.ObservationClassAdapter;
|
||||||
import com.utopiaindustries.hseobservationsapp.adapters.ObservationSubClassAdapter;
|
import com.utopiaindustries.hseobservationsapp.adapters.ObservationSubClassAdapter;
|
||||||
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
import com.utopiaindustries.hseobservationsapp.models.Shift;
|
||||||
|
@ -29,7 +31,7 @@ public class ObservationNearMissActivity extends AppCompatActivity {
|
||||||
private ObservationClassAdapter observationClassAdapter;
|
private ObservationClassAdapter observationClassAdapter;
|
||||||
private ArrayList<Shift> obClassArrayList = new ArrayList<>();
|
private ArrayList<Shift> obClassArrayList = new ArrayList<>();
|
||||||
|
|
||||||
private Button btnNext;
|
private Button btnSubmit;
|
||||||
ImageView imgBack;
|
ImageView imgBack;
|
||||||
|
|
||||||
String observationClass = "";
|
String observationClass = "";
|
||||||
|
@ -55,12 +57,18 @@ public class ObservationNearMissActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnNext.setOnClickListener(new View.OnClickListener() {
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (isValidate()) {
|
/* if (isValidate()) {
|
||||||
|
|
||||||
}
|
}*/
|
||||||
|
Toast.makeText(ObservationNearMissActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(ObservationNearMissActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -76,7 +84,7 @@ public class ObservationNearMissActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public void initializeLayout() {
|
public void initializeLayout() {
|
||||||
observationTextview = findViewById(R.id.observation_near_textview);
|
observationTextview = findViewById(R.id.observation_near_textview);
|
||||||
btnNext = findViewById(R.id.btn_next);
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
imgBack = findViewById(R.id.img_back);
|
imgBack = findViewById(R.id.img_back);
|
||||||
etDescription = findViewById(R.id.et_description);
|
etDescription = findViewById(R.id.et_description);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.ObservationForms;
|
package com.utopiaindustries.hseobservationsapp.activities.ObservationForms;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -12,12 +15,15 @@ import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms.PermitTwoActivity;
|
||||||
|
|
||||||
|
|
||||||
public class ObservationThreeActivity extends AppCompatActivity {
|
public class ObservationThreeActivity extends AppCompatActivity {
|
||||||
|
|
||||||
RadioGroup rg1;
|
RadioGroup rg1;
|
||||||
ImageView imgBack;
|
ImageView imgBack;
|
||||||
|
Button btnSubmit, btnDraft;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -53,11 +59,33 @@ public class ObservationThreeActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(ObservationThreeActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(ObservationThreeActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnDraft.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeLayouts() {
|
private void initializeLayouts() {
|
||||||
|
|
||||||
rg1 = findViewById(R.id.rg1);
|
rg1 = findViewById(R.id.rg1);
|
||||||
imgBack = findViewById(R.id.img_back);
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
|
btnDraft = findViewById(R.id.btn_draft);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,10 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.OtherHSEActivityForms;
|
package com.utopiaindustries.hseobservationsapp.activities.OtherHSEActivityForms;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
@ -9,9 +13,12 @@ import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
|
||||||
public class OtherHseActivity extends AppCompatActivity {
|
public class OtherHseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -22,5 +29,26 @@ public class OtherHseActivity extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(OtherHseActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(OtherHseActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,26 +1,35 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms;
|
package com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.media.ExifInterface;
|
import android.media.ExifInterface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
|
@ -29,13 +38,18 @@ import androidx.core.view.WindowInsetsCompat;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationThreeActivity;
|
||||||
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||||
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -57,7 +71,51 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
String docTypeId = "";
|
String docTypeId = "";
|
||||||
String docTypeTitle = "";
|
String docTypeTitle = "";
|
||||||
private static final int CAMERA_REQUEST_PAPER = 101;
|
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||||
|
private static final int GALLERY_REQUEST = 201;
|
||||||
ImageView imgUpload, imgBack;
|
ImageView imgUpload, imgBack;
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
|
// Activity Result Launcher for Gallery
|
||||||
|
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
|
Uri selectedImage = result.getData().getData();
|
||||||
|
|
||||||
|
uriToByteArrayAsync(
|
||||||
|
this,
|
||||||
|
selectedImage,
|
||||||
|
100, // Target size in KB
|
||||||
|
compressedImage -> {
|
||||||
|
// Handle the compressed image here, e.g., display it
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
compressedImage
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
// Handle any errors
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(this, "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Activity Result Launcher for Paper Camera
|
// Activity Result Launcher for Paper Camera
|
||||||
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
||||||
|
@ -143,7 +201,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
imgUpload.setOnClickListener(new View.OnClickListener() {
|
imgUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
openPaperCamera();
|
alertForPictures(PermitTwoActivity.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -153,6 +211,79 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(PermitTwoActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void alertForPictures(Context con) {
|
||||||
|
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
TextView dialogCameraBtn, dialogGalleryBtn;
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||||
|
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_image, viewGroup, false);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setView(view1);
|
||||||
|
|
||||||
|
dialogCameraBtn = view1.findViewById(R.id.dialog_camera_btn);
|
||||||
|
dialogGalleryBtn = view1.findViewById(R.id.dialog_gallery_btn);
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
dialogCameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogGalleryBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(GALLERY_REQUEST)
|
||||||
|
public void openGallery() {
|
||||||
|
if (hasGalleryPermission()) {
|
||||||
|
// Have permission, do the thing!
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
|
// Start the Intent
|
||||||
|
//startActivityForResult(galleryIntent, GALLERY_REQUEST);
|
||||||
|
imagePickerLauncher.launch(galleryIntent);
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
|
||||||
|
}
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_gallery), GALLERY_REQUEST, perms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeLayouts() {
|
private void initializeLayouts() {
|
||||||
|
@ -160,6 +291,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
checkboxContractor = findViewById(R.id.checkbox_contractor);
|
checkboxContractor = findViewById(R.id.checkbox_contractor);
|
||||||
imgUpload = findViewById(R.id.img_upload);
|
imgUpload = findViewById(R.id.img_upload);
|
||||||
imgBack = findViewById(R.id.img_back);
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
|
|
||||||
ptwRecyclerView = findViewById(R.id.ptwRecyclerView);
|
ptwRecyclerView = findViewById(R.id.ptwRecyclerView);
|
||||||
|
|
||||||
|
@ -170,7 +302,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
||||||
public void openPaperCamera() {
|
public void openCamera() {
|
||||||
if (hasCameraPermission()) {
|
if (hasCameraPermission()) {
|
||||||
try {
|
try {
|
||||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
@ -277,6 +409,18 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
return EasyPermissions.hasPermissions(this, perms);
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasGalleryPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
private Bitmap fixImageRotation(String imagePath) {
|
private Bitmap fixImageRotation(String imagePath) {
|
||||||
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
||||||
try {
|
try {
|
||||||
|
@ -371,4 +515,51 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void uriToByteArrayAsync(
|
||||||
|
Context context,
|
||||||
|
Uri uri,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
|
||||||
|
// Load the image as a Bitmap without scaling
|
||||||
|
Bitmap bitmap;
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IOException("Failed to decode image from URI.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,167 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.ProgressiveActivityForms;
|
package com.utopiaindustries.hseobservationsapp.activities.ProgressiveActivityForms;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.media.ExifInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.WeeklyActivityForms.WeeklyFormOne;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||||
|
|
||||||
public class ProgressiveActivity extends AppCompatActivity {
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||||
|
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||||
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
|
public class ProgressiveActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
|
||||||
|
EasyPermissions.RationaleCallbacks {
|
||||||
|
|
||||||
|
RecyclerView picturesRecyclerView;
|
||||||
|
PTWImageAdapter imagePaperAdapter;
|
||||||
|
String paperFilePath = "no_pic";
|
||||||
|
ArrayList<DocumentTypeImageModel> PaperImageList = new ArrayList<>();
|
||||||
|
String docTypeId = "";
|
||||||
|
String docTypeTitle = "";
|
||||||
|
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||||
|
private static final int GALLERY_REQUEST = 201;
|
||||||
|
ImageView imgUpload, imgBack;
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
|
// Activity Result Launcher for Gallery
|
||||||
|
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
|
Uri selectedImage = result.getData().getData();
|
||||||
|
|
||||||
|
uriToByteArrayAsync(
|
||||||
|
this,
|
||||||
|
selectedImage,
|
||||||
|
100, // Target size in KB
|
||||||
|
compressedImage -> {
|
||||||
|
// Handle the compressed image here, e.g., display it
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
compressedImage
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
// Handle any errors
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(this, "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activity Result Launcher for Paper Camera
|
||||||
|
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
|
||||||
|
if (result.getResultCode() == RESULT_OK) {
|
||||||
|
|
||||||
|
File imageFile = new File(paperFilePath);
|
||||||
|
if (imageFile.exists()) {
|
||||||
|
|
||||||
|
Bitmap originalBitmap = fixImageRotation(paperFilePath);
|
||||||
|
|
||||||
|
//Bitmap timestampedBitmap = addTimestampToImage(originalBitmap);
|
||||||
|
|
||||||
|
bitmapToByteArrayAsync(
|
||||||
|
originalBitmap,
|
||||||
|
100, // Target size in KB
|
||||||
|
imageBytes -> {
|
||||||
|
this.runOnUiThread(() -> {
|
||||||
|
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
imageBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Image file not found!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -22,5 +173,370 @@ public class ProgressiveActivity extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
imgUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
alertForPictures(ProgressiveActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
imgBack.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(ProgressiveActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(ProgressiveActivity.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
imgUpload = findViewById(R.id.img_upload);
|
||||||
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
|
|
||||||
|
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
|
||||||
|
|
||||||
|
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
|
||||||
|
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
picturesRecyclerView.setAdapter(imagePaperAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void alertForPictures(Context con) {
|
||||||
|
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
TextView dialogCameraBtn, dialogGalleryBtn;
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||||
|
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_image, viewGroup, false);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setView(view1);
|
||||||
|
|
||||||
|
dialogCameraBtn = view1.findViewById(R.id.dialog_camera_btn);
|
||||||
|
dialogGalleryBtn = view1.findViewById(R.id.dialog_gallery_btn);
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
dialogCameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogGalleryBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(GALLERY_REQUEST)
|
||||||
|
public void openGallery() {
|
||||||
|
if (hasGalleryPermission()) {
|
||||||
|
// Have permission, do the thing!
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
|
// Start the Intent
|
||||||
|
//startActivityForResult(galleryIntent, GALLERY_REQUEST);
|
||||||
|
imagePickerLauncher.launch(galleryIntent);
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
|
||||||
|
}
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_gallery), GALLERY_REQUEST, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
||||||
|
public void openCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
getPackageName(),
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
paperCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_PAPER, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@AfterPermissionGranted(CAMERA_REQUEST_ITEM)
|
||||||
|
public void openItemCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile("Item");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
"com.utopia.inventorymanagement",
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
itemCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_ITEM, perms);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
@NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
// EasyPermissions handles the request result.
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
|
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
|
||||||
|
new AppSettingsDialog.Builder(this).build().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCameraPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log.e("perms: ",""+perms);
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasGalleryPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap fixImageRotation(String imagePath) {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
||||||
|
try {
|
||||||
|
ExifInterface exif = new ExifInterface(imagePath);
|
||||||
|
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
|
||||||
|
|
||||||
|
int rotationAngle = 0;
|
||||||
|
switch (orientation) {
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||||
|
rotationAngle = 90;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||||
|
rotationAngle = 180;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||||
|
rotationAngle = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotationAngle != 0) {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.postRotate(rotationAngle);
|
||||||
|
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
// Create an image file name
|
||||||
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||||
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||||
|
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
|
File image = File.createTempFile(
|
||||||
|
imageFileName, //prefix
|
||||||
|
".jpg", //suffix
|
||||||
|
storageDir //directory
|
||||||
|
);
|
||||||
|
|
||||||
|
paperFilePath = image.getAbsolutePath();
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleAccepted(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleDenied(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bitmapToByteArrayAsync(
|
||||||
|
Bitmap bitmap,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IllegalArgumentException("Bitmap cannot be null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void uriToByteArrayAsync(
|
||||||
|
Context context,
|
||||||
|
Uri uri,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
|
||||||
|
// Load the image as a Bitmap without scaling
|
||||||
|
Bitmap bitmap;
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IOException("Failed to decode image from URI.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,169 @@
|
||||||
package com.utopiaindustries.hseobservationsapp.activities.WeeklyActivityForms;
|
package com.utopiaindustries.hseobservationsapp.activities.WeeklyActivityForms;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.media.ExifInterface;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.utopiaindustries.hseobservationsapp.R;
|
import com.utopiaindustries.hseobservationsapp.R;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms.InjuryFormFour;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms.InjuryFormThree;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationThreeActivity;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
|
||||||
|
import com.utopiaindustries.hseobservationsapp.models.DocumentTypeImageModel;
|
||||||
|
|
||||||
public class WeeklyFormOne extends AppCompatActivity {
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||||
|
import pub.devrel.easypermissions.AppSettingsDialog;
|
||||||
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
|
public class WeeklyFormOne extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
|
||||||
|
EasyPermissions.RationaleCallbacks {
|
||||||
|
|
||||||
|
RecyclerView picturesRecyclerView;
|
||||||
|
PTWImageAdapter imagePaperAdapter;
|
||||||
|
String paperFilePath = "no_pic";
|
||||||
|
ArrayList<DocumentTypeImageModel> PaperImageList = new ArrayList<>();
|
||||||
|
String docTypeId = "";
|
||||||
|
String docTypeTitle = "";
|
||||||
|
private static final int CAMERA_REQUEST_PAPER = 101;
|
||||||
|
private static final int GALLERY_REQUEST = 201;
|
||||||
|
ImageView imgUpload, imgBack;
|
||||||
|
Button btnSubmit;
|
||||||
|
|
||||||
|
// Activity Result Launcher for Gallery
|
||||||
|
private final ActivityResultLauncher<Intent> imagePickerLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
if (result.getResultCode() == RESULT_OK && result.getData() != null) {
|
||||||
|
Uri selectedImage = result.getData().getData();
|
||||||
|
|
||||||
|
uriToByteArrayAsync(
|
||||||
|
this,
|
||||||
|
selectedImage,
|
||||||
|
100, // Target size in KB
|
||||||
|
compressedImage -> {
|
||||||
|
// Handle the compressed image here, e.g., display it
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
compressedImage
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
// Handle any errors
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
Toast.makeText(this, "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Gallery Selection Cancelled!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activity Result Launcher for Paper Camera
|
||||||
|
private final ActivityResultLauncher<Intent> paperCameraLauncher =
|
||||||
|
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
|
||||||
|
if (result.getResultCode() == RESULT_OK) {
|
||||||
|
|
||||||
|
File imageFile = new File(paperFilePath);
|
||||||
|
if (imageFile.exists()) {
|
||||||
|
|
||||||
|
Bitmap originalBitmap = fixImageRotation(paperFilePath);
|
||||||
|
|
||||||
|
//Bitmap timestampedBitmap = addTimestampToImage(originalBitmap);
|
||||||
|
|
||||||
|
bitmapToByteArrayAsync(
|
||||||
|
originalBitmap,
|
||||||
|
100, // Target size in KB
|
||||||
|
imageBytes -> {
|
||||||
|
this.runOnUiThread(() -> {
|
||||||
|
|
||||||
|
DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
|
||||||
|
docTypeId,
|
||||||
|
docTypeTitle,
|
||||||
|
imageBytes
|
||||||
|
);
|
||||||
|
|
||||||
|
//Log.e("doc-image: ",""+ documentImage);
|
||||||
|
|
||||||
|
int position = PaperImageList.size();
|
||||||
|
PaperImageList.add(documentImage);
|
||||||
|
imagePaperAdapter.notifyItemInserted(position);
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error -> {
|
||||||
|
error.printStackTrace();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Image file not found!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (result.getResultCode() == RESULT_CANCELED) {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Camera capture failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -22,5 +175,369 @@ public class WeeklyFormOne extends AppCompatActivity {
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initializeLayouts();
|
||||||
|
|
||||||
|
imgUpload.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
alertForPictures(WeeklyFormOne.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
imgBack.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(WeeklyFormOne.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(WeeklyFormOne.this, DashboardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeLayouts() {
|
||||||
|
|
||||||
|
imgUpload = findViewById(R.id.img_upload);
|
||||||
|
imgBack = findViewById(R.id.img_back);
|
||||||
|
btnSubmit = findViewById(R.id.btn_submit);
|
||||||
|
|
||||||
|
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
|
||||||
|
|
||||||
|
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
|
||||||
|
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
picturesRecyclerView.setAdapter(imagePaperAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void alertForPictures(Context con) {
|
||||||
|
ViewGroup viewGroup = findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
TextView dialogCameraBtn, dialogGalleryBtn;
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(con);
|
||||||
|
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_image, viewGroup, false);
|
||||||
|
builder.setCancelable(false);
|
||||||
|
builder.setView(view1);
|
||||||
|
|
||||||
|
dialogCameraBtn = view1.findViewById(R.id.dialog_camera_btn);
|
||||||
|
dialogGalleryBtn = view1.findViewById(R.id.dialog_gallery_btn);
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
dialogCameraBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openCamera();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogGalleryBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
openGallery();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(GALLERY_REQUEST)
|
||||||
|
public void openGallery() {
|
||||||
|
if (hasGalleryPermission()) {
|
||||||
|
// Have permission, do the thing!
|
||||||
|
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||||
|
// Start the Intent
|
||||||
|
//startActivityForResult(galleryIntent, GALLERY_REQUEST);
|
||||||
|
imagePickerLauncher.launch(galleryIntent);
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
|
||||||
|
}
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_gallery), GALLERY_REQUEST, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterPermissionGranted(CAMERA_REQUEST_PAPER)
|
||||||
|
public void openCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
getPackageName(),
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
paperCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_PAPER, perms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@AfterPermissionGranted(CAMERA_REQUEST_ITEM)
|
||||||
|
public void openItemCamera() {
|
||||||
|
if (hasCameraPermission()) {
|
||||||
|
try {
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
File photoFile = null;
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile("Item");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
// Error occurred while creating the File
|
||||||
|
}
|
||||||
|
|
||||||
|
if (photoFile != null) {
|
||||||
|
Uri photoURI = FileProvider.getUriForFile(this,
|
||||||
|
"com.utopia.inventorymanagement",
|
||||||
|
photoFile);
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
|
//startActivityForResult(takePictureIntent, CAMERA_REQUEST);
|
||||||
|
itemCameraLauncher.launch(takePictureIntent);
|
||||||
|
}
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, "Camera app not found", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Ask for one permission
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
}
|
||||||
|
|
||||||
|
EasyPermissions.requestPermissions(this, getString(R.string.rationale_camera), CAMERA_REQUEST_ITEM, perms);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode,
|
||||||
|
@NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
// EasyPermissions handles the request result.
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
|
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
|
||||||
|
new AppSettingsDialog.Builder(this).build().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasCameraPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.CAMERA};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Log.e("perms: ",""+perms);
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasGalleryPermission() {
|
||||||
|
String[] perms = {};
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
perms = new String[]{Manifest.permission.READ_MEDIA_IMAGES};
|
||||||
|
} else {
|
||||||
|
perms = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||||
|
}
|
||||||
|
|
||||||
|
return EasyPermissions.hasPermissions(this, perms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap fixImageRotation(String imagePath) {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
|
||||||
|
try {
|
||||||
|
ExifInterface exif = new ExifInterface(imagePath);
|
||||||
|
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
|
||||||
|
|
||||||
|
int rotationAngle = 0;
|
||||||
|
switch (orientation) {
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_90:
|
||||||
|
rotationAngle = 90;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_180:
|
||||||
|
rotationAngle = 180;
|
||||||
|
break;
|
||||||
|
case ExifInterface.ORIENTATION_ROTATE_270:
|
||||||
|
rotationAngle = 270;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotationAngle != 0) {
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.postRotate(rotationAngle);
|
||||||
|
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
// Create an image file name
|
||||||
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||||
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
||||||
|
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||||
|
File image = File.createTempFile(
|
||||||
|
imageFileName, //prefix
|
||||||
|
".jpg", //suffix
|
||||||
|
storageDir //directory
|
||||||
|
);
|
||||||
|
|
||||||
|
paperFilePath = image.getAbsolutePath();
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleAccepted(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRationaleDenied(int requestCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bitmapToByteArrayAsync(
|
||||||
|
Bitmap bitmap,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IllegalArgumentException("Bitmap cannot be null.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void uriToByteArrayAsync(
|
||||||
|
Context context,
|
||||||
|
Uri uri,
|
||||||
|
int targetSizeInKB,
|
||||||
|
Consumer<byte[]> onSuccess,
|
||||||
|
Consumer<Exception> onError
|
||||||
|
) {
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
int targetSizeInBytes = targetSizeInKB * 1024;
|
||||||
|
|
||||||
|
// Load the image as a Bitmap without scaling
|
||||||
|
Bitmap bitmap;
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||||
|
bitmap = BitmapFactory.decodeStream(inputStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bitmap == null) {
|
||||||
|
throw new IOException("Failed to decode image from URI.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
int minQuality = 10;
|
||||||
|
int maxQuality = 100;
|
||||||
|
int quality = maxQuality;
|
||||||
|
|
||||||
|
// Binary search for the best quality that meets the target size
|
||||||
|
while (minQuality <= maxQuality) {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
|
||||||
|
|
||||||
|
int byteSize = byteArrayOutputStream.size();
|
||||||
|
if (byteSize > targetSizeInBytes) {
|
||||||
|
maxQuality = quality - 1;
|
||||||
|
} else {
|
||||||
|
minQuality = quality + 1;
|
||||||
|
}
|
||||||
|
quality = (minQuality + maxQuality) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccess.accept(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
onError.accept(e);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,7 +58,7 @@ public class PTWImageAdapter extends RecyclerView.Adapter<PTWImageAdapter.ImageV
|
||||||
.apply(new RequestOptions().centerCrop())
|
.apply(new RequestOptions().centerCrop())
|
||||||
.into(holder.imageView);*/
|
.into(holder.imageView);*/
|
||||||
|
|
||||||
holder.docTypeTitle.setText(imageList.get(position).getDocumentTypeName());
|
//holder.docTypeTitle.setText(imageList.get(position).getDocumentTypeName());
|
||||||
byte[] imageData = imageList.get(position).getImage();
|
byte[] imageData = imageList.get(position).getImage();
|
||||||
|
|
||||||
// Load the image using Glide
|
// Load the image using Glide
|
||||||
|
@ -73,19 +73,12 @@ public class PTWImageAdapter extends RecyclerView.Adapter<PTWImageAdapter.ImageV
|
||||||
.apply(new RequestOptions().centerCrop())
|
.apply(new RequestOptions().centerCrop())
|
||||||
.into(holder.imageView);
|
.into(holder.imageView);
|
||||||
|
|
||||||
/*if (classType.equalsIgnoreCase("Review")) {
|
|
||||||
holder.btnDelete.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
holder.btnDelete.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
// Set a click listener for the delete button
|
|
||||||
holder.btnDelete.setOnClickListener(v -> {
|
holder.btnDelete.setOnClickListener(v -> {
|
||||||
imageList.remove(position);
|
imageList.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
notifyItemRangeChanged(position, imageList.size());
|
notifyItemRangeChanged(position, imageList.size());
|
||||||
Toast.makeText(context, "Image deleted", Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, "Image deleted", Toast.LENGTH_SHORT).show();
|
||||||
});*/
|
});
|
||||||
|
|
||||||
holder.imageView.setOnClickListener(new View.OnClickListener() {
|
holder.imageView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,14 +98,14 @@ public class PTWImageAdapter extends RecyclerView.Adapter<PTWImageAdapter.ImageV
|
||||||
|
|
||||||
public class ImageViewHolder extends RecyclerView.ViewHolder {
|
public class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||||
ImageView imageView;
|
ImageView imageView;
|
||||||
Button btnDelete;
|
ImageView btnDelete;
|
||||||
TextView docTypeTitle;
|
//TextView docTypeTitle;
|
||||||
|
|
||||||
public ImageViewHolder(@NonNull View itemView) {
|
public ImageViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
imageView = itemView.findViewById(R.id.imageView);
|
imageView = itemView.findViewById(R.id.imageView);
|
||||||
btnDelete = itemView.findViewById(R.id.btnDelete);
|
btnDelete = itemView.findViewById(R.id.btnDelete);
|
||||||
docTypeTitle = itemView.findViewById(R.id.docTypeTitle);
|
//docTypeTitle = itemView.findViewById(R.id.docTypeTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import com.utopiaindustries.hseobservationsapp.fragments.HomeFragment;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class PagerAdapter extends FragmentStatePagerAdapter {
|
public class PagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
String tabTitles[] = new String[]{"Home", "Draft"};
|
String tabTitles[] = new String[]{"Home", "List"};
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
public PagerAdapter(FragmentManager fm, Context context) {
|
public PagerAdapter(FragmentManager fm, Context context) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="0.7dp"
|
android:width="0.9dp"
|
||||||
android:color="@color/grey_400" />
|
android:color="@color/grey_500" />
|
||||||
|
|
||||||
<corners
|
<corners
|
||||||
android:radius="5dp"/>
|
android:radius="5dp"/>
|
||||||
|
|
|
@ -59,10 +59,10 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Topic Of Safety Training "
|
android:text="Topic Of Safety Training *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:hint="@string/select_safety_training"
|
android:hint="@string/select_safety_training"
|
||||||
android:padding="5dp"
|
android:padding="2dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent">
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Total No of Employees Present in Training"
|
android:text="Total No of Employees Present in Training *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@ -102,9 +102,9 @@
|
||||||
android:id="@+id/et_no_of_employees"
|
android:id="@+id/et_no_of_employees"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
android:hint="No Of Employees"
|
android:hint="No Of Employees"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
|
@ -115,10 +115,10 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Target Audience "
|
android:text="Target Audience *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@ -143,10 +143,17 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ptw_heading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Training Pictures "
|
android:text="Training Pictures "
|
||||||
|
@ -154,8 +161,26 @@
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_upload"
|
||||||
|
android:layout_width="35dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_toEndOf="@+id/ptw_heading"
|
||||||
|
android:src="@drawable/img_upload" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:textSize="@dimen/_10sdp"
|
||||||
|
android:text="Upload up to 5 supported files: PDF or image. Max 10 MB per file."/>
|
||||||
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/paperRecyclerView"
|
android:id="@+id/tPicturesRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
|
@ -167,6 +192,7 @@
|
||||||
android:paddingTop="5dp"
|
android:paddingTop="5dp"
|
||||||
android:paddingEnd="2dp"
|
android:paddingEnd="2dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
|
android:background="@color/grey_200"
|
||||||
android:scrollbars="horizontal" />
|
android:scrollbars="horizontal" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -53,15 +53,16 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Total Minutes of Training Sessions"
|
android:text="Total Minutes of Training Sessions *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@ -70,9 +71,9 @@
|
||||||
android:id="@+id/et_no_of_employees"
|
android:id="@+id/et_no_of_employees"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginEnd="10dp"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
android:hint="No Of Employees"
|
android:hint="No Of Employees"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
|
@ -84,10 +85,10 @@
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description"
|
android:text="Description *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -101,7 +102,7 @@
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
android:gravity="top|start"
|
android:gravity="top|start"
|
||||||
android:hint="Write Description Here"
|
android:hint="Write Description Here"
|
||||||
|
@ -119,7 +120,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Injury Form First"
|
android:text="Injury Form Four"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="@dimen/_15sdp"
|
android:textSize="@dimen/_15sdp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
|
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
|
||||||
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Action Taken *"
|
android:text="Action Taken *"
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Status After First Aid *"
|
android:text="Status After First Aid *"
|
||||||
|
@ -121,7 +122,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Root Cause *"
|
android:text="Root Cause *"
|
||||||
|
@ -147,7 +148,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Employee Name *"
|
android:text="Employee Name *"
|
||||||
|
@ -71,7 +72,7 @@
|
||||||
android:id="@+id/et_employee_name"
|
android:id="@+id/et_employee_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
|
@ -84,7 +85,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Employee Type *"
|
android:text="Employee Type *"
|
||||||
|
@ -97,10 +98,10 @@
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="10dp"
|
||||||
android:hint="@string/select_employee_type"
|
android:hint="@string/select_employee_type"
|
||||||
android:padding="5dp"
|
android:padding="2dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent">
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Employee ID Number *"
|
android:text="Employee ID Number *"
|
||||||
|
@ -127,7 +128,7 @@
|
||||||
android:id="@+id/et_employee_id_number"
|
android:id="@+id/et_employee_id_number"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
|
@ -140,7 +141,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Designation of the Employee *"
|
android:text="Designation of the Employee *"
|
||||||
|
@ -152,7 +153,7 @@
|
||||||
android:id="@+id/et_employee_designation"
|
android:id="@+id/et_employee_designation"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
|
@ -165,7 +166,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Date Of Joining *"
|
android:text="Date Of Joining *"
|
||||||
|
@ -201,7 +202,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Employee Tenure(Months) *"
|
android:text="Employee Tenure(Months) *"
|
||||||
|
@ -214,8 +215,8 @@
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="10dp"
|
||||||
android:hint="@string/select_employee_tenure"
|
android:hint="@string/select_employee_tenure"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Severity *"
|
android:text="Severity *"
|
||||||
|
@ -87,10 +88,17 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ptw_heading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Pictures "
|
android:text="Pictures "
|
||||||
|
@ -98,8 +106,25 @@
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_upload"
|
||||||
|
android:layout_width="35dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_toRightOf="@+id/ptw_heading"
|
||||||
|
android:src="@drawable/img_upload" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingStart="5dp"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
android:textSize="@dimen/_10sdp"
|
||||||
|
android:text="Upload up to 5 supported files: PDF or image. Max 10 MB per file."/>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/paperRecyclerView"
|
android:id="@+id/picturesRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
|
@ -116,7 +141,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description *"
|
android:text="Description *"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Injury Form First"
|
android:text="Injury Form Second"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="@dimen/_15sdp"
|
android:textSize="@dimen/_15sdp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
|
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
|
||||||
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="KPI *"
|
android:text="KPI *"
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Type Of Injury *"
|
android:text="Type Of Injury *"
|
||||||
|
@ -121,7 +122,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Type Of Injury *"
|
android:text="Type Of Injury *"
|
||||||
|
@ -152,7 +153,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Parts Of Body *"
|
android:text="Parts Of Body *"
|
||||||
|
@ -183,7 +184,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Department Name *"
|
android:text="Department Name *"
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description"
|
android:text="Description *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -41,6 +41,16 @@
|
||||||
app:layout_constraintTop_toTopOf="@+id/toolbar"
|
app:layout_constraintTop_toTopOf="@+id/toolbar"
|
||||||
app:srcCompat="@drawable/arrow_back" />
|
app:srcCompat="@drawable/arrow_back" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="5dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/toolbar">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_observation_status"
|
android:id="@+id/heading_observation_status"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -48,12 +58,10 @@
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Observation Status"
|
android:text="Observation Status *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
|
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:id="@+id/rg1"
|
android:id="@+id/rg1"
|
||||||
|
@ -61,8 +69,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/heading_observation_status"
|
|
||||||
android:padding="5dp">
|
android:padding="5dp">
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
@ -91,12 +97,10 @@
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description"
|
android:text="Description *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/rg1" />
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_description"
|
android:id="@+id/et_description"
|
||||||
|
@ -115,15 +119,9 @@
|
||||||
android:maxLines="5"
|
android:maxLines="5"
|
||||||
android:minLines="5"
|
android:minLines="5"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:textSize="@dimen/_12sdp"
|
android:textSize="@dimen/_12sdp" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/heading_description"/>
|
|
||||||
|
|
||||||
<View
|
</LinearLayout>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dp"
|
|
||||||
android:background="@color/black"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayout"
|
android:id="@+id/linearLayout"
|
||||||
|
@ -138,7 +136,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_weight="1"
|
android:layout_weight="2"
|
||||||
android:background="@drawable/rounded_btn_login"
|
android:background="@drawable/rounded_btn_login"
|
||||||
android:text="Submit"
|
android:text="Submit"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
|
@ -148,6 +146,7 @@
|
||||||
<View
|
<View
|
||||||
android:layout_width="2dp"
|
android:layout_width="2dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
android:background="@color/black" />
|
android:background="@color/black" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -156,6 +155,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:visibility="gone"
|
||||||
android:background="@drawable/rounded_btn_login"
|
android:background="@drawable/rounded_btn_login"
|
||||||
android:text="Draft"
|
android:text="Draft"
|
||||||
android:textColor="@color/white" />
|
android:textColor="@color/white" />
|
||||||
|
|
|
@ -52,7 +52,8 @@
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="5dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/observation_heading"
|
android:id="@+id/observation_heading"
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Department Name "
|
android:text="Department Name *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
@ -172,7 +173,7 @@
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Risk Level "
|
android:text="Risk Level *"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
android:id="@+id/et_no_of_employees"
|
android:id="@+id/et_no_of_employees"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/et_border"
|
android:background="@drawable/et_border"
|
||||||
|
@ -117,7 +118,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Sub Location *"
|
android:text="Sub Location *"
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="PTW Type *"
|
android:text="PTW Type *"
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="PTW Sub Type "
|
android:text="PTW Sub Type "
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
android:id="@+id/observation_heading"
|
android:id="@+id/observation_heading"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Working Team *"
|
android:text="Working Team *"
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
android:id="@+id/scrollView2"
|
android:id="@+id/scrollView2"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/btn_next"
|
app:layout_constraintBottom_toTopOf="@+id/btn_submit"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar">
|
app:layout_constraintTop_toBottomOf="@+id/toolbar">
|
||||||
|
@ -172,7 +172,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Name of Activity *"
|
android:text="Name of Activity *"
|
||||||
|
@ -87,10 +88,17 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ptw_heading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Activity Pictures "
|
android:text="Activity Pictures "
|
||||||
|
@ -98,8 +106,17 @@
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_upload"
|
||||||
|
android:layout_width="35dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_toRightOf="@+id/ptw_heading"
|
||||||
|
android:src="@drawable/img_upload" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/paperRecyclerView"
|
android:id="@+id/picturesRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
|
@ -116,7 +133,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description"
|
android:text="Description"
|
||||||
|
@ -150,7 +167,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -53,13 +53,14 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:padding="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/heading_description"
|
android:id="@+id/heading_description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Name of Activities *"
|
android:text="Name of Activities *"
|
||||||
|
@ -72,8 +73,8 @@
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="10dp"
|
||||||
android:hint="@string/select_activities"
|
android:hint="@string/select_activities"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
@ -87,10 +88,17 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ptw_heading"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Activity Pictures "
|
android:text="Activity Pictures "
|
||||||
|
@ -98,8 +106,17 @@
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_upload"
|
||||||
|
android:layout_width="35dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_toRightOf="@+id/ptw_heading"
|
||||||
|
android:src="@drawable/img_upload" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/paperRecyclerView"
|
android:id="@+id/picturesRecyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
|
@ -116,7 +133,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="left"
|
android:gravity="left"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:text="Description"
|
android:text="Description"
|
||||||
|
@ -150,7 +167,7 @@
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_next"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textSize="@dimen/_13sdp"
|
android:textSize="@dimen/_13sdp"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:text="Draft List"
|
android:text="List"
|
||||||
android:textAlignment="center" />
|
android:textAlignment="center" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
@ -1,25 +1,41 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="170dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="170dp"
|
||||||
android:layout_margin="3dp"
|
android:layout_margin="3dp"
|
||||||
|
android:background="@color/grey_200"
|
||||||
android:background="@color/green100"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<!--<Button
|
||||||
android:id="@+id/btnDelete"
|
android:id="@+id/btnDelete"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/rounded_btn_login"
|
android:background="@drawable/rounded_btn_login"
|
||||||
android:text="Delete" />
|
android:text="Delete" />-->
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/imageView"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="140dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/icon_image" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnDelete"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top|end"
|
||||||
|
android:background="@drawable/circle_background"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:src="@drawable/ic_close" />
|
||||||
|
|
||||||
|
<!--<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="160dp"
|
android:layout_height="160dp"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />-->
|
||||||
|
|
||||||
<TextView
|
<!--<TextView
|
||||||
android:id="@+id/docTypeTitle"
|
android:id="@+id/docTypeTitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -31,6 +47,6 @@
|
||||||
android:background="@color/grey_400"
|
android:background="@color/grey_400"
|
||||||
android:text="Delivery Challan"
|
android:text="Delivery Challan"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:padding="5dp"/>
|
android:padding="5dp"/>-->
|
||||||
|
|
||||||
</LinearLayout>
|
</FrameLayout>
|
Loading…
Reference in New Issue