Feedback implemented

main
saad.siddiq 2024-11-07 12:33:48 +05:00
parent 4668ef5259
commit a0b3bcce24
44 changed files with 2736 additions and 471 deletions

View File

@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET" /> <!-- If your app needs to access network state --> <uses-permission android:name="android.permission.INTERNET" /> <!-- If your app needs to access network state -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
@ -66,6 +69,17 @@
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/> <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter> </intent-filter>
</receiver> </receiver>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application> </application>
</manifest> </manifest>

View File

@ -20,7 +20,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClient { public class RetrofitClient {
private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/"; private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
// private final static String BASE_URL = "http://192.168.91.16:8080/uind/"; // private final static String BASE_URL = "http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
private static Retrofit retrofit; private static Retrofit retrofit;

View File

@ -28,7 +28,7 @@ public class ImageProcessor {
mainHandler = new Handler(Looper.getMainLooper()); mainHandler = new Handler(Looper.getMainLooper());
} }
public void compressImageFromUriAsync(final Context context, final Uri uri, final int maxSizeKB, final OnImageCompressedListener listener) { /*public void compressImageFromUriAsync(final Context context, final Uri uri, final int maxSizeKB, final OnImageCompressedListener listener) {
backgroundHandler.post(() -> { backgroundHandler.post(() -> {
byte[] imageData = getBytesFromUri(context, uri); byte[] imageData = getBytesFromUri(context, uri);
if (imageData != null) { if (imageData != null) {
@ -43,7 +43,7 @@ public class ImageProcessor {
}); });
} }
}); });
} }*/
private byte[] getBytesFromUri(Context context, Uri uri) { private byte[] getBytesFromUri(Context context, Uri uri) {
if (uri != null) { if (uri != null) {
@ -87,11 +87,62 @@ public class ImageProcessor {
return null; return null;
} }
public void uriToByteArrayAsync(Context context, Uri uri, int targetSizeInKB, OnImageCompressedListener listener) {
new Thread(() -> {
try {
// Target file size in bytes
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.");
}
// Initial quality for compression
int minQuality = 10;
int maxQuality = 100;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int quality = maxQuality;
// Use binary search for quality adjustment to find optimal size faster
while (minQuality <= maxQuality) {
byteArrayOutputStream.reset();
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
int byteSize = byteArrayOutputStream.size();
if (byteSize > targetSizeInBytes) {
maxQuality = quality - 5;
} else if (byteSize < targetSizeInBytes) {
minQuality = quality + 5;
} else {
break;
}
quality = (minQuality + maxQuality) / 2;
}
// Return compressed byte array
listener.onCompressed(byteArrayOutputStream.toByteArray());
} catch (IOException e) {
listener.onError(e);
}
}).start();
}
public void shutdown() { public void shutdown() {
executorService.shutdown(); executorService.shutdown();
} }
public interface OnImageCompressedListener { /*public interface OnImageCompressedListener {
void onImageCompressed(byte[] compressedData); void onImageCompressed(byte[] compressedData);
}*/
public interface OnImageCompressedListener {
void onCompressed(byte[] compressedImage);
void onError(Exception e);
} }
} }

View File

@ -66,6 +66,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static final String REPORT_COLUMN_CONTENT = "content"; public static final String REPORT_COLUMN_CONTENT = "content";
public static final String REPORT_COLUMN_SYNCED = "synced"; public static final String REPORT_COLUMN_SYNCED = "synced";
/*
* draft report table
* */
public static final String DRAFT_REPORT_TABLE_NAME = "draft_report";
public static final String DRAFT_REPORT_COLUMN_ID = "id";
public static final String DRAFT_REPORT_COLUMN_CONTENT = "content";
//public static final String DRAFT_REPORT_COLUMN_FNSKU = "fnsku";
public static final String DRAFT_REPORT_COLUMN_SYNCED = "synced";
/* /*
* sku checkpoints standard * sku checkpoints standard
* */ * */
@ -129,6 +139,13 @@ public class DatabaseHelper extends SQLiteOpenHelper {
REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))" REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))"
+ ")"; + ")";
String CREATE_DRAFT_REPORT_TABLE = "CREATE TABLE " + DRAFT_REPORT_TABLE_NAME + " (" +
DRAFT_REPORT_COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
DRAFT_REPORT_COLUMN_CONTENT + " TEXT NOT NULL, " +
// DRAFT_REPORT_COLUMN_FNSKU + " TEXT NOT NULL," +
DRAFT_REPORT_COLUMN_SYNCED + " INTEGER DEFAULT 0 CHECK(synced IN (0, 1))"
+ ")";
String CREATE_SKU_CHECKPOINT_TABLE = "CREATE TABLE " + CHECKPOINT_SKU_TABLE_NAME + " (" + String CREATE_SKU_CHECKPOINT_TABLE = "CREATE TABLE " + CHECKPOINT_SKU_TABLE_NAME + " (" +
CHECKPOINT_SKU_SKU + " TEXT NOT NULL," + CHECKPOINT_SKU_SKU + " TEXT NOT NULL," +
CHECKPOINT_SKU_MARKETPLACE + " TEXT NOT NULL," + CHECKPOINT_SKU_MARKETPLACE + " TEXT NOT NULL," +
@ -142,6 +159,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL( CREATE_DEFECT_TABLE ); db.execSQL( CREATE_DEFECT_TABLE );
db.execSQL( CREATE_UNIT_TABLE ); db.execSQL( CREATE_UNIT_TABLE );
db.execSQL( CREATE_REPORT_TABLE ); db.execSQL( CREATE_REPORT_TABLE );
db.execSQL( CREATE_DRAFT_REPORT_TABLE);
db.execSQL( CREATE_SKU_CHECKPOINT_TABLE ); db.execSQL( CREATE_SKU_CHECKPOINT_TABLE );
} }
@ -153,6 +171,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL( "DROP TABLE IF EXISTS " + DEFECT_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + DEFECT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + UNIT_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + UNIT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + REPORT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + DRAFT_REPORT_TABLE_NAME );
db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_SKU_TABLE_NAME ); db.execSQL( "DROP TABLE IF EXISTS " + CHECKPOINT_SKU_TABLE_NAME );
onCreate(db); onCreate(db);
} }

View File

@ -1,5 +1,8 @@
package com.utopiaindustries.qualitychecker.db; package com.utopiaindustries.qualitychecker.db;
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.DRAFT_REPORT_COLUMN_ID;
import static com.utopiaindustries.qualitychecker.db.DatabaseHelper.DRAFT_REPORT_TABLE_NAME;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
@ -26,8 +29,13 @@ public class ReportRepository {
} }
private void openDatabase() { private void openDatabase() {
if (database == null || !database.isOpen()) { try {
database = dbHelper.getWritableDatabase(); if (database == null || !database.isOpen() || !database.isDbLockedByCurrentThread()) {
database = dbHelper.getWritableDatabase();
}
}
catch (Exception e) {
e.printStackTrace();
} }
} }
@ -50,6 +58,75 @@ public class ReportRepository {
}); });
} }
public void insertOrReplaceUser(InspectionReportWrapper wrapper) {
executeSafely(() -> {
openDatabase();
database.beginTransaction();
try {
ContentValues values = new ContentValues();
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_ID, wrapper.getId()); // You need to explicitly provide the ID
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_CONTENT, wrapper.getContent());
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_SYNCED, wrapper.isSynced());
// Insert or replace a row
database.replace(DRAFT_REPORT_TABLE_NAME, null, values);
} catch (Exception e) {
System.out.println("Draft Button Click-12");
e.printStackTrace();
} finally {
System.out.println("Draft Button Click-13");
database.endTransaction();
close();
}
});
}
public void insertDraft(InspectionReportWrapper wrapper, String fnsku) {
System.out.println("Report-ID: "+ wrapper.getId());
executeSafely(() -> {
openDatabase();
database.beginTransaction();
try {
ContentValues values = new ContentValues();
if (wrapper.getId() != 0) {
System.out.println("final-insertion: " + wrapper.getId());
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_ID, 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.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
database.endTransaction();
close();
}
});
}
// Update data based on the id
/*public void updateData(InspectionReportWrapper wrapper) {
executeSafely(() -> {
openDatabase();
database.beginTransaction();
try {
ContentValues values = new ContentValues();
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_CONTENT, wrapper.getContent());
values.put(DatabaseHelper.DRAFT_REPORT_COLUMN_SYNCED, wrapper.isSynced());
database.update(DRAFT_REPORT_TABLE_NAME, values, DRAFT_REPORT_COLUMN_ID + " = ?", new String[]{String.valueOf(wrapper.getId())});
database.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
database.endTransaction();
close();
}
});
}*/
public void updateSyncStatus(long id) { public void updateSyncStatus(long id) {
executeSafely(() -> { executeSafely(() -> {
openDatabase(); openDatabase();
@ -102,6 +179,73 @@ public class ReportRepository {
return reports; return reports;
} }
/*
* List Of Draft Reports
* */
@SuppressLint("Range")
public List<InspectionReportWrapper> findAllDraftReports() {
List<InspectionReportWrapper> reports = new ArrayList<>();
openDatabase();
try (Cursor cursor = database.query(DRAFT_REPORT_TABLE_NAME,
null,
null,
null,
null,
null,
null)) {
if (cursor != null && cursor.moveToFirst()) {
do {
InspectionReportWrapper wrapper = new InspectionReportWrapper();
wrapper.setId(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_ID)));
wrapper.setContent(cursor.getString(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_CONTENT)));
wrapper.setSynced(cursor.getInt(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_SYNCED)) == 1);
reports.add(wrapper);
} while (cursor.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close();
}
return reports;
}
/*
* Single Draft Report
* */
@SuppressLint("Range")
public InspectionReportWrapper findDraftReportById(long id) {
InspectionReportWrapper report = null;
openDatabase();
String selection = DatabaseHelper.REPORT_COLUMN_ID + " = ?";
String[] selectionArgs = { String.valueOf(id) }; // The ID to search for
try (Cursor cursor = database.query(DRAFT_REPORT_TABLE_NAME,
null, // Columns - null selects all columns
selection, // The WHERE clause
selectionArgs, // The arguments for the WHERE clause
null, // Group by
null, // Having
null)) { // Order by
if (cursor != null && cursor.moveToFirst()) {
report = new InspectionReportWrapper();
report.setId(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_ID)));
report.setContent(cursor.getString(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_CONTENT)));
report.setSynced(cursor.getInt(cursor.getColumnIndex(DatabaseHelper.REPORT_COLUMN_SYNCED)) == 1);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close();
}
return report; // Returns null if no report is found with the given ID
}
/* /*
* Close the database when all operations are complete * Close the database when all operations are complete
*/ */
@ -126,4 +270,30 @@ public class ReportRepository {
e.printStackTrace(); e.printStackTrace();
} }
} }
/*
* Delete Draft Record from draft table
* */
public void deleteDraftRecordById(Long id) {
executeSafely(() -> {
openDatabase();
database.beginTransaction();
try {
String whereClause = DatabaseHelper.DRAFT_REPORT_COLUMN_ID + " = ?";
String[] whereArgs = {String.valueOf(id)};
database.delete(DRAFT_REPORT_TABLE_NAME, whereClause, whereArgs);
database.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
database.endTransaction();
close();
}
});
}
} }

View File

