aggiunta configurazione scanner barcode tramite preferenze app
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
package it.integry.integrywmsnative.core.barcode_reader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Pair;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.barcode_base_android_library.interfaces.BarcodeReaderInterface;
|
||||
import it.integry.barcode_base_android_library.model.BarcodeSetting;
|
||||
import it.integry.honeywellscannerlibrary.HoneyWellBarcodeReader;
|
||||
import it.integry.integrywmsnative.gest.settings.MainSettingsFragment;
|
||||
import it.integry.keyobardemulatorscannerlibrary.KeyboardEmulatorBarcodeReader;
|
||||
import it.integry.pointmobilescannerlibrary.PointMobileBarcodeReader;
|
||||
import it.integry.zebrascannerlibrary.ZebraBarcodeReader;
|
||||
@@ -21,12 +27,7 @@ public class BarcodeManager {
|
||||
private static boolean mEnabled = true;
|
||||
|
||||
|
||||
private static final Class<? extends BarcodeReaderInterface>[] registeredBarcodeReaderInterfaces = new Class[]{
|
||||
PointMobileBarcodeReader.class,
|
||||
ZebraBarcodeReader.class,
|
||||
HoneyWellBarcodeReader.class,
|
||||
KeyboardEmulatorBarcodeReader.class
|
||||
};
|
||||
private static final Class<? extends BarcodeReaderInterface>[] registeredBarcodeReaderInterfaces = new Class[]{PointMobileBarcodeReader.class, ZebraBarcodeReader.class, HoneyWellBarcodeReader.class, KeyboardEmulatorBarcodeReader.class};
|
||||
|
||||
|
||||
public static void init(Context applicationContext) throws Exception {
|
||||
@@ -65,6 +66,18 @@ public class BarcodeManager {
|
||||
}
|
||||
});
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext);
|
||||
var additionalSettings = new ArrayList<Pair<String, Object>>();
|
||||
var scanDelay = sharedPreferences.getString(MainSettingsFragment.KEY_TRIGGER_SCAN_DELAY, null);
|
||||
var scanDelaySetting = new Pair<String, Object>(BarcodeSetting.P_TRIGGER_SCAN_DELAY, scanDelay);
|
||||
additionalSettings.add(scanDelaySetting);
|
||||
|
||||
var scanMode = sharedPreferences.getString(MainSettingsFragment.KEY_TRIGGER_SCAN_MODE, null);
|
||||
var scanModeSetting = new Pair<String, Object>(BarcodeSetting.P_TRIGGER_SCAN_MODE, scanMode);
|
||||
additionalSettings.add(scanModeSetting);
|
||||
|
||||
BarcodeManager.changeSettings(additionalSettings);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -81,8 +94,7 @@ public class BarcodeManager {
|
||||
}
|
||||
|
||||
public static boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
|
||||
if (mCurrentBarcodeInterface != null)
|
||||
mCurrentBarcodeInterface.onKeyEvent(keyEvent);
|
||||
if (mCurrentBarcodeInterface != null) mCurrentBarcodeInterface.onKeyEvent(keyEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -133,6 +145,9 @@ public class BarcodeManager {
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
public static void changeSettings(List<Pair<String, Object>> settings) {
|
||||
mCurrentBarcodeInterface.changeSettings(settings);
|
||||
}
|
||||
|
||||
public static boolean isKeyboardEmulator() {
|
||||
return mCurrentBarcodeInterface instanceof KeyboardEmulatorBarcodeReader;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MainContext {
|
||||
try {
|
||||
BarcodeManager.init(applicationContext);
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
this.initDBData(() -> {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package it.integry.integrywmsnative.core.exception;
|
||||
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public final class EmptyLUException extends Exception {
|
||||
public EmptyLUException() {
|
||||
super(UtilityResources.getString(R.string.empty_lu));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,6 @@ import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
public final class NoArtsFoundException extends Exception {
|
||||
public NoArtsFoundException() {
|
||||
super(UtilityResources.getString(R.string.no_result_from_barcode));
|
||||
super(UtilityResources.getString(R.string.no_arts_found));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.core.CommonConst;
|
||||
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
|
||||
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
||||
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgs;
|
||||
import it.integry.integrywmsnative.core.expansion.RunnableArgss;
|
||||
import it.integry.integrywmsnative.core.interfaces.viewmodel_listeners.ILUBaseOperationsListener;
|
||||
@@ -333,7 +333,7 @@ public class PickingResiViewModel {
|
||||
searchArtFromUL(mtbColt, onComplete);
|
||||
} else this.sendError(new InvalidLUException());
|
||||
} else {
|
||||
this.sendError(new NoArtsFoundException());
|
||||
this.sendError(new NoResultFromBarcodeException(SSCC));
|
||||
}
|
||||
|
||||
}, this::sendError);
|
||||
@@ -417,7 +417,7 @@ public class PickingResiViewModel {
|
||||
|
||||
private void loadMatchedRows(List<WithdrawableDtbDocr> matchedRows) {
|
||||
if (matchedRows == null || matchedRows.size() == 0) {
|
||||
this.sendError(new NoArtsFoundException());
|
||||
this.sendError(new NoResultFromBarcodeException());
|
||||
} else if (matchedRows.size() == 1) {
|
||||
WithdrawableDtbDocr matchedItem = matchedRows.get(0);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.preference.EditTextPreference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
@@ -17,7 +18,9 @@ import com.harrysoft.androidbluetoothserial.BluetoothManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeSetting;
|
||||
import it.integry.integrywmsnative.R;
|
||||
import it.integry.integrywmsnative.core.barcode_reader.BarcodeManager;
|
||||
import it.integry.integrywmsnative.core.interfaces.ITitledFragment;
|
||||
import it.integry.integrywmsnative.core.utility.UtilityResources;
|
||||
|
||||
@@ -26,6 +29,8 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
private final ArrayList<Runnable> onPreDestroyList = new ArrayList<>();
|
||||
|
||||
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";
|
||||
|
||||
private Collection<BluetoothDevice> btPairedDevices;
|
||||
|
||||
@@ -39,11 +44,30 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
setPreferencesFromResource(R.xml.app_preferences, rootKey);
|
||||
|
||||
var palletScaleBtDeviceListPref = (ListPreference) findPreference(KEY_PALLET_BT_DEVICE);
|
||||
var triggerScanDelayPref = (EditTextPreference) findPreference(KEY_TRIGGER_SCAN_DELAY);
|
||||
var triggerScanModeListPref = (ListPreference) findPreference(KEY_TRIGGER_SCAN_MODE);
|
||||
setListPreferenceData(palletScaleBtDeviceListPref);
|
||||
palletScaleBtDeviceListPref.setOnPreferenceChangeListener(this);
|
||||
|
||||
triggerScanDelayPref.setOnPreferenceChangeListener(this);
|
||||
triggerScanDelayPref.setSummary(triggerScanDelayPref.getText());
|
||||
|
||||
loadScanModePreferences();
|
||||
triggerScanModeListPref.setOnPreferenceChangeListener(this);
|
||||
triggerScanModeListPref.setSummary(triggerScanModeListPref.getValue());
|
||||
}
|
||||
|
||||
|
||||
protected void loadScanModePreferences() {
|
||||
var triggerScanModeListPref = (ListPreference) findPreference(KEY_TRIGGER_SCAN_MODE);
|
||||
if (triggerScanModeListPref != null) {
|
||||
var scanModes = BarcodeSetting.getTriggerScanModes();
|
||||
triggerScanModeListPref.setEntries(scanModes);
|
||||
triggerScanModeListPref.setEntryValues(scanModes);
|
||||
triggerScanModeListPref.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setListPreferenceData(ListPreference lp) {
|
||||
BluetoothManager bluetoothManager = BluetoothManager.getInstance();
|
||||
if (bluetoothManager == null) {
|
||||
@@ -54,7 +78,7 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
|
||||
btPairedDevices = bluetoothManager.getPairedDevicesList();
|
||||
|
||||
if(!Stream.of(btPairedDevices).anyMatch(x -> x.getAddress().equalsIgnoreCase(lp.getValue()))) {
|
||||
if (!Stream.of(btPairedDevices).anyMatch(x -> x.getAddress().equalsIgnoreCase(lp.getValue()))) {
|
||||
lp.setValue(null);
|
||||
}
|
||||
|
||||
@@ -106,6 +130,16 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
final var palletScaleBtDeviceListPref = (ListPreference) preference;
|
||||
updatePalletBtDeviceSummary(palletScaleBtDeviceListPref, (String) newValue);
|
||||
break;
|
||||
case KEY_TRIGGER_SCAN_DELAY:
|
||||
final var scanDelayPref = (EditTextPreference) preference;
|
||||
scanDelayPref.setSummary((String) newValue);
|
||||
updateBarcodeScannerSettings();
|
||||
break;
|
||||
case KEY_TRIGGER_SCAN_MODE:
|
||||
final var scanTriggerMode = (ListPreference) preference;
|
||||
scanTriggerMode.setSummary((String) newValue);
|
||||
updateBarcodeScannerSettings();
|
||||
break;
|
||||
|
||||
}
|
||||
// Set result so knows to refresh itself
|
||||
@@ -113,6 +147,14 @@ public class MainSettingsFragment extends PreferenceFragmentCompat implements IT
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateBarcodeScannerSettings() {
|
||||
try {
|
||||
BarcodeManager.init(requireContext());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updatePalletBtDeviceSummary(ListPreference listPref, String btDeviceAddress) {
|
||||
String btDeviceName = Stream.of(btPairedDevices)
|
||||
|
||||
@@ -184,11 +184,12 @@ public class DialogInputQuantityV2View extends BaseDialogFragment implements Dia
|
||||
mHandler.postDelayed(() -> {
|
||||
|
||||
if (mDialogInputQuantityV2DTO.isNumCnfEditable()) {
|
||||
mBindings.inputNumCnfText.requestFocus();
|
||||
UtilityFocus.focusTextBox(requireContext(), mBindings.inputNumCnfText);
|
||||
// mBindings.inputNumCnfText.requestFocus();
|
||||
} else {
|
||||
UtilityFocus.focusTextBox(requireContext(), mBindings.inputQtaTotText);
|
||||
}
|
||||
}, 1000);
|
||||
}, 1500);
|
||||
}
|
||||
return mBindings.getRoot();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
import it.integry.barcode_base_android_library.model.BarcodeScanDTO;
|
||||
import it.integry.integrywmsnative.core.exception.EmptyLUException;
|
||||
import it.integry.integrywmsnative.core.exception.InvalidLUException;
|
||||
import it.integry.integrywmsnative.core.exception.NoArtsFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoLUFoundException;
|
||||
import it.integry.integrywmsnative.core.exception.NoResultFromBarcodeException;
|
||||
import it.integry.integrywmsnative.core.exception.TooManyLUFoundInMonoLUPositionException;
|
||||
@@ -125,7 +125,7 @@ public class DialogScanArtViewModel {
|
||||
onComplete.run(DialogConsts.Results.YES, null, null, mtbColt.getMtbColr());
|
||||
} else this.sendError(new InvalidLUException());
|
||||
} else {
|
||||
this.sendError(new NoArtsFoundException());
|
||||
this.sendError(new EmptyLUException());
|
||||
}
|
||||
|
||||
}, this::sendError);
|
||||
|
||||
24
app/src/main/res/layout/preference_edit_text.xml
Normal file
24
app/src/main/res/layout/preference_edit_text.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatEditText
|
||||
android:id="@android:id/edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"
|
||||
android:singleLine="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginStart="21dp"
|
||||
android:layout_marginEnd="21dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
@@ -413,4 +413,12 @@
|
||||
<string name="scan_lu_to_recover">Scansiona il codice a barre della <b>UL</b> da recuperare</string>
|
||||
<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="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>
|
||||
<string name="scanner_settings_trigger_scan_mode_summary">Seleziona modalità scansione per lo scanner</string>
|
||||
<string name="action_create_doc">Crea documento</string>
|
||||
<string name="no_arts_found">Nessun articolo compatibile trovato</string>
|
||||
<string name="empty_lu">UL vuota</string>
|
||||
</resources>
|
||||
@@ -419,4 +419,12 @@
|
||||
<string name="scan_lu_to_recover">Please scan the <b>LU barcode</b> to recover</string>
|
||||
<string name="action_print_shipping_SSCC">Print shipping label</string>
|
||||
<string name="action_print_production_SSCC">Print production label</string>
|
||||
<string name="scanner_settings">Scanner settings</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>
|
||||
<string name="scanner_settings_trigger_scan_mode_summary">Select scan mode</string>
|
||||
<string name="action_create_doc">Create document</string>
|
||||
<string name="no_arts_found">No product found</string>
|
||||
<string name="empty_lu">Empty LU</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<PreferenceCategory
|
||||
app:title="@string/accettazione_title_fragment"
|
||||
@@ -38,5 +39,29 @@
|
||||
app:title="@string/pallet_scale_bt_device_selection_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
app:title="@string/scanner_settings"
|
||||
app:iconSpaceReserved="false">
|
||||
|
||||
<ListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:dialogTitle="@string/scanner_settings_trigger_scan_mode_title"
|
||||
app:key="TRIG_SCAN_MODE"
|
||||
app:summary="@string/scanner_settings_trigger_scan_mode_summary"
|
||||
app:title="@string/scanner_settings_trigger_scan_mode_title" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="0"
|
||||
android:dialogLayout="@layout/preference_edit_text"
|
||||
app:iconSpaceReserved="false"
|
||||
app:dialogTitle="@string/scanner_settings_scanner_delay_title"
|
||||
app:key="TRIG_SCAN_DELAY"
|
||||
android:inputType="numberDecimal"
|
||||
android:digits="0123456789"
|
||||
app:summary="@string/scanner_settings_scanner_delay_summary"
|
||||
app:title="@string/scanner_settings_scanner_delay_title" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user