Feedbacks implemented

master
saad.siddiq 2025-07-14 16:48:28 +05:00
parent ab19987540
commit 602a07d651
26 changed files with 2829 additions and 1764 deletions

View File

@ -23,17 +23,21 @@
<application
android:name=".utils.HSEManagement"
android:allowBackup="true"
android:allowClearUserData="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:hardwareAccelerated="true"
android:icon="@drawable/hse_login"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HSEObservationsApp"
android:allowClearUserData="true"
android:usesCleartextTraffic="true"
android:hardwareAccelerated="true"
tools:targetApi="31">
<activity
android:name=".activities.ProgressiveActivityForms.ProgressiveTwoActivity"
android:screenOrientation="portrait"
android:exported="false" />
<activity
android:name=".activities.ObservationForms.ObservationNearMissActivity"
android:exported="false" />
@ -66,13 +70,14 @@
<activity
android:name=".activities.InjuryRecordForms.InjuryFormThree"
android:exported="false"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activities.InjuryRecordForms.InjuryFormTwo"
android:name=".activities.InjuryRecordForms.InjuryFormOne"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".activities.InjuryRecordForms.InjuryFormOne"
android:name=".activities.InjuryRecordForms.InjuryFormTwo"
android:exported="false"
android:screenOrientation="portrait" />
<activity
@ -87,8 +92,8 @@
<activity
android:name=".activities.PermitToWorkForms.PermitTwoActivity"
android:exported="false"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".activities.PermitToWorkForms.PermitOneActivity"
android:exported="false"

View File

@ -21,6 +21,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
@ -150,13 +151,21 @@ public class HseOneActivity extends AppCompatActivity {
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
alertExit(HseOneActivity.this);
}
});
}
@Override
/*@Override
public void onBackPressed() {
alertExit(HseOneActivity.this);
}
}*/
private void initializeLayouts() {
imgBack = findViewById(R.id.img_back);

View File

@ -21,11 +21,13 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
@ -85,6 +87,9 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
ImageView imgUpload;
private CheckBox checkboxClassRoom, checkboxOnFloor;
String sessionType = "";
// Activity Result Launcher for Gallery
private final ActivityResultLauncher<Intent> imagePickerLauncher =
registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
@ -98,13 +103,6 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
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 = imageList.size();
imageList.add(compressedImage);
@ -146,14 +144,6 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
imageBytes -> {
this.runOnUiThread(() -> {
/*DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
docTypeId,
docTypeTitle,
imageBytes
);*/
//Log.e("doc-image: ",""+ documentImage);
int position = imageList.size();
imageList.add(imageBytes);
imagePaperAdapter.notifyItemInserted(position);
@ -205,6 +195,28 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
}
});
checkboxClassRoom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (checkboxClassRoom.isChecked()) {
checkboxOnFloor.setChecked(false);
sessionType = "ClassRoomSession";
StorageManager.getInstance().getHseTrainingModel().get(0).setTrainingType("ClassRoomSession");
}
}
});
checkboxOnFloor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (checkboxOnFloor.isChecked()) {
checkboxClassRoom.setChecked(false);
sessionType = "OnFloorSession";
StorageManager.getInstance().getHseTrainingModel().get(0).setTrainingType("OnFloorSession");
}
}
});
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -222,7 +234,16 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
StorageManager.getInstance().getHseTrainingModel().get(0).setPictures(imageList);
finish();
}
});
}
private void initializeLayouts() {
@ -230,6 +251,8 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
imgBack = findViewById(R.id.img_back);
imgUpload = findViewById(R.id.img_upload);
checkboxClassRoom = findViewById(R.id.checkbox_classroom);
checkboxOnFloor = findViewById(R.id.checkbox_onfloor);
trainingPicRecyclerView = findViewById(R.id.tPicturesRecyclerView);
@ -351,6 +374,11 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
boolean returnValue = true;
String message = "";
if (sessionType == null || sessionType.isEmpty()) {
message = "Please select Type of Training.";
returnValue = false;
}
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
@ -666,5 +694,13 @@ public class HseTwoActivity extends AppCompatActivity implements EasyPermissions
trainingPicRecyclerView.setAdapter(imagePaperAdapter);
}
if (StorageManager.getInstance().getHseTrainingModel().get(0).getTrainingType() != null
&& StorageManager.getInstance().getHseTrainingModel().get(0).getTrainingType().equals("ClassRoomSession")) {
checkboxClassRoom.setChecked(true);
} else if (StorageManager.getInstance().getHseTrainingModel().get(0).getTrainingType() != null
&& StorageManager.getInstance().getHseTrainingModel().get(0).getTrainingType().equals("OnFloorSession")) {
checkboxOnFloor.setChecked(true);
}
}
}

View File