@ -1,8 +1,7 @@
package com.utopiaindustries.qualitychecker.models; package com.utopiaindustries.qualitychecker.models;
import androidx.annotation.NonNull;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -23,6 +22,7 @@ public class InspectionItemCheckPoint implements Serializable {
private byte[] file; private byte[] file;
private String imagePath; private String imagePath;
private UUID uuid; private UUID uuid;
private List<byte[]> files = new ArrayList<>();
public InspectionItemCheckPoint(){ public InspectionItemCheckPoint(){
this.uuid = UUID.randomUUID(); // Generate a random UUID this.uuid = UUID.randomUUID(); // Generate a random UUID
@ -122,7 +122,14 @@ public class InspectionItemCheckPoint implements Serializable {
this.quantities = quantities; this.quantities = quantities;
} }
@NonNull public List<byte[]> getFiles() {
return files;
}
public void addImageList(byte[] image) {
this.files.add(image);
}
@Override @Override
public String toString() { public String toString() {
return "InspectionItemCheckPoint{" + return "InspectionItemCheckPoint{" +
@ -138,6 +145,7 @@ public class InspectionItemCheckPoint implements Serializable {
", file=" + Arrays.toString(file) + ", file=" + Arrays.toString(file) +
", imagePath='" + imagePath + '\'' + ", imagePath='" + imagePath + '\'' +
", uuid=" + uuid + ", uuid=" + uuid +
", imageList=" + files +
'}'; '}';
} }

View File

@ -19,6 +19,9 @@ public class InspectionReport implements Serializable {
private long functionId; private long functionId;
private String generalRemarks; private String generalRemarks;
private String reportResult; private String reportResult;
private String qualityAuditor;
private String productionRepresentative;
private String qcRepresentative;
// wrapper // wrapper
List<InspectionReportItem> items; List<InspectionReportItem> items;
@ -134,6 +137,30 @@ public class InspectionReport implements Serializable {
this.wrapperId = wrapperId; this.wrapperId = wrapperId;
} }
public String getQualityAuditor() {
return qualityAuditor;
}
public void setQualityAuditor(String qualityAuditor) {
this.qualityAuditor = qualityAuditor;
}
public String getProductionRepresentative() {
return productionRepresentative;
}
public void setProductionRepresentative(String productionRepresentative) {
this.productionRepresentative = productionRepresentative;
}
public String getQcRepresentative() {
return qcRepresentative;
}
public void setQcRepresentative(String qcRepresentative) {
this.qcRepresentative = qcRepresentative;
}
public String getFilePath() { public String getFilePath() {
return filePath; return filePath;
} }
@ -156,7 +183,11 @@ public class InspectionReport implements Serializable {
", functionId=" + functionId + ", functionId=" + functionId +
", generalRemarks='" + generalRemarks + '\'' + ", generalRemarks='" + generalRemarks + '\'' +
", reportResult='" + reportResult + '\'' + ", reportResult='" + reportResult + '\'' +
", qualityAuditor='" + qualityAuditor + '\'' +
", productionRepresentative='" + productionRepresentative + '\'' +
", qcRepresentative='" + qcRepresentative + '\'' +
", items=" + items + ", items=" + items +
", filePath='" + filePath + '\'' +
", wrapperId=" + wrapperId + ", wrapperId=" + wrapperId +
'}'; '}';
} }

View File

@ -30,6 +30,11 @@ public class InspectionReportItem implements Serializable {
private float cartonsSelected; private float cartonsSelected;
private float packsSelected; private float packsSelected;
private float piecesSelected; private float piecesSelected;
private float checkedCartonsSelected;
private float checkedPacksSelected;
private float checkedPiecesSelected;
private String packingDetails; private String packingDetails;
private String sampleSize; private String sampleSize;
private String dateAdded; private String dateAdded;
@ -255,6 +260,30 @@ public class InspectionReportItem implements Serializable {
this.fnsku = fnsku; this.fnsku = fnsku;
} }
public float getCheckedCartonsSelected() {
return checkedCartonsSelected;
}
public void setCheckedCartonsSelected(float checkedCartonsSelected) {
this.checkedCartonsSelected = checkedCartonsSelected;
}
public float getCheckedPacksSelected() {
return checkedPacksSelected;
}
public void setCheckedPacksSelected(float checkedPacksSelected) {
this.checkedPacksSelected = checkedPacksSelected;
}
public float getCheckedPiecesSelected() {
return checkedPiecesSelected;
}
public void setCheckedPiecesSelected(float checkedPiecesSelected) {
this.checkedPiecesSelected = checkedPiecesSelected;
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View File

@ -0,0 +1,4 @@
package com.utopiaindustries.qualitychecker.models.callback;
public interface SaveDraftReportCallback extends SaveCallback{
}

View File

@ -1,6 +1,8 @@
package com.utopiaindustries.qualitychecker.service; package com.utopiaindustries.qualitychecker.service;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -26,6 +28,7 @@ import com.utopiaindustries.qualitychecker.models.Product;
import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveCheckpointCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDefectCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveDimensionCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveItemCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack; import com.utopiaindustries.qualitychecker.models.callback.SaveProductCallBack;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
@ -170,7 +173,52 @@ public class InspectionReportService {
} }
} }
private synchronized void saveDraftReportInDb( final Context context,
final InspectionReport inspectionReport,
final SaveDraftReportCallback callback) throws IOException {
SharedPreferences sharedPreferences = context.getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
//System.out.println(sharedPreferences.getString("draftReportId", null));
//System.out.println("Draft Button Click-8: " + draftReportId);
try {
// convert into byte array
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream( byteArrayOutputStream );
objectOutputStream.writeObject( inspectionReport );
objectOutputStream.flush();
byte[] bytes = byteArrayOutputStream.toByteArray();
// write bytes in file
long epochSeconds = System.currentTimeMillis() / 1000;
String fileName = "Report-" + epochSeconds + ".bin";
String savedPath = FileUtils.writeFile( context, bytes, fileName );
//System.out.println(fileName + "---" + savedPath );
new ReportRepository( context ).insertDraft(
new InspectionReportWrapper( draftReportId, savedPath, false ),
store.getReport().getItems().get(0).getFnsku()
);
callback.onSuccess();
} catch ( Exception e ){
callback.onFailure( new Exception( "Failed to Save in DB" ) );
e.printStackTrace();
}
}
public void saveDraftInLocalDb( Context context,
InspectionReport inspectionReport ,
SaveDraftReportCallback callback ){
new Thread(() -> {
populateDefectsInBackground( inspectionReport );
//post report
try {
saveDraftReportInDb( context, inspectionReport , callback );
} catch (IOException e) {
throw new RuntimeException(e);
}
}).start();
}
public void saveInLocalDb( Context context, public void saveInLocalDb( Context context,
InspectionReport inspectionReport , InspectionReport inspectionReport ,

View File

@ -130,6 +130,9 @@ public class NetworkService extends Service {
} catch ( Exception e){ } catch ( Exception e){
e.printStackTrace(); e.printStackTrace();
} }
catch (OutOfMemoryError e) {
e.printStackTrace();
}
} }
} }
return reports; return reports;

View File

@ -9,6 +9,7 @@ import android.content.pm.ActivityInfo;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
@ -22,8 +23,10 @@ import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.google.android.material.tabs.TabLayout;
import com.utopiaindustries.qualitychecker.R; import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.apiservice.ApiService; import com.utopiaindustries.qualitychecker.apiservice.ApiService;
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory; import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
@ -44,7 +47,10 @@ import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
import com.utopiaindustries.qualitychecker.receiver.NetworkReceiver; import com.utopiaindustries.qualitychecker.receiver.NetworkReceiver;
import com.utopiaindustries.qualitychecker.service.InspectionReportService; import com.utopiaindustries.qualitychecker.service.InspectionReportService;
import com.utopiaindustries.qualitychecker.store.Store; import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.activities.fragments.ReportsFragment;
import com.utopiaindustries.qualitychecker.ui.adapter.PagerAdapter;
import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter; import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter;
import com.utopiaindustries.qualitychecker.ui.fragments.FirstStepFragment;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -56,15 +62,20 @@ import retrofit2.Response;
public class HomeActivity extends AppCompatActivity implements View.OnClickListener { public class HomeActivity extends AppCompatActivity implements View.OnClickListener {
private Button createReportBtn,refreshReportsBtn,logoutBtn,fetchProductBtn; private Button createReportBtn,refreshReportsBtn,logoutBtn,fetchProductBtn;
private RecyclerView recyclerView; //private RecyclerView recyclerView;
private ApiService apiService; private ApiService apiService;
private TextView usernameTitle, emptyReportTextView; private TextView usernameTitle;//, emptyReportTextView;
private ImageView profileImage; private ImageView profileImage;
private Store store; private Store store;
private InspectionReportService inspectionReportService; private InspectionReportService inspectionReportService;
private NetworkReceiver networkReceiver; private NetworkReceiver networkReceiver;
private boolean isReceiverRegistered = false; private boolean isReceiverRegistered = false;
TabLayout tabLayout;
ViewPager viewPager;
PagerAdapter pagerAdapter;
@SuppressLint("SourceLockedOrientationActivity") @SuppressLint("SourceLockedOrientationActivity")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -89,23 +100,35 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
refreshReportsBtn = findViewById( R.id.refresh_btn ); refreshReportsBtn = findViewById( R.id.refresh_btn );
logoutBtn = findViewById( R.id.logout_btn ); logoutBtn = findViewById( R.id.logout_btn );
fetchProductBtn = findViewById( R.id.fetch_product_btn ); fetchProductBtn = findViewById( R.id.fetch_product_btn );
recyclerView = findViewById( R.id.reports_recyclerview ); //recyclerView = findViewById( R.id.reports_recyclerview );
usernameTitle = findViewById( R.id.username_title ); usernameTitle = findViewById( R.id.username_title );
profileImage = findViewById( R.id.profile_image ); profileImage = findViewById( R.id.profile_image );
emptyReportTextView = findViewById( R.id.empty_report_text ); //emptyReportTextView = findViewById( R.id.empty_report_text );
viewPager = (ViewPager) findViewById(R.id.viewpager);
pagerAdapter = new PagerAdapter(getSupportFragmentManager(), HomeActivity.this);
viewPager.setAdapter(pagerAdapter);
tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.setupWithViewPager(viewPager);
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
tab.setCustomView(pagerAdapter.getTabView(i));
}
refreshReportsBtn.setOnClickListener( this ); refreshReportsBtn.setOnClickListener( this );
createReportBtn.setOnClickListener( this ); createReportBtn.setOnClickListener( this );
logoutBtn.setOnClickListener( this ); logoutBtn.setOnClickListener( this );
fetchProductBtn.setOnClickListener( this ); fetchProductBtn.setOnClickListener( this );
recyclerView.setLayoutManager( new LinearLayoutManager( this ) ); //recyclerView.setLayoutManager( new LinearLayoutManager( this ) );
updateProfileImage(); updateProfileImage();
refreshReportData(); // refreshReportData();
} }
private void refreshReportData(){ /*private void refreshReportData(){
SharedPreferences sharedPreferences = getSharedPreferences("login_prefs", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
String username = sharedPreferences.getString("username", null ); String username = sharedPreferences.getString("username", null );
apiService.fetchAllReports( username ).enqueue( apiService.fetchAllReports( username ).enqueue(
@ -130,13 +153,21 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
} }
} }
); );
} }*/
@Override @Override
public void onClick(View v) { public void onClick(View v) {
int id = v.getId(); int id = v.getId();
if( id == R.id.create_report_btn ){ if( id == R.id.create_report_btn ){
SharedPreferences sharedPreferences = getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("draftReportId", "0");
editor.apply();
Intent intent = new Intent( this, MainActivity.class ); Intent intent = new Intent( this, MainActivity.class );
intent.putExtra("fromClass", "Home");
intent.putExtra("draftID", "0");
startActivity( intent ); startActivity( intent );
} }
if( id == R.id.logout_btn ){ if( id == R.id.logout_btn ){
@ -150,8 +181,11 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
finish(); finish();
} }
if( id == R.id.refresh_btn ){ if( id == R.id.refresh_btn ){
refreshReportData(); // refreshReportData();
updateProfileImage(); updateProfileImage();
ReportsFragment secondFragment = (ReportsFragment) getSupportFragmentManager().getFragments().get(0);
secondFragment.updateData();
} }
if( id == R.id.fetch_product_btn ){ if( id == R.id.fetch_product_btn ){
if( isNetworkConnected() ) { if( isNetworkConnected() ) {
@ -183,6 +217,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
editor.apply(); editor.apply();
usernameTitle.setText( response.body().getName() ); usernameTitle.setText( response.body().getName() );
store.setEmployeePhoto( response.body() ); store.setEmployeePhoto( response.body() );
Log.e("Profile-Image: ",""+store.getProfileImage());
Glide.with( getBaseContext() ) Glide.with( getBaseContext() )
.load( store.getProfileImage( ) ) .load( store.getProfileImage( ) )
.into( profileImage ); .into( profileImage );
@ -376,7 +411,7 @@ public class HomeActivity extends AppCompatActivity implements View.OnClickListe
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
refreshReportData(); // refreshReportData();
} }
@Override @Override

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.Toast; import android.widget.Toast;
@ -22,16 +23,27 @@ import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import com.utopiaindustries.qualitychecker.R; import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.store.Store; import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.fragments.FirstStepFragment; import com.utopiaindustries.qualitychecker.ui.fragments.FirstStepFragment;
import com.utopiaindustries.qualitychecker.ui.fragments.SecondStepFragment; import com.utopiaindustries.qualitychecker.ui.fragments.SecondStepFragment;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult; import com.google.zxing.integration.android.IntentResult;
import com.utopiaindustries.qualitychecker.utils.FileUtils;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private NavController navController; private NavController navController;
private Store store; private Store store;
private String fromClass;
private String draftReportId;
@SuppressLint("SourceLockedOrientationActivity") @SuppressLint("SourceLockedOrientationActivity")
@Override @Override
@ -47,9 +59,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
return insets; return insets;
}); });
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ); setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
navController = Navigation.findNavController( this, R.id.nav_host_fragment );
fromClass = getIntent().getStringExtra("fromClass");
draftReportId = getIntent().getStringExtra("draftID");
if (fromClass.equalsIgnoreCase("Draft")) {
System.out.println("Draft Report ID: " + draftReportId);
}
navController = Navigation.findNavController( this, R.id.nav_host_fragment);
// initializing fields // initializing fields
updateUsername(); updateUsername();
} }
private void updateUsername() { private void updateUsername() {
if ( store.getReport() != null ) { if ( store.getReport() != null ) {
@ -76,19 +98,35 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); Log.e("requestCode: ",""+requestCode);
if (result != null) { Log.e("resultCode: ",""+resultCode);
if (result.getContents() == null) { Log.e("data: ",""+data);
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show(); Log.e("-----------------------","---------------------");
} else {
super.onActivityResult(requestCode, resultCode, data); if (requestCode == IntentIntegrator.REQUEST_CODE) {
FirstStepFragment firstStepFragment = ( FirstStepFragment) getCurrentVisibleFragment(); Log.e("Zxing barcode scan: ","-----");
firstStepFragment.onBarcodeScanResult( result.getContents() );
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
if (result.getContents() == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
super.onActivityResult(requestCode, resultCode, data);
FirstStepFragment firstStepFragment = ( FirstStepFragment) getCurrentVisibleFragment();
firstStepFragment.onBarcodeScanResult( result.getContents() );
}
} }
} else { }
super.onActivityResult(requestCode, resultCode, data); else if (requestCode != -1 && resultCode == -1 && data == null) {
SecondStepFragment secondStepFragment = ( SecondStepFragment) getCurrentVisibleFragment(); Log.e("camera ","------- camera ***");
secondStepFragment.onImagePickerResult( requestCode, resultCode, data ); SecondStepFragment secondStepFragment = ( SecondStepFragment) getCurrentVisibleFragment();
secondStepFragment.onImagePickerResult( requestCode, resultCode, data );
}
else if (requestCode != -1 && resultCode == -1 && data != null) {
Log.e("gallery ","------ gallery ***");
SecondStepFragment secondStepFragment = ( SecondStepFragment) getCurrentVisibleFragment();
secondStepFragment.onImagePickerResult( requestCode, resultCode, data );
} }
} }
@ -98,4 +136,31 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
FragmentManager fragmentManager = navHostFragment.getChildFragmentManager(); FragmentManager fragmentManager = navHostFragment.getChildFragmentManager();
return fragmentManager.getPrimaryNavigationFragment(); return fragmentManager.getPrimaryNavigationFragment();
} }
private InspectionReport getSingleReport(InspectionReportWrapper wrapper) {
InspectionReport report = null;
if (wrapper != null) {
try {
// Get byte array from file content path
byte[] result = FileUtils.readFile(wrapper.getContent());
// Convert byte array to an InspectionReport object
ByteArrayInputStream byteIn = new ByteArrayInputStream(result);
ObjectInputStream in = new ObjectInputStream(byteIn);
report = (InspectionReport) in.readObject();
// Set additional details from the wrapper
report.setWrapperId(wrapper.getId());
report.setFilePath(wrapper.getContent());
} catch (Exception e) {
e.printStackTrace();
}
}
return report;
}
} }

