Skip to content

Commit 399f79c

Browse files
committed
Restricting the oversized barcode approach to only fullscreen view.
1 parent 7dd3969 commit 399f79c

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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,13 +1614,13 @@ public void onGlobalLayout() {
16141614
barcodeImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);
16151615

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ private void drawBarcode(boolean addPadding) {
956956
null,
957957
false,
958958
this,
959-
addPadding);
959+
addPadding,
960+
isFullscreen);
960961
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
961962
}
962963
}

0 commit comments

Comments
 (0)