Add app version in inspection report

main
saad.siddiq 2025-05-09 17:56:50 +05:00
parent 8d6aef0228
commit 79dd070d65
4 changed files with 30 additions and 5 deletions

View File

@ -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;

View File

@ -25,6 +25,7 @@ public class InspectionReport implements Serializable {
private String qcRepresentative; private String qcRepresentative;
private String floor; private String floor;
private String auditDate; private String auditDate;
private String appVersion;
// wrapper // wrapper
@ -189,6 +190,14 @@ public class InspectionReport implements Serializable {
this.auditDate = auditDate; this.auditDate = auditDate;
} }
public String getAppVersion() {
return appVersion;
}
public void setAppVersion(String appVersion) {
this.appVersion = appVersion;
}
@Override @Override
public String toString() { public String toString() {
return "InspectionReport{" + return "InspectionReport{" +

View File

@ -9,6 +9,7 @@ import android.app.DatePickerDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -114,7 +115,6 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
private TextView txtDate; private TextView txtDate;
private int year, month, day; private int year, month, day;
private Calendar calendar; private Calendar calendar;
private LocalDate localDate;
@Nullable @Nullable
@Override @Override
@ -125,6 +125,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
store = Store.getInstance(); store = Store.getInstance();
apiService = ApiServiceFactory.getApiService(); apiService = ApiServiceFactory.getApiService();
setCurrentVersion();
initializeViews(view); initializeViews(view);
checkPermissions(); checkPermissions();
populateViews(); populateViews();
@ -332,7 +333,7 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
// Month is 0-indexed, so we add 1 // Month is 0-indexed, so we add 1
Calendar selectedCalendar = Calendar.getInstance(); Calendar selectedCalendar = Calendar.getInstance();
selectedCalendar.set(year, monthOfYear, dayOfMonth); selectedCalendar.set(year, monthOfYear, dayOfMonth);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
String selectedDate = dateFormat.format(selectedCalendar.getTime()); String selectedDate = dateFormat.format(selectedCalendar.getTime());
txtDate.setText(selectedDate); txtDate.setText(selectedDate);
store.getReport().setAuditDate(selectedDate); store.getReport().setAuditDate(selectedDate);
@ -554,6 +555,8 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
etProdRepresentative.setText(store.getReport().getProductionRepresentative()); etProdRepresentative.setText(store.getReport().getProductionRepresentative());
etQcRepresentative.setText(store.getReport().getQcRepresentative()); etQcRepresentative.setText(store.getReport().getQcRepresentative());
etFloor.setText(store.getReport().getFloor()); etFloor.setText(store.getReport().getFloor());
txtDate.setText(store.getReport().getAuditDate());
etHandFeelNotOk.setText(String.valueOf(store.getReport().getItems().get(0).getHandFeelNotOkay()));
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(),
android.R.layout.simple_spinner_item, android.R.layout.simple_spinner_item,
@ -675,6 +678,19 @@ public class ThirdStepFragment extends Fragment implements View.OnClickListener
} }
} }
private void setCurrentVersion() {
PackageManager packageManager = getContext().getPackageManager();
try {
PackageInfo info = packageManager.getPackageInfo( getContext().getPackageName(), 0 );
//Log.e("VersionName: ",""+info.versionName);
//Log.e("VersionCode: ",""+info.versionCode);
String currentVersion = String.format("v-%s", String.valueOf(info.versionName));
store.getReport().setAppVersion(currentVersion);
} catch ( Exception e ) {
e.printStackTrace();
}
}
private void calculateDimensions() { private void calculateDimensions() {
List<InspectionItemDimension> dimensions = store.getDimensions(); List<InspectionItemDimension> dimensions = store.getDimensions();
System.out.println(dimensions); System.out.println(dimensions);

View File

@ -766,7 +766,7 @@
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:gravity="left" android:gravity="left"
android:hint="MM-dd-yyyy" android:hint="yyyy-MM-dd"
android:padding="5dp" android:padding="5dp"
android:textColor="@color/black" /> android:textColor="@color/black" />