View File

@ -0,0 +1,109 @@
package com.utopiaindustries.qualitychecker.ui.activities.fragments;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.activities.MainActivity;
import com.utopiaindustries.qualitychecker.ui.adapter.DraftReportAdapter;
import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter;
import com.utopiaindustries.qualitychecker.utils.FileUtils;
import com.utopiaindustries.qualitychecker.utils.SelectListener;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.List;
public class DraftFragment extends Fragment implements SelectListener {
RecyclerView recyclerView;
TextView emptyReportTextView;
private Store store;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_draft , container, false );
initializeViews( view );
return view;
}
private void initializeViews( View view ) {
recyclerView = view.findViewById( R.id.draft_recyclerview );
emptyReportTextView = view.findViewById(R.id.empty_report_text);
recyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
store = Store.getInstance();
refreshReportData();
}
@Override
public void onResume() {
super.onResume();
refreshReportData();
}
public void refreshReportData() {
ReportRepository repository = new ReportRepository( getContext() );
List<InspectionReportWrapper> reportWrappers = repository.findAllDraftReports();
System.out.println(reportWrappers.size());
DraftReportAdapter adapter = new DraftReportAdapter( reportWrappers, this );
recyclerView.setAdapter( adapter );
if(reportWrappers.isEmpty()) {
emptyReportTextView.setVisibility( View.VISIBLE ) ;
}
else {
emptyReportTextView.setVisibility( View.INVISIBLE ) ;
}
}
@Override
public void onItemClicked(InspectionReportWrapper reportWrapper) {
//Toast.makeText(getContext(), String.valueOf(reportWrapper.getId()), Toast.LENGTH_SHORT).show();
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("draftReportId", String.valueOf(reportWrapper.getId()));
editor.apply();
Intent intent = new Intent( getContext(), MainActivity.class );
intent.putExtra("fromClass", "Draft");
intent.putExtra("draftID", String.valueOf(reportWrapper.getId()));
startActivity( intent );
}
}

View File

@ -0,0 +1,112 @@
package com.utopiaindustries.qualitychecker.ui.activities.fragments;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.apiservice.ApiService;
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.receiver.NetworkReceiver;
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.adapter.ReportAdapter;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ReportsFragment extends Fragment {
RecyclerView recyclerView;
ApiService apiService;
Store store;
InspectionReportService inspectionReportService;
TextView emptyReportTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_reports , container, false );
initializeViews( view );
// Inflate the layout for this fragment
return view;
}
private void initializeViews( View view ) {
store = Store.getInstance();
apiService = ApiServiceFactory.getApiService();
inspectionReportService = InspectionReportService.getInstance();
recyclerView = view.findViewById( R.id.reports_recyclerview );
emptyReportTextView = view.findViewById(R.id.empty_report_text);
recyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) );
//Toast.makeText(getContext(), "Reports Fragment", Toast.LENGTH_LONG).show();
}
private void refreshReportData(){
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
String username = sharedPreferences.getString("username", null );
apiService.fetchAllReports( username ).enqueue(
new Callback<List<InspectionReport>>() {
@Override
public void onResponse(Call<List<InspectionReport>> call, Response<List<InspectionReport>> response) {
if( response.isSuccessful() && response.body() != null ){
System.out.println( response.body().size() );
ReportAdapter adapter = new ReportAdapter( response.body() );
recyclerView.setAdapter( adapter );
if( response.body().isEmpty() )
emptyReportTextView.setVisibility( View.VISIBLE ) ;
} else {
System.out.println("Error");
emptyReportTextView.setVisibility( View.VISIBLE ) ;
}
}
@Override
public void onFailure(Call<List<InspectionReport>> call, Throwable t) {
System.out.println( t.getMessage() );
emptyReportTextView.setVisibility( View.VISIBLE ) ;
}
}
);
}
@Override
public void onResume() {
super.onResume();
refreshReportData();
}
public void updateData() {
// Your logic to update fragment data
System.out.println("Reports-Update");
refreshReportData();
}
}

View File

@ -1,12 +1,17 @@
package com.utopiaindustries.qualitychecker.ui.adapter; package com.utopiaindustries.qualitychecker.ui.adapter;
import static androidx.core.app.ActivityCompat.startActivityForResult;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.net.Uri;
import android.graphics.BitmapFactory; import android.os.Environment;
import android.provider.MediaStore;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -16,12 +21,12 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -30,7 +35,12 @@ import com.utopiaindustries.qualitychecker.models.InspectionCheckPoint;
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku; import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
import com.utopiaindustries.qualitychecker.models.InspectionDefect; import com.utopiaindustries.qualitychecker.models.InspectionDefect;
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint; import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
import com.utopiaindustries.qualitychecker.utils.ImageUriHolder;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -43,6 +53,7 @@ public class CheckPointAdapter extends
private final List<String> defectTypes; private final List<String> defectTypes;
private final List<InspectionCheckpointSku> checkpointSkus; private final List<InspectionCheckpointSku> checkpointSkus;
private final Context context; private final Context context;
public CheckPointAdapter( List<InspectionItemCheckPoint> checkPointList, public CheckPointAdapter( List<InspectionItemCheckPoint> checkPointList,
List<InspectionCheckPoint> checkPoints, List<InspectionCheckPoint> checkPoints,
List<InspectionDefect> defects, List<InspectionDefect> defects,
@ -74,6 +85,7 @@ public class CheckPointAdapter extends
@Override @Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
InspectionItemCheckPoint checkPoint = checkPointList.get( position ); InspectionItemCheckPoint checkPoint = checkPointList.get( position );
holder.imageRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
holder.bind(checkPoints, defects, defectTypes, checkPoint, checkpointSkus, context ); holder.bind(checkPoints, defects, defectTypes, checkPoint, checkpointSkus, context );
//holder.setIsRecyclable(false); //holder.setIsRecyclable(false);
@ -106,16 +118,60 @@ public class CheckPointAdapter extends
} }
holder.imagePicker.setOnClickListener( v -> { holder.imagePicker.setOnClickListener( v -> {
Intent intent = new Intent( Intent.ACTION_GET_CONTENT ); //--------------------------------------------------------------------------------------
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Choose an Option");
String[] options = {"Gallery", "Camera"};
builder.setItems(options, (dialog, which) -> {
switch (which) {
case 0:
Log.e("Gallery","**********");
Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
intent.addCategory( Intent.CATEGORY_OPENABLE );
intent.setType( "image/*" );
( ( Activity ) context ).startActivityForResult( intent, position );
break;
case 1:
Log.e("Camera: ","***********");
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File imageFile = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "captured_image.jpg");
Uri imageUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", imageFile);
//Log.e("imageUri: ",""+imageUri);
ImageUriHolder.getInstance().setImageUri(imageUri);
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
( ( Activity ) context ).startActivityForResult(camera_intent, position);
break;
}
});
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
AlertDialog dialog = builder.create();
dialog.show();
//--------------------------------------------------------------------------------------
//Image pick from Gallery
/*Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
intent.addCategory( Intent.CATEGORY_OPENABLE ); intent.addCategory( Intent.CATEGORY_OPENABLE );
intent.setType( "image/*" ); intent.setType( "image/*" );
( ( Activity ) context ).startActivityForResult( intent, position ); ( ( Activity ) context ).startActivityForResult( intent, position );*/
//Now image Pick from Camera
/*Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
( ( Activity ) context ).startActivityForResult(camera_intent, position);*/
}); });
holder.deleteImage.setOnClickListener( v -> { holder.deleteImage.setOnClickListener( v -> {
checkPoint.setFile( null ); checkPoint.setFile( null );
checkPoint.setImagePath( "" ); checkPoint.setImagePath( "" );
holder.imagePreview.setImageDrawable( null ); // holder.imagePreview.setImageDrawable( null );
checkPoint.getFiles().listIterator(checkPoint.getFiles().size());
if (!checkPoint.getFiles().isEmpty()) {
checkPoint.getFiles().remove(checkPoint.getFiles().size() - 1);
} else {
System.out.println("The list is empty");
}
notifyItemChanged( position ); notifyItemChanged( position );
}); });
@ -140,12 +196,15 @@ public class CheckPointAdapter extends
private final ImageButton imagePicker,deleteImage,addDefect; private final ImageButton imagePicker,deleteImage,addDefect;
private final LinearLayout linearLayout; private final LinearLayout linearLayout;
private final TextView selectedImage,standard; private final TextView selectedImage,standard;
private final ImageView imagePreview; //private final ImageView imagePreview;
private final RecyclerView defectRecyclerView; private final RecyclerView defectRecyclerView;
private TextWatcher remarksTextWatcher; private TextWatcher remarksTextWatcher;
private CompoundButton.OnCheckedChangeListener okCheckboxListener; private CompoundButton.OnCheckedChangeListener okCheckboxListener;
private CompoundButton.OnCheckedChangeListener noCheckboxListener; private CompoundButton.OnCheckedChangeListener noCheckboxListener;
private RecyclerView imageRecyclerView;
private ImageAdapter imageAdapter;
public ViewHolder(@NonNull View itemView) { public ViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
remarks = itemView.findViewById(R.id.check_point_remarks); remarks = itemView.findViewById(R.id.check_point_remarks);
@ -156,7 +215,10 @@ public class CheckPointAdapter extends
selectedImage = itemView.findViewById( R.id.selected_image ); selectedImage = itemView.findViewById( R.id.selected_image );
linearLayout = itemView.findViewById(R.id.defect_layout); linearLayout = itemView.findViewById(R.id.defect_layout);
deleteImage = itemView.findViewById( R.id.delete_image ); deleteImage = itemView.findViewById( R.id.delete_image );
imagePreview = itemView.findViewById( R.id.preview_image ); // imagePreview = itemView.findViewById( R.id.preview_image );
imageRecyclerView = itemView.findViewById(R.id.imageRecyclerView);
defectRecyclerView = itemView.findViewById( R.id.defects_recyclerview ); defectRecyclerView = itemView.findViewById( R.id.defects_recyclerview );
addDefect = itemView.findViewById( R.id.add_defect ); addDefect = itemView.findViewById( R.id.add_defect );
standard = itemView.findViewById( R.id.standard ); standard = itemView.findViewById( R.id.standard );
@ -181,23 +243,38 @@ public class CheckPointAdapter extends
} }
remarks.setText( data.getRemarks() ); remarks.setText( data.getRemarks() );
imagePreview.setImageBitmap( null ); // imagePreview.setImageBitmap( null );
selectedImage.setText( "" ); selectedImage.setText( "" );
if( data.getFile() != null && data.getFile().length > 0 && data.getImagePath() != null && ! data.getImagePath().isEmpty() ){ /*if( data.getFile() != null && data.getFile().length > 0 && data.getImagePath() != null && ! data.getImagePath().isEmpty() ){
Bitmap bitmap = BitmapFactory.decodeByteArray( data.getFile(), 0 , data.getFile().length ); Bitmap bitmap = BitmapFactory.decodeByteArray( data.getFile(), 0 , data.getFile().length );
imagePreview.setImageBitmap( bitmap ); imagePreview.setImageBitmap( bitmap );
selectedImage.setText( data.getImagePath() ); selectedImage.setText( data.getImagePath() );
} }*/
// initialize recyclerview // initialize recyclerview
List<String> checkPointsList = checkPoints.stream().map(InspectionCheckPoint::getTitle).collect(Collectors.toList()); List<String> checkPointsList = checkPoints.stream().map(InspectionCheckPoint::getTitle).collect(Collectors.toList());
// Populate checklist Spinner dropdown // Populate checklist Spinner dropdown
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(checkpointSpinner.getContext(), ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(checkpointSpinner.getContext(),
android.R.layout.simple_spinner_item, checkPointsList); android.R.layout.simple_spinner_item, checkPointsList);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
checkpointSpinner.setAdapter(spinnerAdapter); checkpointSpinner.setAdapter(spinnerAdapter);
//image Recyclerview
if ( data != null ) {
if (data.getFiles() != null) {
List<byte[]> imageList = data.getFiles();
//System.out.println("Image-size-adapter: " + imageList.size());
imageRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
imageAdapter = new ImageAdapter(imageList, context);
imageRecyclerView.setAdapter(imageAdapter);
imageAdapter.notifyItemChanged(getAdapterPosition());
}
}
// Pre populate // Pre populate
String defaultSelectedItem = data.getTitle(); String defaultSelectedItem = data.getTitle();
int defaultPosition = checkPointsList.indexOf(defaultSelectedItem); int defaultPosition = checkPointsList.indexOf(defaultSelectedItem);

View File

@ -0,0 +1,115 @@
package com.utopiaindustries.qualitychecker.ui.adapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.utils.SelectListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class DraftReportAdapter extends
RecyclerView.Adapter<DraftReportAdapter.ViewHolder>{
private final List<InspectionReportWrapper> reports;
private SelectListener listener;
public DraftReportAdapter(List<InspectionReportWrapper> reports, SelectListener listener) {
this.reports = reports;
this.listener = listener;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from( parent.getContext() ).inflate(R.layout.draft_report_item , parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
try {
holder.bindDate( reports.get( position ) );
holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClicked(reports.get(position));
}
});
holder.delete_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("Delete-Report: ","********");
new ReportRepository(v.getContext()).deleteDraftRecordById(reports.get(position).getId());
reports.remove(position); // Remove from the list
notifyItemRemoved(position); // Notify RecyclerView about the item removal
notifyItemRangeChanged(position, reports.size());
}
});
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public int getItemCount() {
return reports.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
private final TextView codeTv, remarksTv,dateTv,status;//createdByTv,;
private final SimpleDateFormat jsonDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
private final SimpleDateFormat displayDateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm a", Locale.getDefault());
private final CardView cardView;
private final ImageButton delete_image;
public ViewHolder(@NonNull View itemView) {
super(itemView);
codeTv = itemView.findViewById( R.id.code );
//createdByTv = itemView.findViewById( R.id.created_by );
delete_image = itemView.findViewById(R.id.delete_image);
remarksTv = itemView.findViewById( R.id.remarks );
dateTv = itemView.findViewById( R.id.date );
status = itemView.findViewById( R.id.status );
cardView = itemView.findViewById(R.id.main_container);
}
public void bindDate( InspectionReportWrapper report ) throws ParseException {
codeTv.setText( "Report- " + (getAdapterPosition() + 1) );
//createdByTv.setText("" );
remarksTv.setText( "" );
//Date date = jsonDateFormat.parse( new Date().toString() );
// Format the date in 12-hour format
//String formattedDateTime = displayDateFormat.format( date );
String date = displayDateFormat.format(new Date());
dateTv.setText(date);
/* if( report.getReportResult().equalsIgnoreCase("FAILED") ){
status.setBackgroundResource( R.drawable.failed_bg );
}
if( report.getReportResult().equalsIgnoreCase("PASSED") ){
status.setBackgroundResource( R.drawable.passed_bg );
}
if( report.getReportResult().equalsIgnoreCase("ON_HOLD") ){
status.setBackgroundResource( R.drawable.hold_bg );
}*/
status.setText("Draft");
}
}
}

