Refactor to allow updating a loyalty card from a bundle (#2051)

This allows us to send any (partial) loyalty card into the edit
activity, granting us greater flexibility in what kind of scan result we
can parse
This commit is contained in:
Sylvia van Os
2024-09-22 10:20:58 +02:00
committed by GitHub
parent 94cee771bd
commit 727d9ce781
19 changed files with 665 additions and 344 deletions

View File

@@ -42,10 +42,10 @@ public class CardsOnPowerScreenService extends ControlsProviderService {
Cursor loyaltyCardCursor = DBHelper.getLoyaltyCardCursor(mDatabase, DBHelper.LoyaltyCardArchiveFilter.Unarchived);
return subscriber -> {
while (loyaltyCardCursor.moveToNext()) {
LoyaltyCard card = LoyaltyCard.toLoyaltyCard(loyaltyCardCursor);
LoyaltyCard card = LoyaltyCard.fromCursor(loyaltyCardCursor);
Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("id", card.id);
.putExtra(LoyaltyCardViewActivity.BUNDLE_ID, card.id);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), card.id, openIntent, PendingIntent.FLAG_IMMUTABLE);
subscriber.onNext(
new Control.StatelessBuilder(PREFIX + card.id, pendingIntent)
@@ -73,7 +73,7 @@ public class CardsOnPowerScreenService extends ControlsProviderService {
if (card != null) {
Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("id", card.id);
.putExtra(LoyaltyCardViewActivity.BUNDLE_ID, card.id);
PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), card.id, openIntent, PendingIntent.FLAG_IMMUTABLE);
control = new Control.StatefulBuilder(controlId, pendingIntent)
.setTitle(card.store)
@@ -129,7 +129,7 @@ public class CardsOnPowerScreenService extends ControlsProviderService {
consumer.accept(ControlAction.RESPONSE_OK);
Intent openIntent = new Intent(this, LoyaltyCardViewActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra("id", controlIdToCardId(controlId));
.putExtra(LoyaltyCardViewActivity.BUNDLE_ID, controlIdToCardId(controlId));
startActivity(openIntent);
closePowerScreenOnAndroid11();