Aggiornate tutte le icone del drawer e del menu principale.
This commit is contained in:
@@ -20,6 +20,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
package it.integry.honeywellscannerlibrary;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.honeywell.aidc.AidcManager;
|
||||
import com.honeywell.aidc.BarcodeFailureEvent;
|
||||
import com.honeywell.aidc.BarcodeReadEvent;
|
||||
import com.honeywell.aidc.BarcodeReader;
|
||||
import com.honeywell.aidc.InvalidScannerNameException;
|
||||
import com.honeywell.aidc.ScannerUnavailableException;
|
||||
import com.honeywell.aidc.UnsupportedPropertyException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import it.integry.plugins.barcode_base_library.exception.BarcodeAdapterNotFoundException;
|
||||
import it.integry.plugins.barcode_base_library.extension.RunnableArgs;
|
||||
@@ -11,51 +27,156 @@ import it.integry.plugins.barcode_base_library.model.BarcodeScanDTO;
|
||||
|
||||
public class HoneyWellBarcodeReader implements BarcodeReaderInterface {
|
||||
|
||||
private Context mContext;
|
||||
private final AppCompatActivity mContext;
|
||||
private AidcManager manager;
|
||||
private BarcodeReader barcodeReader;
|
||||
|
||||
private boolean canGoOn = false;
|
||||
private static RunnableArgs<BarcodeScanDTO> mOnScanSuccessfull;
|
||||
private static RunnableArgs<Exception> mOnScanFailed;
|
||||
|
||||
public HoneyWellBarcodeReader(Context context) {
|
||||
private static final String TAG = HoneyWellBarcodeReader.class.getName();
|
||||
|
||||
public HoneyWellBarcodeReader(final AppCompatActivity context) {
|
||||
this.mContext = context;
|
||||
|
||||
AidcManager.create(context, new AidcManager.CreatedCallback() {
|
||||
@Override
|
||||
public void onCreated(AidcManager aidcManager) {
|
||||
canGoOn = true;
|
||||
}
|
||||
});
|
||||
|
||||
while(!canGoOn) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightAdapter() {
|
||||
return false;
|
||||
String model = Build.MODEL;
|
||||
if(model.equalsIgnoreCase("EDA50")) {
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws BarcodeAdapterNotFoundException {
|
||||
public void init(final Runnable onDeviceReady) throws BarcodeAdapterNotFoundException {
|
||||
if(isRightAdapter()) {
|
||||
|
||||
AidcManager.create(mContext, new AidcManager.CreatedCallback() {
|
||||
|
||||
@Override
|
||||
public void onCreated(AidcManager aidcManager) {
|
||||
|
||||
manager = aidcManager;
|
||||
|
||||
try{
|
||||
barcodeReader = manager.createBarcodeReader();
|
||||
registerListenersInternal();
|
||||
}
|
||||
catch (InvalidScannerNameException e){
|
||||
Toast.makeText(mContext, "Invalid Scanner Name Exception: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Exception e){
|
||||
Toast.makeText(mContext, "Exception: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
onDeviceReady.run();
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
throw new BarcodeAdapterNotFoundException(getAdapterName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deinit() {
|
||||
if (barcodeReader != null) {
|
||||
// close BarcodeReader to clean up resources.
|
||||
barcodeReader.close();
|
||||
barcodeReader = null;
|
||||
}
|
||||
|
||||
if (manager != null) {
|
||||
// close AidcManager to disconnect from the scanner service.
|
||||
// once closed, the object can no longer be used.
|
||||
manager.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void register(RunnableArgs<BarcodeScanDTO> onScanSuccessfull, RunnableArgs<Exception> onScanFailed) {
|
||||
|
||||
mOnScanSuccessfull = onScanSuccessfull;
|
||||
mOnScanFailed = onScanFailed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getAdapterName() {
|
||||
return null;
|
||||
return "Honeywell";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void registerListenersInternal() {
|
||||
// register bar code event listener
|
||||
barcodeReader.addBarcodeListener(new BarcodeReader.BarcodeListener() {
|
||||
@Override
|
||||
public void onBarcodeEvent(BarcodeReadEvent barcodeReadEvent) {
|
||||
dispatchEvent(barcodeReadEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailureEvent(BarcodeFailureEvent barcodeFailureEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// set the trigger mode to client control
|
||||
try {
|
||||
barcodeReader.setProperty(BarcodeReader.PROPERTY_TRIGGER_CONTROL_MODE,
|
||||
BarcodeReader.TRIGGER_CONTROL_MODE_CLIENT_CONTROL);
|
||||
} catch (UnsupportedPropertyException e) {
|
||||
Toast.makeText(mContext, "Failed to apply properties", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
|
||||
// Set Symbologies On/Off
|
||||
properties.put(BarcodeReader.PROPERTY_EAN_8_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_EAN_13_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_CODE_39_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_CODE_128_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_GS1_128_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_UPC_A_ENABLE, true);
|
||||
|
||||
|
||||
properties.put(BarcodeReader.PROPERTY_EAN_8_CHECK_DIGIT_TRANSMIT_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_EAN_13_CHECK_DIGIT_TRANSMIT_ENABLED, true);
|
||||
properties.put(BarcodeReader.PROPERTY_UPC_A_CHECK_DIGIT_TRANSMIT_ENABLED, true);
|
||||
|
||||
properties.put(BarcodeReader.PROPERTY_TRIGGER_CONTROL_MODE, BarcodeReader.TRIGGER_CONTROL_MODE_AUTO_CONTROL);
|
||||
|
||||
// Apply the settings
|
||||
barcodeReader.setProperties(properties);
|
||||
|
||||
|
||||
try {
|
||||
barcodeReader.claim();
|
||||
} catch (ScannerUnavailableException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void dispatchEvent(BarcodeReadEvent barcodeReadEvent)
|
||||
{
|
||||
mContext.runOnUiThread(() -> {
|
||||
|
||||
BarcodeScanDTO barcodeScanDTO = new BarcodeScanDTO()
|
||||
.setByteValue(barcodeReadEvent.getBarcodeData().getBytes())
|
||||
.setStringValue(barcodeReadEvent.getBarcodeData())
|
||||
.setType(HoneywellBarcodeTypeMapper.map(barcodeReadEvent.getCodeId()))
|
||||
.setName(HoneywellBarcodeTypeMapper.map(barcodeReadEvent.getCodeId()).toString());
|
||||
|
||||
mOnScanSuccessfull.run(barcodeScanDTO);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package it.integry.honeywellscannerlibrary;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import it.integry.plugins.barcode_base_library.model.BarcodeType;
|
||||
|
||||
public class HoneywellBarcodeTypeMapper {
|
||||
|
||||
public static BarcodeType map(String inputType) {
|
||||
|
||||
switch (inputType) {
|
||||
case "h":
|
||||
return BarcodeType.CODE11;
|
||||
case "j":
|
||||
return BarcodeType.CODE128;
|
||||
case "b":
|
||||
return BarcodeType.CODE39;
|
||||
|
||||
case "d":
|
||||
return BarcodeType.EAN13;
|
||||
case "D":
|
||||
return BarcodeType.EAN8;
|
||||
|
||||
case "c":
|
||||
return BarcodeType.UPCA;
|
||||
case "E":
|
||||
return BarcodeType.UPCE;
|
||||
default:
|
||||
Log.d("SCAN TYPE", inputType);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user