Compare commits

...

31 Commits

Author SHA1 Message Date
8d93f3bb61 Finish v1.44.09(478) 2025-03-03 10:12:14 +01:00
a7e8ec4d99 -> v1.44.09 (478) 2025-03-03 10:12:08 +01:00
677ee127ff Fix su dismiss di dialog input quantity 2025-03-03 10:11:11 +01:00
a02035e9b8 Finish v1.44.08(477) 2025-02-28 16:58:53 +01:00
b61948dac3 Finish v1.44.08(477) 2025-02-28 16:58:53 +01:00
deee26d55b -> v1.44.08 (477) 2025-02-28 16:58:48 +01:00
00443b46c8 Fix su dialog info aggiuntive in accettazione 2025-02-28 16:57:57 +01:00
9228eaf01b Finish v1.44.07(476) 2025-02-28 11:51:16 +01:00
51f9e1f58c Finish v1.44.07(476) 2025-02-28 11:51:15 +01:00
6747ee077b -> v1.44.07 (476) 2025-02-28 11:51:11 +01:00
e11e270101 Migliorata gestione caricamenti del Picking libero. 2025-02-28 11:50:11 +01:00
bc27355ed6 Finish Release-2 2025-02-26 11:05:35 +01:00
078d9af116 Finish Release-2 2025-02-26 11:05:34 +01:00
9b14e1186e -> v1.44.06 (475) 2025-02-26 11:05:30 +01:00
779c606c2a Fix vari 2025-02-26 11:04:34 +01:00
581e56a245 Finish Release-1 2025-02-26 10:25:30 +01:00
7f468e19bd Finish Release-1 2025-02-26 10:25:29 +01:00
e8a511d49e -> v1.44.05 (474) 2025-02-26 10:25:25 +01:00
1988ad993f Implementato pulsante di verifica aggiornamenti nelle settings 2025-02-26 10:24:28 +01:00
6105c44dab Gestita installazione delle versioni beta 2025-02-26 10:04:02 +01:00
d3b7cd8cd6 Aggiunta impostazione che permette di abilitare la ricezione degli aggiornamenti beta 2025-02-25 16:52:09 +01:00
36c48f28d1 Finish v1.44.04(473) 2025-02-24 15:31:21 +01:00
93b18531ab Finish v1.44.04(473) 2025-02-24 15:31:21 +01:00
27edd84442 -> v1.44.04 (473) 2025-02-24 15:31:16 +01:00
e24e6858fb Fix su commessa nulla nel caso di picking libero 2025-02-24 15:30:34 +01:00
fa10973626 Migliorata gestione status code nel caso di UnauthorizedAccess nell'interceptor 2025-02-21 11:55:45 +01:00
521e2fe62b Finish v1.44.03(472) 2025-02-19 12:43:54 +01:00
7e7938ea1a Finish v1.44.03(472) 2025-02-19 12:43:53 +01:00
4fe48bd02a -> v1.44.03 (472) 2025-02-19 12:43:48 +01:00
f26bc28ba1 Fix su DialogProgressView 2025-02-19 12:42:58 +01:00
aaf8b96070 Finish v1.44.02(471) 2025-02-19 10:13:14 +01:00
25 changed files with 542 additions and 220 deletions

View File

