Sistemata gestione delle eccezioni non gestite e creato sistema di esportazione Log
This commit is contained in:
@@ -3,11 +3,13 @@ package it.integry.integrywmsnative;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import it.integry.integrywmsnative.core.context.AppContext;
|
import it.integry.integrywmsnative.core.context.AppContext;
|
||||||
import it.integry.integrywmsnative.core.data_store.db.RoomModule;
|
import it.integry.integrywmsnative.core.data_store.db.RoomModule;
|
||||||
|
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
||||||
|
|
||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
@@ -19,6 +21,8 @@ public class MainApplication extends Application {
|
|||||||
public static MainApplicationModule appModule;
|
public static MainApplicationModule appModule;
|
||||||
public static RoomModule roomModule;
|
public static RoomModule roomModule;
|
||||||
|
|
||||||
|
private Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AppContext appContext;
|
AppContext appContext;
|
||||||
|
|
||||||
@@ -40,6 +44,9 @@ public class MainApplication extends Application {
|
|||||||
appComponent.inject(this);
|
appComponent.inject(this);
|
||||||
|
|
||||||
res = getResources();
|
res = getResources();
|
||||||
|
|
||||||
|
defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(_unCaughtExceptionHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by the system when the device configuration changes while your component is running.
|
// Called by the system when the device configuration changes while your component is running.
|
||||||
@@ -61,4 +68,22 @@ public class MainApplication extends Application {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// handler listener
|
||||||
|
private Thread.UncaughtExceptionHandler _unCaughtExceptionHandler =
|
||||||
|
new Thread.UncaughtExceptionHandler() {
|
||||||
|
@Override
|
||||||
|
public void uncaughtException(Thread thread, Throwable ex) {
|
||||||
|
try {
|
||||||
|
UtilityLogger.error(new Exception(ex));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Uncaught error", "Exception Logger failed!", e);
|
||||||
|
//MainApplication.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// re-throw critical exception further to the os (important)
|
||||||
|
defaultUncaughtExceptionHandler.uncaughtException(thread, ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ import it.integry.integrywmsnative.gest.pv_ordini_acquisto.PVOrdiniAcquistoGrigl
|
|||||||
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanGrigliaAcquistoComponent;
|
import it.integry.integrywmsnative.gest.pv_ordini_acquisto.dialogs.DialogScanGrigliaAcquistoComponent;
|
||||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent;
|
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeComponent;
|
||||||
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule;
|
import it.integry.integrywmsnative.gest.rettifica_giacenze.RettificaGiacenzeModule;
|
||||||
|
import it.integry.integrywmsnative.gest.settings.MainSettingsComponent;
|
||||||
|
import it.integry.integrywmsnative.gest.settings.MainSettingsModule;
|
||||||
import it.integry.integrywmsnative.gest.spedizione.SpedizioneComponent;
|
import it.integry.integrywmsnative.gest.spedizione.SpedizioneComponent;
|
||||||
import it.integry.integrywmsnative.gest.spedizione.SpedizioneModule;
|
import it.integry.integrywmsnative.gest.spedizione.SpedizioneModule;
|
||||||
import it.integry.integrywmsnative.gest.spedizione.dialogs.print_sscc_list.DialogPrintOrderSSCCListComponent;
|
import it.integry.integrywmsnative.gest.spedizione.dialogs.print_sscc_list.DialogPrintOrderSSCCListComponent;
|
||||||
@@ -169,6 +171,7 @@ import it.integry.integrywmsnative.view.dialogs.scan_or_create_lu.DialogScanOrCr
|
|||||||
BottomSheetInventarioRowActionsModule.class,
|
BottomSheetInventarioRowActionsModule.class,
|
||||||
BottomSheetMtbColrEditModalModule.class,
|
BottomSheetMtbColrEditModalModule.class,
|
||||||
DialogChooseArtsFromMtbAartListModule.class,
|
DialogChooseArtsFromMtbAartListModule.class,
|
||||||
|
MainSettingsModule.class,
|
||||||
|
|
||||||
})
|
})
|
||||||
public interface MainApplicationComponent {
|
public interface MainApplicationComponent {
|
||||||
@@ -285,6 +288,8 @@ public interface MainApplicationComponent {
|
|||||||
|
|
||||||
DialogChooseArtsFromMtbAartListComponent.Factory dialogDialogDialogChooseArtsFromMtbAartListViewComponent();
|
DialogChooseArtsFromMtbAartListComponent.Factory dialogDialogDialogChooseArtsFromMtbAartListViewComponent();
|
||||||
|
|
||||||
|
MainSettingsComponent.Factory mainSettingsFragmentComponent();
|
||||||
|
|
||||||
void inject(MainApplication mainApplication);
|
void inject(MainApplication mainApplication);
|
||||||
|
|
||||||
void inject(AppContext mainApplication);
|
void inject(AppContext mainApplication);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public class AppContext {
|
|||||||
@Inject
|
@Inject
|
||||||
SettingsManager mSettingsManager;
|
SettingsManager mSettingsManager;
|
||||||
|
|
||||||
|
private File logsFolder;
|
||||||
|
|
||||||
public AppContext(Context context) {
|
public AppContext(Context context) {
|
||||||
this.mApplicationContext = context;
|
this.mApplicationContext = context;
|
||||||
|
|
||||||
@@ -53,6 +55,10 @@ public class AppContext {
|
|||||||
this.initLogger();
|
this.initLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getLogFilePath() {
|
||||||
|
return logsFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initSettings() {
|
private void initSettings() {
|
||||||
Stash.init(mApplicationContext);
|
Stash.init(mApplicationContext);
|
||||||
@@ -82,10 +88,9 @@ public class AppContext {
|
|||||||
private void initLogger() {
|
private void initLogger() {
|
||||||
Logger.addLogAdapter(new AndroidLogAdapter());
|
Logger.addLogAdapter(new AndroidLogAdapter());
|
||||||
|
|
||||||
File logsFolder = new File(mApplicationContext.getExternalFilesDir(null).getAbsolutePath());
|
logsFolder = new File(mApplicationContext.getExternalFilesDir(null).getAbsolutePath());
|
||||||
int maxBytesSize = 5 * 1024 * 1024;
|
int maxBytesSize = 5 * 1024 * 1024;
|
||||||
Logger.addLogAdapter(new DiskLogAdapter(logsFolder, maxBytesSize));
|
Logger.addLogAdapter(new DiskLogAdapter(logsFolder, maxBytesSize));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
package it.integry.integrywmsnative.core.exception;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
|
|
||||||
import it.integry.integrywmsnative.MainApplication;
|
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityLogger;
|
|
||||||
import it.integry.integrywmsnative.view.dialogs.exception.DialogException;
|
|
||||||
|
|
||||||
public class ExceptionsHandler implements Thread.UncaughtExceptionHandler {
|
|
||||||
|
|
||||||
private final static String TAG = ExceptionsHandler.class.getSimpleName();
|
|
||||||
|
|
||||||
private final Activity context;
|
|
||||||
|
|
||||||
public static void init(Activity context) {
|
|
||||||
new ExceptionsHandler(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ExceptionsHandler(Activity context) {
|
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
//if (!BuildConfig.DEBUG) {
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
|
||||||
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uncaughtException(final Thread thread, final Throwable ex) {
|
|
||||||
try {
|
|
||||||
UtilityLogger.error(new Exception(ex));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception Logger failed!", e);
|
|
||||||
MainApplication.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
appendToFile(new Exception(ex));
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Looper.prepare();
|
|
||||||
DialogException.make(context, context::finish).show();
|
|
||||||
Looper.loop();
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void appendToFile(Exception e) {
|
|
||||||
try {
|
|
||||||
File yourFile = new File(Environment.getExternalStorageDirectory(), "log.txt");
|
|
||||||
|
|
||||||
FileWriter fstream = new FileWriter(yourFile.getPath(), true);
|
|
||||||
BufferedWriter out = new BufferedWriter(fstream);
|
|
||||||
PrintWriter pWriter = new PrintWriter(out, true);
|
|
||||||
e.printStackTrace(pWriter);
|
|
||||||
}
|
|
||||||
catch (Exception ie) {
|
|
||||||
throw new RuntimeException("Could not write Exception to file", ie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -101,12 +101,7 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendErrorLogMail(String message) {
|
public void sendErrorLogMail(String message, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
sendErrorLogMail(message, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void sendErrorLogMail(String message, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
|
||||||
|
|
||||||
String currentAzienda = UtilityString.isNullOrEmpty(SettingsManager.i().getUserSession().getProfileDB()) ? "" : " [" + SettingsManager.i().getUserSession().getProfileDB() + "]";
|
String currentAzienda = UtilityString.isNullOrEmpty(SettingsManager.i().getUserSession().getProfileDB()) ? "" : " [" + SettingsManager.i().getUserSession().getProfileDB() + "]";
|
||||||
|
|
||||||
@@ -135,10 +130,10 @@ public class SystemRESTConsumer extends _BaseRESTConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
public void sendMail(MailRequestDTO mailDTO, Runnable onComplete, RunnableArgs<Exception> onFailed) {
|
||||||
|
|
||||||
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
SystemRESTConsumerService service = RESTBuilder.getService(SystemRESTConsumerService.class);
|
||||||
service.sendMail(mailDTO).enqueue(new Callback<ServiceRESTResponse<String>>() {
|
service.sendMail(mailDTO).enqueue(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {
|
public void onResponse(Call<ServiceRESTResponse<String>> call, Response<ServiceRESTResponse<String>> response) {
|
||||||
if (onComplete != null) onComplete.run();
|
if (onComplete != null) onComplete.run();
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package it.integry.integrywmsnative.core.rest.model;
|
||||||
|
|
||||||
|
public class MailAttachmentDTO {
|
||||||
|
|
||||||
|
private String fileName;
|
||||||
|
private String fileb64Content;
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MailAttachmentDTO setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileb64Content() {
|
||||||
|
return fileb64Content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MailAttachmentDTO setFileb64Content(String fileb64Content) {
|
||||||
|
this.fileb64Content = fileb64Content;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package it.integry.integrywmsnative.core.rest.model;
|
package it.integry.integrywmsnative.core.rest.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MailRequestDTO {
|
public class MailRequestDTO {
|
||||||
|
|
||||||
private String from;
|
private String from;
|
||||||
@@ -11,6 +13,7 @@ public class MailRequestDTO {
|
|||||||
private String ccn;
|
private String ccn;
|
||||||
private String subject;
|
private String subject;
|
||||||
private String msgText;
|
private String msgText;
|
||||||
|
private List<MailAttachmentDTO> attachments;
|
||||||
private boolean isHtml = false;
|
private boolean isHtml = false;
|
||||||
private boolean isDebug = false;
|
private boolean isDebug = false;
|
||||||
|
|
||||||
@@ -95,6 +98,15 @@ public class MailRequestDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MailAttachmentDTO> getAttachments() {
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MailRequestDTO setAttachments(List<MailAttachmentDTO> attachments) {
|
||||||
|
this.attachments = attachments;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isHtml() {
|
public boolean isHtml() {
|
||||||
return isHtml;
|
return isHtml;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,7 +316,8 @@ public class ProdOrdineProduzioneElencoFragment extends BaseFragment implements
|
|||||||
.filter(y -> y.getBarcode().equals(x.getBarcode()))
|
.filter(y -> y.getBarcode().equals(x.getBarcode()))
|
||||||
.map(y -> new MainListProdOrdineProduzioneElencoClienteListModel()
|
.map(y -> new MainListProdOrdineProduzioneElencoClienteListModel()
|
||||||
.setPrimaryText(y.getRifOrd())
|
.setPrimaryText(y.getRifOrd())
|
||||||
.setRightText(y.getCodJcom()))
|
.setRightText(y.getCodJcom())
|
||||||
|
.setOriginalModel(y))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
listModel.setClientiListModel(clienti);
|
listModel.setClientiListModel(clienti);
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ui;
|
package it.integry.integrywmsnative.gest.prod_accettazione_ord_produzione.ui;
|
||||||
|
|
||||||
|
import it.integry.integrywmsnative.gest.accettazione.dto.OrdineAccettazioneInevasoDTO;
|
||||||
|
|
||||||
public class MainListProdOrdineProduzioneElencoClienteListModel {
|
public class MainListProdOrdineProduzioneElencoClienteListModel {
|
||||||
private String primaryText;
|
private String primaryText;
|
||||||
private String rightText;
|
private String rightText;
|
||||||
|
|
||||||
|
private OrdineAccettazioneInevasoDTO originalModel;
|
||||||
|
|
||||||
|
|
||||||
public String getPrimaryText() {
|
public String getPrimaryText() {
|
||||||
return primaryText;
|
return primaryText;
|
||||||
@@ -22,4 +26,13 @@ public class MainListProdOrdineProduzioneElencoClienteListModel {
|
|||||||
this.rightText = rightText;
|
this.rightText = rightText;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OrdineAccettazioneInevasoDTO getOriginalModel() {
|
||||||
|
return originalModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainListProdOrdineProduzioneElencoClienteListModel setOriginalModel(OrdineAccettazioneInevasoDTO originalModel) {
|
||||||
|
this.originalModel = originalModel;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package it.integry.integrywmsnative.gest.settings;
|
||||||
|
|
||||||
|
import dagger.Subcomponent;
|
||||||
|
|
||||||
|
@Subcomponent
|
||||||
|
public interface MainSettingsComponent {
|
||||||
|
|
||||||
|
|
||||||
|
@Subcomponent.Factory
|
||||||
|
interface Factory {
|
||||||
|
|
||||||
|
MainSettingsComponent create();
|
||||||
|
}
|
||||||
|
|
||||||
|
void inject(MainSettingsFragment mainSettingsFragment);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,9 +3,14 @@ package it.integry.integrywmsnative.gest.settings;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.util.Base64;
|
||||||
|
import android.util.Base64OutputStream;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
import androidx.preference.EditTextPreference;
|
import androidx.preference.EditTextPreference;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
@@ -15,25 +20,58 @@ import androidx.preference.PreferenceFragmentCompat;
|
|||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
import com.harrysoft.androidbluetoothserial.BluetoothManager;
|
import com.harrysoft.androidbluetoothserial.BluetoothManager;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import it.integry.barcode_base_android_library.model.BarcodeSetting;
|
import it.integry.barcode_base_android_library.model.BarcodeSetting;
|
||||||
|
import it.integry.integrywmsnative.MainApplication;
|
||||||
import it.integry.integrywmsnative.R;
|
import it.integry.integrywmsnative.R;
|
||||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||||
|
import it.integry.integrywmsnative.core.context.AppContext;
|
||||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
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.utility.UtilityResources;
|
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||||
|
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 {
|
public class MainSettingsFragment extends PreferenceFragmentCompat implements ITitledFragment, Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public AppContext appContext;
|
||||||
|
@Inject
|
||||||
|
public SystemRESTConsumer systemRESTConsumer;
|
||||||
|
@Inject
|
||||||
|
public DialogProgressView mCurrentProgress;
|
||||||
|
private boolean progressOpened;
|
||||||
|
|
||||||
private final ArrayList<Runnable> onPreDestroyList = new ArrayList<>();
|
private final ArrayList<Runnable> onPreDestroyList = new ArrayList<>();
|
||||||
|
|
||||||
public static final String KEY_PALLET_BT_DEVICE = "pallet_scale_bt_device";
|
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_MODE = "TRIG_SCAN_MODE";
|
||||||
public static final String KEY_TRIGGER_SCAN_DELAY = "TRIG_SCAN_DELAY";
|
public static final String KEY_TRIGGER_SCAN_DELAY = "TRIG_SCAN_DELAY";
|
||||||
|
public static final String KEY_BUTTON_EXPORT_LOG = "EXPORT_LOG";
|
||||||
|
|
||||||
private Collection<BluetoothDevice> btPairedDevices;
|
private Collection<BluetoothDevice> btPairedDevices;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
MainApplication
|
||||||
|
.appComponent
|
||||||
|
.mainSettingsFragmentComponent()
|
||||||
|
.create()
|
||||||
|
.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
public void onCreateActionBar(AppCompatTextView titleText, Context context) {
|
||||||
titleText.setText(context.getText(R.string.settings_category).toString());
|
titleText.setText(context.getText(R.string.settings_category).toString());
|
||||||
@@ -55,6 +93,13 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
|||||||
loadScanModePreferences();
|
loadScanModePreferences();
|
||||||
triggerScanModeListPref.setOnPreferenceChangeListener(this);
|
triggerScanModeListPref.setOnPreferenceChangeListener(this);
|
||||||
triggerScanModeListPref.setSummary(triggerScanModeListPref.getValue());
|
triggerScanModeListPref.setSummary(triggerScanModeListPref.getValue());
|
||||||
|
|
||||||
|
Preference button = findPreference(KEY_BUTTON_EXPORT_LOG);
|
||||||
|
button.setOnPreferenceClickListener(preference -> {
|
||||||
|
exportLog();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,4 +209,74 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
|||||||
listPref.setSummary(btDeviceName);
|
listPref.setSummary(btDeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void exportLog() {
|
||||||
|
DialogYesNoView.newInstance("Esportazione log", "Vuoi inviare il log degli eventi al supporto?", result -> {
|
||||||
|
this.openProgress();
|
||||||
|
|
||||||
|
File yourFile = appContext.getLogFilePath();
|
||||||
|
var files = yourFile.listFiles();
|
||||||
|
|
||||||
|
var fileToShare = Stream.of(files)
|
||||||
|
.sortBy(x -> -1 * x.lastModified())
|
||||||
|
.findFirstOrElse(null);
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream(fileToShare);
|
||||||
|
|
||||||
|
byte[] buffer = new byte[fis.available()];//specify the size to allow
|
||||||
|
int bytesRead;
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
Base64OutputStream output64 = new Base64OutputStream(output, Base64.DEFAULT);
|
||||||
|
|
||||||
|
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||||
|
output64.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
output64.close();
|
||||||
|
|
||||||
|
var attachment = new MailAttachmentDTO()
|
||||||
|
.setFileName("wms_log.log")
|
||||||
|
.setFileb64Content(output.toString());
|
||||||
|
|
||||||
|
var mailRequest = new MailRequestDTO()
|
||||||
|
.setTo("developer@integry.it")
|
||||||
|
.setMsgText("Questo è una mail che contiene il log del WMS")
|
||||||
|
.setSubject("U vuemmeess")
|
||||||
|
.setAttachments(new ArrayList<>());
|
||||||
|
|
||||||
|
mailRequest.getAttachments().add(attachment);
|
||||||
|
|
||||||
|
systemRESTConsumer.sendMail(mailRequest, this::closeProgress, ex -> {
|
||||||
|
this.closeProgress();
|
||||||
|
DialogSimpleMessageView
|
||||||
|
.makeErrorDialog(new SpannableString(Html.fromHtml(ex.getMessage())), null, null)
|
||||||
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
|
});
|
||||||
|
} catch (Exception ex) {
|
||||||
|
DialogSimpleMessageView
|
||||||
|
.makeErrorDialog(new SpannableString(Html.fromHtml(ex.getMessage())), null, null)
|
||||||
|
.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show(getParentFragmentManager(), "tag");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void openProgress() {
|
||||||
|
if (!progressOpened && !this.mCurrentProgress.isAdded()) {
|
||||||
|
this.progressOpened = true;
|
||||||
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
this.mCurrentProgress.show(requireActivity().getSupportFragmentManager(), "tag");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeProgress() {
|
||||||
|
if (progressOpened) {
|
||||||
|
this.progressOpened = false;
|
||||||
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
mCurrentProgress.dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package it.integry.integrywmsnative.gest.settings;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
|
||||||
|
@Module(subcomponents = MainSettingsComponent.class)
|
||||||
|
public class MainSettingsModule {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -421,6 +421,9 @@
|
|||||||
<string name="action_print_shipping_SSCC">Stampa etichetta spedizione</string>
|
<string name="action_print_shipping_SSCC">Stampa etichetta spedizione</string>
|
||||||
<string name="action_print_production_SSCC">Stampa etichetta lavorazione</string>
|
<string name="action_print_production_SSCC">Stampa etichetta lavorazione</string>
|
||||||
<string name="scanner_settings">Impostazioni scanner</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="scanner_settings_scanner_delay_title">Ritardo scansione</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_scanner_delay_summary">Imposta un ritardo di lettura per la scansione</string>
|
||||||
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>
|
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>
|
||||||
|
|||||||
@@ -427,6 +427,9 @@
|
|||||||
<string name="action_print_shipping_SSCC">Print shipping label</string>
|
<string name="action_print_shipping_SSCC">Print shipping label</string>
|
||||||
<string name="action_print_production_SSCC">Print production label</string>
|
<string name="action_print_production_SSCC">Print production label</string>
|
||||||
<string name="scanner_settings">Scanner settings</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="scanner_settings_scanner_delay_title">Scan delay</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_scanner_delay_summary">Set reading scanner delay</string>
|
||||||
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>
|
<string name="scanner_settings_trigger_scan_mode_title">Modalità scansione</string>
|
||||||
|
|||||||
@@ -62,6 +62,19 @@
|
|||||||
app:title="@string/scanner_settings_scanner_delay_title" />
|
app:title="@string/scanner_settings_scanner_delay_title" />
|
||||||
|
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory
|
||||||
|
app:title="@string/developer_settings"
|
||||||
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:title="@string/developer_settings_title"
|
||||||
|
android:key="EXPORT_LOG"
|
||||||
|
android:summary="@string/developer_settings_summary"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
Reference in New Issue
Block a user