Skip to content

Commit 5386944

Browse files
committed
use reference unit for price formatting, layout adjustments
1 parent 63031ee commit 5386944

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

core/src/main/java/io/snabble/sdk/PriceFormatter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,13 @@ public String format(Product product, boolean discountedPrice) {
5555
String formattedString = format(price);
5656
Product.Type type = product.getType();
5757

58+
Unit referenceUnit = product.getReferenceUnit();
59+
if (referenceUnit == null) {
60+
referenceUnit = Unit.KILOGRAM;
61+
}
62+
5863
if (type == Product.Type.UserWeighed || type == Product.Type.PreWeighed) {
59-
formattedString += " / kg";
64+
formattedString += " / " + referenceUnit.getDisplayValue();
6065
}
6166

6267
return formattedString;

core/src/main/java/io/snabble/sdk/ProductApi.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,6 @@ private Product toProduct(ApiProduct apiProduct, Product depositProduct, Product
487487
} else {
488488
if (referenceUnit == Unit.PIECE) {
489489
builder.setType(Product.Type.Article);
490-
} else {
491-
builder.setType(Product.Type.PreWeighed);
492490
}
493491
}
494492
} else {

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,6 @@ public Product productAtCursor(Cursor cursor) {
800800

801801
if (unit == Unit.PIECE) {
802802
builder.setType(Product.Type.Article);
803-
} else {
804-
builder.setType(Product.Type.PreWeighed);
805803
}
806804
}
807805

ui/src/main/java/io/snabble/sdk/ui/scanner/ProductConfirmationDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private void updatePrice() {
289289
}
290290

291291
if (q > 0 && (scannedCode.hasWeighData() || product.getType() == Product.Type.UserWeighed)) {
292-
price.setText(String.format("%s%s * %s = %s", String.valueOf(q), encodingDisplayValue, singlePrice, priceText));
292+
price.setText(String.format("%s %s * %s = %s", String.valueOf(q), encodingDisplayValue, singlePrice, priceText));
293293
} else if (q > 1) {
294294
if (scannedCode.hasUnitData()) {
295295
price.setText(String.format("%s * %s = %s",

ui/src/main/res/layout/item_shoppingcart_product.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@
136136

137137
<androidx.appcompat.widget.AppCompatTextView
138138
android:id="@+id/quantity_annotation"
139-
android:layout_width="wrap_content"
139+
android:layout_width="32dp"
140140
android:layout_height="wrap_content"
141141
android:layout_gravity="center_vertical"
142-
android:layout_marginRight="16dp"
143-
android:textSize="15dp"
142+
android:layout_marginRight="4dp"
143+
android:gravity="left"
144+
android:text="g"
144145
android:textColor="@color/snabble_textColorDark"
145-
android:text="g" />
146+
android:textSize="15dp" />
146147

147148
<ImageView
148149
android:id="@+id/quantity_edit_apply"

0 commit comments

Comments
 (0)