parent
98cf1bcb5d
commit
39860f782a
|
@ -10,8 +10,8 @@ android {
|
||||||
applicationId "com.utopiaindustries.qualitychecker"
|
applicationId "com.utopiaindustries.qualitychecker"
|
||||||
minSdk 24
|
minSdk 24
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 7
|
versionCode 8
|
||||||
versionName "1.6"
|
versionName "1.7"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
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.44:8081/uind/";//"http://192.168.91.44:8081/uind/";//"http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
|
//private final static String BASE_URL = "http://192.168.91.44:8081/uind/";//"http://192.168.91.44:8081/uind/";//"http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
|
||||||
|
|
||||||
private static Retrofit retrofit;
|
private static Retrofit retrofit;
|
||||||
|
|
||||||
|
|
|
@ -59,4 +59,24 @@ public class NotificationHelper {
|
||||||
// Show the notification
|
// Show the notification
|
||||||
notificationManager.notify(0, builder.build());
|
notificationManager.notify(0, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showNotificationForReportUpload(Context context, int notificationId, String title, String message) {
|
||||||
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
||||||
|
channel.setDescription(CHANNEL_DESCRIPTION);
|
||||||
|
notificationManager.createNotificationChannel(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID)
|
||||||
|
.setSmallIcon(R.drawable.utopia_svg_logo)
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(message)
|
||||||
|
.setStyle(new NotificationCompat.BigTextStyle().bigText(message)) // Allow long messages
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||||
|
|
||||||
|
notificationManager.notify(notificationId, builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ public class InspectionReportService {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
System.out.println(response.body());
|
System.out.println(response.body());
|
||||||
if (response.body().get("result").equalsIgnoreCase("success")) {
|
if (response.body().get("result").equalsIgnoreCase("success")) {
|
||||||
|
FileUtils.Current_SKU = response.body().get("Sku");
|
||||||
callback.onSuccess();
|
callback.onSuccess();
|
||||||
} else {
|
} else {
|
||||||
callback.onFailure(new Exception("Error on submitting report"));
|
callback.onFailure(new Exception("Error on submitting report"));
|
||||||
|
|
|
@ -593,8 +593,10 @@ private int generateRandomNumber(int min, int max) {
|
||||||
Toast.makeText(this, "Uploading Reports. Please wait", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "Uploading Reports. Please wait", Toast.LENGTH_LONG).show();
|
||||||
reportsUploadBtn.setEnabled(false);
|
reportsUploadBtn.setEnabled(false);
|
||||||
final int[] uploadedCount = {0};
|
final int[] uploadedCount = {0};
|
||||||
|
final int[] notificationId = {100};
|
||||||
|
|
||||||
for ( InspectionReport report : reports ) {
|
for ( InspectionReport report : reports ) {
|
||||||
|
final int currentNotificationId = notificationId[0]++;
|
||||||
service.saveReport(report, new SaveReportCallback() {
|
service.saveReport(report, new SaveReportCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
@ -605,14 +607,20 @@ private int generateRandomNumber(int min, int max) {
|
||||||
|
|
||||||
uploadedCount[0]++;
|
uploadedCount[0]++;
|
||||||
|
|
||||||
NotificationHelper.showNotification(
|
/*NotificationHelper.showNotification(
|
||||||
HomeActivity.this,
|
HomeActivity.this,
|
||||||
"Report Uploading",
|
"Report Uploading",
|
||||||
"Uploaded " + uploadedCount[0] + " of " + size + " reports");
|
"Uploaded " + uploadedCount[0] + " of " + size + " reports");*/
|
||||||
|
|
||||||
|
NotificationHelper.showNotificationForReportUpload(
|
||||||
|
HomeActivity.this,
|
||||||
|
currentNotificationId,
|
||||||
|
"Upload Success",
|
||||||
|
"SKU: " + FileUtils.Current_SKU + " uploaded successfully.");
|
||||||
|
|
||||||
//Log.e("Reports-size: ",""+reports.size());
|
//Log.e("Reports-size: ",""+reports.size());
|
||||||
if (uploadedCount[0] == size) {
|
if (uploadedCount[0] == size) {
|
||||||
Toast.makeText(HomeActivity.this, "All reports uploaded successfully", Toast.LENGTH_SHORT).show();
|
//Toast.makeText(HomeActivity.this, "All reports uploaded successfully", Toast.LENGTH_SHORT).show();
|
||||||
reportsUploadBtn.setEnabled(true);
|
reportsUploadBtn.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,15 +630,22 @@ private int generateRandomNumber(int min, int max) {
|
||||||
uploadedCount[0]++;
|
uploadedCount[0]++;
|
||||||
// Even on failure, increment the counter to avoid locking the button forever
|
// Even on failure, increment the counter to avoid locking the button forever
|
||||||
//logErrorToFile(throwable);
|
//logErrorToFile(throwable);
|
||||||
NotificationHelper.showNotification(
|
/*NotificationHelper.showNotification(
|
||||||
HomeActivity.this,
|
HomeActivity.this,
|
||||||
"Report Uploading",
|
"Report Uploading",
|
||||||
"Uploaded " + uploadedCount[0] + " of " + size + " reports (with some errors)");
|
"Uploaded " + uploadedCount[0] + " of " + size + " reports (with some errors)");*/
|
||||||
|
|
||||||
|
NotificationHelper.showNotificationForReportUpload(
|
||||||
|
HomeActivity.this,
|
||||||
|
currentNotificationId,
|
||||||
|
"Upload Failed",
|
||||||
|
"SKU: " + FileUtils.Current_SKU + " failed.\nReason: " + throwable.getMessage());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (uploadedCount[0] == size) {
|
if (uploadedCount[0] == size) {
|
||||||
reportsUploadBtn.setEnabled(true);
|
reportsUploadBtn.setEnabled(true);
|
||||||
Toast.makeText(HomeActivity.this, "Finished uploading with some errors", Toast.LENGTH_SHORT).show();
|
//Toast.makeText(HomeActivity.this, "Finished uploading with some errors", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
|
public static String Current_SKU = "";
|
||||||
public static String writeFile( Context context ,
|
public static String writeFile( Context context ,
|
||||||
byte[] content,
|
byte[] content,
|
||||||
String fileName ){
|
String fileName ){
|
||||||
|
|
Loading…
Reference in New Issue