@ -5,46 +5,80 @@ import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.lifecycle.ViewModelProvider;
import com.utopiaindustries.hseobservationsapp.R;
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
import com.utopiaindustries.hseobservationsapp.adapters.BodyPartAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.IncidentTypeAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.InjuryTypeAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.KpiAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.PersonalIllnessAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.ShiftAdapter;
import com.utopiaindustries.hseobservationsapp.helper.Helper;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseIncidentType;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjuredBodyPart;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjury;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjuryType;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseKpi;
import com.utopiaindustries.hseobservationsapp.models.HseData.Shift;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class InjuryFormOne extends AppCompatActivity {
Button btnNext, btnFetch;
LoginViewModel loginViewModel;
EditText etEmpId, etEmployeeName, etEmployeeDesignation, etEmployeeTenure, etDate, etEmployeeType;
TextView headingIllness;
Button btnNext;
ImageView imgBack;
private AutoCompleteTextView kpiTextview, incidentTypeTextview,
injuryTypeTextview, personalIllnessTextview, bodyPartTextview, riskTypeTextview ;
//private String kpi = "";
private String incidentType = "";
private ShiftAdapter shiftAdapter;
RadioGroup rg1;
RadioButton rbEmployee, rbDailyWage;
private KpiAdapter kpiAdapter;
private ArrayList<HseKpi> kpiArrayList = new ArrayList<>();
LinearLayout layoutEmployeeInfo, layoutDailyWageInfo;
EditText etLocationSite, etCnic, etContractorName, etDivision, etName;
TextView txtEmployeeHeading;
String workerType = "";
private ArrayList<HseIncidentType> incidentTypeArrayList = new ArrayList<>();
private IncidentTypeAdapter incidentTypeAdapter;
private ArrayList<Shift> riskTypeArrayList = new ArrayList<>();
private ShiftAdapter riskTypeAdapter;
private ArrayList<HseInjury> personalIllnessArrayList_temp = new ArrayList<>();
private ArrayList<HseInjury> personalIllnessArrayList = new ArrayList<>();
private PersonalIllnessAdapter personalIllnessAdapter;
private ArrayList<HseInjuryType> injuryTypeArrayList = new ArrayList<>();
private InjuryTypeAdapter injuryTypeAdapter;
//private ShiftAdapter injuryTypeAdapter;
private ArrayList<HseInjuredBodyPart> bodyPartArrayList = new ArrayList<>();
private BodyPartAdapter bodyPartAdapter;
String hseInjury = "";
LinearLayout layoutAccident, layoutInjury, layoutBodyParts;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -57,6 +91,22 @@ public class InjuryFormOne extends AppCompatActivity {
return insets;
});
//Type of injury --- Type of incidents
//Near Miss, Property Damage, Fire, RTA -- risk type dropdown(Major, minor)
//Pictures, description
//--------------------------------
//Personal illness -- Type of personal illness dropdown, risk dropdown(major minor),
// pictuers, description
//---------------------------------
//Accident -- Type of Accident, injury Type, body part dropdowns, risk dropdown(major minor),
// pictuers, description
//-----------------------------------
initializeLayouts();
imgBack.setOnClickListener(new View.OnClickListener() {
@ -66,38 +116,111 @@ public class InjuryFormOne extends AppCompatActivity {
}
});
btnFetch.setOnClickListener(new View.OnClickListener() {
/*kpiTextview.setOnItemClickListener((v, position, id, item) -> {
kpi = kpiArrayList.get(id).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setKpiId(kpiArrayList.get(id).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setKpiName(kpi);
});*/
incidentTypeTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onClick(View v) {
if (!etEmpId.getText().toString().isEmpty()) {
if (workerType.equalsIgnoreCase("Visitor")) {
/*if (etEmpId.getText().toString().isEmpty()) {
Toast.makeText(InjuryFormOne.this, "Please enter visitor id", Toast.LENGTH_SHORT).show();
return;
}*/
loginViewModel.getDailyWageWorkerData(etEmpId.getText().toString());
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("DailyWageWorker");
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
HseIncidentType clickedItem = incidentTypeArrayList.get(position);
incidentType = clickedItem.getTitle();
int selectedId = clickedItem.getId();
StorageManager.getInstance().getInjuryRecordModel().get(0).setIncidentId(selectedId);
StorageManager.getInstance().getInjuryRecordModel().get(0).setIncidentName(clickedItem.getTitle());
//clear old values
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryName("");
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeName("");
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartName("");
//Near Miss = 1, Property Damage = 2, Fire = 5, RTA = 6
//Personal Illness = 4
//Accident = 3
//
switch (selectedId) {
case 1:
case 2:
case 5:
case 6:
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.GONE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case 3:
headingIllness.setText("Type Of Accident *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.VISIBLE);
layoutBodyParts.setVisibility(View.VISIBLE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case 4:
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
default:
headingIllness.setText("Type of Personal illness *");
}
else {
/*if (etEmpId.getText().toString().isEmpty()) {
Toast.makeText(InjuryFormOne.this, "Please enter employee id", Toast.LENGTH_SHORT).show();
return;
}*/
loginViewModel.getEmployeeData(etEmpId.getText().toString());
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
personalIllnessTextview.setText(null);
if (!personalIllnessArrayList_temp.isEmpty()) {
List<HseInjury> filteredUnitItems = personalIllnessArrayList_temp.stream()
.filter(item -> Objects.equals(item.getIncidentId(), clickedItem.getId()))
.collect(Collectors.toList());
personalIllnessArrayList.clear();
personalIllnessArrayList.addAll(filteredUnitItems);
personalIllnessAdapter = new PersonalIllnessAdapter(InjuryFormOne.this, filteredUnitItems);
personalIllnessTextview.setAdapter(personalIllnessAdapter);
}
}
else {
Toast.makeText(InjuryFormOne.this, "Please enter id", Toast.LENGTH_SHORT).show();
}
});
personalIllnessTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
hseInjury = personalIllnessArrayList.get(position).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryId(personalIllnessArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryName(personalIllnessArrayList.get(position).getTitle());
}
});
riskTypeTextview.setOnItemClickListener((v, position, id, item) -> {
StorageManager.getInstance().getInjuryRecordModel().get(0).setRiskLevel(riskTypeArrayList.get(id).getTitle());
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isValidate()) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerId(Integer.parseInt(etEmpId.getText().toString()));
Intent intent = new Intent(InjuryFormOne.this, InjuryFormTwo.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
@ -106,28 +229,192 @@ public class InjuryFormOne extends AppCompatActivity {
}
});
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.rb_employee) {
layoutEmployeeInfo.setVisibility(View.VISIBLE);
layoutDailyWageInfo.setVisibility(View.GONE);
txtEmployeeHeading.setText("Employee ID Number *");
etEmpId.setText("");
workerType = "Employee";
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
} else if (checkedId == R.id.rb_dailyWage) {
layoutEmployeeInfo.setVisibility(View.GONE);
layoutDailyWageInfo.setVisibility(View.VISIBLE);
txtEmployeeHeading.setText("Visitor ID *");
etEmpId.setText("");
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("DailyWageWorker");
workerType = "Visitor";
injuryTypeTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeId(injuryTypeArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeName(injuryTypeArrayList.get(position).getTitle());
}
});
bodyPartTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartId(bodyPartArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartName(bodyPartArrayList.get(position).getTitle());
}
});
}
private void initializeLayouts() {
headingIllness = findViewById(R.id.heading_illness);
btnNext = findViewById(R.id.btn_next);
imgBack = findViewById(R.id.img_back);
// kpiTextview = findViewById(R.id.kpi_textview);
injuryTypeTextview = findViewById(R.id.injury_type_textview);
incidentTypeTextview = findViewById(R.id.incident_type_textview);
riskTypeTextview = findViewById(R.id.risk_type_textview);
personalIllnessTextview = findViewById(R.id.personal_illness_textview);
bodyPartTextview = findViewById(R.id.body_part_textview);
layoutAccident = findViewById(R.id.layout_accident);
layoutInjury = findViewById(R.id.layout_injury);
layoutBodyParts = findViewById(R.id.layout_body_parts);
showLayouts();
//kpi -----------
/*kpiArrayList.addAll(Helper.getList(Helper.hseKpis, this, HseKpi.class));
kpiAdapter = new KpiAdapter(this, kpiArrayList);
kpiTextview.setAdapter(kpiAdapter);*/
//incident type ------------
incidentTypeArrayList.addAll(Helper.getList(Helper.hseIncidentTypes, this, HseIncidentType.class));
incidentTypeAdapter = new IncidentTypeAdapter(this, incidentTypeArrayList);
incidentTypeTextview.setAdapter(incidentTypeAdapter);
//personal illness -----------
personalIllnessArrayList_temp.addAll(Helper.getList(Helper.hseInjuries, this, HseInjury.class));
//Injury Type
injuryTypeArrayList.addAll(Helper.getList(Helper.hseInjuryTypes, this, HseInjuryType.class));
injuryTypeAdapter = new InjuryTypeAdapter(this, injuryTypeArrayList);
injuryTypeTextview.setAdapter(injuryTypeAdapter);
//body part
bodyPartArrayList.addAll(Helper.getList(Helper.hseInjuredBodyPart, this, HseInjuredBodyPart.class));
bodyPartAdapter = new BodyPartAdapter(this, bodyPartArrayList);
bodyPartTextview.setAdapter(bodyPartAdapter);
//risk type
riskTypeArrayList.add(new Shift(1, "Major"));
riskTypeArrayList.add(new Shift(2, "Minor"));
riskTypeAdapter = new ShiftAdapter(this, riskTypeArrayList);
riskTypeTextview.setAdapter(riskTypeAdapter);
}
@Override
protected void onResume() {
super.onResume();
/*if (StorageManager.getInstance().getInjuryRecordModel() != null && !StorageManager.getInstance().getInjuryRecordModel().isEmpty()) {
showPersistData();
}*/
}
public boolean isValidate() {
boolean returnValue = true;
String message = "";
if (incidentType == null || incidentType.isEmpty()) {
message = "Please select incident type.";
returnValue = false;
}
/*if (kpi == null || kpi.isEmpty()) {
message = "Please select KPI.";
returnValue = false;
}*/
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
return returnValue;
}
private void showPersistData() {
// kpiTextview.post(() -> kpiTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getKpiName(), false));
//kpi = StorageManager.getInstance().getInjuryRecordModel().get(0).getKpiName();
incidentTypeTextview.post(() -> incidentTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName(), false));
incidentType = StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName();
personalIllnessTextview.post(() -> personalIllnessTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getInjuryName(), false));
injuryTypeTextview.post(() -> injuryTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getInjuryTypeName(), false));
bodyPartTextview.post(() -> bodyPartTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getBodyPartName(), false));
riskTypeTextview.post(() -> riskTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getRiskLevel(), false));
showLayouts();
if (!personalIllnessArrayList_temp.isEmpty()) {
List<HseInjury> filteredUnitItems = personalIllnessArrayList_temp.stream()
.filter(item -> Objects.equals(item.getIncidentId(), StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentId()))
.collect(Collectors.toList());
personalIllnessArrayList.clear();
personalIllnessArrayList.addAll(filteredUnitItems);
personalIllnessAdapter = new PersonalIllnessAdapter(InjuryFormOne.this, filteredUnitItems);
personalIllnessTextview.setAdapter(personalIllnessAdapter);
}
}
private void showLayouts() {
if (StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName() != null
&& !StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName().isEmpty()) {
switch (StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName()) {
case "Near Miss":
case "Property Damage":
case "RTA":
case "Fire":
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.GONE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case "Accident":
headingIllness.setText("Type Of Accident *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.VISIBLE);
layoutBodyParts.setVisibility(View.VISIBLE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case "Personal Illness":
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
default:
headingIllness.setText("Type of Personal illness *");
}
}
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
alertExit(InjuryFormOne.this);
}
});
}
/*@Override
public void onBackPressed() {
alertExit(InjuryFormOne.this);
}*/
public void alertExit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
@ -167,146 +454,4 @@ public class InjuryFormOne extends AppCompatActivity {
alertDialog.show();
}
private void initializeLayouts() {
btnNext = findViewById(R.id.btn_next);
btnFetch = findViewById(R.id.btn_fetch);
etEmpId = findViewById(R.id.et_employee_id_number);
layoutEmployeeInfo = findViewById(R.id.layout_employee_info);
layoutDailyWageInfo = findViewById(R.id.layout_dailyWage_info);
layoutEmployeeInfo.setVisibility(View.VISIBLE);
layoutDailyWageInfo.setVisibility(View.GONE);
workerType = "Employee";
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
txtEmployeeHeading = findViewById(R.id.txt_employee_heading);
etEmployeeName = findViewById(R.id.et_employee_name);
etEmployeeDesignation = findViewById(R.id.et_employee_designation);
etEmployeeTenure = findViewById(R.id.et_employee_tenure);
imgBack = findViewById(R.id.img_back);
etEmployeeType = findViewById(R.id.et_employee_type);
etDate = findViewById(R.id.et_date);
etLocationSite = findViewById(R.id.et_location_site);
etCnic = findViewById(R.id.et_cnic);
etContractorName = findViewById(R.id.et_contractor_name);
etDivision = findViewById(R.id.et_division);
etName = findViewById(R.id.et_name);
rg1 = findViewById(R.id.rg1);
rbEmployee = findViewById(R.id.rb_employee);
rbDailyWage = findViewById(R.id.rb_dailyWage);
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
loginViewModel.getLoadingState().observe(this, isLoading -> {
if (isLoading != null && isLoading) {
showProgressDialog();
} else {
dismissProgressDialog();
}
});
loginViewModel.getErrorMessage().observe(this, errorResponse -> {
if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
});
loginViewModel.getEmployeeLiveData().observe(this, employeeInfoResponse -> {
if (employeeInfoResponse != null) {
Log.e("Employee-Info: ",""+employeeInfoResponse.toString());
if (employeeInfoResponse.getWorkerType() != null) {
etEmployeeName.setText(employeeInfoResponse.getFullName());
etEmployeeDesignation.setText(employeeInfoResponse.getPositionTitle());
etEmployeeTenure.setText(employeeInfoResponse.getEmployeeTenure());
etDate.setText(employeeInfoResponse.getJoiningDate());
etEmployeeType.setText(employeeInfoResponse.getWorkerType());
}
else {
Toast.makeText(this, "Record not found", Toast.LENGTH_SHORT).show();
etEmpId.setText("");
}
}
});
loginViewModel.getDailyWageLiveData().observe(this, dailyWageInfoResponse -> {
if (dailyWageInfoResponse != null) {
Log.e("Daily-Wage-Info: ",""+dailyWageInfoResponse.toString());
if (dailyWageInfoResponse.getLocationSite() != null) {
etName.setText(dailyWageInfoResponse.getName());
etLocationSite.setText(dailyWageInfoResponse.getLocationSite());
etCnic.setText(dailyWageInfoResponse.getCnic());
etContractorName.setText(dailyWageInfoResponse.getContractorName());
etDivision.setText(dailyWageInfoResponse.getDivisionDepartment());
}
else {
Toast.makeText(this, "Record not found", Toast.LENGTH_SHORT).show();
etEmpId.setText("");
}
}
});
}
@Override
public void onBackPressed() {
alertExit(InjuryFormOne.this);
}
public void showProgressDialog() {
ProgressDialogFragment progressDialog = new ProgressDialogFragment();
progressDialog.setCancelable(false);
progressDialog.show(getSupportFragmentManager(), "progressDialog");
}
public void dismissProgressDialog() {
ProgressDialogFragment progressDialog = (ProgressDialogFragment)
getSupportFragmentManager().findFragmentByTag("progressDialog");
if (progressDialog != null) {
progressDialog.dismiss();
}
}
public boolean isValidate() {
boolean returnValue = true;
String message = "";
if (workerType.equalsIgnoreCase("Visitor")) {
if (etName.getText().toString().isEmpty()) {
message = "Fetch Record First.";
returnValue = false;
}
}
if (workerType.equalsIgnoreCase("Employee")) {
if (etEmployeeName.getText().toString().isEmpty()) {
message = "Fetch Record First.";
returnValue = false;
}
}
if (etEmpId.getText().toString().isEmpty()) {
message = "ID is required.";
returnValue = false;
}
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
return returnValue;
}
}

View File