@@ -10,8 +10,8 @@ apply plugin: 'com.google.gms.google-services'
android {
def appVersionCode = 471
def appVersionName = '1.44.02'
def appVersionCode = 478
def appVersionName = '1.44.09'
signingConfigs {
release {

View File

@@ -132,8 +132,8 @@ public class MainApplicationModule {
@Provides
@Singleton
UpdatesManager provideUpdatesManager() {
return new UpdatesManager();
UpdatesManager provideUpdatesManager(ExecutorService executorService, Handler handler, SystemRESTConsumer systemRESTConsumer) {
return new UpdatesManager(executorService, handler, systemRESTConsumer);
}
@Provides
@@ -238,8 +238,8 @@ public class MainApplicationModule {
@Provides
@Singleton
SystemRESTConsumer provideSystemRESTConsumer(RESTBuilder restBuilder) {
return new SystemRESTConsumer(restBuilder);
SystemRESTConsumer provideSystemRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
return new SystemRESTConsumer(executorService, restBuilder);
}
@Provides

View File

@@ -0,0 +1,26 @@
package it.integry.integrywmsnative.core.helper;
import android.content.Context;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import it.integry.integrywmsnative.core.utility.UtilityContext;
public final class ContextHelper {
public static FragmentManager getFragmentManagerFromContext(Context context) {
if (context == null) {
throw new IllegalArgumentException("Context cannot be null");
}
if (context instanceof FragmentActivity) {
return ((FragmentActivity) context).getSupportFragmentManager();
} else if (UtilityContext.getMainActivity() != null) {
return UtilityContext.getMainActivity().getSupportFragmentManager();
}
return null;
}
}

View File

@@ -6,11 +6,14 @@ import java.io.IOException;
import io.jsonwebtoken.Claims;
import it.integry.integrywmsnative.core.authentication.JwtUtils;
import it.integry.integrywmsnative.core.exception.UnauthorizedAccessException;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.UtilityDate;
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
import okhttp3.Interceptor;
import okhttp3.Protocol;
import okhttp3.Response;
import okhttp3.ResponseBody;
public class AuthInterceptor implements Interceptor {
@@ -30,7 +33,7 @@ public class AuthInterceptor implements Interceptor {
var accessToken = SettingsManager.i().getUserSession().getAccessToken();
var accessTokenExpiryDate = SettingsManager.i().getUserSession().getAccessTokenExpiryDate();
if (accessToken != null && (accessTokenExpiryDate == null || UtilityDate.getNowTime().isAfter(accessTokenExpiryDate))) {
if (accessToken != null && (accessTokenExpiryDate == null || UtilityDate.getNowTime().isAfter(accessTokenExpiryDate.minusSeconds(20)))) {
// Make the token refresh request
try {
@@ -45,6 +48,15 @@ public class AuthInterceptor implements Interceptor {
.setRefreshTokenExpiryDate(response.getExpiryDate());
SettingsManager.update();
} catch (UnauthorizedAccessException uae) {
// Crea una risposta 401 manualmente
return new Response.Builder()
.request(originalRequest)
.protocol(Protocol.HTTP_1_1)
.code(401)
.message("Unauthorized")
.body(ResponseBody.create(new byte[0], null))
.build();
} catch (Exception e) {
return chain.proceed(originalRequest);
}

View File

@@ -16,6 +16,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.inject.Singleton;
@@ -311,15 +313,47 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
});
}
public void fillMtbAartsOfMtbColrs(List<MtbColr> mtbColrs, RunnableArgs<List<MtbColr>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>(mtbColrs.stream()
.map(MtbColr::getCodMart)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toUnmodifiableList()));
mArticoloRESTConsumer.getByCodMarts(codMarts, arts -> {
if (arts != null && !arts.isEmpty()) {
for (MtbColr mtbColr : mtbColrs) {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
}
mtbColr.setMtbAart(foundMtbAart);
}
}
onComplete.run(mtbColrs);
}, onFailed);
}
public void fillMtbAartsOfMtbColts(List<MtbColt> mtbColts, RunnableArgs<List<MtbColt>> onComplete, RunnableArgs<Exception> onFailed) {
List<String> codMarts = new ArrayList<>();
for (MtbColt mtbColt : mtbColts) {
codMarts.addAll(Stream.of(mtbColt.getMtbColr())
codMarts.addAll(mtbColt.getMtbColr().stream()
.map(MtbColr::getCodMart)
.withoutNulls()
.filter(Objects::nonNull)
.distinct()
.toList());
.collect(Collectors.toUnmodifiableList()));
}
@@ -331,10 +365,11 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
MtbAart foundMtbAart = null;
List<MtbAart> mtbAartStream = Stream.of(arts)
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart())).toList();
List<MtbAart> mtbAartStream = arts.stream()
.filter(x -> x.getCodMart().equalsIgnoreCase(mtbColr.getCodMart()))
.collect(Collectors.toList());
if (mtbAartStream != null && !mtbAartStream.isEmpty()) {
if (!mtbAartStream.isEmpty()) {
foundMtbAart = mtbAartStream.get(0);
}
@@ -560,7 +595,9 @@ public class ColliMagazzinoRESTConsumer extends _BaseRESTConsumer {
@Override
public void onResponse(Call<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> call, Response<ServiceRESTResponse<SpostaArtsTraULResponseDTO>> response) {
analyzeAnswer(response, "spostaArtsTraUL", data -> {
onComplete.run(data.getGeneratedMtbColr());
fillMtbAartsOfMtbColrs(data.getGeneratedMtbColr(), onComplete, onFailed);
}, onFailed);
}

View File

@@ -13,6 +13,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
@@ -36,31 +37,24 @@ import retrofit2.Response;
@Singleton
public class SystemRESTConsumer extends _BaseRESTConsumer {
private final ExecutorService executorService;
private final RESTBuilder restBuilder;
public SystemRESTConsumer(RESTBuilder restBuilder) {
public SystemRESTConsumer(ExecutorService executorService, RESTBuilder restBuilder) {
this.executorService = executorService;
this.restBuilder = restBuilder;
}
public void retrieveUpdatesInfo(final RunnableArgs<LatestAppVersionInfoDTO> onSuccess, final RunnableArgs<Exception> onFailed) {
public LatestAppVersionInfoDTO retrieveUpdatesInfoSynchronized(boolean betaVersion) throws Exception {
SystemRESTConsumerService systemRESTConsumerService = restBuilder.getService(SystemRESTConsumerService.class);
systemRESTConsumerService.retrieveUpdatesInfo()
.enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<LatestAppVersionInfoDTO> call, Response<LatestAppVersionInfoDTO> response) {
if(response.code() == 404) {
onSuccess.run(null);
return;
}
var response = systemRESTConsumerService.retrieveUpdatesInfo(betaVersion ? "beta" : null)
.execute();
analyzeAnswerGeneric(response, "updates", onSuccess, onFailed);
}
if (response.code() == 404) {
return null;
}
@Override
public void onFailure(Call<LatestAppVersionInfoDTO> call, @NonNull final Exception e) {
onFailed.run(e);
}
});
return analyzeAnswerGeneric(response, "updates");
}
@@ -161,20 +155,19 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
}
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
public void sendMailSynchronized(MailRequestDTO mailDTO) throws Exception {
SystemRESTConsumerService service = restBuilder.getService(SystemRESTConsumerService.class);
service.sendMail(mailDTO).enqueue(new ManagedErrorCallback<>() {
@Override
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {
if (onComplete != null) onComplete.run();
}
var response = service.sendMail(mailDTO).execute();
analyzeAnswer(response, "sendMail");
}
@Override
public void onFailure(Call<ServiceRESTResponse<String>> call, @NonNull final Exception e) {
if (onFailed != null) {
onFailed.run(e);
}
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
executorService.execute(() -> {
try {
sendMailSynchronized(mailDTO);
if (onComplete != null) onComplete.run();
} catch (Exception ex) {
if (onFailed != null) onFailed.run(ex);
}
});
}

View File

@@ -17,7 +17,7 @@ import retrofit2.http.Query;
public interface SystemRESTConsumerService {
@GET("wms/currentVersion")
Call<LatestAppVersionInfoDTO> retrieveUpdatesInfo();
Call<LatestAppVersionInfoDTO> retrieveUpdatesInfo(@Query("suffix") String suffix);
@POST("device/register")
Call<ServiceRESTResponse<Void>> registerDevice(@Body RegisterDeviceRequestDTO registerDeviceRequestDTO);
@@ -32,6 +32,6 @@ public interface SystemRESTConsumerService {
Call<ServiceRESTResponse<List<AvailableCodMdepsDTO>>> getAvailableCodMdeps();
@POST("sendEmail")
Call<ServiceRESTResponse<String>> sendMail(@Body MailRequestDTO mailDto);
Call<ServiceRESTResponse<Void>> sendMail(@Body MailRequestDTO mailDto);
}

View File

@@ -1,83 +1,117 @@
package it.integry.integrywmsnative.core.update;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceManager;
import java.io.File;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.helper.ContextHelper;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.system.LatestAppVersionInfoDTO;
import it.integry.integrywmsnative.core.settings.SettingsManager;
import it.integry.integrywmsnative.core.utility.FileDownloader;
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
import it.integry.integrywmsnative.view.dialogs.DialogProgressView;
import it.integry.integrywmsnative.view.dialogs.update_available.DialogUpdateAvailableView;
@Singleton
public class UpdatesManager {
private final ExecutorService executorService;
private final Handler handler;
private final SystemRESTConsumer systemRESTConsumer;
private AppCompatActivity mContext;
public void init(AppCompatActivity activityContext, SystemRESTConsumer systemRESTConsumer) {
this.mContext = activityContext;
final String baseEndpoint = SettingsManager.i().getServer().getProtocol() + "://" + SettingsManager.i().getServer().getHost() +
(SettingsManager.i().getServer().getPort() > 0 ? ":" + SettingsManager.i().getServer().getPort() : "");
final String currentVersionUrl = baseEndpoint + "/ems-api/wms/currentVersion";
final String currentDownloadUrl = baseEndpoint + "/ems-api/wms/android-release.apk";
systemRESTConsumer.retrieveUpdatesInfo(latestData -> {
if (latestData == null)
return;
if(latestData.getLatestVersionCode() <= BuildConfig.VERSION_CODE)
return;
showDialog(latestData, () -> {
installAPK(currentDownloadUrl);
});
}, ex -> UtilityExceptions.defaultException(mContext, ex));
public UpdatesManager(ExecutorService executorService, Handler handler, SystemRESTConsumer systemRESTConsumer) {
this.executorService = executorService;
this.handler = handler;
this.systemRESTConsumer = systemRESTConsumer;
}
private void showDialog(LatestAppVersionInfoDTO updatesData, Runnable onUpdateStart) {
public void executeCheck(Context context, boolean forceReinstall) {
executorService.execute(() -> {
try {
final String baseEndpoint = SettingsManager.i().getServer().getProtocol() + "://" + SettingsManager.i().getServer().getHost() +
(SettingsManager.i().getServer().getPort() > 0 ? ":" + SettingsManager.i().getServer().getPort() : "") + "/ems-api/";
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
var betaEnabled = sharedPreferences.getBoolean(MainSettingsFragment.KEY_BUTTON_ENABLE_BETA, false);
LatestAppVersionInfoDTO latestData = systemRESTConsumer.retrieveUpdatesInfoSynchronized(betaEnabled);
if (latestData == null)
return;
if (latestData.getLatestVersionCode() < BuildConfig.VERSION_CODE)
return;
boolean currentVersionIsBeta = BuildConfig.VERSION_NAME.contains("beta");
if(!forceReinstall && currentVersionIsBeta == betaEnabled && latestData.getLatestVersionCode() == BuildConfig.VERSION_CODE)
return;
//Se sto passando da una beta a una stable e viceversa non obbligo l'utente a fare l'aggiornamento
if(currentVersionIsBeta != betaEnabled || forceReinstall) {
latestData.setForced(false);
}
String currentDownloadUrl = baseEndpoint + latestData.getUrl();
showDialog(context, latestData, () -> {
installAPK(context, currentDownloadUrl);
});
} catch (Exception e) {
handler.post(() -> {
UtilityExceptions.defaultException(context, e);
});
}
});
}
private void showDialog(Context context, LatestAppVersionInfoDTO updatesData, Runnable onUpdateStart) {
DialogUpdateAvailableView.newInstance(updatesData, onUpdateStart)
.show(mContext.getSupportFragmentManager(), "dialog-updates");
.show(((FragmentActivity)context).getSupportFragmentManager(), "dialog-updates");
}
private void installAPK(String downloadURL) {
private void installAPK(Context context, String downloadURL) {
File destination = mContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
File destination = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
var progressDialogBuilder = new DialogProgressView("Download", null, false);
progressDialogBuilder.show(mContext.getSupportFragmentManager(), "tag");
progressDialogBuilder.show(Objects.requireNonNull(ContextHelper.getFragmentManagerFromContext(context)), "tag");
var fileDownloader = new FileDownloader()
.setDestFolder(destination)
.setUrlString(downloadURL)
.setOnProgressUpdate(progress -> {
mContext.runOnUiThread(() -> {
handler.post(() -> {
progressDialogBuilder.setProgress(progress);
});
})
.setOnDownloadCompleted(destPath -> {
mContext.runOnUiThread(() -> {
handler.post(() -> {
progressDialogBuilder.dismiss();
if (!destination.exists()) {
UtilityExceptions.defaultException(mContext, new Exception("Errore durante il download dell'aggiornamento"));
UtilityExceptions.defaultException(context, new Exception("Errore durante il download dell'aggiornamento"));
return;
}
@@ -86,8 +120,8 @@ public class UpdatesManager {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
fileLoc = GenericFileProvider.getUriForFile(mContext,
mContext.getApplicationContext().getPackageName() + ".core.update.GenericFileProvider",
fileLoc = GenericFileProvider.getUriForFile(context,
context.getApplicationContext().getPackageName() + ".core.update.GenericFileProvider",
destPath);
} else {
intent = new Intent(Intent.ACTION_VIEW);
@@ -97,19 +131,19 @@ public class UpdatesManager {
intent.setDataAndType(fileLoc, "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
mContext.startActivity(intent);
context.startActivity(intent);
});
});
new Thread(() -> {
executorService.execute(() -> {
try {
fileDownloader.download();
} catch (Exception e) {
progressDialogBuilder.dismissAllowingStateLoss();
UtilityExceptions.defaultException(mContext, e);
UtilityExceptions.defaultException(context, e);
}
}).start();
});
}
}

View File

@@ -3,7 +3,6 @@ package it.integry.integrywmsnative.core.utility;
import android.content.Context;
import android.text.Html;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import com.annimon.stream.Stream;
@@ -14,6 +13,7 @@ import it.integry.integrywmsnative.BuildConfig;
import it.integry.integrywmsnative.core.exception.InvalidConnectionException;
import it.integry.integrywmsnative.core.exception.InvalidLUException;
import it.integry.integrywmsnative.core.exception.InvalidLUGestioneException;
import it.integry.integrywmsnative.core.helper.ContextHelper;
import it.integry.integrywmsnative.core.rest.CommonRESTException;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
@@ -44,13 +44,7 @@ public class UtilityExceptions {
if (ex.getCause() != null) errorMessage += "<br />" + ex.getCause().getMessage();
}
FragmentManager fm = null;
if (context instanceof FragmentActivity) {
fm = ((FragmentActivity) context).getSupportFragmentManager();
} else if (UtilityContext.getMainActivity() != null) {
fm = UtilityContext.getMainActivity().getSupportFragmentManager();
}
FragmentManager fm = ContextHelper.getFragmentManagerFromContext(context);
if (fm != null) {
DialogSimpleMessageView.makeErrorDialog(Html.fromHtml(errorMessage), null, null)

View File

@@ -111,9 +111,14 @@ public class UtilityString {
public static boolean isNullOrEmpty(String stringToCheck){
return stringToCheck == null || stringToCheck.trim().isEmpty();
}
public static String isNull(String stringToCheck, String alternativeString){
return isNullOrEmpty(stringToCheck) ? alternativeString : stringToCheck;
public static String isNull(String... strings) {
for (String string : strings) {
if (!isNullOrEmpty(string)) {
return string;
}
}
return null;
}
public static String empty2null(String stringToCheck) {

View File

@@ -4,6 +4,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.text.SpannableString;
import android.view.Gravity;
@@ -92,6 +93,9 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
@Inject
DialogInputQuantityV2View mDialogInputQuantityV2View;
@Inject
Handler handler;
private final AccettazionePickingFiltroOrdineViewModel mAppliedFilterViewModel = new AccettazionePickingFiltroOrdineViewModel();
private BottomSheetFragmentLUContentViewModel mBottomSheetFragmentLUContentViewModel;
@@ -740,7 +744,9 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
@Override
public void onInfoAggiuntiveRequest(RunnableArgss<String, ObservableMtbTcol> onComplete) {
DialogInfoAggiuntiveLUView.newInstance(onComplete, this::onLoadingEnded).show(getSupportFragmentManager(), DialogInfoAggiuntiveLUView.class.getName());
handler.post(() -> {
DialogInfoAggiuntiveLUView.newInstance(onComplete, this::onLoadingEnded).show(getSupportFragmentManager(), DialogInfoAggiuntiveLUView.class.getName());
});
}
@Override
@@ -781,7 +787,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
public void onRowSaved() {
runOnUiThread(() -> {
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
});
}
@@ -828,7 +834,7 @@ public class AccettazioneOrdiniPickingActivity extends BaseActivity implements A
runOnUiThread(() -> {
noLUPresent.set(false);
Snackbar.make(mBindings.getRoot(), R.string.data_saved, Snackbar.LENGTH_SHORT)
.setBackgroundTint(getResources().getColor(R. color. green_500))
.setBackgroundTint(getResources().getColor(R.color.green_500))
.show();
this.mBottomSheetFragmentLUContentViewModel.setMtbColt(mtbColt);

View File

@@ -89,7 +89,7 @@ public class MainActivity extends BaseActivity
mBinding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_main, null, false);
setContentView(mBinding.getRoot());
updatesManager.init(this, systemRESTConsumer);
updatesManager.executeCheck(this, false);
UtilityContext.initMainActivity(this);
setSupportActionBar(mBinding.appBarMain.toolbar);

View File

@@ -373,10 +373,11 @@ public class PickingLiberoFragment extends BaseFragment implements ITitledFragme
.setPartitaMag(resultDTO.getPartitaMag())
.setDataScad(resultDTO.getDataScad());
this.onLoadingStarted();
onComplete.run(pickedQuantityDTO, shouldCloseLU);
})
.setOnAbort(this::onLoadingEnded)
.setOnAbort(() -> {
onComplete.run(null, false);
})
.show(requireActivity().getSupportFragmentManager(), "tag");
}

View File

@@ -1,9 +1,12 @@
package it.integry.integrywmsnative.gest.picking_libero;
import java.util.concurrent.ExecutorService;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliLavorazioneRESTConsumer;
@@ -18,22 +21,27 @@ public class PickingLiberoModule {
@Provides
@Singleton
PickingLiberoViewModel providesPickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer,
PickingLiberoViewModel providesPickingLiberoViewModel(ExecutorService executorService,
ArticoloRESTConsumer articoloRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
PosizioniRESTConsumer posizioniRESTConsumer,
GiacenzaRESTConsumer giacenzaRESTConsumer,
MagazzinoAutomaticoRESTConsumer magazzinoAutomaticoRESTConsumer,
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
ColliDataRecoverService colliDataRecoverService
) {
return new PickingLiberoViewModel(articoloRESTConsumer,
return new PickingLiberoViewModel(
executorService,
articoloRESTConsumer,
colliMagazzinoRESTConsumer,
barcodeRESTConsumer,
posizioniRESTConsumer,
giacenzaRESTConsumer,
magazzinoAutomaticoRESTConsumer,
colliLavorazioneRESTConsumer,
colliSpedizioneRESTConsumer);
colliSpedizioneRESTConsumer,
colliDataRecoverService);
}
}

View File

@@ -7,12 +7,16 @@ import com.annimon.stream.Stream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.inject.Inject;
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.exception.InvalidCodMdepException;
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
@@ -66,12 +70,14 @@ public class PickingLiberoViewModel {
private MtbColt mCurrentMtbColt = null;
private final ExecutorService executorService;
private final ArticoloRESTConsumer mArticoloRESTConsumer;
private final ColliMagazzinoRESTConsumer mColliMagazzinoRESTConsumer;
private final BarcodeRESTConsumer mBarcodeRESTConsumer;
private final PosizioniRESTConsumer mPosizioniRESTConsumer;
private final GiacenzaRESTConsumer mGiacenzaRESTConsumer;
private final MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer;
private final ColliDataRecoverService mColliDataRecoverService;
private ColliScaricoRESTConsumerInterface mColliScaricoRESTConsumer;
private final ColliLavorazioneRESTConsumer mColliLavorazioneRESTConsumer;
@@ -86,17 +92,21 @@ public class PickingLiberoViewModel {
private Listener mListener;
private Integer mMtbColtSessionID;
@Inject
public PickingLiberoViewModel(ArticoloRESTConsumer articoloRESTConsumer,
public PickingLiberoViewModel(ExecutorService executorService,
ArticoloRESTConsumer articoloRESTConsumer,
ColliMagazzinoRESTConsumer colliMagazzinoRESTConsumer,
BarcodeRESTConsumer barcodeRESTConsumer,
PosizioniRESTConsumer posizioniRESTConsumer,
GiacenzaRESTConsumer giacenzaRESTConsumer,
MagazzinoAutomaticoRESTConsumer mMagazzinoAutomaticoRESTConsumer,
ColliLavorazioneRESTConsumer colliLavorazioneRESTConsumer,
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer) {
ColliSpedizioneRESTConsumer colliSpedizioneRESTConsumer,
ColliDataRecoverService colliDataRecoverService) {
this.executorService = executorService;
this.mArticoloRESTConsumer = articoloRESTConsumer;
this.mColliMagazzinoRESTConsumer = colliMagazzinoRESTConsumer;
this.mBarcodeRESTConsumer = barcodeRESTConsumer;
@@ -105,6 +115,7 @@ public class PickingLiberoViewModel {
this.mMagazzinoAutomaticoRESTConsumer = mMagazzinoAutomaticoRESTConsumer;
this.mColliLavorazioneRESTConsumer = colliLavorazioneRESTConsumer;
this.mColliSpedizioneRESTConsumer = colliSpedizioneRESTConsumer;
this.mColliDataRecoverService = colliDataRecoverService;
}
@@ -186,26 +197,38 @@ public class PickingLiberoViewModel {
.map(MvwSitArtUdcDetInventario::toMtbColr)
.toList();
this.sendArtSelectionRequest(mtbColrs, null, selectedMtbColrs -> {
List<MtbColr> selectedMtbColrs = null;
try {
selectedMtbColrs = this.sendArtSelectionRequest(mtbColrs, null);
} catch (InterruptedException e) {
this.sendError(e);
return;
}
final List<MagazzinoAutomaticoPickItemRequestDTO> magazzinoAutomaticoPickItemRequestDTOList = new ArrayList<>();
for (MtbColr selectedArt : selectedMtbColrs) {
MagazzinoAutomaticoPickItemRequestDTO itemDto = new MagazzinoAutomaticoPickItemRequestDTO(selectedArt.getCodMart())
.setQtaTot(selectedArt.getQtaCol())
.setNumCnf(selectedArt.getNumCnf())
.setUntMis(selectedArt.getUntMis());
if (selectedMtbColrs == null) {
this.sendOnLoadingEnded();
return;
}
magazzinoAutomaticoPickItemRequestDTOList.add(itemDto);
}
final List<MagazzinoAutomaticoPickItemRequestDTO> magazzinoAutomaticoPickItemRequestDTOList = new ArrayList<>();
for (MtbColr selectedArt : selectedMtbColrs) {
MagazzinoAutomaticoPickItemRequestDTO itemDto = new MagazzinoAutomaticoPickItemRequestDTO(selectedArt.getCodMart())
.setQtaTot(selectedArt.getQtaCol())
.setNumCnf(selectedArt.getNumCnf())
.setUntMis(selectedArt.getUntMis());
var magazzinoAutomaticoPickRequest = new MagazzinoAutomaticoPickItemsRequestDTO()
.setShouldCreateUDS(true)
.setDefaultGestioneOfNewUDS(mDefaultGestione.getText())
.setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList);
magazzinoAutomaticoPickItemRequestDTOList.add(itemDto);
}
mMagazzinoAutomaticoRESTConsumer.pickItems(mtbDepoPosizione,
magazzinoAutomaticoPickRequest, onComplete, this::sendError);
}, this::sendOnLoadingEnded);
var magazzinoAutomaticoPickRequest = new MagazzinoAutomaticoPickItemsRequestDTO()
.setShouldCreateUDS(true)
.setDefaultGestioneOfNewUDS(mDefaultGestione.getText())
.setItemsToPick(magazzinoAutomaticoPickItemRequestDTOList);
mMagazzinoAutomaticoRESTConsumer.pickItems(mtbDepoPosizione,
magazzinoAutomaticoPickRequest, onComplete, this::sendError);
this.sendOnLoadingEnded();
}, this::sendError);
@@ -382,6 +405,8 @@ public class PickingLiberoViewModel {
mColliScaricoRESTConsumer.createUDS(createUDSRequest, mtbColt -> {
mMtbColtSessionID = mColliDataRecoverService.startNewSession(mtbColt, null);
mtbColt
.setMtbColr(new ObservableArrayList<>());
@@ -526,6 +551,11 @@ public class PickingLiberoViewModel {
true,
true,
(pickedQuantityDTO, shouldCloseLU) -> {
if (pickedQuantityDTO == null) {
this.sendOnLoadingEnded();
return;
}
this.saveNewRow(pickingObjectDTO,
pickedQuantityDTO.getNumCnf(),
pickedQuantityDTO.getQtaCnf(),
@@ -541,24 +571,40 @@ public class PickingLiberoViewModel {
}
private void pickMerceULtoUL(MtbColt sourceMtbColt, MtbAart mtbAart, Runnable onComplete) {
List<MtbColr> mtbColrsToPick = Stream.of(sourceMtbColt.getMtbColr())
.filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO))
.toList();
executorService.execute(() -> {
this.sendArtSelectionRequest(mtbColrsToPick, mtbAart, pickedAarts -> {
List<MtbColr> destNewMtbColr = new ArrayList<>();
try {
List<MtbColr> mtbColrsToPick = sourceMtbColt.getMtbColr().stream()
.filter(x -> UtilityBigDecimal.greaterThan(x.getQtaCol(), BigDecimal.ZERO))
.collect(Collectors.toList());
if (!pickedAarts.isEmpty()) {
askQuantities(pickedAarts.iterator(), destNewMtbColr, () -> {
if (!destNewMtbColr.isEmpty()) {
List<MtbColr> pickedAarts = this.sendArtSelectionRequest(mtbColrsToPick, mtbAart);
destNewMtbColr.forEach(x -> x.setCodJcom(this.mDefaultCommessa.getCodJcom()));
if (pickedAarts == null) {
this.sendOnLoadingEnded();
return;
}
MtbColt clonedTestata = (MtbColt) sourceMtbColt.clone();
clonedTestata.getMtbColr().clear();
clonedTestata.getMtbColr().addAll(destNewMtbColr);
List<MtbColr> mtbColrsToMove = new ArrayList<>();
mColliMagazzinoRESTConsumer.spostaArtsTraUL(clonedTestata,
if (!pickedAarts.isEmpty()) {
for (var pickedArt : pickedAarts) {
var mtbColr = askSingleQuantity(pickedArt);
if (mtbColr != null)
mtbColrsToMove.add(mtbColr);
}
if (!mtbColrsToMove.isEmpty()) {
if (this.mDefaultCommessa != null)
mtbColrsToMove.forEach(x -> x.setCodJcom(this.mDefaultCommessa.getCodJcom()));
MtbColt clonedSourceTestata = (MtbColt) sourceMtbColt.clone();
clonedSourceTestata.getMtbColr().clear();
clonedSourceTestata.getMtbColr().addAll(mtbColrsToMove);
mColliMagazzinoRESTConsumer.spostaArtsTraUL(clonedSourceTestata,
this.mCurrentMtbColt, true, (generatedMtbColrs) -> {
mCurrentMtbColt.getMtbColr().addAll(generatedMtbColrs);
@@ -568,27 +614,24 @@ public class PickingLiberoViewModel {
onComplete.run();
}, this::sendError);
} else {
onComplete.run();
this.sendOnLoadingEnded();
}
}, onComplete);
} else {
onComplete.run();
} else {
onComplete.run();
this.sendOnLoadingEnded();
}
} catch (InterruptedException e) {
this.sendError(e);
}
}, this::sendOnLoadingEnded);
});
}
private void askQuantities(Iterator<MtbColr> sourceMtbColrs, List<MtbColr> destMtbColr, Runnable onComplete, Runnable onAbort) {
if (sourceMtbColrs.hasNext()) {
askSingleQuantity(sourceMtbColrs.next(), mtbColr -> {
destMtbColr.add(mtbColr);
askQuantities(sourceMtbColrs, destMtbColr, onComplete, onAbort);
}, onAbort);
} else {
onComplete.run();
}
}
private void askSingleQuantity(MtbColr mtbColr, RunnableArgs<MtbColr> onComplete, Runnable onAbort) {
private MtbColr askSingleQuantity(MtbColr mtbColr) throws InterruptedException {
MtbColt sourceMtbColt = new MtbColt()
.setNumCollo(mtbColr.getNumCollo())
@@ -607,6 +650,8 @@ public class PickingLiberoViewModel {
new PickDataDTO()
.setSourceMtbColt(sourceMtbColt));
CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<MtbColr> result = new AtomicReference<>();
this.sendOnItemDispatched(
pickingObjectDTO,
@@ -626,6 +671,10 @@ public class PickingLiberoViewModel {
false,
false,
(pickedQuantityDTO, shouldCloseLU) -> {
if (pickedQuantityDTO == null) {
countDownLatch.countDown();
return;
}
mtbColr
.setPartitaMag(pickedQuantityDTO.getPartitaMag())
@@ -633,16 +682,21 @@ public class PickingLiberoViewModel {
.setQtaCol(pickedQuantityDTO.getQtaTot())
.setQtaCnf(pickedQuantityDTO.getQtaCnf())
.setNumCnf(pickedQuantityDTO.getNumCnf())
.setDatetimeRow(UtilityDate.getDateInstance());
.setDatetimeRow(UtilityDate.getDateInstance())
.setMtbAart(pickingObjectDTO.getMtbAart());
onComplete.run(mtbColr);
result.set(mtbColr);
countDownLatch.countDown();
});
countDownLatch.await();
return result.get();
}
public void saveNewRow(PickingObjectDTO pickingObjectDTO, BigDecimal numCnf, BigDecimal qtaCnf, BigDecimal qtaTot, String partitaMag, LocalDate dataScad, boolean shouldCloseLU) {
new Thread(this::sendOnLoadingStarted).start();
this.sendOnLoadingStarted();
final MtbColr mtbColr = new MtbColr()
.setCodMart(pickingObjectDTO.getMtbAart().getCodMart())
@@ -771,8 +825,12 @@ public class PickingLiberoViewModel {
mtbColrToUpdate.getDataScadPartita(),
false,
false,
true,
false,
(pickedQuantityDTO, shouldCloseLU) -> {
if (pickedQuantityDTO == null) {
this.sendOnLoadingEnded();
return;
}
this.saveEditedRow(mtbColrToUpdate,
pickedQuantityDTO.getNumCnf(),
@@ -871,6 +929,9 @@ public class PickingLiberoViewModel {
mColliMagazzinoRESTConsumer.canULBeDeleted(mCurrentMtbColt, canBeDeleted -> {
if (canBeDeleted) {
deleteLU(() -> {
if (mMtbColtSessionID != null)
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
this.sendLUClosed();
this.sendOnLoadingEnded();
@@ -892,6 +953,9 @@ public class PickingLiberoViewModel {
}
this.mColliScaricoRESTConsumer.closeUDS(closeUDSRequest, response -> {
if (mMtbColtSessionID != null)
this.mColliDataRecoverService.closeSession(mMtbColtSessionID);
this.sendLUClosed();
this.sendOnLoadingEnded();
@@ -950,9 +1014,21 @@ public class PickingLiberoViewModel {
if (this.mListener != null) mListener.onLUCommessaRequired(onComplete, onAbort);
}
private void sendArtSelectionRequest(List<MtbColr> mtbColrsToPick, MtbAart mtbAart, RunnableArgs<List<MtbColr>> onComplete, Runnable onAbort) {
private List<MtbColr> sendArtSelectionRequest(List<MtbColr> mtbColrsToPick, MtbAart mtbAart) throws InterruptedException {
CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<List<MtbColr>> result = new AtomicReference<>();
if (this.mListener != null)
mListener.onArtSelectionRequest(mtbColrsToPick, mtbAart, onComplete, onAbort);
mListener.onArtSelectionRequest(mtbColrsToPick, mtbAart, mtbColrs -> {
result.set(mtbColrs);
countDownLatch.countDown();
}, countDownLatch::countDown);
else countDownLatch.countDown();
countDownLatch.await();
return result.get();
}
private void sendOnItemDispatched(PickingObjectDTO pickingObjectDTO,
@@ -972,6 +1048,7 @@ public class PickingLiberoViewModel {
boolean canPartitaMagBeChanged,
boolean canLUBeClosed,
RunnableArgss<PickedQuantityDTO, Boolean> onComplete) {
if (this.mListener != null) mListener.onItemDispatched(pickingObjectDTO,
mtbAart,
initialNumCnf,

View File

@@ -3,8 +3,8 @@ package it.integry.integrywmsnative.gest.settings;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.os.Handler;
import android.os.Looper;
import android.util.Base64;
import android.widget.Toast;
@@ -18,6 +18,7 @@ import androidx.preference.PreferenceFragmentCompat;
import androidx.sqlite.db.SimpleSQLiteQuery;
import com.annimon.stream.Stream;
import com.google.android.material.snackbar.Snackbar;
import com.harrysoft.androidbluetoothserial.BluetoothManager;
import java.io.BufferedReader;
@@ -31,6 +32,7 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -44,10 +46,11 @@ import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.core.rest.model.MailAttachmentDTO;
import it.integry.integrywmsnative.core.rest.model.MailRequestDTO;
import it.integry.integrywmsnative.core.update.UpdatesManager;
import it.integry.integrywmsnative.core.utility.UtilityExceptions;
import it.integry.integrywmsnative.core.utility.UtilityResources;
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
import it.integry.integrywmsnative.view.dialogs.DialogProgressView;
import it.integry.integrywmsnative.view.dialogs.base.DialogSimpleMessageView;
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
public class MainSettingsFragment extends PreferenceFragmentCompat implements ITitledFragment, Preference.OnPreferenceChangeListener {
@@ -67,6 +70,9 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
@Inject
public ExecutorService executorService;
@Inject
public UpdatesManager updatesManager;
private boolean progressOpened;
@@ -75,6 +81,8 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
public static final String KEY_PALLET_BT_DEVICE = "pallet_scale_bt_device";
public static final String KEY_TRIGGER_SCAN_MODE = "TRIG_SCAN_MODE";
public static final String KEY_TRIGGER_SCAN_DELAY = "TRIG_SCAN_DELAY";
public static final String KEY_BUTTON_ENABLE_BETA = "ENABLE_BETA";
public static final String KEY_BUTTON_CHECK_UPDATES = "CHECK_UPDATES";
public static final String KEY_BUTTON_EXPORT_LOG = "EXPORT_LOG";
private Collection<BluetoothDevice> btPairedDevices;
@@ -113,8 +121,14 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
triggerScanModeListPref.setOnPreferenceChangeListener(this);
triggerScanModeListPref.setSummary(triggerScanModeListPref.getValue());
Preference button = findPreference(KEY_BUTTON_EXPORT_LOG);
button.setOnPreferenceClickListener(preference -> {
Preference checkUpdatesButton = findPreference(KEY_BUTTON_CHECK_UPDATES);
checkUpdatesButton.setOnPreferenceClickListener(preference -> {
checkUpdates();
return true;
});
Preference exportLogButton = findPreference(KEY_BUTTON_EXPORT_LOG);
exportLogButton.setOnPreferenceClickListener(preference -> {
exportLog();
return true;
});
@@ -126,8 +140,12 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
var triggerScanModeListPref = (ListPreference) findPreference(KEY_TRIGGER_SCAN_MODE);
if (triggerScanModeListPref != null) {
var scanModes = BarcodeSetting.getTriggerScanModes();
triggerScanModeListPref.setEntries(scanModes);
triggerScanModeListPref.setEntryValues(scanModes);
var values = scanModes.keySet().toArray(new String[0]);
var descriptions = scanModes.values().toArray(new CharSequence[0]);
triggerScanModeListPref.setEntries(descriptions);
triggerScanModeListPref.setEntryValues(values);
triggerScanModeListPref.setOnPreferenceChangeListener(this);
}
}
@@ -150,15 +168,15 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
if (!btPairedDevices.isEmpty()) {
CharSequence[] entries = new CharSequence[btPairedDevices.size()];
Stream.of(btPairedDevices)
btPairedDevices.stream()
.map(BluetoothDevice::getName)
.toList()
.collect(Collectors.toList())
.toArray(entries);
CharSequence[] entryValues = new CharSequence[btPairedDevices.size()];
Stream.of(btPairedDevices)
btPairedDevices.stream()
.map(BluetoothDevice::getAddress)
.toList()
.collect(Collectors.toList())
.toArray(entryValues);
lp.setEntries(entries);
@@ -228,9 +246,20 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
listPref.setSummary(btDeviceName);
}
private void checkUpdates() {
Snackbar.make(getView(), R.string.checking_updates, Snackbar.LENGTH_SHORT)
.show();
updatesManager.executeCheck(getContext(), true);
}
private void exportLog() {
var handler = new Handler(Looper.getMainLooper());
DialogYesNoView.newInstance("Esportazione log", "Vuoi inviare il log degli eventi al supporto?", result -> {
if (result == DialogConsts.Results.NO || result == DialogConsts.Results.ABORT)
return;
this.openProgress();
executorService.execute(() -> {
@@ -246,7 +275,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
try {
List<MailAttachmentDTO> attachmentDTOList = new ArrayList<>();
if(fileToShare != null) {
if (fileToShare != null) {
var htmlContent = createAppLogAttachment(fileToShare);
byte[] buffer = htmlContent.getBytes();//specify the size to allow.
@@ -265,7 +294,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
dbFiles[1] = requireContext().getDatabasePath("integry_wms-shm");
dbFiles[2] = requireContext().getDatabasePath("integry_wms-wal");
for(int i = 0; i < dbFiles.length; i++){
for (int i = 0; i < dbFiles.length; i++) {
byte[] dbFileBytes = new byte[(int) dbFiles[i].length()];
FileInputStream inputStream = new FileInputStream(dbFiles[i]);
final int read = inputStream.read(dbFileBytes);
@@ -284,25 +313,14 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
.setAttachments(attachmentDTOList);
systemRESTConsumer.sendMail(mailRequest, this::closeProgress, ex -> {
this.closeProgress();
requireActivity().runOnUiThread(() -> {
DialogSimpleMessageView
.makeErrorDialog(new SpannableString(Html.fromHtml(ex.getMessage())), null, null)
.show(requireActivity().getSupportFragmentManager(), "tag");
});
});
} catch (Exception ex) {
UtilityExceptions.defaultException(requireContext(), ex);
this.closeProgress();
systemRESTConsumer.sendMailSynchronized(mailRequest);
// requireActivity().runOnUiThread(() -> {
// DialogSimpleMessageView
// .makeErrorDialog(new SpannableString(Html.fromHtml(ex.getMessage())), null, null)
// .show(requireActivity().getSupportFragmentManager(), "tag");
// });
//
// FirebaseCrashlytics.getInstance().recordException(ex);
this.closeProgress();
} catch (Exception ex) {
handler.post(() -> {
this.closeProgress();
UtilityExceptions.defaultException(requireContext(), ex);
});
}
});
})
@@ -310,16 +328,15 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
}
private void openProgress() {
// executorService.execute(() -> {
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager());
// });
}
private void closeProgress() {
// executorService.execute(() -> {
mCurrentProgress.dismiss();
mCurrentProgress.dismiss();
// });
}
@@ -334,7 +351,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
while ((line = br.readLine()) != null) {
if(!line.matches("\\d{13}.*")) {
if (!line.matches("\\d{13}.*")) {
int lastNewLineChar = text.lastIndexOf("\n");
text.deleteCharAt(text.length() - 1);
}
@@ -411,7 +428,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
}
htmlContent.append("""
<script type="text/javascript">
document.querySelectorAll(".message").forEach(el => el.innerHTML = el.innerHTML.replaceAll(/at it\\.integry.*?(?:<br>)/g, '<b>$&</b>'));
</script>

View File

@@ -0,0 +1,55 @@
package it.integry.integrywmsnative.view.components;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.SwitchPreferenceCompat;
import it.integry.integrywmsnative.R;
import it.integry.integrywmsnative.view.dialogs.DialogConsts;
import it.integry.integrywmsnative.view.dialogs.yes_no.DialogYesNoView;
public class ConfirmSwitchPreferenceCompat extends SwitchPreferenceCompat {
private final String confirmTitle;
private final String confirmMessage;
public ConfirmSwitchPreferenceCompat(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ConfirmSwitchPreferenceCompat);
String confirmTitle = a.getString(R.styleable.ConfirmSwitchPreferenceCompat_confirmTitle);
String confirmMessage = a.getString(R.styleable.ConfirmSwitchPreferenceCompat_confirmMessage);
a.recycle();
if(confirmTitle == null) confirmTitle = "Confirm";
if(confirmMessage == null) confirmMessage = "Are you sure you want to change this setting?";
this.confirmMessage = confirmMessage;
this.confirmTitle = confirmTitle;
}
@Override
protected void onClick() {
if (isChecked()) {
// showConfirmationDialog(false);
setChecked(false);
} else {
showConfirmationDialog(true);
}
}
private void showConfirmationDialog(final boolean newValue) {
DialogYesNoView.newInstance(confirmTitle, confirmMessage, result -> {
if(result == DialogConsts.Results.YES) {
setChecked(newValue);
}
}).show(((FragmentActivity) getContext()).getSupportFragmentManager(), "dialog-enable-beta");
}
}

View File

@@ -71,9 +71,15 @@ public class DialogProgressView extends DialogFragment {
isPending = true;
handler.post(() -> {
try {
if (!manager.isDestroyed() && !isAdded()) {
manager.executePendingTransactions();
try {
manager.executePendingTransactions();
} catch (IllegalStateException e) {
//ignore
String a = "";
}
showNow(manager, "loading-dialog");
mBindings.progressBar.setIndeterminate(isIndeterminateProgress());
@@ -90,7 +96,16 @@ public class DialogProgressView extends DialogFragment {
handler.post(() -> {
if (isAdded()) {
dismissAllowingStateLoss();
if (!getParentFragmentManager().isDestroyed()) {
try {
getParentFragmentManager().executePendingTransactions();
} catch (IllegalStateException e) {
//ignore
String a = "";
}
}
}
});
}

View File

@@ -267,8 +267,7 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
if (validated) {
this.mAbort = false;
dismiss();
this.mOnComplete.run(this.mViewModel.getResult(), false);
dismiss(this.mViewModel.getResult(), false);
}
});
});
@@ -278,14 +277,29 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
this.mViewModel.validate(validated -> {
if (validated) {
this.mAbort = false;
dismiss();
this.mOnComplete.run(this.mViewModel.getResult(), true);
dismiss(this.mViewModel.getResult(), true);
} else {
this.onLoadingEnded();
}
});
}
@Override
public void dismiss() {
dismiss(null, false);
}
private void dismiss(DialogInputQuantityV2ResultDTO result, boolean shouldCloseLu) {
super.dismiss();
if (this.mOnComplete != null) {
if(result == null) {
mOnAbort.run();
} else {
this.mOnComplete.run(result, shouldCloseLu);
}
}
}
@Override
public void onStart() {
super.onStart();

View File

@@ -2,7 +2,6 @@ package it.integry.integrywmsnative.view.dialogs.yes_no;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.NonNull;
@@ -39,7 +38,7 @@ public class DialogYesNoView extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
var binding = DialogYesNoBinding.inflate(LayoutInflater.from(requireContext()));
var binding = DialogYesNoBinding.inflate(getLayoutInflater());
binding.executePendingBindings();
if (UtilityString.isNullOrEmpty(title)) {

View File

@@ -190,6 +190,8 @@
<string name="tare_pckg">Tara collo</string>
<string name="tare_art">Tara articolo</string>
<string name="checking_updates">Controllo gli aggiornamenti</string>
<string name="saving">Salvataggio</string>
<string name="data_saved">Salvataggio completato</string>
<string name="alert_print_completed_message">Stampa completata</string>
@@ -457,9 +459,11 @@
<string name="action_print_shipping_SSCC">Stampa etichetta spedizione</string>
<string name="action_print_production_SSCC">Stampa etichetta lavorazione</string>
<string name="scanner_settings">Impostazioni scanner</string>
<string name="developer_settings">Svilupppo</string>
<string name="developer_settings_title">Esporta log</string>
<string name="developer_settings_summary">Esporta il log degli eventi</string>
<string name="developer_settings">Sviluppo</string>
<string name="developer_settings_export_log_title">Esporta log</string>
<string name="developer_settings_export_log_summary">Esporta il log degli eventi</string>
<string name="developer_settings_enable_beta_version_title">Aggiornamenti beta</string>
<string name="developer_settings_enable_beta_version_summary">Abilita aggiornamenti beta (fortemente sconsigliato)</string>
<string name="scanner_settings_scanner_delay_title">Ritardo scansione</string>
<string name="scanner_settings_scanner_delay_summary">Imposta un ritardo di lettura per la scansione</string>
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>

View File

@@ -20,4 +20,10 @@
<attr name="backgroundView" />
<attr name="parentView" />
</declare-styleable>
<declare-styleable name="ConfirmSwitchPreferenceCompat">
<attr name="confirmTitle" format="string" />
<attr name="confirmMessage" format="string" />
</declare-styleable>
</resources>

View File

@@ -189,6 +189,8 @@
<string name="tare_art">Tare product</string>
<string name="tare_pckg">Tare pckg</string>
<string name="checking_updates">Checking for updates</string>
<string name="saving">Saving</string>
<string name="data_saved">Data saved</string>
<string name="alert_print_completed_message">Printing job completed</string>
@@ -463,8 +465,10 @@
<string name="action_print_production_SSCC">Print production label</string>
<string name="scanner_settings">Scanner settings</string>
<string name="developer_settings">Developer settings</string>
<string name="developer_settings_title">Esporta log</string>
<string name="developer_settings_summary">Esporta il log degli eventi</string>
<string name="developer_settings_export_log_title">Export log</string>
<string name="developer_settings_export_log_summary">Export event log</string>
<string name="developer_settings_enable_beta_version_title">Beta updates</string>
<string name="developer_settings_enable_beta_version_summary">Enable beta updates (strongly discouraged)</string>
<string name="scanner_settings_scanner_delay_title">Scan delay</string>
<string name="scanner_settings_scanner_delay_summary">Set reading scanner delay</string>
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>

View File

@@ -67,10 +67,27 @@
app:title="@string/developer_settings"
app:iconSpaceReserved="false">
<it.integry.integrywmsnative.view.components.ConfirmSwitchPreferenceCompat
android:title="@string/developer_settings_enable_beta_version_title"
android:key="ENABLE_BETA"
android:summary="@string/developer_settings_enable_beta_version_summary"
app:iconSpaceReserved="false"
android:defaultValue="false"
app:confirmTitle="@string/developer_settings_enable_beta_version_title"
app:confirmMessage="Sei sicuro di voler abilitare gli aggiornamenti beta? Se accetti dovrai chiudere e riaprire l'app per scaricare l'aggiornamento."
/>
<Preference
android:title="@string/developer_settings_title"
android:title="Verifica aggiornamenti"
android:key="CHECK_UPDATES"
android:summary="Verifica la disponibilità di nuovi aggiornamenti"
app:iconSpaceReserved="false"
/>
<Preference
android:title="@string/developer_settings_export_log_title"
android:key="EXPORT_LOG"
android:summary="@string/developer_settings_summary"
android:summary="@string/developer_settings_export_log_summary"
app:iconSpaceReserved="false"
/>

View File

@@ -1,7 +1,6 @@
package it.integry.barcode_base_android_library.model;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
public class BarcodeSetting {
@@ -13,14 +12,13 @@ public class BarcodeSetting {
public static final String P_TRIGGER_SCAN_DELAY = "TRIG_SCAN_DELAY";
public static CharSequence[] getTriggerScanModes() {
List<String> keys = new ArrayList<>();
keys.add(V_TRIGGER_SCAN_MODE_READ_ON_RELEASE);
keys.add(V_TRIGGER_SCAN_MODE_ONE_SHOT);
// keys.add(V_TRIGGER_SCAN_MODE_CONTINUOS);
// keys.add(V_TRIGGER_SCAN_MODE_READ_ON_SECOND_TRIGGER_PRESS);
return keys.toArray(new String[0]);
public static HashMap<String, CharSequence> getTriggerScanModes() {
return new HashMap<>() {{
put(V_TRIGGER_SCAN_MODE_READ_ON_RELEASE, "Read on release");
put(V_TRIGGER_SCAN_MODE_ONE_SHOT, "One shot");
// put(V_TRIGGER_SCAN_MODE_CONTINUOS, "Continuous");
// put(V_TRIGGER_SCAN_MODE_READ_ON_SECOND_TRIGGER_PRESS, "Read on second trigger press");
}};
}
}