Skip to content

Commit f8a8a84

Browse files
Merge pull request #2038 from CatimaLoyalty/feature/pkpass2024
Add Pkpass parser
2 parents 3bdc06b + 8009bac commit f8a8a84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1665
-668
lines changed

app/build.gradle.kts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.github.spotbugs.snom.SpotBugsTask
44
plugins {
55
id("com.android.application")
66
id("com.github.spotbugs")
7+
id("org.jetbrains.kotlin.android")
78
}
89

910
spotbugs {
@@ -62,8 +63,8 @@ android {
6263
// Flag to enable support for the new language APIs
6364
isCoreLibraryDesugaringEnabled = true
6465

65-
sourceCompatibility = JavaVersion.VERSION_11
66-
targetCompatibility = JavaVersion.VERSION_11
66+
sourceCompatibility = JavaVersion.VERSION_17
67+
targetCompatibility = JavaVersion.VERSION_17
6768
}
6869

6970
sourceSets {
@@ -84,25 +85,26 @@ android {
8485
lint {
8586
lintConfig = file("lint.xml")
8687
}
88+
kotlinOptions {
89+
jvmTarget = "17"
90+
}
8791
}
8892

8993
dependencies {
90-
9194
// AndroidX
9295
implementation("androidx.appcompat:appcompat:1.7.0")
9396
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
97+
implementation("androidx.core:core-ktx:1.13.1")
98+
implementation("androidx.core:core-splashscreen:1.0.1")
9499
implementation("androidx.exifinterface:exifinterface:1.3.7")
95100
implementation("androidx.palette:palette:1.0.0")
96101
implementation("androidx.preference:preference:1.2.1")
97102
implementation("com.google.android.material:material:1.12.0")
98-
implementation("com.github.yalantis:ucrop:2.2.10")
99103
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.3")
100104

101-
// Splash Screen
102-
implementation("androidx.core:core-splashscreen:1.0.1")
103-
104105
// Third-party
105106
implementation("com.journeyapps:zxing-android-embedded:4.3.0@aar")
107+
implementation("com.github.yalantis:ucrop:2.2.10")
106108
implementation("com.google.zxing:core:3.5.3")
107109
implementation("org.apache.commons:commons-csv:1.9.0")
108110
implementation("com.jaredrummler:colorpicker:1.1.0")

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,24 @@
4040
<category android:name="android.intent.category.LAUNCHER" />
4141
</intent-filter>
4242
<intent-filter>
43-
<action android:name="android.intent.action.SEND" />
43+
<action android:name="android.intent.action.VIEW" />
44+
45+
<category android:name="android.intent.category.DEFAULT" />
4446

47+
<data android:scheme="content"/>
48+
<data android:host="*"/>
49+
<data android:mimeType="image/*" />
50+
<data android:mimeType="application/pdf" />
51+
<data android:mimeType="application/vnd.apple.pkpass" />
52+
</intent-filter>
53+
<intent-filter>
54+
<action android:name="android.intent.action.SEND" />
4555
<category android:name="android.intent.category.DEFAULT" />
56+
4657
<data android:mimeType="text/plain" />
4758
<data android:mimeType="image/*" />
4859
<data android:mimeType="application/pdf" />
60+
<data android:mimeType="application/vnd.apple.pkpass" />
4961
</intent-filter>
5062
</activity>
5163
<activity

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected void onResume() {
6666
private void onClickAction(int position) {
6767
Cursor selected = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.All);
6868
selected.moveToPosition(position);
69-
LoyaltyCard loyaltyCard = LoyaltyCard.fromCursor(selected);
69+
LoyaltyCard loyaltyCard = LoyaltyCard.fromCursor(CardShortcutConfigure.this, selected);
7070

7171
Log.d(TAG, "Creating shortcut for card " + loyaltyCard.store + "," + loyaltyCard.id);
7272

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Flow.Publisher<Control> createPublisherForAllAvailable() {
4242
Cursor loyaltyCardCursor = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.Unarchived);
4343
return subscriber -> {
4444
while (loyaltyCardCursor.moveToNext()) {
45-
LoyaltyCard card = LoyaltyCard.fromCursor(loyaltyCardCursor);
45+
LoyaltyCard card = LoyaltyCard.fromCursor(this, loyaltyCardCursor);
4646
Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
4747
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
4848
.putExtra(LoyaltyCardViewActivity.BUNDLE_ID, card.id);
@@ -69,7 +69,7 @@ public Flow.Publisher<Control> createPublisherFor(@NonNull List<String> controlI
6969
for (String controlId : controlIds) {
7070
Control control;
7171
Integer cardId = this.controlIdToCardId(controlId);
72-
LoyaltyCard card = DBHelper.getLoyaltyCard(mDatabase, cardId);
72+
LoyaltyCard card = DBHelper.getLoyaltyCard(this, mDatabase, cardId);
7373
if (card != null) {
7474
Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
7575
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -99,7 +99,7 @@ public Flow.Publisher<Control> createPublisherFor(@NonNull List<String> controlI
9999
}
100100

101101
private Bitmap getIcon(Context context, LoyaltyCard loyaltyCard) {
102-
Bitmap cardIcon = Utils.retrieveCardImage(context, loyaltyCard.id, ImageLocationType.icon);
102+
Bitmap cardIcon = loyaltyCard.getImageThumbnail(context);
103103

104104
if (cardIcon != null) {
105105
return cardIcon;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ public static Set<String> imageFiles(Context context, final SQLiteDatabase datab
332332
Set<String> files = new HashSet<>();
333333
Cursor cardCursor = getLoyaltyCardCursor(database);
334334
while (cardCursor.moveToNext()) {
335-
LoyaltyCard card = LoyaltyCard.fromCursor(cardCursor);
335+
LoyaltyCard card = LoyaltyCard.fromCursor(context, cardCursor);
336336
for (ImageLocationType imageLocationType : ImageLocationType.values()) {
337337
String name = Utils.getCardImageFileName(card.id, imageLocationType);
338-
if (Utils.retrieveCardImageAsFile(context, name).exists()) {
338+
if (card.getImageForImageLocationType(context, imageLocationType) != null) {
339339
files.add(name);
340340
}
341341
}
@@ -535,14 +535,14 @@ public static boolean updateLoyaltyCardBalance(SQLiteDatabase database, final in
535535
return (rowsUpdated == 1);
536536
}
537537

538-
public static LoyaltyCard getLoyaltyCard(SQLiteDatabase database, final int id) {
538+
public static LoyaltyCard getLoyaltyCard(Context context, SQLiteDatabase database, final int id) {
539539
Cursor data = database.query(LoyaltyCardDbIds.TABLE, null, whereAttrs(LoyaltyCardDbIds.ID), withArgs(id), null, null, null);
540540

541541
LoyaltyCard card = null;
542542

543543
if (data.getCount() == 1) {
544544
data.moveToFirst();
545-
card = LoyaltyCard.fromCursor(data);
545+
card = LoyaltyCard.fromCursor(context, data);
546546
}
547547

548548
data.close();

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,29 @@ public LoyaltyCard parse(Uri uri) throws InvalidObjectException {
125125
headerColor = Integer.parseInt(unparsedHeaderColor);
126126
}
127127

128-
return new LoyaltyCard(-1, store, note, validFrom, expiry, balance, balanceType, cardId, barcodeId, barcodeType, headerColor, 0, Utils.getUnixTime(), 100, 0);
128+
return new LoyaltyCard(
129+
-1,
130+
store,
131+
note,
132+
validFrom,
133+
expiry,
134+
balance,
135+
balanceType,
136+
cardId,
137+
barcodeId,
138+
barcodeType,
139+
headerColor,
140+
0,
141+
Utils.getUnixTime(),
142+
100,
143+
0,
144+
null,
145+
null,
146+
null,
147+
null,
148+
null,
149+
null
150+
);
129151
} catch (NumberFormatException | UnsupportedEncodingException | ArrayIndexOutOfBoundsException ex) {
130152
throw new InvalidObjectException("Not a valid import URI");
131153
}

0 commit comments

Comments
 (0)