@ -24,6 +24,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
@ -31,6 +33,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
@ -44,14 +47,14 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.utopiaindustries.hseobservationsapp.R;
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationTwoActivity;
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.SafetyTrainingAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.ShiftAdapter;
import com.utopiaindustries.hseobservationsapp.helper.Helper;
import com.utopiaindustries.hseobservationsapp.helper.Preference;
import com.utopiaindustries.hseobservationsapp.models.HseData.Shift;
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.HseReportRequest;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.InjuryRecordModel;
@ -85,8 +88,13 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
private static final int GALLERY_REQUEST = 2010;
ImageView imgUpload, imgBack;
Button btnNext;
EditText etDescription;
EditText etDescription, etRootCause;
LoginViewModel loginViewModel;
AutoCompleteTextView actionTakenTextview, statusAfterFirstAidTextview;
private ShiftAdapter actionTakenAdapter, statusAfterAdapter;
private ArrayList<Shift> actionTakenArrayList = new ArrayList<>();
private ArrayList<Shift> statusAfterArrayList = new ArrayList<>();
String actionTaken = "", statusAfter = "";
// Activity Result Launcher for Gallery
private final ActivityResultLauncher<Intent> imagePickerLauncher =
@ -101,13 +109,6 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
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(compressedImage);
@ -149,14 +150,6 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
imageBytes -> {
this.runOnUiThread(() -> {
/*DocumentTypeImageModel documentImage = new DocumentTypeImageModel(
docTypeId,
docTypeTitle,
imageBytes
);*/
//Log.e("doc-image: ",""+ documentImage);
int position = PaperImageList.size();
PaperImageList.add(imageBytes);
imagePaperAdapter.notifyItemInserted(position);
@ -203,6 +196,7 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
imgBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setPictures(PaperImageList);
finish();
}
});
@ -211,7 +205,6 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
@Override
public void onClick(View v) {
if (isValidate()) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setPictures(PaperImageList);
//Log.e("PaperImageList-size: ",""+PaperImageList.size());
//Log.e("Storage-Size: ",""+StorageManager.getInstance().getInjuryRecordModel().get(0).getPictures().size());
// Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
@ -236,8 +229,56 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
}
});
etRootCause.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setRootCause(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
actionTakenTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
actionTaken = actionTakenArrayList.get(position).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setActionTaken(actionTaken);
}
});
statusAfterFirstAidTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
statusAfter = statusAfterArrayList.get(position).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setStatusAfterFirstAid(statusAfter);
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
StorageManager.getInstance().getInjuryRecordModel().get(0).setPictures(PaperImageList);
finish();
}
});
}
/*@Override
public void onBackPressed() {
StorageManager.getInstance().getInjuryRecordModel().get(0).setPictures(PaperImageList);
finish();
}*/
public void alertReportSubmit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
@ -307,6 +348,9 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
etDescription = findViewById(R.id.et_description);
etDescription.setImeOptions(EditorInfo.IME_ACTION_DONE);
etDescription.setRawInputType(InputType.TYPE_CLASS_TEXT);
etRootCause = findViewById(R.id.et_rootCause);
actionTakenTextview = findViewById(R.id.action_taken_textview);
statusAfterFirstAidTextview = findViewById(R.id.status_after_textview);
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
@ -344,9 +388,26 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
}
});
//Images
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
picturesRecyclerView.setAdapter(imagePaperAdapter);
//Action Taken
actionTakenArrayList.add(new Shift(1, "First Aid Given"));
actionTakenArrayList.add(new Shift(2, "Check Vitals"));
actionTakenArrayList.add(new Shift(3, "Refer To Hospital"));
actionTakenAdapter = new ShiftAdapter(this, actionTakenArrayList);
actionTakenTextview.setAdapter(actionTakenAdapter);
//Status After First Aid
statusAfterArrayList.add(new Shift(1, "Refer To Hospital"));
statusAfterArrayList.add(new Shift(2, "Back To Work"));
statusAfterAdapter = new ShiftAdapter(this, statusAfterArrayList);
statusAfterFirstAidTextview.setAdapter(statusAfterAdapter);
}
@SuppressLint("MissingInflatedId")
@ -681,6 +742,21 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
returnValue = false;
}
if (statusAfter.isEmpty()) {
message = "Please select Status After First Aid.";
returnValue = false;
}
if (actionTaken.isEmpty()) {
message = "Please select Action Taken.";
returnValue = false;
}
if (etRootCause.getText().toString().isEmpty()) {
message = "Please enter Root Cause.";
returnValue = false;
}
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
@ -713,6 +789,9 @@ public class InjuryFormThree extends AppCompatActivity implements EasyPermission
}
private void showPersistData() {
etRootCause.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getRootCause());
actionTakenTextview.post(() -> actionTakenTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getActionTaken(), false));
statusAfterFirstAidTextview.post(() -> statusAfterFirstAidTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getStatusAfterFirstAid(), false));
etDescription.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getDescription());
if (StorageManager.getInstance().getInjuryRecordModel().get(0).getPictures() != null

View File

@ -1,78 +1,51 @@
package com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.lifecycle.ViewModelProvider;
import com.utopiaindustries.hseobservationsapp.R;
import com.utopiaindustries.hseobservationsapp.adapters.BodyPartAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.IncidentTypeAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.InjuryTypeAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.KpiAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.PersonalIllnessAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.ShiftAdapter;
import com.utopiaindustries.hseobservationsapp.helper.Helper;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseIncidentType;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjuredBodyPart;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjury;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseInjuryType;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseKpi;
import com.utopiaindustries.hseobservationsapp.models.HseData.Shift;
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
public class InjuryFormTwo extends AppCompatActivity {
TextView headingIllness;
Button btnNext;
Button btnNext, btnFetch;
LoginViewModel loginViewModel;
EditText etEmpId, etEmployeeName, etEmployeeDesignation, etEmployeeTenure, etDate, etEmployeeType;
ImageView imgBack;
private AutoCompleteTextView kpiTextview, incidentTypeTextview,
injuryTypeTextview, personalIllnessTextview, bodyPartTextview, riskTypeTextview ;
private String kpi = "";
private String incidentType = "";
private ShiftAdapter shiftAdapter;
private KpiAdapter kpiAdapter;
private ArrayList<HseKpi> kpiArrayList = new ArrayList<>();
RadioGroup rg1;
RadioButton rbEmployee, rbDailyWage;
private ArrayList<HseIncidentType> incidentTypeArrayList = new ArrayList<>();
private IncidentTypeAdapter incidentTypeAdapter;
private ArrayList<Shift> riskTypeArrayList = new ArrayList<>();
private ShiftAdapter riskTypeAdapter;
private ArrayList<HseInjury> personalIllnessArrayList_temp = new ArrayList<>();
private ArrayList<HseInjury> personalIllnessArrayList = new ArrayList<>();
private PersonalIllnessAdapter personalIllnessAdapter;
private ArrayList<HseInjuryType> injuryTypeArrayList = new ArrayList<>();
private InjuryTypeAdapter injuryTypeAdapter;
//private ShiftAdapter injuryTypeAdapter;
private ArrayList<HseInjuredBodyPart> bodyPartArrayList = new ArrayList<>();
private BodyPartAdapter bodyPartAdapter;
String hseInjury = "";
LinearLayout layoutAccident, layoutInjury, layoutBodyParts;
LinearLayout layoutEmployeeInfo, layoutDailyWageInfo;
EditText etLocationSite, etCnic, etContractorName, etDivision, etName;
TextView txtEmployeeHeading;
String workerType = "";
boolean isFromPersist = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -85,136 +58,40 @@ public class InjuryFormTwo extends AppCompatActivity {
return insets;
});
//Type of injury --- Type of incidents
//Near Miss, Property Damage, Fire, RTA -- risk type dropdown(Major, minor)
//Pictures, description
//--------------------------------
//Personal illness -- Type of personal illness dropdown, risk dropdown(major minor),
// pictuers, description
//---------------------------------
//Accident -- Type of Accident, injury Type, body part dropdowns, risk dropdown(major minor),
// pictuers, description
//-----------------------------------
initializeLayouts();
imgBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// alertExit(InjuryFormOne.this);
finish();
}
});
kpiTextview.setOnItemClickListener((v, position, id, item) -> {
kpi = kpiArrayList.get(id).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setKpiId(kpiArrayList.get(id).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setKpiName(kpi);
});
incidentTypeTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
btnFetch.setOnClickListener(new View.OnClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
HseIncidentType clickedItem = incidentTypeArrayList.get(position);
incidentType = clickedItem.getTitle();
int selectedId = clickedItem.getId();
StorageManager.getInstance().getInjuryRecordModel().get(0).setIncidentId(selectedId);
StorageManager.getInstance().getInjuryRecordModel().get(0).setIncidentName(clickedItem.getTitle());
//clear old values
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryName("");
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeName("");
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartId(0);
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartName("");
//Near Miss = 1, Property Damage = 2, Fire = 5, RTA = 6
//Personal Illness = 4
//Accident = 3
//
switch (selectedId) {
case 1:
case 2:
case 5:
case 6:
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.GONE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case 3:
headingIllness.setText("Type Of Accident *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.VISIBLE);
layoutBodyParts.setVisibility(View.VISIBLE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case 4:
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
default:
headingIllness.setText("Type of Personal illness *");
public void onClick(View v) {
if (!etEmpId.getText().toString().isEmpty()) {
if (workerType.equalsIgnoreCase("Visitor")) {
loginViewModel.getDailyWageWorkerData(etEmpId.getText().toString());
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("DailyWageWorker");
}
personalIllnessTextview.setText(null);
if (!personalIllnessArrayList_temp.isEmpty()) {
List<HseInjury> filteredUnitItems = personalIllnessArrayList_temp.stream()
.filter(item -> Objects.equals(item.getIncidentId(), clickedItem.getId()))
.collect(Collectors.toList());
personalIllnessArrayList.clear();
personalIllnessArrayList.addAll(filteredUnitItems);
personalIllnessAdapter = new PersonalIllnessAdapter(InjuryFormTwo.this, filteredUnitItems);
personalIllnessTextview.setAdapter(personalIllnessAdapter);
else {
loginViewModel.getEmployeeData(etEmpId.getText().toString());
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
}
}
});
personalIllnessTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
hseInjury = personalIllnessArrayList.get(position).getTitle();
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryId(personalIllnessArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryName(personalIllnessArrayList.get(position).getTitle());
else {
Toast.makeText(InjuryFormTwo.this, "Please enter id", Toast.LENGTH_SHORT).show();
}
}
});
riskTypeTextview.setOnItemClickListener((v, position, id, item) -> {
StorageManager.getInstance().getInjuryRecordModel().get(0).setRiskLevel(riskTypeArrayList.get(id).getTitle());
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isValidate()) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerId(Integer.parseInt(etEmpId.getText().toString()));
Intent intent = new Intent(InjuryFormTwo.this, InjuryFormThree.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
@ -223,92 +100,234 @@ public class InjuryFormTwo extends AppCompatActivity {
}
});
injuryTypeTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.rb_employee) {
layoutEmployeeInfo.setVisibility(View.VISIBLE);
layoutDailyWageInfo.setVisibility(View.GONE);
txtEmployeeHeading.setText("Employee ID Number *");
if (!isFromPersist) {
etEmpId.setText("");
}
workerType = "Employee";
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
} else if (checkedId == R.id.rb_dailyWage) {
layoutEmployeeInfo.setVisibility(View.GONE);
layoutDailyWageInfo.setVisibility(View.VISIBLE);
txtEmployeeHeading.setText("Visitor ID *");
if (!isFromPersist) {
etEmpId.setText("");
}
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("DailyWageWorker");
workerType = "Visitor";
}
}
});
}
public void alertExit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
TextView dialogOkBtn, dialogCancelBtn;
AlertDialog.Builder builder = new AlertDialog.Builder(con);
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_exit, viewGroup, false);
builder.setCancelable(false);
builder.setView(view1);
dialogOkBtn = view1.findViewById(R.id.dialogOkBtn);
dialogCancelBtn = view1.findViewById(R.id.dialogCancelBtn);
AlertDialog alertDialog = builder.create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialogOkBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeId(injuryTypeArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setInjuryTypeName(injuryTypeArrayList.get(position).getTitle());
public void onClick(View view) {
alertDialog.dismiss();
StorageManager.getInstance().clearInjuryRecordModule();
finish();
}
});
bodyPartTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
dialogCancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartId(bodyPartArrayList.get(position).getId());
StorageManager.getInstance().getInjuryRecordModel().get(0).setBodyPartName(bodyPartArrayList.get(position).getTitle());
public void onClick(View view) {
alertDialog.dismiss();
}
});
alertDialog.show();
}
private void initializeLayouts() {
headingIllness = findViewById(R.id.heading_illness);
btnNext = findViewById(R.id.btn_next);
btnFetch = findViewById(R.id.btn_fetch);
etEmpId = findViewById(R.id.et_employee_id_number);
layoutEmployeeInfo = findViewById(R.id.layout_employee_info);
layoutDailyWageInfo = findViewById(R.id.layout_dailyWage_info);
layoutEmployeeInfo.setVisibility(View.VISIBLE);
layoutDailyWageInfo.setVisibility(View.GONE);
workerType = "Employee";
txtEmployeeHeading = findViewById(R.id.txt_employee_heading);
etEmployeeName = findViewById(R.id.et_employee_name);
etEmployeeDesignation = findViewById(R.id.et_employee_designation);
etEmployeeTenure = findViewById(R.id.et_employee_tenure);
imgBack = findViewById(R.id.img_back);
kpiTextview = findViewById(R.id.kpi_textview);
injuryTypeTextview = findViewById(R.id.injury_type_textview);
incidentTypeTextview = findViewById(R.id.incident_type_textview);
riskTypeTextview = findViewById(R.id.risk_type_textview);
personalIllnessTextview = findViewById(R.id.personal_illness_textview);
bodyPartTextview = findViewById(R.id.body_part_textview);
etEmployeeType = findViewById(R.id.et_employee_type);
etDate = findViewById(R.id.et_date);
layoutAccident = findViewById(R.id.layout_accident);
layoutInjury = findViewById(R.id.layout_injury);
layoutBodyParts = findViewById(R.id.layout_body_parts);
etLocationSite = findViewById(R.id.et_location_site);
etCnic = findViewById(R.id.et_cnic);
etContractorName = findViewById(R.id.et_contractor_name);
etDivision = findViewById(R.id.et_division);
etName = findViewById(R.id.et_name);
showLayouts();
rg1 = findViewById(R.id.rg1);
rbEmployee = findViewById(R.id.rb_employee);
rbDailyWage = findViewById(R.id.rb_dailyWage);
//kpi -----------
kpiArrayList.addAll(Helper.getList(Helper.hseKpis, this, HseKpi.class));
kpiAdapter = new KpiAdapter(this, kpiArrayList);
kpiTextview.setAdapter(kpiAdapter);
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
//incident type ------------
incidentTypeArrayList.addAll(Helper.getList(Helper.hseIncidentTypes, this, HseIncidentType.class));
incidentTypeAdapter = new IncidentTypeAdapter(this, incidentTypeArrayList);
incidentTypeTextview.setAdapter(incidentTypeAdapter);
loginViewModel.getLoadingState().observe(this, isLoading -> {
//personal illness -----------
personalIllnessArrayList_temp.addAll(Helper.getList(Helper.hseInjuries, this, HseInjury.class));
//Injury Type
injuryTypeArrayList.addAll(Helper.getList(Helper.hseInjuryTypes, this, HseInjuryType.class));
injuryTypeAdapter = new InjuryTypeAdapter(this, injuryTypeArrayList);
injuryTypeTextview.setAdapter(injuryTypeAdapter);
//body part
bodyPartArrayList.addAll(Helper.getList(Helper.hseInjuredBodyPart, this, HseInjuredBodyPart.class));
bodyPartAdapter = new BodyPartAdapter(this, bodyPartArrayList);
bodyPartTextview.setAdapter(bodyPartAdapter);
//risk type
riskTypeArrayList.add(new Shift(1, "Major"));
riskTypeArrayList.add(new Shift(2, "Minor"));
riskTypeAdapter = new ShiftAdapter(this, riskTypeArrayList);
riskTypeTextview.setAdapter(riskTypeAdapter);
if (isLoading != null && isLoading) {
showProgressDialog();
} else {
dismissProgressDialog();
}
});
loginViewModel.getErrorMessage().observe(this, errorResponse -> {
if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
});
loginViewModel.getEmployeeLiveData().observe(this, employeeInfoResponse -> {
if (employeeInfoResponse != null) {
Log.e("Employee-Info: ",""+employeeInfoResponse.toString());
if (employeeInfoResponse.getWorkerType() != null) {
etEmployeeName.setText(employeeInfoResponse.getFullName());
StorageManager.getInstance().getInjuryRecordModel().get(0).setEmployeeFullName(employeeInfoResponse.getFullName());
etEmployeeDesignation.setText(employeeInfoResponse.getPositionTitle());
StorageManager.getInstance().getInjuryRecordModel().get(0).setEmployeePositionTitle(employeeInfoResponse.getPositionTitle());
etEmployeeTenure.setText(employeeInfoResponse.getEmployeeTenure());
StorageManager.getInstance().getInjuryRecordModel().get(0).setEmployeeTenure(employeeInfoResponse.getEmployeeTenure());
etDate.setText(employeeInfoResponse.getJoiningDate());
StorageManager.getInstance().getInjuryRecordModel().get(0).setEmployeeJoiningDate(employeeInfoResponse.getJoiningDate());
etEmployeeType.setText(employeeInfoResponse.getWorkerType());
StorageManager.getInstance().getInjuryRecordModel().get(0).setEmployeeWorkerType(employeeInfoResponse.getWorkerType());
}
else {
Toast.makeText(this, "Record not found", Toast.LENGTH_SHORT).show();
etEmpId.setText("");
}
}
});
loginViewModel.getDailyWageLiveData().observe(this, dailyWageInfoResponse -> {
if (dailyWageInfoResponse != null) {
Log.e("Daily-Wage-Info: ",""+dailyWageInfoResponse.toString());
if (dailyWageInfoResponse.getLocationSite() != null) {
etName.setText(dailyWageInfoResponse.getName());
StorageManager.getInstance().getInjuryRecordModel().get(0).setDailyWageWorkerName(dailyWageInfoResponse.getName());
etLocationSite.setText(dailyWageInfoResponse.getLocationSite());
StorageManager.getInstance().getInjuryRecordModel().get(0).setLocationSite(dailyWageInfoResponse.getLocationSite());
etCnic.setText(dailyWageInfoResponse.getCnic());
StorageManager.getInstance().getInjuryRecordModel().get(0).setCnic(dailyWageInfoResponse.getCnic());
etContractorName.setText(dailyWageInfoResponse.getContractorName());
StorageManager.getInstance().getInjuryRecordModel().get(0).setContractorName(dailyWageInfoResponse.getContractorName());
etDivision.setText(dailyWageInfoResponse.getDivisionDepartment());
StorageManager.getInstance().getInjuryRecordModel().get(0).setDivisionDepartment(dailyWageInfoResponse.getDivisionDepartment());
}
else {
Toast.makeText(this, "Record not found", Toast.LENGTH_SHORT).show();
etEmpId.setText("");
}
}
});
}
/*@Override
public void onBackPressed() {
alertExit(InjuryFormOne.this);
}*/
@Override
protected void onResume() {
super.onResume();
if (StorageManager.getInstance().getInjuryRecordModel() != null && !StorageManager.getInstance().getInjuryRecordModel().isEmpty()) {
if (StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerId() != 0) {
Log.e("Worker-Id: ",""+StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerId());
etEmpId.setText(String.valueOf(StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerId()));
}
showPersistData();
}
else {
StorageManager.getInstance().getInjuryRecordModel().get(0).setWorkerType("Employee/Contractor-Worker");
rbEmployee.setChecked(true);
}
}
public void showProgressDialog() {
ProgressDialogFragment progressDialog = new ProgressDialogFragment();
progressDialog.setCancelable(false);
progressDialog.show(getSupportFragmentManager(), "progressDialog");
}
public void dismissProgressDialog() {
ProgressDialogFragment progressDialog = (ProgressDialogFragment)
getSupportFragmentManager().findFragmentByTag("progressDialog");
if (progressDialog != null) {
progressDialog.dismiss();
}
}
public boolean isValidate() {
boolean returnValue = true;
String message = "";
if (incidentType == null || incidentType.isEmpty()) {
message = "Please select incident type.";
if (workerType.equalsIgnoreCase("Visitor")) {
if (etName.getText().toString().isEmpty()) {
message = "Fetch Record First.";
returnValue = false;
}
}
if (kpi == null || kpi.isEmpty()) {
message = "Please select KPI.";
if (workerType.equalsIgnoreCase("Employee")) {
if (etEmployeeName.getText().toString().isEmpty()) {
message = "Fetch Record First.";
returnValue = false;
}
}
if (etEmpId.getText().toString().isEmpty()) {
message = "ID is required.";
returnValue = false;
}
@ -320,78 +339,31 @@ public class InjuryFormTwo extends AppCompatActivity {
}
private void showPersistData() {
kpiTextview.post(() -> kpiTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getKpiName(), false));
kpi = StorageManager.getInstance().getInjuryRecordModel().get(0).getKpiName();
incidentTypeTextview.post(() -> incidentTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName(), false));
incidentType = StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName();
personalIllnessTextview.post(() -> personalIllnessTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getInjuryName(), false));
injuryTypeTextview.post(() -> injuryTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getInjuryTypeName(), false));
bodyPartTextview.post(() -> bodyPartTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getBodyPartName(), false));
riskTypeTextview.post(() -> riskTypeTextview.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getRiskLevel(), false));
showLayouts();
if (!personalIllnessArrayList_temp.isEmpty()) {
List<HseInjury> filteredUnitItems = personalIllnessArrayList_temp.stream()
.filter(item -> Objects.equals(item.getIncidentId(), StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentId()))
.collect(Collectors.toList());
personalIllnessArrayList.clear();
personalIllnessArrayList.addAll(filteredUnitItems);
personalIllnessAdapter = new PersonalIllnessAdapter(InjuryFormTwo.this, filteredUnitItems);
personalIllnessTextview.setAdapter(personalIllnessAdapter);
}
}
private void showLayouts() {
if (StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName() != null
&& !StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName().isEmpty()) {
switch (StorageManager.getInstance().getInjuryRecordModel().get(0).getIncidentName()) {
case "Near Miss":
case "Property Damage":
case "RTA":
case "Fire":
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.GONE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case "Accident":
headingIllness.setText("Type Of Accident *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.VISIBLE);
layoutBodyParts.setVisibility(View.VISIBLE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
case "Personal Illness":
headingIllness.setText("Type of Personal illness *");
layoutAccident.setVisibility(View.VISIBLE);
layoutInjury.setVisibility(View.GONE);
layoutBodyParts.setVisibility(View.GONE);
personalIllnessTextview.setText(null);
injuryTypeTextview.setText(null);
bodyPartTextview.setText(null);
break;
default:
headingIllness.setText("Type of Personal illness *");
Log.e("Worker-Type-1: ",""+StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType());
if (StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType() != null
&& StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType().equalsIgnoreCase("Employee/Contractor-Worker")) {
isFromPersist = true;
rbEmployee.setChecked(true);
layoutEmployeeInfo.setVisibility(View.VISIBLE);
layoutDailyWageInfo.setVisibility(View.GONE);
etEmployeeName.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getEmployeeFullName());
etEmployeeDesignation.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getEmployeePositionTitle());
etEmployeeTenure.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getEmployeeTenure());
etDate.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getEmployeeJoiningDate());
etEmployeeType.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType());
}
else if (StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType() != null
&& StorageManager.getInstance().getInjuryRecordModel().get(0).getWorkerType().equalsIgnoreCase("DailyWageWorker")){
isFromPersist = true;
rbDailyWage.setChecked(true);
layoutEmployeeInfo.setVisibility(View.GONE);
layoutDailyWageInfo.setVisibility(View.VISIBLE);
etName.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getDailyWageWorkerName());
etLocationSite.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getLocationSite());
etCnic.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getCnic());
etContractorName.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getContractorName());
etDivision.setText(StorageManager.getInstance().getInjuryRecordModel().get(0).getDivisionDepartment());
}
}
}

