parent
08d62cbc01
commit
b2cf9380a0
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "com.utopiaindustries.qualitychecker"
|
||||
minSdk 24
|
||||
targetSdk 34
|
||||
versionCode 8
|
||||
versionName "1.7"
|
||||
versionCode 9
|
||||
versionName "1.8"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
|
||||
public class RetrofitClient {
|
||||
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
||||
//private final static String BASE_URL = "http://192.168.91.44:8081/uind/";//"http://192.168.91.44:8081/uind/";//"http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
|
||||
//private final static String BASE_URL = "http://192.168.91.44:8081/uind/";
|
||||
|
||||
private static Retrofit retrofit;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.DRAFT_REPORT
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.util.Log;
|
||||
|
@ -23,10 +24,12 @@ public class ReportRepository {
|
|||
private final DatabaseHelper dbHelper;
|
||||
private SQLiteDatabase database;
|
||||
private final ExecutorService executorService;
|
||||
private Context cxt;
|
||||
|
||||
public ReportRepository(Context context) {
|
||||
dbHelper = new DatabaseHelper(context);
|
||||
executorService = Executors.newSingleThreadExecutor();
|
||||
cxt = context;
|
||||
}
|
||||
|
||||
private void openDatabase() {
|
||||
|
@ -116,20 +119,35 @@ public class ReportRepository {
|
|||
}
|
||||
|
||||
public void insertDraft(InspectionReportWrapper wrapper, String fnsku) {
|
||||
System.out.println("Report-ID: "+ wrapper.getId());
|
||||
//System.out.println("Report-ID: "+ wrapper.getId());
|
||||
long[] recordId = new long[1];
|
||||
executeSafely(() -> {
|
||||
openDatabase();
|
||||
database.beginTransaction();
|
||||
try {
|
||||
ContentValues values = new ContentValues();
|
||||
if (wrapper.getId() != 0) {
|
||||
System.out.println("final-insertion: " + wrapper.getId());
|
||||
//System.out.println("final-insertion: " + wrapper.getId());
|
||||
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_ID, wrapper.getId());
|
||||
//Log.e("RecordId-Existing: ",""+wrapper.getId());
|
||||
recordId[0] = wrapper.getId();
|
||||
}
|
||||
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_CONTENT, wrapper.getContent());
|
||||
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_SYNCED, wrapper.isSynced());
|
||||
database.insertWithOnConflict(DRAFT_REPORT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
//database.insertWithOnConflict(DRAFT_REPORT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
long rowId = database.insertWithOnConflict(DRAFT_REPORT_TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
database.setTransactionSuccessful();
|
||||
if (wrapper.getId() == 0 && rowId != -1) {
|
||||
//Log.e("RecordId-New: ", "" + rowId);
|
||||
recordId[0] = rowId;
|
||||
}
|
||||
|
||||
SharedPreferences sharedPreferences = cxt.getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
|
||||
editor.putString("draftReportId", String.valueOf(recordId[0]));
|
||||
editor.apply();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
|
|
@ -536,6 +536,10 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
if (!s.toString().isEmpty() && s.toString() != null) {
|
||||
trackSampleCode(Integer.parseInt(s.toString()), (int) Double.parseDouble(inspectionLevel), Double.parseDouble(qualityLevelMajor), Double.parseDouble(qualityLevelMinor));
|
||||
}
|
||||
else {
|
||||
aqlSampleSize.setText("");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -734,6 +738,10 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
try {
|
||||
store.getReport().getItems().get(0).setSampleSize(Long.parseLong(s.toString()));
|
||||
|
||||
/*if (!s.toString().isEmpty() && s.toString() != null) {
|
||||
trackSampleCodeWithSampleSize((int) Double.parseDouble(inspectionLevel), Double.parseDouble(qualityLevelMajor), Double.parseDouble(qualityLevelMinor),Integer.parseInt(s.toString()));
|
||||
}*/
|
||||
} catch (Exception e) {
|
||||
store.getReport().getItems().get(0).setSampleSize(0);
|
||||
}
|
||||
|
@ -805,7 +813,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
editor.putString("draftReportId", "0");
|
||||
editor.apply();
|
||||
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
//Objects.requireNonNull(getActivity()).finish();
|
||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||
"Utopia QA App",
|
||||
"Report is successfully drafted");
|
||||
|
@ -977,23 +985,36 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
|
||||
//Log.e("Carton: ",""+String.valueOf(store.getReport().getItems().get(0).getCartonsSelected()));
|
||||
|
||||
boxCartonSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCartonsSelected()));
|
||||
boxCartonSelected.setText(store.getReport().getItems().get(0).getCartonsSelected() != 0
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCartonsSelected()) : "");
|
||||
|
||||
//itemPerBoxSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPacksSelected()));
|
||||
//piecesSelected.setText(String.valueOf(store.getReport().getItems().get(0).getPiecesSelected()));
|
||||
|
||||
checkedBoxCartonSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCheckedCartonsSelected()));
|
||||
checkedBoxCartonSelected.setText(store.getReport().getItems().get(0).getCheckedCartonsSelected() != 0
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCheckedCartonsSelected()) : "");
|
||||
|
||||
//checkedItemPerBoxSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCheckedPacksSelected()));
|
||||
//checkedPiecesSelected.setText(String.valueOf(store.getReport().getItems().get(0).getCheckedPiecesSelected()));
|
||||
|
||||
cartonWeight.setText(String.valueOf(store.getReport().getItems().get(0).getCartonWeight()));
|
||||
cartonLength.setText(String.valueOf(store.getReport().getItems().get(0).getCartonLength()));
|
||||
cartonWidth.setText(String.valueOf(store.getReport().getItems().get(0).getCartonWidth()));
|
||||
cartonHeight.setText(String.valueOf(store.getReport().getItems().get(0).getCartonHeight()));
|
||||
cartonWeight.setText(store.getReport().getItems().get(0).getCartonWeight() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCartonWeight()) : "");
|
||||
cartonLength.setText(store.getReport().getItems().get(0).getCartonLength() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCartonLength()) : "");
|
||||
cartonWidth.setText(store.getReport().getItems().get(0).getCartonWidth() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCartonWidth()) : "");
|
||||
cartonHeight.setText(store.getReport().getItems().get(0).getCartonHeight() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getCartonHeight()) : "");
|
||||
|
||||
packWeight.setText(store.getReport().getItems().get(0).getPackWeight() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getPackWeight()) : "");
|
||||
packLength.setText(store.getReport().getItems().get(0).getPackLength() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getPackLength()) : "");
|
||||
packWidth.setText(store.getReport().getItems().get(0).getPackWidth() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getPackWidth()) : "");
|
||||
packHeight.setText(store.getReport().getItems().get(0).getPackHeight() != 0.0f
|
||||
? String.valueOf(store.getReport().getItems().get(0).getPackHeight()) : "");
|
||||
|
||||
packWeight.setText(String.valueOf(store.getReport().getItems().get(0).getPackWeight()));
|
||||
packLength.setText(String.valueOf(store.getReport().getItems().get(0).getPackLength()));
|
||||
packWidth.setText(String.valueOf(store.getReport().getItems().get(0).getPackWidth()));
|
||||
packHeight.setText(String.valueOf(store.getReport().getItems().get(0).getPackHeight()));
|
||||
|
||||
aqlSampleSize.setText(String.valueOf(store.getReport().getItems().get(0).getSampleSize()));
|
||||
|
||||
|
@ -1320,6 +1341,56 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
|
|||
|
||||
}
|
||||
|
||||
private void trackSampleCodeWithSampleSize(int inspectionLevel, double selectedLevelMajor, double selectedLevelMinor, int aqlSampleSizeValue) {
|
||||
try {
|
||||
String sampleCode = "";
|
||||
double levelMajor = 0.0, levelMinor = 0.0;
|
||||
int sampleSizeMajor = 0;
|
||||
int sampleSizeMinor = 0;
|
||||
|
||||
List<InspectionLabel> inspectionGeneralLabels = new InspectionLabelRepository(getContext()).getInspectionLabels();
|
||||
List<QualityLabel> inspectionAcceptableQualities = new InspectionLabelRepository(getContext()).getQualityLabels();
|
||||
|
||||
// Now determine the sample code based on aqlSampleSizeValue
|
||||
outerLoop:
|
||||
for (InspectionLabel label : inspectionGeneralLabels) {
|
||||
if (label.getInspectionLevel() == inspectionLevel) {
|
||||
// Look for the QualityLabel that matches the desired sample size and sample code
|
||||
for (QualityLabel quality : inspectionAcceptableQualities) {
|
||||
if (Objects.equals(quality.getSampleCode(), label.getSampleCode()) &&
|
||||
quality.getSampleSize() == aqlSampleSizeValue) {
|
||||
sampleCode = label.getSampleCode();
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For level major and minor
|
||||
for (QualityLabel quality : inspectionAcceptableQualities) {
|
||||
if (Objects.equals(quality.getSampleCode(), sampleCode)) {
|
||||
if (quality.getQualityLevel() == selectedLevelMajor) {
|
||||
levelMajor = quality.getNoOfAcceptedDefects();
|
||||
sampleSizeMajor = quality.getSampleSize();
|
||||
}
|
||||
|
||||
if (quality.getQualityLevel() == selectedLevelMinor) {
|
||||
levelMinor = quality.getNoOfAcceptedDefects();
|
||||
sampleSizeMinor = quality.getSampleSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//store.getReport().getItems().get(0).setSampleSize(sampleSizeMajor);
|
||||
store.getReport().getItems().get(0).setLevelMajorDefects((int) levelMajor);
|
||||
store.getReport().getItems().get(0).setLevelMinorDefects((int) levelMinor);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class SecondStepFragment extends Fragment
|
|||
implements View.OnClickListener {
|
||||
|
||||
private NavController navController;
|
||||
private Button leftFab, rightFab, draftFab, moveToBottom;
|
||||
private Button leftFab, rightFab, draftFab, moveToBottom, closeBtn;
|
||||
private RecyclerView recyclerView;
|
||||
private CheckPointAdapter adapter;
|
||||
private TextView profileName;
|
||||
|
@ -84,6 +84,7 @@ public class SecondStepFragment extends Fragment
|
|||
draftFab = view.findViewById(R.id.button_draft_second);
|
||||
leftFab = view.findViewById(R.id.button_left_frag_2);
|
||||
rightFab = view.findViewById(R.id.button_right_frag_2);
|
||||
closeBtn = view.findViewById(R.id.button_close);
|
||||
moveToBottom = view.findViewById(R.id.button_move_to_bottom);
|
||||
recyclerView = view.findViewById(R.id.check_point_recycler_view);
|
||||
profileName = view.findViewById(R.id.second_profile_name);
|
||||
|
@ -130,6 +131,7 @@ public class SecondStepFragment extends Fragment
|
|||
leftFab.setOnClickListener(this);
|
||||
rightFab.setOnClickListener(this);
|
||||
draftFab.setOnClickListener(this);
|
||||
closeBtn.setOnClickListener(this);
|
||||
moveToBottom.setOnClickListener(this);
|
||||
updateProfileViews();
|
||||
return view;
|
||||
|
@ -156,7 +158,7 @@ public class SecondStepFragment extends Fragment
|
|||
editor.putString("draftReportId", "0");
|
||||
editor.apply();
|
||||
// progressBar.setVisibility(View.INVISIBLE);
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
//Objects.requireNonNull(getActivity()).finish();
|
||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||
"Utopia QA App",
|
||||
"Report is successfully drafted");
|
||||
|
@ -194,6 +196,12 @@ public class SecondStepFragment extends Fragment
|
|||
Log.e("Fab-Button","click");
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
if (v.getId() == R.id.button_close) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onImagePickerResult(int requestCode, int resultCode, Intent data) {
|
||||
|
|
|
@ -87,7 +87,7 @@ import retrofit2.Response;
|
|||
|
||||
public class ThirdStepFragment extends Fragment implements View.OnClickListener {
|
||||
private NavController navController;
|
||||
private Button backBtn, nextBtn, openDimensionDialog, btnDraft;
|
||||
private Button backBtn, nextBtn, openDimensionDialog, btnDraft, closeBtn;
|
||||
private ImageButton imagePicker, deleteImage;
|
||||
private TextView profileName;
|
||||
private ImageView profileImage;
|
||||
|
@ -411,7 +411,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
|||
editor.putString("draftReportId", "0");
|
||||
editor.apply();
|
||||
// progressBar.setVisibility(View.INVISIBLE);
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
//Objects.requireNonNull(getActivity()).finish();
|
||||
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
|
||||
"Utopia QA App",
|
||||
"Report is successfully drafted");
|
||||
|
@ -442,6 +442,12 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
|||
if (v.getId() == R.id.button_open_dimension) {
|
||||
openDimensionDialog();
|
||||
}
|
||||
|
||||
if (v.getId() == R.id.button_close) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*private void saveReportDirectlyToServer(Store store) {
|
||||
|
@ -784,6 +790,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
|||
backBtn = view.findViewById(R.id.button_left_frag_3);
|
||||
nextBtn = view.findViewById(R.id.button_right_frag_3);
|
||||
btnDraft = view.findViewById(R.id.button_draft_third);
|
||||
closeBtn = view.findViewById(R.id.button_close);
|
||||
imagePicker = view.findViewById(R.id.image_picker);
|
||||
deleteImage = view.findViewById(R.id.delete_image);
|
||||
imageRecyclerView = view.findViewById(R.id.imageRecyclerView);
|
||||
|
@ -865,6 +872,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
|
|||
nextBtn.setOnClickListener(this);
|
||||
backBtn.setOnClickListener(this);
|
||||
btnDraft.setOnClickListener(this);
|
||||
closeBtn.setOnClickListener(this);
|
||||
openDimensionDialog.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -734,18 +734,18 @@
|
|||
android:id="@+id/button_left_frag_1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/button_draft_first"
|
||||
android:layout_alignBaseline="@id/button_show_history"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toStartOf="@id/button_draft_first"
|
||||
android:layout_toStartOf="@id/button_show_history"
|
||||
android:text="Close" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_show_history"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/button_left_frag_1"
|
||||
android:layout_alignBaseline="@id/button_draft_first"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toStartOf="@id/button_left_frag_1"
|
||||
android:layout_toStartOf="@id/button_draft_first"
|
||||
android:text="History" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -195,6 +195,15 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:layout_toStartOf="@id/button_left_frag_2"
|
||||
android:text="Move to Bottom" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/button_move_to_bottom"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toStartOf="@id/button_move_to_bottom"
|
||||
android:text="Close" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
|
|
|
@ -855,6 +855,15 @@
|
|||
android:layout_toStartOf="@id/button_left_frag_3"
|
||||
android:text="Add Dimensions" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@id/button_open_dimension"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_toStartOf="@id/button_open_dimension"
|
||||
android:text="Close" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ProgressBar
|
||||
|
|
Loading…
Reference in New Issue