Skip to content

Commit 302fee0

Browse files
committed
Restricting the oversized barcode approach to only fullscreen view.
1 parent 92ea609 commit 302fee0

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class BarcodeImageWriterTask implements CompatCallable<Bitmap> {
4949
BarcodeImageWriterTask(
5050
Context context, ImageView imageView, String cardIdString,
5151
CatimaBarcode barcodeFormat, TextView textView,
52-
boolean showFallback, BarcodeImageWriterResultCallback callback, boolean roundCornerPadding
52+
boolean showFallback, BarcodeImageWriterResultCallback callback, boolean roundCornerPadding, boolean isFullscreen
5353
) {
5454
mContext = context;
5555

@@ -86,6 +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 && !isFullscreen) {
90+
imageHeight = imageViewHeight;
91+
imageWidth = imageViewWidth;
8992
} else {
9093
// Scale down the image to reduce the memory needed to produce it
9194
imageWidth = Math.min(MAX_WIDTH, this.mContext.getResources().getDisplayMetrics().widthPixels);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ public void onGlobalLayout() {
9292

9393
Log.d(TAG, "Generating barcode for type " + formatType);
9494

95-
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true);
95+
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true, false);
9696
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
9797
}
9898
});
9999
} else {
100100
Log.d(TAG, "Generating barcode for type " + formatType);
101-
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true);
101+
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true, false);
102102
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
103103
}
104104
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1615,13 +1615,13 @@ public void onGlobalLayout() {
16151615
barcodeImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);
16161616

16171617
Log.d(TAG, "ImageView size now known");
1618-
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, LoyaltyCardEditActivity.this, true);
1618+
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, LoyaltyCardEditActivity.this, true, false);
16191619
viewModel.getTaskHandler().executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
16201620
}
16211621
});
16221622
} else {
16231623
Log.d(TAG, "ImageView size known known, creating barcode");
1624-
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, this, true);
1624+
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, this, true, false);
16251625
viewModel.getTaskHandler().executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
16261626
}
16271627
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,8 @@ private void drawBarcode(boolean addPadding) {
957957
null,
958958
false,
959959
this,
960-
addPadding);
960+
addPadding,
961+
isFullscreen);
961962
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
962963
}
963964
}

0 commit comments

Comments
 (0)