View File

@ -26,6 +26,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
@ -353,13 +354,21 @@ public class ObservationOneActivity extends AppCompatActivity implements EasyPer
StorageManager.getInstance().getObservationsModel().get(0).setHseObservationSubClassName(observationSubClass);
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
alertExit(ObservationOneActivity.this);
}
});
}
@Override
/*@Override
public void onBackPressed() {
alertExit(ObservationOneActivity.this);
}
}*/
public void alertExit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);

View File

@ -1,11 +1,14 @@
package com.utopiaindustries.hseobservationsapp.activities.PermitToWorkForms;
import android.annotation.SuppressLint;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -13,11 +16,13 @@ import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
@ -45,8 +50,11 @@ import com.utopiaindustries.hseobservationsapp.models.HseData.HsePtwType;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseWorkingTeam;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
@ -70,6 +78,9 @@ public class PermitOneActivity extends AppCompatActivity {
String ptwType = "", workingTeam = "";
private CheckBox checkboxCompany, checkboxContractor;
String workingParty = "";
EditText etStartTime, etEndTime;
ImageView imgStartTime, imgEndTime;
Calendar selectedDateTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -144,13 +155,41 @@ public class PermitOneActivity extends AppCompatActivity {
}
});
imgStartTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//StorageManager.getInstance().getPermitToWorkModel().get(0).setStartTime(etStartTime.getText().toString());
showDatePicker("StartTime");
}
});
imgEndTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDatePicker("EndTime");
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
alertExit(PermitOneActivity.this);
}
});
}
/*@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
alertExit(PermitOneActivity.this);
}
}*/
public void alertExit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
@ -194,6 +233,8 @@ public class PermitOneActivity extends AppCompatActivity {
private void initializeLayout() {
selectedDateTime = Calendar.getInstance();
btnNext = findViewById(R.id.btn_next);
imgBack = findViewById(R.id.img_back);
@ -203,6 +244,12 @@ public class PermitOneActivity extends AppCompatActivity {
ptwTypeTextView = findViewById(R.id.ptw_type_textview);
ptwTextInputLayout = findViewById(R.id.ptw_type_input);
etStartTime = findViewById(R.id.et_start_time);
etEndTime = findViewById(R.id.et_end_time);
imgStartTime = findViewById(R.id.img_start_time);
imgEndTime = findViewById(R.id.img_end_time);
ptwTypeTextView.setFocusable(false);
ptwTypeTextView.setCursorVisible(false);
ptwTypeTextView.setKeyListener(null); // disables keyboard
@ -237,6 +284,16 @@ public class PermitOneActivity extends AppCompatActivity {
returnValue = false;
}
if (etEndTime.getText().toString().isEmpty()) {
message = "Please select End Time.";
returnValue = false;
}
if (etStartTime.getText().toString().isEmpty()) {
message = "Please select Start Time.";
returnValue = false;
}
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
@ -256,13 +313,25 @@ public class PermitOneActivity extends AppCompatActivity {
builder.setPositiveButton("OK", (dialog, which) -> {
List<HsePtwType> selected = adapter.getSelectedItems();
if (selected.size() != 2) {
Toast.makeText(this, "Please select exactly 2 items", Toast.LENGTH_SHORT).show();
if (selected.isEmpty() || selected.size() > 3) {
Toast.makeText(this, "Please select between 1 and 3 items", Toast.LENGTH_SHORT).show();
return;
}
String selectedTitles = selected.get(0).getTitle() + ", " + selected.get(1).getTitle();
String selectedTypeSubType = selected.get(0).getId() + ", " + selected.get(1).getId();
StringBuilder titlesBuilder = new StringBuilder();
StringBuilder idsBuilder = new StringBuilder();
for (int i = 0; i < selected.size(); i++) {
titlesBuilder.append(selected.get(i).getTitle());
idsBuilder.append(selected.get(i).getId());
if (i != selected.size() - 1) {
titlesBuilder.append(", ");
idsBuilder.append(", ");
}
}
String selectedTitles = titlesBuilder.toString();
String selectedTypeSubType = idsBuilder.toString();
textView.setText(selectedTitles);
ptwType = selectedTitles;
StorageManager.getInstance().getPermitToWorkModel().get(0).setTypeId(selectedTypeSubType);
@ -298,5 +367,54 @@ public class PermitOneActivity extends AppCompatActivity {
}
}
private void showDatePicker(String selectedType) {
Calendar now = Calendar.getInstance();
new DatePickerDialog(
this,
(view, year, month, dayOfMonth) -> {
selectedDateTime.set(Calendar.YEAR, year);
selectedDateTime.set(Calendar.MONTH, month);
selectedDateTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
showTimePicker(selectedType);
},
now.get(Calendar.YEAR),
now.get(Calendar.MONTH),
now.get(Calendar.DAY_OF_MONTH)
).show();
}
private void showTimePicker(String selectedType) {
Calendar now = Calendar.getInstance();
new TimePickerDialog(
this,
(view, hourOfDay, minute) -> {
selectedDateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
selectedDateTime.set(Calendar.MINUTE, minute);
updateDateTimeDisplay(selectedType);
},
now.get(Calendar.HOUR_OF_DAY),
now.get(Calendar.MINUTE),
false // set to false for 12-hour format with AM/PM
).show();
}
private void updateDateTimeDisplay(String selectedType) {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm a", Locale.getDefault());
String formatted = sdf.format(selectedDateTime.getTime());
//tvSelectedDateTime.setText("Selected Date & Time: " + formatted);
if (selectedType.equalsIgnoreCase("StartTime")) {
StorageManager.getInstance().getPermitToWorkModel().get(0).setStartTime(formatted);
etStartTime.setText(formatted);
}
else {
StorageManager.getInstance().getPermitToWorkModel().get(0).setEndTime(formatted);
etEndTime.setText(formatted);
}
//Log.e("Selected Date & Time: ", selectedType + " - " + formatted);
}
}

View File

@ -32,6 +32,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
@ -220,7 +221,7 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
public void onClick(View v) {
Log.e("btn-Submit: ","******");
if (isValidate()) {
StorageManager.getInstance().getPermitToWorkModel().get(0).setPictures(imageList);
// Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
alertReportSubmit(PermitTwoActivity.this);
}
@ -245,6 +246,15 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
StorageManager.getInstance().getPermitToWorkModel().get(0).setPictures(imageList);
finish();
}
});
/*etDescription.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
new Handler().postDelayed(() -> {
@ -253,6 +263,13 @@ public class PermitTwoActivity extends AppCompatActivity implements EasyPermissi
}
});*/
}
/*@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
finish();
StorageManager.getInstance().getPermitToWorkModel().get(0).setPictures(imageList);
}*/
public void alertReportSubmit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);

View File

@ -1,193 +1,48 @@
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.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.utopiaindustries.hseobservationsapp.R;
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
import com.utopiaindustries.hseobservationsapp.activities.ObservationForms.ObservationTwoActivity;
import com.utopiaindustries.hseobservationsapp.activities.InjuryRecordForms.InjuryFormOne;
import com.utopiaindustries.hseobservationsapp.adapters.HseActivitiesAdapter;
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
import com.utopiaindustries.hseobservationsapp.helper.Helper;
import com.utopiaindustries.hseobservationsapp.helper.Preference;
import com.utopiaindustries.hseobservationsapp.models.HseData.HseActivity;
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.HseReportRequest;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.ReportActivityModel;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
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 {
public class ProgressiveActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
EasyPermissions.RationaleCallbacks {
RecyclerView picturesRecyclerView;
PTWImageAdapter imagePaperAdapter;
String paperFilePath = "no_pic";
ArrayList<byte[]> PaperImageList = new ArrayList<>();
String docTypeId = "";
String docTypeTitle = "";
private static final int CAMERA_REQUEST_PAPER = 1012;
private static final int GALLERY_REQUEST = 2012;
ImageView imgUpload, imgBack;
Button btnSubmit;
ImageView imgBack;
Button btnNext;
private AutoCompleteTextView activitiesTextview;
private HseActivitiesAdapter hseActivitiesAdapter;
private ArrayList<HseActivity> hseActivityArrayList = new ArrayList<>();
String activityName = "";
EditText etDescription;
LoginViewModel loginViewModel;
// 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(compressedImage);
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(imageBytes);
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();
}
});
private RadioGroup radioGroup;
private String activityFrequency = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -202,73 +57,101 @@ public class ProgressiveActivity extends AppCompatActivity implements EasyPermis
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();
alertExit(ProgressiveActivity.this);
}
});
btnSubmit.setOnClickListener(new View.OnClickListener() {
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StorageManager.getInstance().getProgressiveActivityModel().get(0).setPictures(PaperImageList);
// Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
alertReportSubmit(ProgressiveActivity.this);
/*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);
if (isValidate()) {
Intent intent = new Intent(ProgressiveActivity.this, ProgressiveTwoActivity.class);
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);*/
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
}
});
activitiesTextview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Perform action when shiftTextview item is clicked
//Toast.makeText(ObservationOneActivity.this, "Item clicked: " + obSubClassArrayList.get(position).getTitle(), Toast.LENGTH_SHORT).show();
activityName = hseActivityArrayList.get(position).getTitle();
StorageManager.getInstance().getProgressiveActivityModel().get(0).setActivityName(hseActivityArrayList.get(position).getTitle());
}
});
etDescription.addTextChangedListener(new TextWatcher() {
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = findViewById(checkedId);
activityFrequency = radioButton.getText().toString();
StorageManager.getInstance().getProgressiveActivityModel().get(0).setActivityFrequency(activityFrequency);
Toast.makeText(ProgressiveActivity.this, "Selected Frequency is : " + radioButton.getText(), Toast.LENGTH_SHORT).show();
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
StorageManager.getInstance().getProgressiveActivityModel().get(0).setDescription(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
public void handleOnBackPressed() {
alertExit(ProgressiveActivity.this);
}
});
}
public void alertReportSubmit(Context con) {
/*@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
alertExit(ProgressiveActivity.this);
}*/
private void initializeLayouts() {
imgBack = findViewById(R.id.img_back);
btnNext = findViewById(R.id.btn_next);
activitiesTextview = findViewById(R.id.activities_textview);
radioGroup = findViewById(R.id.radioGroup);
hseActivityArrayList.addAll(Helper.getList(Helper.hseActivities, this, HseActivity.class));
hseActivitiesAdapter = new HseActivitiesAdapter(this, hseActivityArrayList);
activitiesTextview.setAdapter(hseActivitiesAdapter);
}
public boolean isValidate() {
boolean returnValue = true;
String message = "";
if (activityFrequency.isEmpty()) {
message = "Please select Activity Frequency.";
returnValue = false;
}
if (activityName.isEmpty()) {
message = "Please select Activity.";
returnValue = false;
}
if (!returnValue) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
return returnValue;
}
public void alertExit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
TextView dialogOkBtn, dialogCancelBtn;
AlertDialog.Builder builder = new AlertDialog.Builder(con);
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_report_submission, viewGroup, false);
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_exit, viewGroup, false);
builder.setCancelable(false);
builder.setView(view1);
@ -284,28 +167,8 @@ public class ProgressiveActivity extends AppCompatActivity implements EasyPermis
alertDialog.dismiss();
List<ReportActivityModel> reportList = StorageManager.getInstance().getProgressiveActivityModel();
HseReportRequest<ReportActivityModel> reportRequest = new HseReportRequest<>();
reportRequest.setObservation_date(StorageManager.getInstance().getObservation_date());
reportRequest.setUserId(StorageManager.getInstance().getUserId());
reportRequest.setSiteId(StorageManager.getInstance().getSite_id());
reportRequest.setSupervisorId(StorageManager.getInstance().getSupervisorId());
reportRequest.setSupervisorName(StorageManager.getInstance().getSupervisorName());
reportRequest.setShift(StorageManager.getInstance().getShift());
reportRequest.setDepartmentId(StorageManager.getInstance().getDepartmentId());
reportRequest.setBuildingId(StorageManager.getInstance().getBuildingId());
reportRequest.setFloorId(StorageManager.getInstance().getFloorId());
reportRequest.setRecordTypeId(StorageManager.getInstance().getRecordTypeId());
reportRequest.setCreatedBy(Preference.getMyStringPref(Helper.project_file, Helper.logInUser, ProgressiveActivity.this));
reportRequest.setAppVersion(StorageManager.getInstance().getAppVersion());
reportRequest.setReportData(reportList);
/*Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonRequest = gson.toJson(reportRequest);
Log.e("RequestModel JSON", jsonRequest);*/
loginViewModel.saveHSEData(reportRequest);
StorageManager.getInstance().clearProgressiveActivityModule();
finish();
}
});
@ -315,403 +178,10 @@ public class ProgressiveActivity extends AppCompatActivity implements EasyPermis
public void onClick(View view) {
alertDialog.dismiss();
//Toast.makeText(con, "Cancel", Toast.LENGTH_SHORT).show();
}
});
alertDialog.show();
}
private void initializeLayouts() {
imgUpload = findViewById(R.id.img_upload);
imgBack = findViewById(R.id.img_back);
btnSubmit = findViewById(R.id.btn_submit);
activitiesTextview = findViewById(R.id.activities_textview);
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
etDescription = findViewById(R.id.et_description);
etDescription.setImeOptions(EditorInfo.IME_ACTION_DONE);
etDescription.setRawInputType(InputType.TYPE_CLASS_TEXT);
hseActivityArrayList.addAll(Helper.getList(Helper.hseActivities, this, HseActivity.class));
hseActivitiesAdapter = new HseActivitiesAdapter(this, hseActivityArrayList);
activitiesTextview.setAdapter(hseActivitiesAdapter);
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
picturesRecyclerView.setAdapter(imagePaperAdapter);
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
loginViewModel.getLoadingState().observe(this, isLoading -> {
if (isLoading != null && isLoading) {
showProgressDialog();
} else {
dismissProgressDialog();
}
});
loginViewModel.getErrorMessage().observe(this, errorResponse -> {
if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
});
loginViewModel.getUserSaveLiveData().observe(this, hseSaveResponse -> {
Log.e("Response: ",""+hseSaveResponse.toString());
if (hseSaveResponse != null && hseSaveResponse.getResult().equalsIgnoreCase("success")) {
StorageManager.getInstance().clearProgressiveActivityModule();
Toast.makeText(this, "Report Submitted Successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(ProgressiveActivity.this, DashboardActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
}
@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(true);
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();
}
public void showProgressDialog() {
ProgressDialogFragment progressDialog = new ProgressDialogFragment();
progressDialog.setCancelable(false);
progressDialog.show(getSupportFragmentManager(), "progressDialog");
}
public void dismissProgressDialog() {
ProgressDialogFragment progressDialog = (ProgressDialogFragment)
getSupportFragmentManager().findFragmentByTag("progressDialog");
if (progressDialog != null) {
progressDialog.dismiss();
}
}
}

View File

@ -0,0 +1,695 @@
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.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.activity.OnBackPressedCallback;
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.core.content.FileProvider;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.utopiaindustries.hseobservationsapp.R;
import com.utopiaindustries.hseobservationsapp.activities.DashboardActivity;
import com.utopiaindustries.hseobservationsapp.adapters.PTWImageAdapter;
import com.utopiaindustries.hseobservationsapp.helper.Helper;
import com.utopiaindustries.hseobservationsapp.helper.Preference;
import com.utopiaindustries.hseobservationsapp.utils.ProgressDialogFragment;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.HseReportRequest;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.ReportActivityModel;
import com.utopiaindustries.hseobservationsapp.utils.StorageManager.StorageManager;
import com.utopiaindustries.hseobservationsapp.viewmodels.LoginViewModel;
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 ProgressiveTwoActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,
EasyPermissions.RationaleCallbacks{
RecyclerView picturesRecyclerView;
PTWImageAdapter imagePaperAdapter;
String paperFilePath = "no_pic";
ArrayList<byte[]> PaperImageList = new ArrayList<>();
String docTypeId = "";
String docTypeTitle = "";
private static final int CAMERA_REQUEST_PAPER = 1012;
private static final int GALLERY_REQUEST = 2012;
EditText etDescription;
Button btnSubmit;
LoginViewModel loginViewModel;
ImageView imgUpload, imgBack;
// 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(compressedImage);
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(imageBytes);
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
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_progressive_two);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
return insets;
});
initializeLayouts();
imgBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StorageManager.getInstance().getProgressiveActivityModel().get(0).setPictures(PaperImageList);
finish();
}
});
etDescription.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
StorageManager.getInstance().getProgressiveActivityModel().get(0).setDescription(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
btnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toast.makeText(PermitTwoActivity.this,"Reported Submitted",Toast.LENGTH_SHORT).show();
alertReportSubmit(ProgressiveTwoActivity.this);
/*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);*/
}
});
imgUpload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertForPictures(ProgressiveTwoActivity.this);
}
});
// Using OnBackPressedDispatcher
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
StorageManager.getInstance().getProgressiveActivityModel().get(0).setPictures(PaperImageList);
finish();
}
});
}
/*@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
finish();
StorageManager.getInstance().getProgressiveActivityModel().get(0).setPictures(PaperImageList);
}*/
private void initializeLayouts() {
picturesRecyclerView = findViewById(R.id.picturesRecyclerView);
btnSubmit = findViewById(R.id.btn_submit);
imgUpload = findViewById(R.id.img_upload);
imgBack = findViewById(R.id.img_back);
etDescription = findViewById(R.id.et_description);
etDescription.setImeOptions(EditorInfo.IME_ACTION_DONE);
etDescription.setRawInputType(InputType.TYPE_CLASS_TEXT);
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
picturesRecyclerView.setAdapter(imagePaperAdapter);
loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
loginViewModel.getLoadingState().observe(this, isLoading -> {
if (isLoading != null && isLoading) {
showProgressDialog();
} else {
dismissProgressDialog();
}
});
loginViewModel.getErrorMessage().observe(this, errorResponse -> {
if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
});
loginViewModel.getUserSaveLiveData().observe(this, hseSaveResponse -> {
Log.e("Response: ",""+hseSaveResponse.toString());
if (hseSaveResponse != null && hseSaveResponse.getResult().equalsIgnoreCase("success")) {
StorageManager.getInstance().clearProgressiveActivityModule();
Toast.makeText(this, "Report Submitted Successfully", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(ProgressiveTwoActivity.this, DashboardActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
}
@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(true);
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);
}
}
public void alertReportSubmit(Context con) {
ViewGroup viewGroup = findViewById(android.R.id.content);
TextView dialogOkBtn, dialogCancelBtn;
AlertDialog.Builder builder = new AlertDialog.Builder(con);
View view1 = LayoutInflater.from(con).inflate(R.layout.custom_layout_for_report_submission, viewGroup, false);
builder.setCancelable(false);
builder.setView(view1);
dialogOkBtn = view1.findViewById(R.id.dialogOkBtn);
dialogCancelBtn = view1.findViewById(R.id.dialogCancelBtn);
AlertDialog alertDialog = builder.create();
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialogOkBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
alertDialog.dismiss();
List<ReportActivityModel> reportList = StorageManager.getInstance().getProgressiveActivityModel();
HseReportRequest<ReportActivityModel> reportRequest = new HseReportRequest<>();
reportRequest.setObservation_date(StorageManager.getInstance().getObservation_date());
reportRequest.setUserId(StorageManager.getInstance().getUserId());
reportRequest.setSiteId(StorageManager.getInstance().getSite_id());
reportRequest.setSupervisorId(StorageManager.getInstance().getSupervisorId());
reportRequest.setSupervisorName(StorageManager.getInstance().getSupervisorName());
reportRequest.setShift(StorageManager.getInstance().getShift());
reportRequest.setDepartmentId(StorageManager.getInstance().getDepartmentId());
reportRequest.setBuildingId(StorageManager.getInstance().getBuildingId());
reportRequest.setFloorId(StorageManager.getInstance().getFloorId());
reportRequest.setRecordTypeId(StorageManager.getInstance().getRecordTypeId());
reportRequest.setCreatedBy(Preference.getMyStringPref(Helper.project_file, Helper.logInUser, ProgressiveTwoActivity.this));
reportRequest.setAppVersion(StorageManager.getInstance().getAppVersion());
reportRequest.setReportData(reportList);
/*Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonRequest = gson.toJson(reportRequest);
Log.e("RequestModel JSON", jsonRequest);*/
loginViewModel.saveHSEData(reportRequest);
}
});
dialogCancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
alertDialog.dismiss();
//Toast.makeText(con, "Cancel", Toast.LENGTH_SHORT).show();
}
});
alertDialog.show();
}
@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();
}
public void showProgressDialog() {
ProgressDialogFragment progressDialog = new ProgressDialogFragment();
progressDialog.setCancelable(false);
progressDialog.show(getSupportFragmentManager(), "progressDialog");
}
public void dismissProgressDialog() {
ProgressDialogFragment progressDialog = (ProgressDialogFragment)
getSupportFragmentManager().findFragmentByTag("progressDialog");
if (progressDialog != null) {
progressDialog.dismiss();
}
}
@Override
protected void onResume() {
super.onResume();
if (StorageManager.getInstance().getProgressiveActivityModel() != null &&
!StorageManager.getInstance().getProgressiveActivityModel().isEmpty()) {
showPersistData();
}
}
private void showPersistData() {
etDescription.setText(StorageManager.getInstance().getProgressiveActivityModel().get(0).getDescription());
if (StorageManager.getInstance().getProgressiveActivityModel().get(0).getPictures() != null
&& !StorageManager.getInstance().getProgressiveActivityModel().get(0).getPictures().isEmpty()) {
PaperImageList.clear();
PaperImageList.addAll(StorageManager.getInstance().getProgressiveActivityModel().get(0).getPictures());
imagePaperAdapter = new PTWImageAdapter(PaperImageList, this, "");
picturesRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
picturesRecyclerView.setAdapter(imagePaperAdapter);
}
}
}

