Adding and viewing front/back images (#215)

* Adding and viewing front/back images

* Fix import and export

* Fix unit tests

* Smaller preview pictures but clickable to make big

* Implement removing image

* Add card photo direct from camera

* Read Exif rotation info from picture taken

* Fix bad copy-paste

* Refactor to use local file system

* Delete card images when deleting card

* Prepare for image-based unit tests in ViewActivityTest
This commit is contained in:
Sylvia van Os
2021-06-28 20:40:52 +02:00
committed by GitHub
parent b913fad847
commit 8d48da431e
22 changed files with 921 additions and 188 deletions

View File

@@ -6,9 +6,11 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import com.google.zxing.BarcodeFormat;
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Currency;
@@ -52,9 +54,13 @@ public class DBHelper extends SQLiteOpenHelper
public static final String groupID = "groupId";
}
private Context mContext;
public DBHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
mContext = context;
}
@Override
@@ -78,7 +84,7 @@ public class DBHelper extends SQLiteOpenHelper
LoyaltyCardDbIds.CARD_ID + " TEXT not null," +
LoyaltyCardDbIds.BARCODE_ID + " TEXT," +
LoyaltyCardDbIds.BARCODE_TYPE + " TEXT," +
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0' )");
LoyaltyCardDbIds.STAR_STATUS + " INTEGER DEFAULT '0')");
// create associative table for cards in groups
db.execSQL("create table " + LoyaltyCardDbIdsGroups.TABLE + "(" +
@@ -426,7 +432,7 @@ public class DBHelper extends SQLiteOpenHelper
}
}
public boolean deleteLoyaltyCard (final int id)
public boolean deleteLoyaltyCard(final int id)
{
SQLiteDatabase db = getWritableDatabase();
// Delete card
@@ -439,6 +445,14 @@ public class DBHelper extends SQLiteOpenHelper
LoyaltyCardDbIdsGroups.cardID + " = ? ",
new String[]{String.format("%d", id)});
// Also wipe card images associated with this card
try {
Utils.saveCardImage(mContext, null, id, true);
Utils.saveCardImage(mContext, null, id, false);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return (rowsDeleted == 1);
}