View File

@ -0,0 +1,72 @@
package com.utopiaindustries.qualitychecker.ui.adapter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.utopiaindustries.qualitychecker.R;
import java.util.List;
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
//private byte[] file;
//private List<String> imageList;
List<byte[]> imageList;
private Context context;
public ImageAdapter(List<byte[]> imageList, Context context) {
this.imageList = imageList;
this.context = context;
}
@NonNull
@Override
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image, parent, false);
return new ImageViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
//holder.imageView.setImageBitmap(null);
holder.imageView.setImageResource(R.drawable.img_load);
//Bitmap bitmap = BitmapFactory.decodeByteArray( imageList.get(position), 0 , imageList.get(position).length );
//holder.imageView.setImageBitmap( bitmap );
/*Glide.with(context)
.load(bitmap) // Load the Bitmap directly
.placeholder(R.drawable.img_load)
.apply(new RequestOptions().centerCrop()) // Optional: apply transformations like center crop
.into(holder.imageView);*/
Glide.with(context)
.load(imageList.get(position)) // Glide will handle the decoding and placeholder
.placeholder(R.drawable.img_load)
.apply(new RequestOptions().centerCrop())
.into(holder.imageView);
}
@Override
public int getItemCount() {
return imageList.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
ImageView imageView;
public ImageViewHolder(@NonNull View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
}
}
}

View File

@ -0,0 +1,62 @@
package com.utopiaindustries.qualitychecker.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.ui.activities.fragments.DraftFragment;
import com.utopiaindustries.qualitychecker.ui.activities.fragments.ReportsFragment;
@SuppressWarnings("deprecation")
public class PagerAdapter extends FragmentStatePagerAdapter {
String tabTitles[] = new String[]{"Reports", "Draft"};
Context context;
public PagerAdapter(FragmentManager fm, Context context) {
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
this.context = context;
}
@Override
public int getCount() {
return tabTitles.length;
}
@NonNull
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return new ReportsFragment();
case 1:
return new DraftFragment();
}
return null;
}
@Override
public CharSequence getPageTitle(int position) {
// Generate title based on item position
// return tabTitles[position];
return null;
}
public View getTabView(int position) {
View tab = LayoutInflater.from(context).inflate(R.layout.custom_tab, null);
TextView tv = (TextView) tab.findViewById(R.id.txt_name);
tv.setText(tabTitles[position]);
// tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, context.getResources().getDimension(R.dimen.tab_text_size));
return tab;
}
}

View File

