Skip to content

Commit 7dd3969

Browse files
committed
Exploring the approach to draw an oversized barcode and let it be scaled down. Also increasing the minimum value for the width seeker.
1 parent 12d9d06 commit 7dd3969

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,9 @@ public class BarcodeImageWriterTask implements CompatCallable<Bitmap> {
8686

8787
if (format.isSquare()) {
8888
imageHeight = imageWidth = Math.min(imageViewHeight, Math.min(MAX_WIDTH, imageViewWidth));
89-
} else if (imageView.getWidth() < MAX_WIDTH) {
90-
imageHeight = imageViewHeight;
91-
imageWidth = imageViewWidth;
9289
} else {
9390
// Scale down the image to reduce the memory needed to produce it
94-
imageWidth = MAX_WIDTH;
91+
imageWidth = Math.min(MAX_WIDTH, this.mContext.getResources().getDisplayMetrics().widthPixels);
9592
double ratio = (double) MAX_WIDTH / (double) imageViewWidth;
9693
imageHeight = (int) (imageViewHeight * ratio);
9794
}

app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.google.android.material.color.MaterialColors;
5353
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
5454
import com.google.android.material.textfield.TextInputEditText;
55+
import com.google.zxing.BarcodeFormat;
5556

5657
import java.io.File;
5758
import java.io.UnsupportedEncodingException;
@@ -1150,7 +1151,8 @@ private void setFullscreen(boolean enabled) {
11501151
binding.fullscreenLayout.setVisibility(View.VISIBLE);
11511152

11521153
// Only show width slider if the barcode isn't square (square barcodes will resize height and width together)
1153-
binding.setWidthLayout.setVisibility(format.isSquare() ? View.GONE : View.VISIBLE);
1154+
// or if the internals of the barcode are squares, like DATA_MATRIX
1155+
binding.setWidthLayout.setVisibility((format.isSquare() || format.format() == BarcodeFormat.DATA_MATRIX) ? View.GONE : View.VISIBLE);
11541156

11551157
drawMainImage(mainImageIndex, true, isFullscreen);
11561158

app/src/main/res/layout/loyalty_card_view_layout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
android:layout_height="wrap_content"
235235
android:layout_gravity="center"
236236
android:contentDescription="@string/setBarcodeWidth"
237-
android:min="10"
237+
android:min="20"
238238
android:max="100" />
239239
</LinearLayout>
240240

0 commit comments

Comments
 (0)