View File

@ -53,9 +53,9 @@ public class HsePtwTypeAdapter extends RecyclerView.Adapter<HsePtwTypeAdapter.Vi
holder.checkbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
int selectedCount = getSelectedItems().size();
if (isChecked && selectedCount >= 2) {
if (isChecked && selectedCount >= 3) {
holder.checkbox.setChecked(false);
Toast.makeText(context, "Only 2 selections allowed", Toast.LENGTH_SHORT).show();
Toast.makeText(context, "Max 3 selections allowed", Toast.LENGTH_SHORT).show();
} else {
item.setSelected(isChecked);
}

View File

@ -12,10 +12,10 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClient {
//Live url
//private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
//Test Url
private final static String BASE_URL = "http://192.168.91.44:8081/uind/";
//private final static String BASE_URL = "http://192.168.91.44:8081/uind/";
private static Retrofit retrofit;

View File

@ -6,6 +6,7 @@ public class HseTrainingModel {
private int safetyTopicId;
private String safetyTopicName;
private String trainingType;
private int employeeAttendance;
private double trainingMinutes;
private String description;
@ -58,4 +59,12 @@ public class HseTrainingModel {
public void setSafetyTopicName(String safetyTopicName) {
this.safetyTopicName = safetyTopicName;
}
public String getTrainingType() {
return trainingType;
}
public void setTrainingType(String trainingType) {
this.trainingType = trainingType;
}
}

View File

@ -6,8 +6,22 @@ public class InjuryRecordModel {
private int workerId;
private String workerType;
private int kpiId;
private String KpiName;
/*private int kpiId;
private String KpiName;*/
//Employee data
private String employeeFullName;
private String employeePositionTitle;
private String employeeTenure;
private String employeeJoiningDate;
private String employeeWorkerType;
//Daily Wage Worker data
private String dailyWageWorkerName;
private String locationSite;
private String cnic;
private String contractorName;
private String divisionDepartment;
private int incidentId;
private String incidentName;
@ -25,6 +39,10 @@ public class InjuryRecordModel {
private String riskLevel;
private String description;
private String rootCause;
private String actionTaken;
private String statusAfterFirstAid;
private List<byte[]> pictures;
@ -36,13 +54,13 @@ public class InjuryRecordModel {
this.workerId = workerId;
}
public String getKpiName() {
/*public String getKpiName() {
return KpiName;
}
public void setKpiName(String kpiName) {
KpiName = kpiName;
}
}*/
public int getBodyPartId() {
return bodyPartId;
@ -124,6 +142,14 @@ public class InjuryRecordModel {
this.description = description;
}
public String getRootCause() {
return rootCause;
}
public void setRootCause(String rootCause) {
this.rootCause = rootCause;
}
public String getWorkerType() {
return workerType;
}
@ -132,13 +158,13 @@ public class InjuryRecordModel {
this.workerType = workerType;
}
public int getKpiId() {
/*public int getKpiId() {
return kpiId;
}
public void setKpiId(int kpiId) {
this.kpiId = kpiId;
}
}*/
public int getInjuryId() {
return injuryId;
@ -156,11 +182,107 @@ public class InjuryRecordModel {
this.injuryName = injuryName;
}
public String getEmployeeFullName() {
return employeeFullName;
}
public void setEmployeeFullName(String employeeFullName) {
this.employeeFullName = employeeFullName;
}
public String getEmployeePositionTitle() {
return employeePositionTitle;
}
public void setEmployeePositionTitle(String employeePositionTitle) {
this.employeePositionTitle = employeePositionTitle;
}
public String getEmployeeTenure() {
return employeeTenure;
}
public void setEmployeeTenure(String employeeTenure) {
this.employeeTenure = employeeTenure;
}
public String getEmployeeJoiningDate() {
return employeeJoiningDate;
}
public void setEmployeeJoiningDate(String employeeJoiningDate) {
this.employeeJoiningDate = employeeJoiningDate;
}
public String getEmployeeWorkerType() {
return employeeWorkerType;
}
public void setEmployeeWorkerType(String employeeWorkerType) {
this.employeeWorkerType = employeeWorkerType;
}
public String getDailyWageWorkerName() {
return dailyWageWorkerName;
}
public void setDailyWageWorkerName(String dailyWageWorkerName) {
this.dailyWageWorkerName = dailyWageWorkerName;
}
public String getLocationSite() {
return locationSite;
}
public void setLocationSite(String locationSite) {
this.locationSite = locationSite;
}
public String getCnic() {
return cnic;
}
public void setCnic(String cnic) {
this.cnic = cnic;
}
public String getContractorName() {
return contractorName;
}
public void setContractorName(String contractorName) {
this.contractorName = contractorName;
}
public String getDivisionDepartment() {
return divisionDepartment;
}
public void setDivisionDepartment(String divisionDepartment) {
this.divisionDepartment = divisionDepartment;
}
public String getActionTaken() {
return actionTaken;
}
public void setActionTaken(String actionTaken) {
this.actionTaken = actionTaken;
}
public String getStatusAfterFirstAid() {
return statusAfterFirstAid;
}
public void setStatusAfterFirstAid(String statusAfterFirstAid) {
this.statusAfterFirstAid = statusAfterFirstAid;
}
@Override
public String toString() {
return "InjuryRecordModel{" +
"employeeId=" + workerId +
", Kpi='" + KpiName + '\'' +
//", Kpi='" + KpiName + '\'' +
", incidentTypeId=" + incidentId +
", incidentTypeName='" + incidentName + '\'' +
", injuryTypeId=" + injuryTypeId +

View File

@ -9,6 +9,8 @@ public class PermitToWorkModel {
private int workingTeamId;
private String workingTeamName;
private String workingPartyType;
private String startTime;
private String endTime;
private String description;
@ -69,4 +71,20 @@ public class PermitToWorkModel {
public void setWorkingTeamName(String workingTeamName) {
this.workingTeamName = workingTeamName;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}

View File

@ -5,6 +5,7 @@ import java.util.List;
public class ReportActivityModel {
private String activityName;
private String activityFrequency;
private String description;
private List<byte[]> pictures;
@ -24,6 +25,14 @@ public class ReportActivityModel {
this.description = description;
}
public String getActivityFrequency() {
return activityFrequency;
}
public void setActivityFrequency(String activityFrequency) {
this.activityFrequency = activityFrequency;
}
public List<byte[]> getPictures() {
return pictures;
}

View File

@ -56,7 +56,35 @@
android:padding="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="left"
android:padding="5dp"
android:text="Type Of Training *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<CheckBox
android:id="@+id/checkbox_classroom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class Room Session" />
<CheckBox
android:id="@+id/checkbox_onfloor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="On Floor Session" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
@ -89,6 +117,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="5dp"
android:layout_marginStart="10dp"
android:paddingEnd="5dp"
android:textSize="@dimen/_10sdp"
android:text="Upload up to 5 supported files: PDF or image. Max 10 MB per file."/>

View File

@ -42,144 +42,61 @@
app:layout_constraintTop_toTopOf="@+id/toolbar"
app:srcCompat="@drawable/arrow_back" />
<LinearLayout
android:id="@+id/layout_employee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar">
<RadioGroup
android:id="@+id/rg1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:weightSum="2"
android:orientation="horizontal"
android:padding="5dp">
<RadioButton
android:id="@+id/rb_employee"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:buttonTint="@color/theme_color"
android:padding="5dp"
android:checked="true"
android:text="Employee"
android:textSize="@dimen/_12sdp" />
<RadioButton
android:id="@+id/rb_dailyWage"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:buttonTint="@color/theme_color"
android:padding="5dp"
android:text="Daily Wage Worker"
android:textSize="@dimen/_12sdp" />
</RadioGroup>
<TextView
android:id="@+id/txt_employee_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="ID Number *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:id="@+id/et_employee_id_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="0.5"
android:background="@drawable/et_border"
android:hint="ID Number"
android:imeOptions="actionDone"
android:inputType="number"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<Button
android:id="@+id/btn_fetch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/rounded_btn_login"
android:text="Fetch Data"
android:textColor="@color/white"
android:textSize="@dimen/_12sdp" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="2dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="5dp"
android:fadeScrollbars="false"
android:fillViewport="true"
android:scrollbarFadeDuration="0"
android:scrollbarThumbVertical="@android:color/darker_gray"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/btn_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout_employee">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="5dp">
app:layout_constraintTop_toBottomOf="@+id/toolbar">
<LinearLayout
android:id="@+id/layout_employee_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:orientation="vertical"
android:visibility="gone"
android:padding="5dp">
<TextView
<!--<TextView
android:id="@+id/heading_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Employee Name "
android:text="KPI *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_employee_name"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/kpi_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="No Of Employees"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_kpi"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/kpi_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>-->
<TextView
android:layout_width="match_parent"
@ -187,113 +104,146 @@
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Employee Type "
android:text="Type Of Incident *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_employee_type"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/incident_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Type"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_incident"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
<AutoCompleteTextView
android:id="@+id/incident_type_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="@+id/layout_accident"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Designation of the Employee "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_employee_designation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
android:orientation="vertical">
<TextView
android:id="@+id/heading_illness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Date Of Joining "
android:text="Type of Personal illness "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_date"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/personal_illness_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_illness_type"
android:padding="5dp"
android:text="Employee Tenure(Months) "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@+id/et_employee_tenure"
<AutoCompleteTextView
android:id="@+id/personal_illness_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Tenure"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_dailyWage_info"
android:id="@+id/layout_injury"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:padding="5dp">
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="5dp"
android:text="Type of Injury "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/injury_type_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_injury"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/injury_type_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_body_parts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="5dp"
android:text="Body Parts "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/body_part_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_body_part"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/body_part_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
@ -301,132 +251,32 @@
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Name "
android:text="Risk Level "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_name"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/risk_type_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Name"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_risk_type"
android:padding="5dp"
android:text="Location Site "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@+id/et_location_site"
<AutoCompleteTextView
android:id="@+id/risk_type_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Location Site"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="CNIC Number "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_cnic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="CNIC Number"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Contractor Name "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_contractor_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Contractor Name"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Division/Department "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_division"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
@ -440,5 +290,4 @@
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="5dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -53,10 +53,97 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Root Cause *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_rootCause"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:hint="Enter Root Cause"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="15sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Action Taken *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/actionTaken_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_actionTaken"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/action_taken_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Status After First Aid *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/statusAfter_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_statusAfter"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/status_after_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -42,28 +42,116 @@
app:layout_constraintTop_toTopOf="@+id/toolbar"
app:srcCompat="@drawable/arrow_back" />
<ScrollView
android:id="@+id/scrollView2"
<LinearLayout
android:id="@+id/layout_employee"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="2dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="5dp"
android:fadeScrollbars="false"
android:fillViewport="true"
android:scrollbarFadeDuration="0"
android:scrollbarThumbVertical="@android:color/darker_gray"
android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/btn_next"
android:layout_marginEnd="5dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar">
<RadioGroup
android:id="@+id/rg1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:weightSum="2"
android:orientation="horizontal"
android:padding="5dp">
<RadioButton
android:id="@+id/rb_employee"
android:layout_width="0dp"
android:layout_weight="1.05"
android:layout_height="wrap_content"
android:buttonTint="@color/theme_color"
android:padding="5dp"
android:checked="true"
android:text="Employee/Contractor"
android:textSize="@dimen/_12sdp" />
<RadioButton
android:id="@+id/rb_dailyWage"
android:layout_width="0dp"
android:layout_weight="0.95"
android:layout_height="wrap_content"
android:buttonTint="@color/theme_color"
android:padding="5dp"
android:text="Daily Wage worker"
android:textSize="@dimen/_12sdp" />
</RadioGroup>
<TextView
android:id="@+id/txt_employee_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="ID Number *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:id="@+id/et_employee_id_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="0.5"
android:background="@drawable/et_border"
android:hint="ID Number"
android:imeOptions="actionDone"
android:inputType="number"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<Button
android:id="@+id/btn_fetch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/rounded_btn_login"
android:text="Fetch Data"
android:textColor="@color/white"
android:textSize="@dimen/_12sdp" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
app:layout_constraintBottom_toTopOf="@+id/btn_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout_employee">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="5dp">
<LinearLayout
android:id="@+id/layout_employee_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
android:padding="5dp">
<TextView
@ -73,30 +161,25 @@
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="KPI *"
android:text="Employee Name "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/kpi_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
<EditText
android:id="@+id/et_employee_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_kpi"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/kpi_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="No Of Employees"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
@ -104,146 +187,113 @@
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Type Of Incident *"
android:text="Employee Type "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/incident_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
<EditText
android:id="@+id/et_employee_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_incident"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Type"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<AutoCompleteTextView
android:id="@+id/incident_type_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="@+id/layout_accident"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/heading_illness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="5dp"
android:text="Type of Personal illness "
android:text="Designation of the Employee "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/personal_illness_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
<EditText
android:id="@+id/et_employee_designation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_illness_type"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<AutoCompleteTextView
android:id="@+id/personal_illness_textview"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Date Of Joining "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Employee Tenure(Months) "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_employee_tenure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Tenure"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_injury"
android:id="@+id/layout_dailyWage_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="5dp"
android:text="Type of Injury "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/injury_type_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_injury"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/injury_type_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_body_parts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:padding="5dp"
android:text="Body Parts "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/body_part_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_body_part"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/body_part_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
android:orientation="vertical"
android:visibility="gone"
android:padding="5dp">
<TextView
android:layout_width="match_parent"
@ -251,32 +301,132 @@
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Risk Level "
android:text="Name "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/risk_type_input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:hint="@string/select_risk_type"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Name"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<AutoCompleteTextView
android:id="@+id/risk_type_textview"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Location Site "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_location_site"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Location Site"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="CNIC Number "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_cnic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="CNIC Number"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Contractor Name "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_contractor_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Contractor Name"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Division/Department "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<EditText
android:id="@+id/et_division"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Employee Designation"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="13dp"
android:textSize="@dimen/_12sdp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
@ -290,4 +440,5 @@
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="5dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -57,6 +57,96 @@
android:padding="5dp"
android:orientation="vertical">
<TextView
android:id="@+id/heading_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="left"
android:padding="5dp"
android:text="PTW Start Time *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<EditText
android:id="@+id/et_start_time"
android:layout_width="0dp"
android:layout_weight="1.95"
android:layout_marginEnd="10dp"
android:layout_height="wrap_content"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Enter Start Time"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="16dp"
android:textSize="@dimen/_12sdp" />
<ImageView
android:id="@+id/img_start_time"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_below="@+id/date_heading"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="@drawable/icon_calendar" />
</LinearLayout>
<TextView
android:id="@+id/heading_end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:gravity="left"
android:padding="5dp"
android:text="PTW End Time *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<EditText
android:id="@+id/et_end_time"
android:layout_width="0dp"
android:layout_weight="1.95"
android:layout_marginEnd="10dp"
android:layout_height="wrap_content"
android:background="@drawable/et_border"
android:enabled="false"
android:hint="Enter End Time"
android:imeOptions="actionDone"
android:inputType="text"
android:padding="16dp"
android:textSize="@dimen/_12sdp" />
<ImageView
android:id="@+id/img_end_time"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_below="@+id/date_heading"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:src="@drawable/icon_calendar" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -46,6 +46,7 @@
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/btn_next"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar">
@ -53,14 +54,14 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:padding="5dp"
android:orientation="vertical">
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/heading_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginTop="5dp"
android:gravity="left"
android:padding="5dp"
android:text="Name of Activity *"
@ -91,88 +92,79 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Description"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rg1" />
<EditText
android:id="@+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="5dp"
android:background="@drawable/et_border"
android:gravity="top|start"
android:hint="Write Description Here"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:lines="5"
android:maxLines="5"
android:minLines="5"
android:padding="10dp"
android:textSize="@dimen/_12sdp" />
<RelativeLayout
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_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Activity Pictures "
android:text="Activity Frequency *"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
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
android:id="@+id/picturesRecyclerView"
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:fadeScrollbars="false"
android:orientation="horizontal"
android:overScrollMode="always"
android:paddingStart="2dp"
android:paddingTop="5dp"
android:paddingEnd="2dp"
android:paddingBottom="10dp"
android:scrollbars="horizontal" />
android:orientation="vertical"
android:padding="2dp">
<!--adding a radio button -->
<RadioButton
android:id="@+id/radio_daily"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Daily"
android:textSize="16sp" />
<!--adding a radio button -->
<RadioButton
android:id="@+id/radio_weekly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Weekly"
android:textSize="16sp" />
<!--adding a radio button -->
<RadioButton
android:id="@+id/radio_monthly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Monthly"
android:textSize="16sp" />
<RadioButton
android:id="@+id/radio_quarterly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quarterly" />
<RadioButton
android:id="@+id/radio_half_yearly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Half Yearly" />
<RadioButton
android:id="@+id/radio_yearly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yearly" />
</RadioGroup>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/btn_submit"
android:id="@+id/btn_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/rounded_btn_login"
android:text="Submit"
android:text="Next"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="5dp" />

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".activities.ProgressiveActivityForms.ProgressiveTwoActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/theme_color"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Progressive Activities Form"
android:textColor="@color/white"
android:textSize="@dimen/_15sdp"
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
app:layout_constraintEnd_toEndOf="@+id/toolbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/toolbar" />
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="@+id/toolbar"
app:layout_constraintStart_toStartOf="@+id/toolbar"
app:layout_constraintTop_toTopOf="@+id/toolbar"
app:srcCompat="@drawable/arrow_back" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/btn_submit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="left"
android:padding="5dp"
android:text="Description"
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rg1" />
<EditText
android:id="@+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="5dp"
android:background="@drawable/et_border"
android:gravity="top|start"
android:hint="Write Description Here"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:lines="5"
android:maxLines="5"
android:minLines="5"
android:padding="10dp"
android:textSize="@dimen/_12sdp" />
<RelativeLayout
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_alignParentStart="true"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:gravity="left"
android:padding="5dp"
android:text="Activity Pictures "
android:textColor="@color/black"
android:textSize="@dimen/_13sdp"
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
android:id="@+id/picturesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginBottom="10dp"
android:fadeScrollbars="false"
android:orientation="horizontal"
android:overScrollMode="always"
android:paddingStart="2dp"
android:paddingTop="5dp"
android:paddingEnd="2dp"
android:paddingBottom="10dp"
android:scrollbars="horizontal" />
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/btn_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/rounded_btn_login"
android:text="Submit"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="5dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -8,7 +8,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<TextView
android:id="@+id/draft_text"
@ -18,14 +18,16 @@
android:textStyle="bold"
android:textSize="@dimen/_13sdp"
android:textColor="@color/black"
android:text="List"
android:textAlignment="center" />
android:text="Listing will be reflect in next phase"
android:layout_centerInParent="true"
android:gravity="center" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/draft_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/draft_text"
android:visibility="gone"
android:padding="16dp">
</androidx.recyclerview.widget.RecyclerView>

View File

@ -37,6 +37,9 @@
<string name="select_incident">Select Incident Type</string>
<string name="select_body_part">Select Body Part</string>
<string name="select_actionTaken">Choose Action</string>
<string name="select_statusAfter">Choose Status</string>
<string name="select_body_parts">Select Body parts</string>
<string name="select_action">Select Action</string>
<string name="select_status">Select Status</string>