@ -4,6 +4,8 @@ import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -18,6 +20,7 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -35,16 +38,24 @@ import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
import com.utopiaindustries.qualitychecker.db.DimensionRepository; import com.utopiaindustries.qualitychecker.db.DimensionRepository;
import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository; import com.utopiaindustries.qualitychecker.db.InspectionCheckpointSkuRepository;
import com.utopiaindustries.qualitychecker.db.ProductRepository; import com.utopiaindustries.qualitychecker.db.ProductRepository;
import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku; import com.utopiaindustries.qualitychecker.models.InspectionCheckpointSku;
import com.utopiaindustries.qualitychecker.models.InspectionDimension; import com.utopiaindustries.qualitychecker.models.InspectionDimension;
import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.InspectionReportItem; import com.utopiaindustries.qualitychecker.models.InspectionReportItem;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
import com.utopiaindustries.qualitychecker.models.Product; import com.utopiaindustries.qualitychecker.models.Product;
import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
import com.utopiaindustries.qualitychecker.service.InspectionReportService; import com.utopiaindustries.qualitychecker.service.InspectionReportService;
import com.utopiaindustries.qualitychecker.store.Store; import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.adapter.ItemHistoryAdapter; import com.utopiaindustries.qualitychecker.ui.adapter.ItemHistoryAdapter;
import com.google.zxing.integration.android.IntentIntegrator; import com.google.zxing.integration.android.IntentIntegrator;
import com.journeyapps.barcodescanner.CaptureActivity; import com.journeyapps.barcodescanner.CaptureActivity;
import com.utopiaindustries.qualitychecker.utils.FileUtils;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -58,8 +69,8 @@ import retrofit2.Response;
public class FirstStepFragment extends Fragment implements View.OnClickListener { public class FirstStepFragment extends Fragment implements View.OnClickListener {
private NavController navController; private NavController navController;
private Button leftFab,rightFab,showHistoryBtn; private Button leftFab,rightFab,showHistoryBtn, btnDraft;
private EditText sku,boxCarton,itemPerBox,pieces,packagingDetails,boxCartonSelected,itemPerBoxSelected,piecesSelected; private EditText sku,boxCarton,itemPerBox,pieces,packagingDetails,boxCartonSelected,itemPerBoxSelected,piecesSelected, checkedBoxCartonSelected, checkedItemPerBoxSelected, checkedPiecesSelected;
private Spinner markerplace,modelNumber,title,color,size; private Spinner markerplace,modelNumber,title,color,size;
private CheckBox fri,refri; private CheckBox fri,refri;
private ImageButton searchSku,scanBtn; private ImageButton searchSku,scanBtn;
@ -67,23 +78,62 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
private ImageView profileImage; private ImageView profileImage;
private ApiService apiService; private ApiService apiService;
private Store store; private Store store;
private InspectionReportService inspectionReportService;
List<String> sizes = Collections.singletonList("[Size]");
List<String> colors = Collections.singletonList("[Color]");
List<String> titles = Collections.singletonList("[Title]");
List<String> modelNumbers = Collections.singletonList("[Model Number]");
List<String> marketplaces = Collections.singletonList("[ Marketplace ]");
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_first_step , container, false ); View view = inflater.inflate(R.layout.fragment_first_step , container, false );
//System.out.println("onCreateView---------->");
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
//System.out.println("onCreateView---------->" + draftReportId);
store = Store.getInstance();
if (draftReportId > 0) {
ReportRepository repository = new ReportRepository( getContext() );
InspectionReportWrapper report = repository.findDraftReportById(Long.parseLong(String.valueOf(draftReportId)));
InspectionReport inspectionReport = getSingleReport(report);
//System.out.println(inspectionReport);
store.setReport(inspectionReport);
//System.out.println("Report-SKU: " + store.getReport().getItems().get(0).getFnsku());
}
initializeViews( view ); initializeViews( view );
apiService = ApiServiceFactory.getApiService(); apiService = ApiServiceFactory.getApiService();
store = Store.getInstance(); inspectionReportService = InspectionReportService.getInstance();
// set on click listener // set on click listener
leftFab.setOnClickListener( this ); leftFab.setOnClickListener( this );
rightFab.setOnClickListener( this ); rightFab.setOnClickListener( this );
searchSku.setOnClickListener( this ); searchSku.setOnClickListener( this );
btnDraft.setOnClickListener( this);
scanBtn.setOnClickListener( this ); scanBtn.setOnClickListener( this );
showHistoryBtn.setOnClickListener( this ); showHistoryBtn.setOnClickListener( this );
populateItem( store.getProducts(), true ); populateItem( store.getProducts(), true );
prePopulateData( store.getProducts() ); prePopulateData( store.getProducts() );
updateProfileViews(); updateProfileViews();
// sku.setText(store.getReport().getItems().get(0).getFnsku());
if (draftReportId > 0) {
String selectedString = store.getReport().getItems().get(0).getMarketplace();
int index = marketplaces.indexOf(selectedString);
markerplace.setSelection(index);
if( sku.getText() != null ){
populateProductDataOnSelection( sku.getText().toString(), "", true );
store.setCheckpointSkus( new ArrayList<>() );
populateSkuCheckpointsParams( store.getReport().getItems().get(0).getSku(),
store.getReport().getItems().get(0).getMarketplace());
}
}
fri.setOnCheckedChangeListener((buttonView, isChecked) -> { fri.setOnCheckedChangeListener((buttonView, isChecked) -> {
if( isChecked ){ if( isChecked ){
@ -196,6 +246,8 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
}); });
//onTextChanges logic implementation
//box = 1, itemPerBox, pieces
boxCartonSelected.addTextChangedListener(new TextWatcher() { boxCartonSelected.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -205,6 +257,22 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
try { try {
int packsCount = 0, piecesCount = 0;
int boxCount = Integer.parseInt(s.toString());
if (itemPerBox.getText().toString().isEmpty() || pieces.getText().toString().isEmpty()) {
Toast.makeText(getContext(), "Enter Item/Pieces Per box", Toast.LENGTH_SHORT).show();
}
else {
packsCount = (int) store.getProducts().get(0).getItemPerPack();
piecesCount = (int) store.getProducts().get(0).getItemPerBox();
int totalPacks = boxCount * packsCount;
int totalPieces = totalPacks * piecesCount;
itemPerBoxSelected.setText(String.valueOf(totalPacks));
piecesSelected.setText(String.valueOf(totalPieces));
}
store.getReport().getItems().get(0).setCartonsSelected( Long.parseLong( s.toString() ) ); store.getReport().getItems().get(0).setCartonsSelected( Long.parseLong( s.toString() ) );
} catch ( Exception e ){ } catch ( Exception e ){
store.getReport().getItems().get(0).setCartonsSelected( 0 ); store.getReport().getItems().get(0).setCartonsSelected( 0 );
@ -217,6 +285,44 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
}); });
//checked Item
checkedBoxCartonSelected.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) {
try {
int packsCount = 0, piecesCount = 0;
int boxCount = Integer.parseInt(s.toString());
if (itemPerBox.getText().toString().isEmpty() || pieces.getText().toString().isEmpty()) {
Toast.makeText(getContext(), "Enter Item/Pieces Per box", Toast.LENGTH_SHORT).show();
}
else {
packsCount = (int) store.getProducts().get(0).getItemPerPack();
piecesCount = (int) store.getProducts().get(0).getItemPerBox();
int totalPacks = boxCount * packsCount;
int totalPieces = totalPacks * piecesCount;
checkedItemPerBoxSelected.setText(String.valueOf(totalPacks));
checkedPiecesSelected.setText(String.valueOf(totalPieces));
}
store.getReport().getItems().get(0).setCheckedCartonsSelected( Long.parseLong( s.toString() ) );
} catch ( Exception e ){
store.getReport().getItems().get(0).setCheckedCartonsSelected( 0 );
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
itemPerBoxSelected.addTextChangedListener(new TextWatcher() { itemPerBoxSelected.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -238,6 +344,28 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
}); });
//checkedItemPerBox
checkedItemPerBoxSelected.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) {
try {
store.getReport().getItems().get(0).setCheckedPacksSelected( Long.parseLong( s.toString() ) );
} catch ( Exception e ){
store.getReport().getItems().get(0).setCheckedPacksSelected( 0 );
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
piecesSelected.addTextChangedListener(new TextWatcher() { piecesSelected.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -259,6 +387,28 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
}); });
//checkedPieces
checkedPiecesSelected.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) {
try {
store.getReport().getItems().get(0).setCheckedPiecesSelected( Long.parseLong( s.toString() ) );
} catch ( Exception e ){
store.getReport().getItems().get(0).setCheckedPiecesSelected( 0 );
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
// generalRemarks.addTextChangedListener(new TextWatcher() { // generalRemarks.addTextChangedListener(new TextWatcher() {
// @Override // @Override
// public void beforeTextChanged(CharSequence s, int start, int count, int after) { // public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -283,19 +433,85 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
return view; return view;
} }
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//System.out.println("onViewCreated---------->");
store = Store.getInstance();
//System.out.println("Draft Button Click-1" + store.getReport());
//System.out.println("Report: " + store.getReport());
//System.out.println("SKU: " + store.getReport().getItems().get(0).getFnsku());
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {
navController = Navigation.findNavController( requireView() ); navController = Navigation.findNavController( requireView() );
if (v.getId() == R.id.button_draft_first) {
//--Draft Incomplete Report
//Log.e("sku: ",""+sku.getText().toString());
//Log.e("Market-place: ",""+store.getReport().getItems().get(0).getMarketplace());
if(!sku.getText().toString().isEmpty() && !store.getReport().getItems().get(0).getMarketplace().equalsIgnoreCase("[ Marketplace ]")) {
if (store.getReport() != null) {
inspectionReportService.saveDraftInLocalDb(getContext(), store.getReport(), new SaveDraftReportCallback() {
@Override
public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
// progressBar.setVisibility(View.INVISIBLE);
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("draftReportId", "0");
editor.apply();
Objects.requireNonNull(getActivity()).finish();
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Report is successfully drafted");
Toast.makeText(getContext(), "Report Saved as Draft", Toast.LENGTH_SHORT).show();
});
}
@Override
public void onFailure(Throwable throwable) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(getContext(), throwable.getMessage(), Toast.LENGTH_LONG).show();
//progressBar.setVisibility(View.INVISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Error in saving report");
});
}
});
}
}
else {
Toast.makeText(getContext(),"Please enter or scan sku details", Toast.LENGTH_SHORT).show();
}
//---
}
if( v.getId() == R.id.button_left_frag_1 ){ if( v.getId() == R.id.button_left_frag_1 ){
if( getActivity() != null ){ if( getActivity() != null ){
getActivity().finish(); getActivity().finish();
} }
} }
if( v.getId() == R.id.button_right_frag_1 ){ if( v.getId() == R.id.button_right_frag_1 ){
navController.navigate( R.id.action_firstStepFragment_to_secondStepFragment ); if (!sku.getText().toString().isEmpty() && !store.getReport().getItems().get(0).getMarketplace().equalsIgnoreCase("[ Marketplace ]")) {
navController.navigate( R.id.action_firstStepFragment_to_secondStepFragment );
}
else {
Toast.makeText(getContext(),"Please enter or scan sku details", Toast.LENGTH_SHORT).show();
}
} }
if( v.getId() == R.id.search_sku_btn ){ if( v.getId() == R.id.search_sku_btn ){
if( sku.getText() != null ){ if( sku.getText() != null && !sku.getText().toString().isEmpty() ){
populateProductDataOnSelection( sku.getText().toString(), "", true ); populateProductDataOnSelection( sku.getText().toString(), "", true );
store.setCheckpointSkus( new ArrayList<>() ); store.setCheckpointSkus( new ArrayList<>() );
populateSkuCheckpointsParams( store.getReport().getItems().get(0).getSku(), populateSkuCheckpointsParams( store.getReport().getItems().get(0).getSku(),
@ -344,6 +560,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
} }
private void prePopulateData( List<Product> products ){ private void prePopulateData( List<Product> products ){
System.out.println("prePopulateData: " + store.getReport().getItems().get(0).getFnsku());
fri.setChecked( store.getReport().getFri() ); fri.setChecked( store.getReport().getFri() );
refri.setChecked( ! store.getReport().getFri() ); refri.setChecked( ! store.getReport().getFri() );
// sku // sku
@ -397,6 +614,12 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
boxCartonSelected.setText( String.valueOf( store.getReport().getItems().get(0).getCartonsSelected() )); boxCartonSelected.setText( String.valueOf( store.getReport().getItems().get(0).getCartonsSelected() ));
itemPerBoxSelected.setText( String.valueOf( store.getReport().getItems().get(0).getPacksSelected() ) ); itemPerBoxSelected.setText( String.valueOf( store.getReport().getItems().get(0).getPacksSelected() ) );
piecesSelected.setText( String.valueOf( store.getReport().getItems().get(0).getPiecesSelected() ) ); piecesSelected.setText( String.valueOf( store.getReport().getItems().get(0).getPiecesSelected() ) );
checkedBoxCartonSelected.setText( 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() ) );
// generalRemarks.setText( store.getReport().getItems().get(0).getSampleSize() ); // generalRemarks.setText( store.getReport().getItems().get(0).getSampleSize() );
store.getReport().getItems().get(0).setTotalPresentPieces( Long.parseLong( inventory ) ); store.getReport().getItems().get(0).setTotalPresentPieces( Long.parseLong( inventory ) );
@ -415,7 +638,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
private void populateSize( List<Product> products ){ private void populateSize( List<Product> products ){
List<String> sizes = Collections.singletonList("[Size]");
if( ! products.isEmpty() ){ if( ! products.isEmpty() ){
sizes = products.stream().map( Product::getSmSize ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ); sizes = products.stream().map( Product::getSmSize ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
} }
@ -430,7 +653,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
private void populateColor( List<Product> products ){ private void populateColor( List<Product> products ){
List<String> colors = Collections.singletonList("[Color]");
if( ! products.isEmpty() ){ if( ! products.isEmpty() ){
colors = products.stream().map( Product::getSmColor ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ); colors = products.stream().map( Product::getSmColor ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
} }
@ -445,7 +668,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
private void populateTitle( List<Product> products ){ private void populateTitle( List<Product> products ){
List<String> titles = Collections.singletonList("[Title]");
if( ! products.isEmpty() ){ if( ! products.isEmpty() ){
titles = products.stream().map( Product::getTitle ).distinct().filter(Objects::nonNull).collect(Collectors.toList()) ; titles = products.stream().map( Product::getTitle ).distinct().filter(Objects::nonNull).collect(Collectors.toList()) ;
} }
@ -459,7 +682,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
private void populateModelNumber( List<Product> products ){ private void populateModelNumber( List<Product> products ){
List<String> modelNumbers = Collections.singletonList("[Model Number]");
if( ! products.isEmpty() ){ if( ! products.isEmpty() ){
modelNumbers = products.stream().map( Product::getModelNumber ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ) ; modelNumbers = products.stream().map( Product::getModelNumber ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ) ;
} }
@ -473,7 +696,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
} }
private void populateMarketplaces( List<Product> products ){ private void populateMarketplaces( List<Product> products ){
List<String> marketplaces = Collections.singletonList("[ Marketplace ]");
if( ! products.isEmpty() ){ if( ! products.isEmpty() ){
marketplaces = products.stream().map( Product::getMarketplace ).distinct().filter(Objects::nonNull).collect(Collectors.toList() ); marketplaces = products.stream().map( Product::getMarketplace ).distinct().filter(Objects::nonNull).collect(Collectors.toList() );
} }
@ -493,6 +716,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
private void initializeViews( View view ){ private void initializeViews( View view ){
leftFab = view.findViewById( R.id.button_left_frag_1 ); leftFab = view.findViewById( R.id.button_left_frag_1 );
rightFab = view.findViewById( R.id.button_right_frag_1 ); rightFab = view.findViewById( R.id.button_right_frag_1 );
btnDraft = view.findViewById(R.id.button_draft_first);
markerplace = view.findViewById( R.id.marketplace ); markerplace = view.findViewById( R.id.marketplace );
sku = view.findViewById( R.id.sku ); sku = view.findViewById( R.id.sku );
modelNumber = view.findViewById( R.id.model_number ); modelNumber = view.findViewById( R.id.model_number );
@ -506,6 +730,11 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
boxCartonSelected = view.findViewById( R.id.box_carton_selected ); boxCartonSelected = view.findViewById( R.id.box_carton_selected );
itemPerBoxSelected = view.findViewById( R.id.item_per_box_selected ); itemPerBoxSelected = view.findViewById( R.id.item_per_box_selected );
piecesSelected = view.findViewById( R.id.pieces_selected ); piecesSelected = view.findViewById( R.id.pieces_selected );
checkedBoxCartonSelected = view.findViewById(R.id.checked_box_carton_selected);
checkedItemPerBoxSelected = view.findViewById(R.id.checked_item_per_box_selected);
checkedPiecesSelected = view.findViewById(R.id.checked_pieces_selected);
fri = view.findViewById( R.id.fri ); fri = view.findViewById( R.id.fri );
refri = view.findViewById( R.id.refri ); refri = view.findViewById( R.id.refri );
searchSku = view.findViewById( R.id.search_sku_btn ); searchSku = view.findViewById( R.id.search_sku_btn );
@ -518,6 +747,7 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
public void onBarcodeScanResult( String result ){ public void onBarcodeScanResult( String result ){
if( result != null && ! result.isEmpty() ){ if( result != null && ! result.isEmpty() ){
store.getReport().getItems().get(0).setSku( result ); store.getReport().getItems().get(0).setSku( result );
System.out.println("SKU-2: " + store.getReport().getItems().get(0).getFnsku());
sku.setText( result ); sku.setText( result );
} }
} }
@ -578,4 +808,29 @@ public class FirstStepFragment extends Fragment implements View.OnClickListener
.load( store.getProfileImage( ) ) .load( store.getProfileImage( ) )
.into( profileImage ); .into( profileImage );
} }
private InspectionReport getSingleReport(InspectionReportWrapper wrapper) {
InspectionReport report = null;
if (wrapper != null) {
try {
// Get byte array from file content path
byte[] result = FileUtils.readFile(wrapper.getContent());
// Convert byte array to an InspectionReport object
ByteArrayInputStream byteIn = new ByteArrayInputStream(result);
ObjectInputStream in = new ObjectInputStream(byteIn);
report = (InspectionReport) in.readObject();
// Set additional details from the wrapper
report.setWrapperId(wrapper.getId());
report.setFilePath(wrapper.getContent());
} catch (Exception e) {
e.printStackTrace();
}
}
return report;
}
} }

View File

@ -7,9 +7,14 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect; import android.graphics.Rect;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -33,15 +38,29 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.utopiaindustries.qualitychecker.R; import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.async.ImageProcessor; import com.utopiaindustries.qualitychecker.async.ImageProcessor;
import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
import com.utopiaindustries.qualitychecker.service.InspectionReportService; import com.utopiaindustries.qualitychecker.service.InspectionReportService;
import com.utopiaindustries.qualitychecker.store.Store; import com.utopiaindustries.qualitychecker.store.Store;
import com.utopiaindustries.qualitychecker.ui.adapter.CheckPointAdapter; import com.utopiaindustries.qualitychecker.ui.adapter.CheckPointAdapter;
import com.utopiaindustries.qualitychecker.utils.FileUtils;
import com.utopiaindustries.qualitychecker.utils.ImageUriHolder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
public class SecondStepFragment extends Fragment public class SecondStepFragment extends Fragment
implements View.OnClickListener { implements View.OnClickListener {
private NavController navController; private NavController navController;
private Button leftFab,rightFab; private Button leftFab, rightFab, draftFab;
private RecyclerView recyclerView; private RecyclerView recyclerView;
private CheckPointAdapter adapter; private CheckPointAdapter adapter;
private TextView profileName; private TextView profileName;
@ -49,112 +68,294 @@ public class SecondStepFragment extends Fragment
private InspectionReportService inspectionReportService; private InspectionReportService inspectionReportService;
private Store store; private Store store;
private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 100; private static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 100;
private static final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 101; private static final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 101;
private static final int MY_PERMISSIONS_REQUEST_CAMERA = 102;
List<byte[]> temp_path = new ArrayList<>();
private HashMap<String, List<String>> imagesMap = new HashMap<>();
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_second_step , container, false ); View view = inflater.inflate(R.layout.fragment_second_step, container, false);
store = Store.getInstance(); store = Store.getInstance();
inspectionReportService = InspectionReportService.getInstance(); inspectionReportService = InspectionReportService.getInstance();
leftFab = view.findViewById( R.id.button_left_frag_2 ); draftFab = view.findViewById(R.id.button_draft_second);
rightFab = view.findViewById( R.id.button_right_frag_2 ); leftFab = view.findViewById(R.id.button_left_frag_2);
recyclerView = view.findViewById( R.id.check_point_recycler_view ); rightFab = view.findViewById(R.id.button_right_frag_2);
profileName = view.findViewById( R.id.second_profile_name ); recyclerView = view.findViewById(R.id.check_point_recycler_view);
profileImage = view.findViewById( R.id.second_step_profile_image ); profileName = view.findViewById(R.id.second_profile_name);
recyclerView.setLayoutManager( new LinearLayoutManager( getContext() ) ); profileImage = view.findViewById(R.id.second_step_profile_image);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// PERMISSIONS // PERMISSIONS
{ {
// Check if permission is not granted // Check if permission is not granted
if ( ContextCompat.checkSelfPermission( getContext(), Manifest.permission.READ_EXTERNAL_STORAGE ) if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted, request it // Permission is not granted, request it
ActivityCompat.requestPermissions( getActivity(), ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
} }
if (ContextCompat.checkSelfPermission( getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions( getActivity(), ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
} }
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{Manifest.permission.CAMERA},
MY_PERMISSIONS_REQUEST_CAMERA);
}
} }
adapter = new CheckPointAdapter( store.getReport().getItems().get( 0 ).getCheckPoints(), adapter = new CheckPointAdapter(store.getReport().getItems().get(0).getCheckPoints(),
store.getCheckPoints(), store.getCheckPoints(),
store.getDefects(), store.getDefects(),
inspectionReportService.getDefectTypes(), inspectionReportService.getDefectTypes(),
store.getCheckpointSkus(), store.getCheckpointSkus(),
getContext()); getContext());
recyclerView.setAdapter( adapter ); recyclerView.setAdapter(adapter);
// set on click listener // set on click listener
leftFab.setOnClickListener( this ); leftFab.setOnClickListener(this);
rightFab.setOnClickListener( this ); rightFab.setOnClickListener(this);
draftFab.setOnClickListener(this);
updateProfileViews(); updateProfileViews();
return view; return view;
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
navController = Navigation.findNavController( requireView() ); navController = Navigation.findNavController(requireView());
if( v.getId() == R.id.button_left_frag_2 ){
navController.navigate( R.id.action_secondStepFragment_to_firstStepFragment ); if (v.getId() == R.id.button_draft_second) {
//System.out.println("Draft Button Click-1" + store.getReport());
//--Storing draft report in database
if (store.getReport() != null) {
//System.out.println("Draft Button Click-2");
inspectionReportService.saveDraftInLocalDb(getContext(), store.getReport(), new SaveDraftReportCallback() {
@Override
public void onSuccess() {
//System.out.println("Draft Button Click-3");
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("draftReportId", "0");
editor.apply();
// progressBar.setVisibility(View.INVISIBLE);
Objects.requireNonNull(getActivity()).finish();
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Report is successfully drafted");
});
Toast.makeText(getContext(), "Report saved as Draft", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Throwable throwable) {
System.out.println("Draft Button Click-4");
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(getContext(), throwable.getMessage(), Toast.LENGTH_LONG).show();
//progressBar.setVisibility(View.INVISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Error in saving report");
});
}
});
}
//---
} }
if( v.getId() == R.id.button_right_frag_2 ){ if (v.getId() == R.id.button_left_frag_2) {
checkIsRecyclerViewIsCompletelyScrolled( recyclerView ); navController.navigate(R.id.action_secondStepFragment_to_firstStepFragment);
}
if (v.getId() == R.id.button_right_frag_2) {
checkIsRecyclerViewIsCompletelyScrolled(recyclerView);
} }
} }
public void onImagePickerResult(int requestCode, int resultCode, Intent data) { public void onImagePickerResult(int requestCode, int resultCode, Intent data) {
if ( resultCode == RESULT_OK && data != null ) { if (requestCode != RESULT_OK) {
try { try {
System.out.println( requestCode ); System.out.println(requestCode);
ImageProcessor imageProcessor = new ImageProcessor(); ImageProcessor imageProcessor = new ImageProcessor();
Uri selectedImageUri = data.getData(); /*Bitmap photo = (Bitmap) data.getExtras().get("data");
assert selectedImageUri != null; assert photo != null;
String imagePath = selectedImageUri.getPath();
store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setImagePath(imagePath);
imageProcessor.compressImageFromUriAsync( getContext(), selectedImageUri, 200, compressedData -> { Uri selectedImageUri = FileUtils.getImageUriFromBitmap(requireContext(), photo);
assert selectedImageUri != null;
String imagePath = selectedImageUri.getPath();*/
String imagePath = "";
Uri selectedImageUri = null;
if (data != null) {
Log.e("onImagePickerResult: ", "Gallery: " + data);
/*Bitmap photo = (Bitmap) data.getExtras().get("data");
assert photo != null;
selectedImageUri = FileUtils.getImageUriFromBitmap(requireContext(), photo);
imagePath = selectedImageUri.getPath();*/
selectedImageUri = data.getData();
assert selectedImageUri != null;
imagePath = selectedImageUri.getPath();
} else {
Log.e("onImagePickerResult: ", "Camera");
selectedImageUri = ImageUriHolder.getInstance().getImageUri();
imagePath = selectedImageUri.getPath();
}
store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setImagePath(imagePath);
//store.getReport().getItems().get(0).getCheckPoints().get(requestCode).addImageList(uriToByteArray(getContext(), selectedImageUri));
uriToByteArrayAsync(
getContext(),
selectedImageUri,
100, // Target size in KB
compressedImage -> {
// Handle the compressed image here, e.g., display it
requireActivity().runOnUiThread(() -> {
store.getReport().getItems().get(0).getCheckPoints().get(requestCode).addImageList(compressedImage);
adapter.notifyItemChanged(requestCode);
});
},
error -> {
// Handle any errors
requireActivity().runOnUiThread(() -> {
Toast.makeText(getContext(), "Error compressing image: " + error.getMessage(), Toast.LENGTH_SHORT).show();
});
}
);
/*imageProcessor.compressImageFromUriAsync( getContext(), selectedImageUri, 500, compressedData -> {
if (compressedData != null) { if (compressedData != null) {
store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setFile(compressedData); store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setFile(compressedData);
//store.getReport().getItems().get(0).getCheckPoints().get(requestCode).addImageList(compressedData);
} else { } else {
store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setFile(null); store.getReport().getItems().get(0).getCheckPoints().get(requestCode).setFile(null);
} }
adapter.notifyItemChanged( requestCode ); adapter.notifyItemChanged( requestCode );
}); });*/
} catch ( Exception e ){ //adapter.notifyItemChanged(requestCode);
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
private void checkIsRecyclerViewIsCompletelyScrolled( RecyclerView recyclerView ){ public byte[] uriToByteArray(Context context, Uri uri) throws IOException {
// Target file size in bytes (100 KB)
int targetSizeInBytes = 100 * 1024;
// Load the image as a Bitmap without scaling down
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.");
}
// Compress the bitmap with an initial high quality
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
// Gradually reduce quality until the image is under the target size
while (byteArrayOutputStream.size() > targetSizeInBytes && quality > 10) {
byteArrayOutputStream.reset(); // Clear the stream for new compression
quality -= 5; // Reduce quality by 5 each time
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
}
return byteArrayOutputStream.toByteArray();
}
public void uriToByteArrayAsync(
Context context,
Uri uri,
int targetSizeInKB,
Consumer<byte[]> onSuccess,
Consumer<Exception> onError
) {
new Thread(() -> {
try {
int targetSizeInBytes = targetSizeInKB * 1024;
// Load the image as a Bitmap without scaling
Bitmap bitmap;
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
bitmap = BitmapFactory.decodeStream(inputStream);
}
if (bitmap == null) {
throw new IOException("Failed to decode image from URI.");
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int minQuality = 10;
int maxQuality = 100;
int quality = maxQuality;
// Binary search for the best quality that meets the target size
while (minQuality <= maxQuality) {
byteArrayOutputStream.reset();
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, byteArrayOutputStream);
int byteSize = byteArrayOutputStream.size();
if (byteSize > targetSizeInBytes) {
maxQuality = quality - 1;
} else {
minQuality = quality + 1;
}
quality = (minQuality + maxQuality) / 2;
}
onSuccess.accept(byteArrayOutputStream.toByteArray());
} catch (IOException e) {
onError.accept(e);
}
}).start();
}
private void checkIsRecyclerViewIsCompletelyScrolled(RecyclerView recyclerView) {
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) { if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
int lastVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition(); int lastVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
int totalItemCount = layoutManager.getItemCount(); int totalItemCount = layoutManager.getItemCount();
if ( lastVisibleItemPosition == totalItemCount - 1 ) { if (lastVisibleItemPosition == totalItemCount - 1) {
navController.navigate( R.id.action_secondStepFragment_to_thirdStepFragment ); navController.navigate(R.id.action_secondStepFragment_to_thirdStepFragment);
} else { } else {
Toast.makeText( getContext(), "Please Scroll at the bottom to continue", Toast.LENGTH_SHORT ).show(); Toast.makeText(getContext(), "Please Scroll at the bottom to continue", Toast.LENGTH_SHORT).show();
} }
} }
} }
private void updateProfileViews( ) throws NullPointerException{ private void updateProfileViews() throws NullPointerException {
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getActivity().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
profileName.setText( sharedPreferences.getString("name", null ) ); profileName.setText(sharedPreferences.getString("name", null));
Glide.with( getContext() ) Glide.with(getContext())
.load( store.getProfileImage( ) ) .load(store.getProfileImage())
.into( profileImage ); .into(profileImage);
} }
} }

View File

@ -35,9 +35,11 @@ import com.bumptech.glide.Glide;
import com.utopiaindustries.qualitychecker.R; import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.apiservice.ApiService; import com.utopiaindustries.qualitychecker.apiservice.ApiService;
import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory; import com.utopiaindustries.qualitychecker.apiservice.ApiServiceFactory;
import com.utopiaindustries.qualitychecker.db.ReportRepository;
import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint; import com.utopiaindustries.qualitychecker.models.InspectionItemCheckPoint;
import com.utopiaindustries.qualitychecker.models.InspectionItemDimension; import com.utopiaindustries.qualitychecker.models.InspectionItemDimension;
import com.utopiaindustries.qualitychecker.models.InspectionReport; import com.utopiaindustries.qualitychecker.models.InspectionReport;
import com.utopiaindustries.qualitychecker.models.callback.SaveDraftReportCallback;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback; import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer; import com.utopiaindustries.qualitychecker.models.VoiceOfCustomer;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper; import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
@ -57,7 +59,7 @@ import retrofit2.Response;
public class ThirdStepFragment extends Fragment implements View.OnClickListener { public class ThirdStepFragment extends Fragment implements View.OnClickListener {
private NavController navController; private NavController navController;
private Button backBtn,nextBtn,openDimensionDialog; private Button backBtn,nextBtn,openDimensionDialog, btnDraft;
private TextView profileName; private TextView profileName;
private ImageView profileImage; private ImageView profileImage;
private InspectionReportService inspectionReportService; private InspectionReportService inspectionReportService;
@ -65,7 +67,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
private Store store; private Store store;
private Spinner resultSpinner; private Spinner resultSpinner;
private ApiService apiService; private ApiService apiService;
private EditText generalRemarks; private EditText generalRemarks, etQualityAuditor, etProdRepresentative, etQcRepresentative;
private TextView minorCountTv,majorCountTv,criticalCountTv; private TextView minorCountTv,majorCountTv,criticalCountTv;
@ -106,6 +108,69 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() ); ItemDimensionAdapter adapter = new ItemDimensionAdapter( store.getReport().getItems().get(0).getDimensions() );
itemDimensionsRecyclerView.setAdapter( adapter ); itemDimensionsRecyclerView.setAdapter( adapter );
etQcRepresentative.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) {
try {
store.getReport().setQcRepresentative( s.toString() );
} catch ( Exception e ){
store.getReport().setQcRepresentative( "");
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
etProdRepresentative.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) {
try {
store.getReport().setProductionRepresentative( s.toString() );
} catch ( Exception e ){
store.getReport().setProductionRepresentative( "");
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
etQualityAuditor.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) {
try {
store.getReport().setQualityAuditor( s.toString() );
} catch ( Exception e ){
store.getReport().setQualityAuditor( "");
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
generalRemarks.addTextChangedListener(new TextWatcher() { generalRemarks.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@ -135,6 +200,46 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
if( v.getId() == R.id.button_left_frag_3 ){ if( v.getId() == R.id.button_left_frag_3 ){
navController.navigate( R.id.action_thirdStepFragment_to_secondStepFragment ); navController.navigate( R.id.action_thirdStepFragment_to_secondStepFragment );
} }
if (v.getId() == R.id.button_draft_third) {
//--
if (store.getReport() != null) {
inspectionReportService.saveDraftInLocalDb( getContext(), store.getReport(), new SaveDraftReportCallback() {
@Override
public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("draftReportId", "0");
editor.apply();
// progressBar.setVisibility(View.INVISIBLE);
Objects.requireNonNull(getActivity()).finish();
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Report is successfully drafted");
});
Toast.makeText(getContext(), "Report saved as Draft", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Throwable throwable) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(getContext(), throwable.getMessage(), Toast.LENGTH_LONG).show();
//progressBar.setVisibility(View.INVISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(getContext()),
"Utopia QA App",
"Error in saving report");
});
}
});
}
//---
}
if( v.getId() == R.id.button_right_frag_3 ){ if( v.getId() == R.id.button_right_frag_3 ){
saveReportDialog(); saveReportDialog();
} }
@ -162,6 +267,11 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
public void onSuccess() { public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> { handler.post(() -> {
SharedPreferences sharedPreferences = getContext().getSharedPreferences("login_prefs", Context.MODE_PRIVATE);
long draftReportId = Long.parseLong(sharedPreferences.getString("draftReportId", null));
new ReportRepository(getContext()).deleteDraftRecordById(draftReportId);
Toast.makeText(getContext(), "Report saved Successfully", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "Report saved Successfully", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.INVISIBLE);
Objects.requireNonNull(getActivity()).finish(); Objects.requireNonNull(getActivity()).finish();
@ -246,6 +356,9 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
private void populateViews(){ private void populateViews(){
generalRemarks.setText( store.getReport().getGeneralRemarks() ); generalRemarks.setText( store.getReport().getGeneralRemarks() );
etQualityAuditor.setText(store.getReport().getQualityAuditor());
etProdRepresentative.setText(store.getReport().getProductionRepresentative());
etQcRepresentative.setText(store.getReport().getQcRepresentative());
ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(), ArrayAdapter<String> adapter = new ArrayAdapter<>( getContext(),
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_item,
@ -358,6 +471,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
private void initializeViews( View view ){ private void initializeViews( View view ){
backBtn = view.findViewById( R.id.button_left_frag_3 ); backBtn = view.findViewById( R.id.button_left_frag_3 );
nextBtn = view.findViewById( R.id.button_right_frag_3 ); nextBtn = view.findViewById( R.id.button_right_frag_3 );
btnDraft = view.findViewById(R.id.button_draft_third);
openDimensionDialog = view.findViewById( R.id.button_open_dimension ); openDimensionDialog = view.findViewById( R.id.button_open_dimension );
profileImage = view.findViewById( R.id.third_step_profile_image ); profileImage = view.findViewById( R.id.third_step_profile_image );
profileName = view.findViewById( R.id.third_profile_name ); profileName = view.findViewById( R.id.third_profile_name );
@ -368,10 +482,15 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
minorCountTv = view.findViewById( R.id.minor_count ); minorCountTv = view.findViewById( R.id.minor_count );
majorCountTv = view.findViewById( R.id.major_count ); majorCountTv = view.findViewById( R.id.major_count );
criticalCountTv = view.findViewById( R.id.critical_count ); criticalCountTv = view.findViewById( R.id.critical_count );
etQualityAuditor = view.findViewById(R.id.et_quality_auditor);
etProdRepresentative = view.findViewById(R.id.et_prod_represent);
etQcRepresentative = view.findViewById(R.id.et_qc_represent);
} }
private void setOnClickListeners(){ private void setOnClickListeners(){
nextBtn.setOnClickListener( this ); nextBtn.setOnClickListener( this );
backBtn.setOnClickListener( this ); backBtn.setOnClickListener( this );
btnDraft.setOnClickListener( this);
openDimensionDialog.setOnClickListener( this); openDimensionDialog.setOnClickListener( this);
} }

View File

@ -1,12 +1,31 @@
package com.utopiaindustries.qualitychecker.utils; package com.utopiaindustries.qualitychecker.utils;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider;
import com.utopiaindustries.qualitychecker.R;
import com.utopiaindustries.qualitychecker.models.callback.SaveReportCallback;
import com.utopiaindustries.qualitychecker.notification.NotificationHelper;
import com.utopiaindustries.qualitychecker.service.InspectionReportService;
import com.utopiaindustries.qualitychecker.store.Store;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
public class FileUtils { public class FileUtils {
public static String writeFile( Context context , public static String writeFile( Context context ,
@ -39,7 +58,7 @@ public class FileUtils {
File file = new File(filePath); File file = new File(filePath);
try (FileInputStream fis = new FileInputStream(file); try (FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream()) { ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[8192];
int bytesRead; int bytesRead;
while ((bytesRead = fis.read(buffer)) != -1) { while ((bytesRead = fis.read(buffer)) != -1) {
baos.write(buffer, 0, bytesRead); baos.write(buffer, 0, bytesRead);
@ -60,4 +79,79 @@ public class FileUtils {
System.out.println("File does not exist"); System.out.println("File does not exist");
} }
} }
public static Uri getImageUriFromBitmap(Context context, Bitmap bitmap) {
// Create a file in the cache directory
File cachePath = new File(context.getCacheDir(), "images");
cachePath.mkdirs(); // Create the directory if it doesn't exist
File file = new File(cachePath, "image.png"); // File name with PNG format
try {
// Write the bitmap to the file
FileOutputStream stream = new FileOutputStream(file);
//bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); // 100 indicates no compression
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
stream.flush();
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
// Get the URI using FileProvider
Uri uri = FileProvider.getUriForFile(context, "com.utopiaindustries.qualitychecker.fileprovider", file);
return uri;
}
private void saveDraftReportDialog(Context context, InspectionReportService inspectionReportService, Store store) {
LayoutInflater inflater = LayoutInflater.from(context );
View dialogView = inflater.inflate( R.layout.save_report_dialog, null);
// progress bar
ProgressBar progressBar = dialogView.findViewById( R.id.save_report_progress );
AlertDialog.Builder builder = new AlertDialog.Builder( Objects.requireNonNull(context) );
builder.setView( dialogView )
.setTitle("So you want to save report as draft?")
.setPositiveButton( "Save",(dialog, which) -> {
progressBar.setVisibility(View.VISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(context),
"Utopia QA App",
"Report is saving keep patience...");
inspectionReportService.saveInLocalDb(context, store.getReport(), new SaveReportCallback() {
@Override
public void onSuccess() {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(context, "Report draft Successfully", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.INVISIBLE);
//Objects.requireNonNull(context).finish();
NotificationHelper.showNotification(Objects.requireNonNull(context),
"Utopia QA App",
"Report is successfully saved");
});
}
@Override
public void onFailure(Throwable throwable) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
Toast.makeText(context, throwable.getMessage(), Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.INVISIBLE);
NotificationHelper.showNotification(Objects.requireNonNull(context),
"Utopia QA App",
"Error in saving report");
});
}
});
})
.setNegativeButton("Cancel", (dialog, which) -> {
// Handle Cancel button click
dialog.dismiss();
});
// Show the dialog
AlertDialog dialog = builder.create();
progressBar.setVisibility( View.GONE );
dialog.show();
}
} }

View File

@ -0,0 +1,25 @@
package com.utopiaindustries.qualitychecker.utils;
import android.net.Uri;
public class ImageUriHolder {
private static ImageUriHolder instance;
private Uri imageUri;
private ImageUriHolder() {}
public static ImageUriHolder getInstance() {
if (instance == null) {
instance = new ImageUriHolder();
}
return instance;
}
public Uri getImageUri() {
return imageUri;
}
public void setImageUri(Uri uri) {
this.imageUri = uri;
}
}

View File

@ -0,0 +1,33 @@
package com.utopiaindustries.qualitychecker.utils;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.viewpager.widget.ViewPager;
/**
* Created by Development on 05-Oct-2021.
*/
public class NonSwipeableViewPager extends ViewPager
{
public NonSwipeableViewPager(Context context) {
super(context);
}
public NonSwipeableViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
// Never allow swiping to switch between pages
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// Never allow swiping to switch between pages
return false;
}
}

View File

@ -0,0 +1,8 @@
package com.utopiaindustries.qualitychecker.utils;
import com.utopiaindustries.qualitychecker.models.InspectionReportWrapper;
public interface SelectListener {
void onItemClicked(InspectionReportWrapper reportWrapper);
}

View File

@ -0,0 +1,12 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="2dp"
android:topRightRadius="0dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="0dp" />
<stroke
android:width="1dp"
android:color="@android:color/white" />
<solid android:color="#F5F5F5"/>
</shape>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M18.32,4.26C16.84,3.05 15.01,2.25 13,2.05v2.02c1.46,0.18 2.79,0.76 3.9,1.62L18.32,4.26zM19.93,11h2.02c-0.2,-2.01 -1,-3.84 -2.21,-5.32L18.31,7.1C19.17,8.21 19.75,9.54 19.93,11zM18.31,16.9l1.43,1.43c1.21,-1.48 2.01,-3.32 2.21,-5.32h-2.02C19.75,14.46 19.17,15.79 18.31,16.9zM13,19.93v2.02c2.01,-0.2 3.84,-1 5.32,-2.21l-1.43,-1.43C15.79,19.17 14.46,19.75 13,19.93zM13,12V7h-2v5H7l5,5l5,-5H13zM11,19.93v2.02c-5.05,-0.5 -9,-4.76 -9,-9.95s3.95,-9.45 9,-9.95v2.02C7.05,4.56 4,7.92 4,12S7.05,19.44 11,19.93z" />
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/tab_bg_selected" android:state_selected="true"/>
<item android:drawable="@color/tab_bg_unselected"/>
</selector>

View File

@ -2,9 +2,9 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/main"
tools:context=".ui.activities.LoginActivity"> tools:context=".ui.activities.LoginActivity">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
@ -58,7 +58,7 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.022" /> app:layout_constraintVertical_bias="0.022" />
<LinearLayout <RelativeLayout
android:layout_width="797dp" android:layout_width="797dp"
android:layout_height="1090dp" android:layout_height="1090dp"
android:orientation="vertical" android:orientation="vertical"
@ -70,6 +70,7 @@
app:layout_constraintVertical_bias="1.0"> app:layout_constraintVertical_bias="1.0">
<LinearLayout <LinearLayout
android:id="@+id/layout_heading"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -85,7 +86,23 @@
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
android:layout_below="@+id/layout_heading" />
<com.utopiaindustries.qualitychecker.utils.NonSwipeableViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tab_layout"
android:background="@color/white" />
<!--<androidx.recyclerview.widget.RecyclerView
android:id="@+id/reports_recyclerview" android:id="@+id/reports_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -99,8 +116,8 @@
android:text="No Report Found" android:text="No Report Found"
android:textAlignment="center" android:textAlignment="center"
android:visibility="invisible"> android:visibility="invisible">
</TextView> </TextView>-->
</LinearLayout> </RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -71,18 +71,27 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:weightSum="1"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/imageRecyclerView"
android:layout_width="wrap_content"
android:layout_weight="0.8"
android:layout_height="150dp"
android:orientation="horizontal"
android:layout_margin="10dp"/>
<ImageView <!--<ImageView
android:id="@+id/preview_image" android:id="@+id/preview_image"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="150dp"> android:layout_height="150dp">
</ImageView> </ImageView>-->
<TextView <TextView
android:id="@+id/selected_image" android:id="@+id/selected_image"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="0.2"
android:textAlignment="center" android:textAlignment="center"
android:text=""> android:text="">
</TextView> </TextView>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
android:id="@+id/custom_tab"
android:orientation="vertical">
<TextView
android:id="@+id/txt_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text"
android:gravity="center"
android:textStyle="bold"
android:layout_centerInParent="true"
android:textColor="@color/black"
android:layout_gravity="center"
android:textSize="20sp" />
</RelativeLayout>

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp"
android:id="@+id/main_container"
android:layout_margin="3dp">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textStyle="bold"
android:textColor="@color/black"
android:text="IR-357-0000001"
android:layout_weight="1">
</TextView>
<!--<TextView
android:id="@+id/created_by"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:text="test.test"
android:layout_weight="1">
</TextView>-->
<ImageButton
android:id="@+id/delete_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_delete"
android:background="@null"
android:layout_weight="0.2"
android:padding="8dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/remarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:textStyle="bold|italic"
android:textColor="@color/black"
android:text="Remarks"
android:layout_weight="1">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:text="Date"
android:gravity="start"
>
</TextView>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView
android:paddingVertical="5dp"
android:paddingHorizontal="10dp"
android:textColor="@color/white"
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:text="Passed"
android:gravity="end"
>
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ui.activities.fragments.DraftFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/draft_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
</androidx.recyclerview.widget.RecyclerView>
<TextView
android:id="@+id/empty_report_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Report Found"
android:textAlignment="center"
android:visibility="invisible">
</TextView>
</LinearLayout>
</FrameLayout>

View File

@ -1,373 +1,478 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView 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:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.activities.LoginActivity"> android:scrollbars="vertical"
android:scrollbarFadeDuration="0"
android:fadeScrollbars="false"
android:scrollbarThumbVertical="@android:color/darker_gray"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="806dp" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="1200dp" xmlns:tools="http://schemas.android.com/tools"
app:layout_constraintBottom_toTopOf="@+id/relativeLayout" android:layout_width="match_parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_height="wrap_content"
app:layout_constraintHorizontal_bias="0.333" android:layout_marginEnd="2dp"
app:layout_constraintStart_toStartOf="parent" tools:context=".ui.activities.LoginActivity">
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<TextView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/textView3" android:layout_width="806dp"
android:layout_width="wrap_content" android:layout_height="1150dp"
android:layout_height="wrap_content" app:layout_constraintBottom_toTopOf="@+id/relativeLayout"
android:text="@string/screen_title"
android:textColor="#000000"
android:textSize="35sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.054" app:layout_constraintHorizontal_bias="0.333"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.032" /> app:layout_constraintVertical_bias="0.0">
<ImageView <TextView
android:id="@+id/first_step_profile_image" android:id="@+id/textView3"
android:layout_width="93dp" android:layout_width="wrap_content"
android:layout_height="86dp" android:layout_height="wrap_content"
android:text="@string/screen_title"
android:textColor="#000000"
android:textSize="35sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.054"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.032" />
<ImageView
android:id="@+id/first_step_profile_image"
android:layout_width="93dp"
android:layout_height="86dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.367"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.014"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/first_step_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.325"
app:layout_constraintStart_toEndOf="@+id/first_step_profile_image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.022" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="750dp"
android:layout_height="70dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.119">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/light_blue"
android:text="STEP 1 INFO" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/white"
android:text="STEP 2 Checkpoints" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/white"
android:text="STEP 3 Dimension" />
</LinearLayout>
<LinearLayout
android:layout_width="800dp"
android:layout_height="950dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- guide lines-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/guide_lne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Guidelines"
android:textColor="@color/black"
android:textStyle="bold" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/guide_line_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.067"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guide_lne"
app:layout_constraintVertical_bias="0.008" />
</LinearLayout>
<!-- inspection checkboxes-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp">
<TextView
android:id="@+id/inspection_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Inspection type"
android:textColor="@color/black"
android:textStyle="bold" />
<CheckBox
android:id="@+id/fri"
android:layout_width="95dp"
android:layout_height="20dp"
android:layout_weight="1"
android:text="FRI" />
<CheckBox
android:id="@+id/refri"
android:layout_width="95dp"
android:layout_height="20dp"
android:layout_weight="1"
android:text="RE-FRI" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/box_border"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Item / SKU Detal"
android:textColor="@color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp">
<EditText
android:id="@+id/sku"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:hint="SKU"
android:inputType="text" />
<ImageButton
android:id="@+id/scan_sku_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:padding="8dp"
android:src="@drawable/scan" />
<ImageButton
android:id="@+id/search_sku_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:padding="8dp"
android:src="@drawable/ic_search" />
<Spinner
android:id="@+id/model_number"
android:layout_width="210dp"
android:layout_height="44dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">
<Spinner
android:id="@+id/title"
android:layout_width="450dp"
android:layout_height="45dp" />
<Spinner
android:id="@+id/marketplace"
android:layout_width="200dp"
android:layout_height="45dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">
<Spinner
android:id="@+id/color"
android:layout_width="325dp"
android:layout_height="45dp" />
<Spinner
android:id="@+id/size"
android:layout_width="325dp"
android:layout_height="45dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/box_border"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Stock Details"
android:textColor="@color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp">
<EditText
android:id="@+id/box_carton"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Box / Carton "
android:inputType="numberDecimal" />
<EditText
android:id="@+id/item_per_box"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Packs (Item / box)"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/pieces"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Pieces"
android:inputType="numberDecimal" />
</LinearLayout>
<EditText
android:id="@+id/packaging"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:hint="Packaging Details"
android:inputType="text" />
</LinearLayout>
<!--Item checked details-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/box_border"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Item Presented Details"
android:textColor="@color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp">
<EditText
android:id="@+id/checked_box_carton_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Box / Carton "
android:inputType="numberDecimal" />
<EditText
android:id="@+id/checked_item_per_box_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Packs (Item / box)"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/checked_pieces_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Pieces"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
<!--Item checked details-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/box_border"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Item Selected Details"
android:textColor="@color/black"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:paddingBottom="5dp">
<EditText
android:id="@+id/box_carton_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Box / Carton "
android:inputType="numberDecimal" />
<EditText
android:id="@+id/item_per_box_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Packs (Item / box)"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/pieces_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Pieces"
android:inputType="numberDecimal" />
</LinearLayout>
</LinearLayout>
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="General Remarks"-->
<!-- android:textColor="@color/black"-->
<!-- android:textStyle="bold"-->
<!-- android:layout_margin="16dp" />-->
<!-- <EditText-->
<!-- android:id="@+id/general_remarks"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:hint="General Remarks"-->
<!-- android:layout_marginHorizontal="10dp"-->
<!-- android:layout_marginVertical="10dp"-->
<!-- android:inputType="text"/>-->
</LinearLayout>
</ScrollView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="805dp"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.367"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.014"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/first_step_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold|italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.325"
app:layout_constraintStart_toEndOf="@+id/first_step_profile_image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.022" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="750dp"
android:layout_height="70dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.119">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/light_blue"
android:text="STEP 1 INFO" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/white"
android:text="STEP 2 Checkpoints" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/white"
android:text="STEP 3 Dimension"/>
</LinearLayout>
<LinearLayout
android:layout_width="800dp"
android:layout_height="1000dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"> app:layout_constraintVertical_bias="1.0">
<ScrollView <Button
android:layout_width="match_parent" android:id="@+id/button_right_frag_1"
android:layout_height="match_parent"> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:backgroundTint="@color/light_blue"
android:text="Next" />
<LinearLayout <Button
android:layout_width="match_parent" android:id="@+id/button_draft_first"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical"> android:layout_height="wrap_content"
<!-- guide lines--> android:layout_toStartOf="@id/button_right_frag_1"
<LinearLayout android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_marginEnd="16dp"
android:layout_height="wrap_content" android:layout_marginBottom="16dp"
android:orientation="vertical" android:text="Draft" />
android:layout_margin="16dp">
<TextView
android:id="@+id/guide_lne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Guidelines"
android:textColor="@color/black"
android:textStyle="bold"/>
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/guide_line_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.067"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guide_lne"
app:layout_constraintVertical_bias="0.008" />
</LinearLayout>
<!-- inspection checkboxes-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:orientation="horizontal">
<TextView
android:id="@+id/inspection_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Inspection type"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_weight="1"/>
<CheckBox
android:id="@+id/fri"
android:layout_width="95dp"
android:layout_height="20dp"
android:text="FRI"
android:layout_weight="1"
/>
<CheckBox
android:id="@+id/refri"
android:layout_width="95dp"
android:layout_height="20dp"
android:text="RE-FRI"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item / SKU Detal"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="16dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
>
<EditText
android:id="@+id/sku"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:hint="SKU"
android:inputType="text"/>
<ImageButton
android:id="@+id/scan_sku_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/scan"
android:background="@null"
android:padding="8dp"/>
<ImageButton
android:id="@+id/search_sku_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_search"
android:background="@null"
android:padding="8dp"/>
<Spinner
android:id="@+id/model_number"
android:layout_width="210dp"
android:layout_height="44dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
>
<Spinner
android:id="@+id/title"
android:layout_width="450dp"
android:layout_height="45dp" />
<Spinner
android:id="@+id/marketplace"
android:layout_width="200dp"
android:layout_height="45dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
>
<Spinner
android:id="@+id/color"
android:layout_width="325dp"
android:layout_height="45dp" />
<Spinner
android:id="@+id/size"
android:layout_width="325dp"
android:layout_height="45dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Presented Details"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
>
<EditText
android:id="@+id/box_carton"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Box / Carton "
android:inputType="numberDecimal"/>
<EditText
android:id="@+id/item_per_box"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Packs (Item / box)"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/pieces"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Pieces"
android:inputType="numberDecimal" />
</LinearLayout>
<EditText
android:id="@+id/packaging"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Packaging Details"
android:layout_margin="16dp"
android:inputType="text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Selected Details"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
>
<EditText
android:id="@+id/box_carton_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Box / Carton "
android:inputType="numberDecimal" />
<EditText
android:id="@+id/item_per_box_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Packs (Item / box)"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/pieces_selected"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Pieces"
android:inputType="numberDecimal"/>
</LinearLayout>
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="General Remarks"-->
<!-- android:textColor="@color/black"-->
<!-- android:textStyle="bold"-->
<!-- android:layout_margin="16dp" />-->
<!-- <EditText-->
<!-- android:id="@+id/general_remarks"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:hint="General Remarks"-->
<!-- android:layout_marginHorizontal="10dp"-->
<!-- android:layout_marginVertical="10dp"-->
<!-- android:inputType="text"/>-->
</LinearLayout>
</ScrollView>
</LinearLayout>
<Button
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_marginEnd="16dp"
android:layout_toStartOf="@id/button_draft_first"
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_marginEnd="16dp"
android:layout_toStartOf="@id/button_left_frag_1"
android:text="History" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="805dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<Button
android:id="@+id/button_right_frag_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:backgroundTint="@color/light_blue"
android:text="Next" />
<Button
android:id="@+id/button_left_frag_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/button_right_frag_1"
android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/button_right_frag_1"
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_marginEnd="16dp"
android:layout_toStartOf="@id/button_left_frag_1"
android:text="History" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".ui.activities.fragments.ReportsFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/reports_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
</androidx.recyclerview.widget.RecyclerView>
<TextView
android:id="@+id/empty_report_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Report Found"
android:textAlignment="center"
android:visibility="invisible">
</TextView>
</LinearLayout>
</FrameLayout>

View File

@ -165,13 +165,23 @@
android:backgroundTint="@color/light_blue" android:backgroundTint="@color/light_blue"
android:text="Next" /> android:text="Next" />
<Button
android:id="@+id/button_draft_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/button_right_frag_2"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="Draft" />
<Button <Button
android:id="@+id/button_left_frag_2" android:id="@+id/button_left_frag_2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBaseline="@id/button_right_frag_2" android:layout_alignBaseline="@id/button_draft_second"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/button_right_frag_2" android:layout_toStartOf="@id/button_draft_second"
android:text="Back" /> android:text="Back" />
<!-- <Button--> <!-- <Button-->

View File

@ -312,6 +312,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp" android:padding="10dp"
android:layout_margin="5dp"
android:background="@drawable/box_border"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -362,9 +364,94 @@
android:textSize="16sp"/> android:textSize="16sp"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:layout_margin="5dp"
android:padding="5dp"
android:background="@drawable/box_border"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Quality Auditor"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="10dp" />
<EditText
android:id="@+id/et_quality_auditor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Quality Auditor"
android:maxLines="1"
android:layout_marginHorizontal="10dp"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Production Representative"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="10dp" />
<EditText
android:id="@+id/et_prod_represent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:hint="Production Representative"
android:layout_marginHorizontal="10dp"
android:inputType="text"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QC Representative"
android:textColor="@color/black"
android:textStyle="bold"
android:layout_margin="10dp" />
<EditText
android:id="@+id/et_qc_represent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="QC Representative"
android:maxLines="1"
android:layout_marginHorizontal="10dp"
android:inputType="text"/>
</LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_margin="5dp"
android:padding="5dp"
android:background="@drawable/box_border"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
@ -373,7 +460,7 @@
android:text="General Remarks" android:text="General Remarks"
android:textColor="@color/black" android:textColor="@color/black"
android:textStyle="bold" android:textStyle="bold"
android:layout_margin="10dp" /> android:layout_margin="5dp" />
<EditText <EditText
android:id="@+id/general_remarks" android:id="@+id/general_remarks"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -434,20 +521,30 @@
android:id="@+id/button_right_frag_3" android:id="@+id/button_right_frag_3"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:layout_alignParentEnd="true"
android:backgroundTint="@color/light_blue" android:backgroundTint="@color/light_blue"
android:text="Submit" /> android:text="Submit" />
<Button
android:id="@+id/button_draft_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/button_right_frag_3"
android:layout_alignParentBottom="true"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="Draft" />
<Button <Button
android:id="@+id/button_left_frag_3" android:id="@+id/button_left_frag_3"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBaseline="@id/button_right_frag_3" android:layout_alignBaseline="@id/button_draft_third"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:layout_toStartOf="@id/button_right_frag_3" android:layout_toStartOf="@id/button_draft_third"
android:text="Back" /> android:text="Back" />
<Button <Button

View File

@ -0,0 +1,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:scaleType="centerCrop" />
</LinearLayout>

View File

@ -11,4 +11,8 @@
<color name="light_blue">#29DAF1</color> <color name="light_blue">#29DAF1</color>
<color name="light_blue_2">#AFEEF6</color> <color name="light_blue_2">#AFEEF6</color>
<color name="cp_bg_color">#FFFFFF</color> <color name="cp_bg_color">#FFFFFF</color>
<color name="tabcolor_bg">#2a203e</color>
<color name = "tab_bg_selected">#ffffff</color>
<color name = "tab_bg_unselected">#ffffff</color>
</resources> </resources>

View File

@ -10,4 +10,6 @@
<string name="required">Required</string> <string name="required">Required</string>
<string name="actual">Actual</string> <string name="actual">Actual</string>
<string name="difference">Difference</string> <string name="difference">Difference</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>

View File

@ -27,5 +27,11 @@
<item name="cornerSize">0dp</item> <!-- Adjust the corner size as needed --> <item name="cornerSize">0dp</item> <!-- Adjust the corner size as needed -->
</style> </style>
<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">14sp</item>
<item name="tabPaddingStart">0dp</item>
<item name="tabPaddingEnd">0dp</item>
</style>
</resources> </resources>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path
name="images"
path="images/" />
<external-path name="external_files" path="." />
</paths>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<network-security-config> <network-security-config>
<domain-config cleartextTrafficPermitted="true"> <domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">192.168.91.16</domain> <!--<domain includeSubdomains="true">192.168.91.16</domain>-->
<domain includeSubdomains="true">192.168.90.27</domain>
<domain includeSubdomains="true">portal.utopiaindustries.pk</domain> <domain includeSubdomains="true">portal.utopiaindustries.pk</domain>
<domain includeSubdomains="true">utopiaindustries.pk</domain>
</domain-config> </domain-config>
</network-security-config> </network-security-config>