parent
98cf1bcb5d
commit
39860f782a
|
@ -10,8 +10,8 @@ android {
|
|||
applicationId "com.utopiaindustries.qualitychecker"
|
||||
minSdk 24
|
||||
targetSdk 34
|
||||
versionCode 7
|
||||
versionName "1.6"
|
||||
versionCode 8
|
||||
versionName "1.7"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import retrofit2.Retrofit;
|
|||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class RetrofitClient {
|
||||
//private final static String BASE_URL = "https://portal.utopiaindustries.pk/uind/";
|
||||
private final static String BASE_URL = "http://192.168.91.44:8081/uind/";//"http://192.168.91.44:8081/uind/";//"http://192.168.90.27:8080/uind/";//"http://192.168.91.16:8080/uind/";
|
||||
private final static String BASE_URL = "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 static Retrofit retrofit;
|
||||
|
||||
|
|
|
@ -59,4 +59,24 @@ public class NotificationHelper {
|
|||
// Show the notification
|
||||
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()) {
|
||||
System.out.println(response.body());
|
||||
if (response.body().get("result").equalsIgnoreCase("success")) {
|
||||
FileUtils.Current_SKU = response.body().get("Sku");
|
||||
callback.onSuccess();
|
||||
} else {
|
||||
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();
|
||||
reportsUploadBtn.setEnabled(false);
|
||||
final int[] uploadedCount = {0};
|
||||
final int[] notificationId = {100};
|
||||
|
||||
for ( InspectionReport report : reports ) {
|
||||
final int currentNotificationId = notificationId[0]++;
|
||||
service.saveReport(report, new SaveReportCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -605,14 +607,20 @@ private int generateRandomNumber(int min, int max) {
|
|||
|
||||
uploadedCount[0]++;
|
||||
|
||||
NotificationHelper.showNotification(
|
||||
/*NotificationHelper.showNotification(
|
||||
HomeActivity.this,
|
||||
"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());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -622,15 +630,22 @@ private int generateRandomNumber(int min, int max) {
|
|||
uploadedCount[0]++;
|
||||
// Even on failure, increment the counter to avoid locking the button forever
|
||||
//logErrorToFile(throwable);
|
||||
NotificationHelper.showNotification(
|
||||
/*NotificationHelper.showNotification(
|
||||
HomeActivity.this,
|
||||
"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) {
|
||||
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;
|
||||
|
||||
public class FileUtils {
|
||||
public static String Current_SKU = "";
|
||||
public static String writeFile( Context context ,
|
||||
byte[] content,
|
||||
String fileName ){
|
||||
|
|
Loading…
Reference in New Issue