diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 4c745cc9..bb89238d 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/app/build.gradle b/app/build.gradle index 15cbb0ff..0519ce11 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -99,7 +99,7 @@ dependencies { implementation 'com.orhanobut:logger:2.2.0' implementation 'com.google.firebase:firebase-core:17.0.0' implementation 'com.google.firebase:firebase-crash:16.2.1' - implementation 'com.google.firebase:firebase-perf:18.0.0' + implementation 'com.google.firebase:firebase-perf:18.0.1' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'androidx.appcompat:appcompat:1.1.0-beta01' implementation 'androidx.legacy:legacy-support-v4:1.0.0' @@ -147,6 +147,7 @@ dependencies { //AppUpdate implementation 'com.github.javiersantos:AppUpdater:2.7' + //Barcode implementation project(':pointmobilescannerlibrary') implementation project(':zebrascannerlibrary') diff --git a/app/src/main/java/it/integry/integrywmsnative/core/di/BindableBoolean.java b/app/src/main/java/it/integry/integrywmsnative/core/di/BindableBoolean.java index d9009fe2..64175f0e 100644 --- a/app/src/main/java/it/integry/integrywmsnative/core/di/BindableBoolean.java +++ b/app/src/main/java/it/integry/integrywmsnative/core/di/BindableBoolean.java @@ -1,16 +1,83 @@ package it.integry.integrywmsnative.core.di; +import androidx.annotation.NonNull; import androidx.databinding.BaseObservable; +import androidx.databinding.Bindable; +import androidx.databinding.Observable; +import androidx.databinding.PropertyChangeRegistry; + +public class BindableBoolean implements Observable { -public class BindableBoolean extends BaseObservable { boolean mValue; - public BindableBoolean() {} + private transient PropertyChangeRegistry mCallbacks; + + public BindableBoolean() { + } public BindableBoolean(boolean startValue) { this.mValue = startValue; } + + @Override + public void addOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) { + synchronized (this) { + if (mCallbacks == null) { + mCallbacks = new PropertyChangeRegistry(); + } + } + mCallbacks.add(callback); + } + + @Override + public void removeOnPropertyChangedCallback(@NonNull OnPropertyChangedCallback callback) { + synchronized (this) { + if (mCallbacks == null) { + return; + } + } + mCallbacks.remove(callback); + } + + public void resetOnPropertyChangedCallback() { + synchronized (this) { + if (mCallbacks == null) { + return; + } + } + mCallbacks.clear(); + mCallbacks = null; + } + + /** + * Notifies listeners that all properties of this instance have changed. + */ + public void notifyChange() { + synchronized (this) { + if (mCallbacks == null) { + return; + } + } + mCallbacks.notifyCallbacks(this, 0, null); + } + + /** + * Notifies listeners that a specific property has changed. The getter for the property + * that changes should be marked with {@link Bindable} to generate a field in + * BR to be used as fieldId. + * + * @param fieldId The generated BR id for the Bindable field. + */ + public void notifyPropertyChanged(int fieldId) { + synchronized (this) { + if (mCallbacks == null) { + return; + } + } + mCallbacks.notifyCallbacks(this, fieldId, null); + } + public boolean get() { return mValue; } diff --git a/app/src/main/java/it/integry/integrywmsnative/gest/vendita/core/MainListVenditaAdapter.java b/app/src/main/java/it/integry/integrywmsnative/gest/vendita/core/MainListVenditaAdapter.java index 01e8dcc2..4e17a907 100644 --- a/app/src/main/java/it/integry/integrywmsnative/gest/vendita/core/MainListVenditaAdapter.java +++ b/app/src/main/java/it/integry/integrywmsnative/gest/vendita/core/MainListVenditaAdapter.java @@ -29,8 +29,6 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter mCallbacksDictionary = new HashMap<>(); - private List mDataset; private RunnableArgs mOnSingleSelectionChanged; @@ -103,6 +101,10 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd())) .anyMatch(OrdineVenditaInevasoDTO::isSelected); + List ordersToSelect = + Stream.of(mDataset) + .filter(x -> x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd())).toList(); + Stream.of(mDataset) .filter(x -> x.getCodAnagOrd().equals(mDataset.get(nextItemPosition).getCodAnagOrd())) .forEach(x -> x.setSelected(!anySelected)); @@ -110,14 +112,15 @@ public class MainListVenditaAdapter extends SectionedRecyclerViewAdapter { ordine.setSelected(isChecked); mOnSingleSelectionChanged.run(ordine); }); - - ordine.selected.addOnPropertyChangedCallback(mCallbacksDictionary.get(ordine.selected)); } diff --git a/app/src/main/java/it/integry/integrywmsnative/ui/CheckBoxThreeStates.java b/app/src/main/java/it/integry/integrywmsnative/ui/CheckBoxThreeStates.java new file mode 100644 index 00000000..62cf64fd --- /dev/null +++ b/app/src/main/java/it/integry/integrywmsnative/ui/CheckBoxThreeStates.java @@ -0,0 +1,293 @@ +package it.integry.integrywmsnative.ui; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.ViewDebug; + +import androidx.annotation.ArrayRes; +import androidx.appcompat.widget.AppCompatCheckBox; + +import it.integry.integrywmsnative.R; + +public class CheckBoxThreeStates extends AppCompatCheckBox { + + + private boolean mBroadcasting; + private boolean mIndeterminate; + + private OnCheckedChangeListener mOnCheckedChangeListener; + + + private static final int[] INDETERMINATE_STATE_SET = { +// R.attr.state_indeterminate + }; + + private static final int[] DEFAULT_CYCLE = { + 1, 0, 1, 0 + }; + + private int[] mCycle = DEFAULT_CYCLE; + +// public CheckBoxThreeStates(final Context context) { +// this(context, null); +// } + +// public CheckBoxThreeStates(final Context context, final AttributeSet attrs) { +// this(context, attrs, R.attr.checkbox3Style); +// } + + public CheckBoxThreeStates(final Context context, final AttributeSet attrs, final int defStyleAttr) { + super(context, attrs, defStyleAttr); +/* + final TypedArray a = + context.obtainStyledAttributes(attrs, R.styleable.CheckBox3, defStyleAttr, R.style.Widget_Checkbox3); + + try { + + if (a.hasValue(R.styleable.CheckBox3_checkbox3_checkableCycle)) { + int cycleRes = a.getResourceId(R.styleable.CheckBox3_checkbox3_checkableCycle, 0); + if (cycleRes != 0) { + setCycle(getResources().getIntArray(cycleRes)); + } + } + + if (a.hasValue(R.styleable.CheckBox3_android_fontFamily)) { + final String font = a.getString(R.styleable.CheckBox3_android_fontFamily); + setTypeface(TypefaceUtils.loadFromAsset(getResources().getAssets(), font)); + } + + final boolean indeterminate = a.getBoolean(R.styleable.CheckBox3_checkbox3_indeterminate, false); + final boolean checked = a.getBoolean(R.styleable.CheckBox3_android_checked, false); + + mBroadcasting = true; + + int index = getStateIndex(checked, indeterminate); + if (!isValidStateIndex(index)) { + index = getFirstValidStateIndex(index); + } + moveToState(index); + + } finally { + a.recycle(); + } + */ + } + + public void setCycle(@ArrayRes final int cycleRes) { + setCycle(getResources().getIntArray(cycleRes)); + } + + /** + * Change the cycle used to determine the next state of the checkbox when the user + * click the component, or when the {@link #toggle()} is called.
+ * The value passed is an array of 4 integer elements, representing the state of the checkbox.
+ * The value of each element can be 0 or 1, with 0 to disable the state and 1 to enable the state.
+ * The states are (in order): + *
    + *
  • Checked
  • + *
  • Indeterminate (checked)
  • + *
  • Unchecked
  • + *
  • Indeterminate (unchecked)
  • + *
+ * So if a cycle like this one is used: + * int[] cycle = new int[]{1,0,1,0} + * the checkbox will only cycle between checked and unchecked state. + * The default cycle is: {1,0,1,0} + *

+ *

The method throws an exception if the array is not valid. A valid array must match the following rules: + *

    + *
  • If not null, must have 4 elements
  • + *
  • At least 2 elements must be not equal to 0
  • + *

+ * + * @param cycle change the cycle + */ + public void setCycle(final int[] cycle) { + validateCycle(cycle); + mCycle = cycle == null ? DEFAULT_CYCLE : cycle; + } + + /** + * Move to the next state of the checkbox + */ + @Override + public void toggle() { + if (null == mCycle) return; + + final int currentIndex = getCurrentStateIndex(); + moveToNextState(currentIndex); + } + + @Override + public void setChecked(boolean checked) { + if (null == mCycle) return; + + int index = getStateIndex(checked, isIndeterminate()); + if (!isValidStateIndex(index)) { + return; + } + + super.setChecked(checked); + } + + /** + * Change the state of the checkbox + * + * @param checked + * @param indeterminate + */ + public void setChecked(boolean checked, boolean indeterminate) { + if (null == mCycle) return; + + if (isChecked() == checked) { + setIndeterminate(indeterminate); + } else { + mIndeterminate = indeterminate; + } + setChecked(checked); + } + + @ViewDebug.ExportedProperty + public boolean isIndeterminate() { + return mIndeterminate; + } + + public void setIndeterminate(boolean indeterminate) { + if (null == mCycle) return; + + int index = getStateIndex(isChecked(), indeterminate); + if (!isValidStateIndex(index)) { + return; + } + + setIndeterminateImpl(indeterminate, true); + } + + private void moveToNextState(final int index) { + int nextIndex = getNextValidIndex(index); + boolean checked = nextIndex < 2; + mIndeterminate = nextIndex == 1 || nextIndex == 3; + setChecked(checked); + } + + private void moveToState(final int nextIndex) { + if (!isValidStateIndex(nextIndex)) { + } + boolean checked = nextIndex < 2; + mIndeterminate = nextIndex == 1 || nextIndex == 3; + setChecked(checked); + } + + + private void validateCycle(final int[] cycle) { + if (null == cycle) { + return; + } + if (cycle.length != 4) { + throw new IllegalArgumentException("Invalid cycle length. Expected 4 an array or 4 int"); + } + + int total = 0; + for (final int i1 : cycle) { + if (i1 != 0) { + total++; + } + } + if (total < 2) { + throw new IllegalArgumentException("Invalid cycle. At least 2 elements must be positive"); + } + } + + private int getCurrentStateIndex() { + return getStateIndex(isChecked(), isIndeterminate()); + } + + private int getStateIndex(boolean checked, boolean indeterminate) { + int index = 0; + if (checked) { + index += indeterminate ? 1 : 0; + } else { + index = indeterminate ? 3 : 2; + } + return index; + } + + private int getFirstValidStateIndex(int index) { + int i = index; + while (i >= 0) { + if (mCycle[i] != 0) return i; + i--; + } + + i = index; + while (i < mCycle.length) { + if (mCycle[i] != 0) return i; + i++; + } + + return -1; + } + + private boolean isValidStateIndex(int index) { + return mCycle[index] != 0; + } + + private int getNextValidIndex(int index) { + int nextIndex = index + 1 >= mCycle.length ? 0 : index + 1; + if (mCycle[nextIndex] != 0) { + return nextIndex; + } + return getNextValidIndex(nextIndex); + } + + @Override + public void setOnCheckedChangeListener(final OnCheckedChangeListener listener) { + super.setOnCheckedChangeListener(listener); + mOnCheckedChangeListener = listener; + } + + @Override + protected int[] onCreateDrawableState(int extraSpace) { + final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); + if (isIndeterminate()) { + mergeDrawableStates(drawableState, INDETERMINATE_STATE_SET); + } + return drawableState; + } + + @Override + protected void drawableStateChanged() { + super.drawableStateChanged(); + } + + private void setIndeterminateImpl(boolean indeterminate, boolean notify) { + if (mIndeterminate != indeterminate) { + mIndeterminate = indeterminate; + refreshDrawableState(); + if (notify) { + notifyStateListener(); + } + } + } + + private void notifyStateListener() { + if (mBroadcasting) { + return; + } + + mBroadcasting = true; + + if (mOnCheckedChangeListener != null) { + mOnCheckedChangeListener.onCheckedChanged(this, isChecked()); + } + mBroadcasting = false; + + } + + @Override + public CharSequence getAccessibilityClassName() { + return CheckBoxThreeStates.class.getName(); + } + +} diff --git a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java index b288d59a..190a6064 100644 --- a/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java +++ b/app/src/main/java/it/integry/integrywmsnative/view/dialogs/input_quantity/DialogInputQuantity.java @@ -5,6 +5,7 @@ import android.app.DatePickerDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.res.ColorStateList; + import androidx.databinding.DataBindingUtil; import androidx.databinding.Observable; @@ -40,6 +41,7 @@ import it.integry.integrywmsnative.core.utility.UtilityBarcode; import it.integry.integrywmsnative.core.utility.UtilityDate; import it.integry.integrywmsnative.core.utility.UtilityExceptions; import it.integry.integrywmsnative.core.utility.UtilityLogger; +import it.integry.integrywmsnative.core.utility.UtilityNumber; import it.integry.integrywmsnative.core.utility.UtilityProgress; import it.integry.integrywmsnative.core.utility.UtilityString; import it.integry.integrywmsnative.databinding.DialogInputQuantityArticoloBinding; @@ -371,6 +373,8 @@ public class DialogInputQuantity { quantityDTO.expireDate = c.getTime(); } + refreshQtaDescriptionText(); + } @@ -502,6 +506,8 @@ public class DialogInputQuantity { } } + +// refreshQtaDescriptionText(); } }); @@ -537,6 +543,7 @@ public class DialogInputQuantity { } } +// refreshQtaDescriptionText(); } }); @@ -567,6 +574,8 @@ public class DialogInputQuantity { } } + +// refreshQtaDescriptionText(); } }); @@ -627,6 +636,42 @@ public class DialogInputQuantity { } + private void refreshQtaDescriptionText() { + + int numConf = (int) (currentQuantityDto.qtaDaEvadere.get() / currentQuantityDto.qtaCnf.get()); + float qtaTot = currentQuantityDto.qtaDaEvadere.get().floatValue(); + + float mod = qtaTot % numConf; + + String text = ""; + + if(numConf > 0) { + text += "" + numConf + " " + currentContext.getResources().getQuantityString(R.plurals.item_package, numConf).toUpperCase() + ""; + } + if(numConf > 0 && mod > 0) { + text += " e "; + } + if(mod > 0) { + + text += "" + UtilityNumber.decimalToString(mod) + " "; + if(mod == 1) { + text += currentContext.getResources().getQuantityString(R.plurals.pieces, (int) mod).toUpperCase(); + } else { + text += currentContext.getString(R.string.piece).toUpperCase(); + } + + text += ""; + + + + } + + currentBinding.qtaDescriptionText.setText(Html.fromHtml(text)); + + } + + + private void onConfirm(Context context, QuantityDTO quantityDTO, RunnableArgss dialogCallback, boolean closeUL){ if(currentDTO.mtbAart.isFlagTracciabilita() && (quantityDTO.batchLot == null || quantityDTO.batchLot.get().trim().length() == 0)){ diff --git a/app/src/main/res/layout/dialog_input_quantity_articolo.xml b/app/src/main/res/layout/dialog_input_quantity_articolo.xml index ab6504e0..f6283472 100644 --- a/app/src/main/res/layout/dialog_input_quantity_articolo.xml +++ b/app/src/main/res/layout/dialog_input_quantity_articolo.xml @@ -213,6 +213,15 @@ + + diff --git a/app/src/main/res/layout/vendita_main_list_group_model.xml b/app/src/main/res/layout/vendita_main_list_group_model.xml index 001e2b32..20fc1109 100644 --- a/app/src/main/res/layout/vendita_main_list_group_model.xml +++ b/app/src/main/res/layout/vendita_main_list_group_model.xml @@ -14,7 +14,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingStart="8dp" + android:paddingStart="2dp" android:paddingEnd="4dp"> @@ -30,7 +30,7 @@ android:background="@color/full_white"> - - + + + + + + + + + + android:paddingStart="12dp" + android:paddingTop="8dp" + android:paddingEnd="8dp" + android:paddingBottom="8dp"> - + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b6edd4b4..31a9a986 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -77,6 +77,14 @@ %d ordine]]> %d ordini]]> + + @string/piece + pezzi + + + confezione + confezioni + Chiudi UL Articoli presenti Ordini @@ -85,6 +93,7 @@ Data Posizione Preparato da + Pezzo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f58d92bf..764bf300 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -75,6 +75,14 @@ %d order selected]]> %d orders selected]]> + + @string/piece + pieces + + + package + packages + Close LU Submitted items Orders @@ -86,7 +94,7 @@ Picking not available Please scan an item barcode Extra item - + Piece between 3 and 30 alphanumeric characters enter a valid username