mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-03-30 13:21:43 -04:00
Merge pull request #2254 from perepujal/main
Adding the ability to resize the width in the fullscreen view.
This commit is contained in:
@@ -49,7 +49,7 @@ public class BarcodeImageWriterTask implements CompatCallable<Bitmap> {
|
||||
BarcodeImageWriterTask(
|
||||
Context context, ImageView imageView, String cardIdString,
|
||||
CatimaBarcode barcodeFormat, TextView textView,
|
||||
boolean showFallback, BarcodeImageWriterResultCallback callback, boolean roundCornerPadding
|
||||
boolean showFallback, BarcodeImageWriterResultCallback callback, boolean roundCornerPadding, boolean isFullscreen
|
||||
) {
|
||||
mContext = context;
|
||||
|
||||
@@ -86,13 +86,13 @@ public class BarcodeImageWriterTask implements CompatCallable<Bitmap> {
|
||||
|
||||
if (format.isSquare()) {
|
||||
imageHeight = imageWidth = Math.min(imageViewHeight, Math.min(MAX_WIDTH, imageViewWidth));
|
||||
} else if (imageView.getWidth() < MAX_WIDTH) {
|
||||
} else if (imageView.getWidth() < MAX_WIDTH && !isFullscreen) {
|
||||
imageHeight = imageViewHeight;
|
||||
imageWidth = imageViewWidth;
|
||||
} else {
|
||||
// Scale down the image to reduce the memory needed to produce it
|
||||
imageWidth = MAX_WIDTH;
|
||||
double ratio = (double) MAX_WIDTH / (double) imageViewWidth;
|
||||
imageWidth = Math.min(MAX_WIDTH, this.mContext.getResources().getDisplayMetrics().widthPixels);
|
||||
double ratio = (double) imageWidth / (double) imageViewWidth;
|
||||
imageHeight = (int) (imageViewHeight * ratio);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,13 +92,13 @@ public class BarcodeSelectorAdapter extends ArrayAdapter<CatimaBarcodeWithValue>
|
||||
|
||||
Log.d(TAG, "Generating barcode for type " + formatType);
|
||||
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true);
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true, false);
|
||||
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.d(TAG, "Generating barcode for type " + formatType);
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true);
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getContext(), image, cardId, format, text, true, null, true, false);
|
||||
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.Set;
|
||||
public class DBHelper extends SQLiteOpenHelper {
|
||||
public static final String DATABASE_NAME = "Catima.db";
|
||||
public static final int ORIGINAL_DATABASE_VERSION = 1;
|
||||
public static final int DATABASE_VERSION = 16;
|
||||
public static final int DATABASE_VERSION = 17;
|
||||
|
||||
// NB: changing this value requires a migration
|
||||
// NB: changing these values requires a migration
|
||||
public static final int DEFAULT_ZOOM_LEVEL = 100;
|
||||
public static final int DEFAULT_ZOOM_LEVEL_WIDTH = 100;
|
||||
|
||||
public static class LoyaltyCardDbGroups {
|
||||
public static final String TABLE = "groups";
|
||||
@@ -51,6 +52,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
public static final String STAR_STATUS = "starstatus";
|
||||
public static final String LAST_USED = "lastused";
|
||||
public static final String ZOOM_LEVEL = "zoomlevel";
|
||||
public static final String ZOOM_LEVEL_WIDTH = "zoomlevelwidth";
|
||||
public static final String ARCHIVE_STATUS = "archive";
|
||||
}
|
||||
|
||||
@@ -113,6 +115,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0'," +
|
||||
LoyaltyCardDbIds.LAST_USED + " INTEGER DEFAULT '0', " +
|
||||
LoyaltyCardDbIds.ZOOM_LEVEL + " INTEGER DEFAULT '" + DEFAULT_ZOOM_LEVEL + "', " +
|
||||
LoyaltyCardDbIds.ZOOM_LEVEL_WIDTH + " INTEGER DEFAULT '" + DEFAULT_ZOOM_LEVEL_WIDTH + "', " +
|
||||
LoyaltyCardDbIds.ARCHIVE_STATUS + " INTEGER DEFAULT '0' )");
|
||||
|
||||
// create associative table for cards in groups
|
||||
@@ -327,6 +330,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
db.execSQL("ALTER TABLE " + LoyaltyCardDbIds.TABLE
|
||||
+ " ADD COLUMN " + LoyaltyCardDbIds.VALID_FROM + " INTEGER");
|
||||
}
|
||||
|
||||
if (oldVersion < 17 && newVersion >= 17) {
|
||||
db.execSQL("ALTER TABLE " + LoyaltyCardDbIds.TABLE
|
||||
+ " ADD COLUMN " + LoyaltyCardDbIds.ZOOM_LEVEL_WIDTH + " INTEGER DEFAULT '100' ");
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> imageFiles(Context context, final SQLiteDatabase database) {
|
||||
@@ -516,15 +524,17 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
return (rowsUpdated == 1);
|
||||
}
|
||||
|
||||
public static boolean updateLoyaltyCardZoomLevel(SQLiteDatabase database, int loyaltyCardId, int zoomLevel) {
|
||||
public static boolean updateLoyaltyCardZoomLevel(SQLiteDatabase database, int loyaltyCardId, int zoomLevel, int zoomLevelWidth) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(LoyaltyCardDbIds.ZOOM_LEVEL, zoomLevel);
|
||||
contentValues.put(LoyaltyCardDbIds.ZOOM_LEVEL_WIDTH, zoomLevelWidth);
|
||||
Log.d("updateLoyaltyCardZLevel", "Card Id = " + loyaltyCardId + " Zoom level= " + zoomLevel);
|
||||
Log.d("updateLoyaltyCardZoomLW", "Card Id = " + loyaltyCardId + " Zoom level width= " + zoomLevelWidth);
|
||||
int rowsUpdated = database.update(LoyaltyCardDbIds.TABLE, contentValues,
|
||||
whereAttrs(LoyaltyCardDbIds.ID),
|
||||
withArgs(loyaltyCardId));
|
||||
Log.d("updateLoyaltyCardZLevel", "Rows changed = " + rowsUpdated);
|
||||
return (rowsUpdated == 1);
|
||||
Log.d("updateLoyaltyCardZLevel", "Card Id = " + loyaltyCardId + " Zoom level = " + zoomLevel + " Zoom level width = " + zoomLevelWidth);
|
||||
return (rowsUpdated >= 1);
|
||||
}
|
||||
|
||||
public static boolean updateLoyaltyCardBalance(SQLiteDatabase database, final int id, final BigDecimal newBalance) {
|
||||
|
||||
@@ -140,6 +140,7 @@ public class ImportURIHelper {
|
||||
0,
|
||||
Utils.getUnixTime(),
|
||||
100,
|
||||
100,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -35,8 +35,10 @@ public class LoyaltyCard {
|
||||
public int starStatus;
|
||||
public long lastUsed;
|
||||
public int zoomLevel;
|
||||
public int zoomLevelWidth;
|
||||
public int archiveStatus;
|
||||
|
||||
|
||||
@Nullable
|
||||
private Bitmap imageThumbnail;
|
||||
@Nullable
|
||||
@@ -64,6 +66,7 @@ public class LoyaltyCard {
|
||||
public static final String BUNDLE_LOYALTY_CARD_STAR_STATUS = "loyaltyCardStarStatus";
|
||||
public static final String BUNDLE_LOYALTY_CARD_LAST_USED = "loyaltyCardLastUsed";
|
||||
public static final String BUNDLE_LOYALTY_CARD_ZOOM_LEVEL = "loyaltyCardZoomLevel";
|
||||
public static final String BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH = "loyaltyCardZoomLevelWidth";
|
||||
public static final String BUNDLE_LOYALTY_CARD_ARCHIVE_STATUS = "loyaltyCardArchiveStatus";
|
||||
public static final String BUNDLE_LOYALTY_CARD_IMAGE_THUMBNAIL = "loyaltyCardImageThumbnail";
|
||||
public static final String BUNDLE_LOYALTY_CARD_IMAGE_FRONT = "loyaltyCardImageFront";
|
||||
@@ -91,6 +94,7 @@ public class LoyaltyCard {
|
||||
setStarStatus(0);
|
||||
setLastUsed(Utils.getUnixTime());
|
||||
setZoomLevel(100);
|
||||
setZoomLevelWidth(100);
|
||||
setArchiveStatus(0);
|
||||
setImageThumbnail(null, null);
|
||||
setImageFront(null, null);
|
||||
@@ -114,13 +118,14 @@ public class LoyaltyCard {
|
||||
* @param starStatus
|
||||
* @param lastUsed
|
||||
* @param zoomLevel
|
||||
* @param zoomLevelWidth
|
||||
* @param archiveStatus
|
||||
*/
|
||||
public LoyaltyCard(final int id, final String store, final String note, @Nullable final Date validFrom,
|
||||
@Nullable final Date expiry, final BigDecimal balance, @Nullable final Currency balanceType,
|
||||
final String cardId, @Nullable final String barcodeId, @Nullable final CatimaBarcode barcodeType,
|
||||
@Nullable final Integer headerColor, final int starStatus,
|
||||
final long lastUsed, final int zoomLevel, final int archiveStatus,
|
||||
final long lastUsed, final int zoomLevel, final int zoomLevelWidth, final int archiveStatus,
|
||||
@Nullable Bitmap imageThumbnail, @Nullable String imageThumbnailPath,
|
||||
@Nullable Bitmap imageFront, @Nullable String imageFrontPath,
|
||||
@Nullable Bitmap imageBack, @Nullable String imageBackPath) {
|
||||
@@ -138,6 +143,7 @@ public class LoyaltyCard {
|
||||
setStarStatus(starStatus);
|
||||
setLastUsed(lastUsed);
|
||||
setZoomLevel(zoomLevel);
|
||||
setZoomLevelWidth(zoomLevelWidth);
|
||||
setArchiveStatus(archiveStatus);
|
||||
setImageThumbnail(imageThumbnail, imageThumbnailPath);
|
||||
setImageFront(imageFront, imageFrontPath);
|
||||
@@ -262,6 +268,14 @@ public class LoyaltyCard {
|
||||
this.zoomLevel = zoomLevel;
|
||||
}
|
||||
|
||||
public void setZoomLevelWidth(int zoomLevelWidth) {
|
||||
if (zoomLevelWidth < 0 || zoomLevelWidth > 100) {
|
||||
throw new IllegalArgumentException("zoomLevelWidth must be in range 0-100");
|
||||
}
|
||||
|
||||
this.zoomLevelWidth = zoomLevelWidth;
|
||||
}
|
||||
|
||||
public void setArchiveStatus(int archiveStatus) {
|
||||
if (archiveStatus != 0 && archiveStatus != 1) {
|
||||
throw new IllegalArgumentException("archiveStatus must be 0 or 1");
|
||||
@@ -386,6 +400,11 @@ public class LoyaltyCard {
|
||||
} else if (requireFull) {
|
||||
throw new IllegalArgumentException("Missing key " + BUNDLE_LOYALTY_CARD_ZOOM_LEVEL);
|
||||
}
|
||||
if (bundle.containsKey(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH)) {
|
||||
setZoomLevelWidth(bundle.getInt(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH));
|
||||
} else if (requireFull) {
|
||||
throw new IllegalArgumentException("Missing key " + BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH);
|
||||
}
|
||||
if (bundle.containsKey(BUNDLE_LOYALTY_CARD_ARCHIVE_STATUS)) {
|
||||
setArchiveStatus(bundle.getInt(BUNDLE_LOYALTY_CARD_ARCHIVE_STATUS));
|
||||
} else if (requireFull) {
|
||||
@@ -455,6 +474,9 @@ public class LoyaltyCard {
|
||||
if (!exportIsLimited || exportLimit.contains(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL)) {
|
||||
bundle.putInt(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL, zoomLevel);
|
||||
}
|
||||
if (!exportIsLimited || exportLimit.contains(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH)) {
|
||||
bundle.putInt(BUNDLE_LOYALTY_CARD_ZOOM_LEVEL_WIDTH, zoomLevelWidth);
|
||||
}
|
||||
if (!exportIsLimited || exportLimit.contains(BUNDLE_LOYALTY_CARD_ARCHIVE_STATUS)) {
|
||||
bundle.putInt(BUNDLE_LOYALTY_CARD_ARCHIVE_STATUS, archiveStatus);
|
||||
}
|
||||
@@ -526,6 +548,8 @@ public class LoyaltyCard {
|
||||
long lastUsed = cursor.getLong(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.LAST_USED));
|
||||
// zoomLevel
|
||||
int zoomLevel = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ZOOM_LEVEL));
|
||||
// zoomLevelWidth
|
||||
int zoomLevelWidth = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ZOOM_LEVEL_WIDTH));
|
||||
// archiveStatus
|
||||
int archiveStatus = cursor.getInt(cursor.getColumnIndexOrThrow(DBHelper.LoyaltyCardDbIds.ARCHIVE_STATUS));
|
||||
|
||||
@@ -544,6 +568,7 @@ public class LoyaltyCard {
|
||||
starStatus,
|
||||
lastUsed,
|
||||
zoomLevel,
|
||||
zoomLevelWidth,
|
||||
archiveStatus,
|
||||
null,
|
||||
Utils.getCardImageFileName(id, ImageLocationType.icon),
|
||||
@@ -556,7 +581,7 @@ public class LoyaltyCard {
|
||||
|
||||
public static boolean isDuplicate(Context context, final LoyaltyCard a, final LoyaltyCard b) {
|
||||
// Note: Bitmap comparing is slow, be careful when calling this method
|
||||
// Skip lastUsed & zoomLevel
|
||||
// Skip lastUsed & zoomLevel*
|
||||
return a.id == b.id && // non-nullable int
|
||||
a.store.equals(b.store) && // non-nullable String
|
||||
a.note.equals(b.note) && // non-nullable String
|
||||
@@ -595,7 +620,7 @@ public class LoyaltyCard {
|
||||
return String.format(
|
||||
"LoyaltyCard{%n id=%s,%n store=%s,%n note=%s,%n validFrom=%s,%n expiry=%s,%n"
|
||||
+ " balance=%s,%n balanceType=%s,%n cardId=%s,%n barcodeId=%s,%n barcodeType=%s,%n"
|
||||
+ " headerColor=%s,%n starStatus=%s,%n lastUsed=%s,%n zoomLevel=%s,%n archiveStatus=%s%n"
|
||||
+ " headerColor=%s,%n starStatus=%s,%n lastUsed=%s,%n zoomLevel=%s,%n zoomLevelWidth=%s,%n archiveStatus=%s%n"
|
||||
+ " imageThumbnail=%s,%n imageThumbnailPath=%s,%n imageFront=%s,%n imageFrontPath=%s,%n imageBack=%s,%n imageBackPath=%s,%n}",
|
||||
this.id,
|
||||
this.store,
|
||||
@@ -611,6 +636,7 @@ public class LoyaltyCard {
|
||||
this.starStatus,
|
||||
this.lastUsed,
|
||||
this.zoomLevel,
|
||||
this.zoomLevelWidth,
|
||||
this.archiveStatus,
|
||||
this.imageThumbnail,
|
||||
this.imageThumbnailPath,
|
||||
|
||||
@@ -1615,13 +1615,13 @@ public class LoyaltyCardEditActivity extends CatimaAppCompatActivity implements
|
||||
barcodeImage.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
|
||||
Log.d(TAG, "ImageView size now known");
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, LoyaltyCardEditActivity.this, true);
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, LoyaltyCardEditActivity.this, true, false);
|
||||
viewModel.getTaskHandler().executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.d(TAG, "ImageView size known known, creating barcode");
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, this, true);
|
||||
BarcodeImageWriterTask barcodeWriter = new BarcodeImageWriterTask(getApplicationContext(), barcodeImage, cardIdString, barcodeFormat, null, false, this, true, false);
|
||||
viewModel.getTaskHandler().executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import com.google.android.material.color.MaterialColors;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -139,6 +140,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
// If the barcode is shown, switch to fullscreen layout
|
||||
if (imageType == ImageType.BARCODE) {
|
||||
setFullscreen(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +223,13 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
} else {
|
||||
binding.scalerGuideline.setGuidelinePercent(0.5f * scale);
|
||||
}
|
||||
}
|
||||
|
||||
private void setScalerWidthGuideline(int zoomLevelWidth) {
|
||||
float halfscale = zoomLevelWidth / 200f;
|
||||
|
||||
binding.scalerEndwidthguideline.setGuidelinePercent(0.5f + halfscale);
|
||||
binding.scalerStartwidthguideline.setGuidelinePercent(0.5f - halfscale);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,36 +287,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
database = new DBHelper(this).getWritableDatabase();
|
||||
importURIHelper = new ImportURIHelper(this);
|
||||
|
||||
binding.barcodeScaler.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (!fromUser) {
|
||||
Log.d(TAG, "non user triggered onProgressChanged, ignoring, progress is " + progress);
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "Progress is " + progress);
|
||||
Log.d(TAG, "Max is " + binding.barcodeScaler.getMax());
|
||||
float scale = (float) progress / (float) binding.barcodeScaler.getMax();
|
||||
Log.d(TAG, "Scaling to " + scale);
|
||||
|
||||
loyaltyCard.zoomLevel = progress;
|
||||
DBHelper.updateLoyaltyCardZoomLevel(database, loyaltyCardId, loyaltyCard.zoomLevel);
|
||||
|
||||
setScalerGuideline(loyaltyCard.zoomLevel);
|
||||
|
||||
drawMainImage(mainImageIndex, true, isFullscreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
binding.barcodeScaler.setOnSeekBarChangeListener(setOnSeekBarChangeListenerUnifiedFunction());
|
||||
binding.barcodeWidthscaler.setOnSeekBarChangeListener(setOnSeekBarChangeListenerUnifiedFunction());
|
||||
|
||||
rotationEnabled = true;
|
||||
|
||||
@@ -370,6 +350,46 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
});
|
||||
}
|
||||
|
||||
private SeekBar.OnSeekBarChangeListener setOnSeekBarChangeListenerUnifiedFunction() {
|
||||
return new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (!fromUser) {
|
||||
Log.d(TAG, "non user triggered onProgressChanged, ignoring, progress is " + progress);
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "Progress is " + progress);
|
||||
if (seekBar.getId() == binding.barcodeScaler.getId()) {
|
||||
Log.d(TAG, "Max is " + binding.barcodeScaler.getMax());
|
||||
float scale = (float) progress / (float) binding.barcodeScaler.getMax();
|
||||
Log.d(TAG, "Scaling to " + scale);
|
||||
}
|
||||
else {
|
||||
Log.d(TAG, "Max is " + binding.barcodeWidthscaler.getMax());
|
||||
float scale = (float) progress / (float) binding.barcodeWidthscaler.getMax();
|
||||
Log.d(TAG, "Scaling to " + scale);
|
||||
}
|
||||
if (seekBar.getId() == binding.barcodeScaler.getId()) {
|
||||
loyaltyCard.zoomLevel = progress;
|
||||
setScalerGuideline(loyaltyCard.zoomLevel);
|
||||
}
|
||||
else {
|
||||
loyaltyCard.zoomLevelWidth = progress;
|
||||
setScalerWidthGuideline(loyaltyCard.zoomLevelWidth);
|
||||
}
|
||||
|
||||
DBHelper.updateLoyaltyCardZoomLevel(database, loyaltyCardId, loyaltyCard.zoomLevel, loyaltyCard.zoomLevelWidth);
|
||||
drawMainImage(mainImageIndex, true, isFullscreen);
|
||||
}
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private SpannableStringBuilder padSpannableString(SpannableStringBuilder spannableStringBuilder) {
|
||||
if (spannableStringBuilder.length() > 0) {
|
||||
spannableStringBuilder.append("\n\n");
|
||||
@@ -708,6 +728,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
int darkenedColor = ColorUtils.blendARGB(backgroundHeaderColor, Color.BLACK, 0.1f);
|
||||
binding.barcodeScaler.setProgressTintList(ColorStateList.valueOf(darkenedColor));
|
||||
binding.barcodeScaler.setThumbTintList(ColorStateList.valueOf(darkenedColor));
|
||||
binding.barcodeWidthscaler.setProgressTintList(ColorStateList.valueOf(darkenedColor));
|
||||
binding.barcodeWidthscaler.setThumbTintList(ColorStateList.valueOf(darkenedColor));
|
||||
|
||||
// Set bottomAppBar and system navigation bar color
|
||||
binding.bottomAppBar.setBackgroundColor(darkenedColor);
|
||||
@@ -936,7 +958,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
null,
|
||||
false,
|
||||
this,
|
||||
addPadding);
|
||||
addPadding,
|
||||
isFullscreen);
|
||||
mTasks.executeTask(TaskHandler.TYPE.BARCODE, barcodeWriter);
|
||||
}
|
||||
}
|
||||
@@ -1130,11 +1153,18 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
|
||||
binding.container.setVisibility(View.GONE);
|
||||
binding.fullscreenLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
// Only show width slider if the barcode isn't square (square barcodes will resize height and width together)
|
||||
// or if the internals of the barcode are squares, like DATA_MATRIX
|
||||
binding.setWidthLayout.setVisibility((format.isSquare() || format.format() == BarcodeFormat.DATA_MATRIX) ? View.GONE : View.VISIBLE);
|
||||
|
||||
drawMainImage(mainImageIndex, true, isFullscreen);
|
||||
|
||||
binding.barcodeScaler.setProgress(loyaltyCard.zoomLevel);
|
||||
setScalerGuideline(loyaltyCard.zoomLevel);
|
||||
|
||||
binding.barcodeWidthscaler.setProgress(loyaltyCard.zoomLevelWidth);
|
||||
setScalerWidthGuideline(loyaltyCard.zoomLevelWidth);
|
||||
|
||||
// Hide actionbar
|
||||
if (actionBar != null) {
|
||||
actionBar.hide();
|
||||
|
||||
@@ -41,6 +41,7 @@ class PkpassParser(context: Context, uri: Uri?) {
|
||||
private val starStatus = 0
|
||||
private val lastUsed: Long = 0
|
||||
private val zoomLevel = DBHelper.DEFAULT_ZOOM_LEVEL
|
||||
private val zoomLevelWidth = DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH
|
||||
private var archiveStatus = 0
|
||||
|
||||
var image: Bitmap? = null
|
||||
@@ -125,6 +126,7 @@ class PkpassParser(context: Context, uri: Uri?) {
|
||||
starStatus,
|
||||
lastUsed,
|
||||
zoomLevel,
|
||||
zoomLevelWidth,
|
||||
archiveStatus,
|
||||
image,
|
||||
null,
|
||||
|
||||
@@ -505,6 +505,7 @@ public class CatimaImporter implements Importer {
|
||||
starStatus,
|
||||
lastUsed,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH,
|
||||
archiveStatus,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -164,6 +164,7 @@ public class FidmeImporter implements Importer {
|
||||
starStatus,
|
||||
Utils.getUnixTime(),
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH,
|
||||
archiveStatus,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -369,6 +369,7 @@ public class StocardImporter implements Importer {
|
||||
0,
|
||||
lastUsed,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -166,6 +166,7 @@ public class VoucherVaultImporter implements Importer {
|
||||
0,
|
||||
Utils.getUnixTime(),
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL,
|
||||
DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH,
|
||||
0,
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@@ -142,20 +143,30 @@
|
||||
android:background="@android:color/transparent"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/fullscreen_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Top white background that stays white even when scaling the fullscreen image-->
|
||||
<ImageView
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#FFFFFFFF"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/scaler_guideline" />
|
||||
|
||||
<ImageView
|
||||
android:importantForAccessibility="no"
|
||||
android:id="@+id/fullscreen_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/scaler_guideline"/>
|
||||
app:layout_constraintBottom_toTopOf="@+id/scaler_guideline"
|
||||
app:layout_constraintStart_toStartOf="@+id/scaler_startwidthguideline"
|
||||
app:layout_constraintEnd_toEndOf="@+id/scaler_endwidthguideline"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/scaler_guideline"
|
||||
@@ -164,10 +175,24 @@
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.5"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/scaler_startwidthguideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="1"/>
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/scaler_endwidthguideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_percent="1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toTopOf="@+id/fullscreen_button_minimize"
|
||||
app:layout_constraintBottom_toTopOf="@+id/set_width_layout"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:layout_marginStart="15.0dip"
|
||||
android:layout_marginEnd="15.0dip">
|
||||
@@ -188,6 +213,31 @@
|
||||
android:max="100" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/set_width_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15.0dip"
|
||||
android:layout_marginEnd="15.0dip"
|
||||
app:layout_constraintBottom_toTopOf="@+id/fullscreen_button_minimize">
|
||||
|
||||
<TextView
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/width"/>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/barcode_widthscaler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/setBarcodeWidth"
|
||||
android:min="20"
|
||||
android:max="100" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/fullscreen_button_minimize"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -361,4 +361,6 @@
|
||||
<string name="addFromPkpass">Select a Passbook file (.pkpass)</string>
|
||||
<string name="unsupportedFile">This file is not supported</string>
|
||||
<string name="generic_error_please_retry">Sorry, something went wrong, please try again...</string>
|
||||
<string name="width">Width</string>
|
||||
<string name="setBarcodeWidth">Set Barcode Width</string>
|
||||
</resources>
|
||||
|
||||
@@ -494,6 +494,7 @@ public class DatabaseTest {
|
||||
assertEquals(0, card.starStatus);
|
||||
assertEquals(0, card.lastUsed);
|
||||
assertEquals(100, card.zoomLevel);
|
||||
assertEquals(100, card.zoomLevelWidth);
|
||||
|
||||
// Determine that the entries are queryable and the fields are correct
|
||||
LoyaltyCard card2 = DBHelper.getLoyaltyCard(mActivity.getApplicationContext(), database, newCardId2);
|
||||
@@ -510,6 +511,7 @@ public class DatabaseTest {
|
||||
assertEquals(0, card2.starStatus);
|
||||
assertEquals(0, card2.lastUsed);
|
||||
assertEquals(100, card2.zoomLevel);
|
||||
assertEquals(100, card2.zoomLevelWidth);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -106,6 +106,7 @@ class PkpassTest {
|
||||
Assert.assertEquals(0, parsedCard.archiveStatus)
|
||||
Assert.assertEquals(0, parsedCard.lastUsed)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL, parsedCard.zoomLevel)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH, parsedCard.zoomLevelWidth)
|
||||
|
||||
// Confirm correct image is used
|
||||
Assert.assertTrue(imageBitmap.sameAs(parser.image))
|
||||
@@ -171,6 +172,7 @@ class PkpassTest {
|
||||
Assert.assertEquals(0, parsedCard.archiveStatus)
|
||||
Assert.assertEquals(0, parsedCard.lastUsed)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL, parsedCard.zoomLevel)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH, parsedCard.zoomLevelWidth)
|
||||
|
||||
// Confirm correct image is used
|
||||
Assert.assertTrue(imageBitmap.sameAs(parser.image))
|
||||
@@ -294,6 +296,7 @@ class PkpassTest {
|
||||
Assert.assertEquals(0, parsedCard.archiveStatus)
|
||||
Assert.assertEquals(0, parsedCard.lastUsed)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL, parsedCard.zoomLevel)
|
||||
Assert.assertEquals(DBHelper.DEFAULT_ZOOM_LEVEL_WIDTH, parsedCard.zoomLevelWidth)
|
||||
|
||||
// Confirm correct image is used
|
||||
Assert.assertTrue(imageBitmap.sameAs(parser.image))
|
||||
|
||||
Reference in New Issue
Block a user