HomeTaskerSmarter Loyalty and Reward Cards Tasker Project

Smarter Loyalty and Reward Cards Tasker Project

Not the easiest project to explain.

The initial tutorial was over 2500 words long, there is no way anyone would read through that slog, therefore, a final Reward Cards Tasker Project has been redesigned to make it more compressed. It’s slightly different from the video showcase. I skipped the multiple cards part and copy the code/ID option to make this tutorial simpler. If you wish to retain this functionality both versions of the project are provided in the file, while the video explains the more robust project. This should keep things simpler, and easier to understand.

Prerequisites for Reward Cards Tasker Project

The first step is to turn my reward cards into a digital version. I found a great app for that: Barcode Generator. It’s simple, scan the barcode or QR code and the app will give you an option to save it as png/jpg and save the decoded number. Save both. While traditional barcodes can be used ‘as is’ QR codes need editing to fit the notification.

Open QR codes in SnapSeed, I’m particular about the app, as it comes with an ‘expand’ function.  Expands allows you to increase the size of a canvas. Be sure to select the edges to be white and repeat the action three times to get the ideal padding around the picture. Organize your files and name it accordingly. It will help to navigate to the files later.

Next up, I will need logos for each shop I have a reward program for. A quick Google Image search will get you the results needed. The pictures used by me has been set to 2:1 ratio (1000:500). As with the barcodes, I will keep the shop logos in a separate folder.

Reward Cards Tasker Project

Now that we have everything ready, it’s time to build a data structure. I used 3 arrays to store the all the information in. (More arrays is used to have additional features – see the video)

Important
You MUST enter the data for each array in the same order. Ie: if your first shop’s name is Tesco, the first element of %ShoppingPaths() would be a path to Tesco barcode.
Array NameContains
%ShopNames()Names of shops: tesco,morrisons,paperchase etc
%ShoppingPaths()Paths to barcodes: /sdcard/path/tesco.png, etc
%ShopIcons()Paths to shop icons: sdcard/path/tesco.png, etc

Here is how the task should look like (My values are random):

TASKER TASK - Shopping Arrays
Shopping Arrays 
	A1: Array Set [ Variable Array:%ShopNames Values:
		tesco,
		morrisons,
		bandq,
		paperchase,
		nectar 
		Splitter:, ] 
	A2: Array Set [ Variable Array:%ShoppingPaths Values:
		/storage/Tesco/tesco.png,
		/storage/morrisons.png,
		/storage/bandq.png,
		/storage/paperchase.png,
		/storage/nectar.png
		Splitter:, ] 	
	A3: Array Set [ Variable Array:%ShopIcons Values:
	        /storage/icons/shopping_logo/tesco.png,
	        /storage/icons/shopping_logo/morrisons.png,
	        /storage/icons/shopping_logo/bandq.png,
	        /storage/icons/shopping_logo/paperchase.png,
	        /storage/icons/shopping_logo/nectar.png 
	        Splitter:, ] 

Create AutoNotification Tile (optional)

Feel free to skip to the next chapter if you don’t want to use the tile to manually trigger the card selection screen. You can also pick another way (ie: task shortcut) to open this up.

AutoNotification Tiles are available on Android 7. To create a tile, create a new task and use AutoNotification Tile action to go through the config. This is a one-time setup and the only thing you must pay attention to is the issued command: shop_button=:=showdialog.

You can delete the task once the setup is complete.

Shop Buttons Actions Profile

This profile will handle the AutoTools Web screen and a notification that you are in the shopping center. Each AutoNotification command will share the same prefix shop_button.

TASKER PROFILE - Shop Buttons Actions
Profile: Shop Buttons Actions (
	Event: AutoNotification [ Configuration:Event Behaviour
		   Filter: shop_button (regex) ]
Shop Buttons 
	A1: AutoNotification [ Configuration:Title: Reward Cards available
		Text: Click to open all rewards
		Icon: /storage/ic_cart_outline.png
		Status Bar Icon Manual: /storage/ic_cart.png
		Status Bar Text Size: 16
		Id: shopnotification
		Button 1: shop_button=:=showdialog
		Label 1: Show Reward Cards
		Action Icon 1 Manual: /storage/ic_cash_usd.png Timeout (Seconds):20 ] 
			If [ %antitle ~R Retail|Shopping ]
	A2: AutoTools Web Screen [ Configuration:Screen Preset: Card List
		Display Mode: Dialog
		Source: /storage/emulated/0/AutoTools/cardlist/page.html
		Toast Duration: 5000
		Gravity: Center
		Animation: Slide In From Top
		Show Duration: 500
		Hide Duration: 250
		Close On Command: true
		Title: Shopping rewards
		Title Icon: /storage/ic_cart_outline.png
		Title Buttons Icons: android.resource://net.dinglisch.android.taskerm/hd_ab_content_remove
		Title Button Commands: shopping=:=close
		Search Color: #ffffff
		Filter With Search: true
		Command Prefix: search
		Drawer Width: 80%
		Card Commands: tesco,morrisons,bandq,paperchase,nectar
		Commands Prefix: shoppingcard
		Round Card Icons: true
		Card Images: 
			/storage/tesco.png,
			/storage/morrisons.png,
			/storage/bandq.png,
			/storage/paperchase.png,
			/storage/nectar.png
		Background Color: #E8F5E9
		Card Background Color: #FFFFFF
		Accent Color: #004D40
		Max Card Widths: 60
		Max Image Heights: 35
		Title Text Size: 18
		Subtitle Text Size: 22
		Card Padding: 24
		Card Alignment: Top
		Item Separator: , Timeout (Seconds):30 ]
		If [ %ancomm ~ showdialog | %aacomm ~ showdialog ]
	A3: AutoNotification Cancel [ Configuration:Id: shopnotification Timeout (Seconds):0 ] 
		If [ %ancomm ~ showdialog ]
	A4: Status Bar [ Set:Collapsed ] 
		If [ %ancomm ~ showdialog ]

Display all rewards – WebScreen Dialog

Let’s start with an action that can display all the cards. AutoTools plugin is great for displaying content on your screen. I’m using this action to show all the shops.

TASKER TASK - Shop Buttons
Shop Buttons
	A1: AutoTools Web Screen [ Configuration:Screen Preset: Card List
		Display Mode: Dialog
		Source: 
		/storage/emulated/0/AutoTools/cardlist/page.html
		Toast Duration: 5000
		Gravity: Center
		Animation: Slide In From Top
		Show Duration: 500
		Hide Duration: 250
		Close On Command: true
		Title: Shopping rewards
		Title Icon: 
		/storage/ icons/random_icons/ic_cart_outline.png
		Title Buttons Icons: 
		android.resource://net.dinglisch.android.taskerm/hd_ab_content_remove
		Title Button Commands: 
		Search Color: #ffffff
		Filter With Search: true
		Command Prefix: search
		Drawer Width: 80%
		Card Commands: 
		tesco,morrisons,bandq,paperchase,nectar
		Commands Prefix: shoppingcard
		Round Card Icons: true
		Card Images: 
		/storage/icons/shopping_logo/tesco.png, 
		/storage/icons/shopping_logo/morrisons.png, 
		/storage/icons/shopping_logo/bandq.png,
		/storage/icons/shopping_logo/paperchase.png,
		/storage/icons/shopping_logo/nectar.png
		Background Color: #E8F5E9
		Card Background Color: #FFFFFF
		Accent Color: #004D40
		Max Card Widths: 60
		Max Image Heights: 35
		Title Text Size: 18
		Subtitle Text Size: 22
		Card Padding: 24
		Card Alignment: Top
		Item Separator: , Timeout (Seconds):30 ] 


If you have your preferred way of displaying the content feel free to override this. Be mindful that each card triggers a specific command. When a card has been pressed a command: shoppingcard=:= tesco (morrisons,bandq..etc) is issued. Please modify the command prefix and card command accordingly.

Shopping center notifications

While we are working on this task, let’s attach a context that will capture the Google notification that says Retail park or Shopping center. Be aware that you should monitor your notifications to make sure, that words used in the filters are correct. This notification will prompt a new notification with a button to open our AutoTools Dialog. The AutoNotification trigger checks the title of the Google notification for

Retail|Shopping

and issues the notification. This notification is canceled in the same task when button issuing command shpu_button=:=showdialog is pressed. See abbreviated description of the profile

TASKER PROFILE - Near Shopping Center
Profile: Near Shopping center 
	Event: AutoNotification Intercept [ Configuration:Event Behaviour: true
			Notification Type: Only Created Notifications
			Notification App: Google
			Notification Title: Retail|Shopping (regex)
			Package Name: com.google.android.googlequicksearchbox ]
Enter: Shop Buttons 
	A1: AutoNotification [ Configuration:Title: Reward Cards available
		Text: Click to open all rewards
		Icon: /storage/ic_cart_outline.png
		Status Bar Icon Manual: /storage /ic_cart.png
		Status Bar Text Size: 16
		Id: shopnotification
		Button 1: shop_button=:=showdialog
		Label 1: Show Reward Cards
		Action Icon 1 Manual: /storage/ic_cash_usd.png Timeout (Seconds):20 ] 
		If [ %antitle ~R Retail|Shopping ]
		
...............................
	
	A3: AutoNotification Cancel [ Configuration:Id: shopnotification Timeout (Seconds):0 ] 	
		If [ %ancomm ~ showdialog ]
	A4: Status Bar [ Set:Collapsed ] 
		If [ %ancomm ~ showdialog ]

Show Shopping Barcode – The Main Task

This is the main task. It is triggered by three different profiles so let’s take a look at the triggers.

Google Location notification come in two flavors. This means we have to check both fields %antitle and %antext against our shop names. Our AutoNotification Event filter should look like this:

Tesco|Morrisons|B&Q

Look up the exact spelling of your shops on Google Maps to make sure you can intercept it correctly.

The 3rd trigger is the AutoApps command issued by the AutoTools Dialog we have created earlier. The command looks like this: shoppingcard=:=shopname. The name of the shop will be used in %aacomm later on in this task to display the correct barcode.

TASKER TASK -Show Shopping Barcode
Show Shopping Barcode 
	
	A1: If [ %antitle Set ]
	A2: Variable Set [ Name:%shoplocation To:tesco 
		Recurse Variables:Off Do Maths:Off Append:Off ]
		If [ %antitle ~R Tesco | %antext ~R Tesco ]
	A3: Variable Set [ Name:%shoplocation To:morrisons 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
		If [ %antitle ~ Morrison | %antext ~ Morrison ]
	A4: Variable Set [ Name:%shoplocation To:bandq 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
		If [ %antitle ~ B&Q | %antext ~ B&Q ]
	A5: Variable Set [ Name:%shoplocation To:paperchase 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
		If [ %antitle ~ Paperchase | %antext ~ Paperchase ]
	A6: End If 
	A7: Variable Set [ Name:%ShopPicture To:%ShopNames(#?~R%shoplocation) 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
		If [ %antitle Set ]
	A8: Variable Set [ Name:%ShopPicture To:%ShopNames(#?~R%aacomm) 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
		If [ %aacomm Set ]
	A9: AutoNotification [ Configuration:Title: Rewards %ShopNames(%ShopPicture)
		Icon: %ShopIcons(%ShopPicture)
		Status Bar Icon: ic_action_barcode_1
		Status Bar Text Size: 16
		Id: shop
		Title Expanded: %ShopNames(%ShopPicture)
		Picture: %ShoppingPaths(%ShopPicture)
		Icon 1: ic_launcher
		Action Icon 1 Manual: /storage/ic_clipboard_arrow_down.png Timeout (Seconds):20 ] 

A1-A6

These actions are linked to Google Card notifications and set a local variable %shoplocation to a specific name. I can’t use the default %antext/%antitle variables as some shops contain not compatible characters for paths to files etc. This part runs only if %antitle is set (it is skipped if there is no notification).

A7

This segment is used when the trigger is a notification. If %antitle is set I want to set a new variable %ShopPicture that will contain a number – index of the element from the array that contains the shop names %ShopNames()

%ShopNames(#?~R%shoplocation)

Thanks to an excellent find by r/RatchetGuy we can search the arrays and return an index value that matches the specific regex. What it means that if my %shoplocation = tesco searching the array for a matching entry will return number 1 (I stored Tesco as the first element of my array).

A8

The same as above, but the segment is used when the barcode is triggered from a dialog. The %shoplocation has been substituted by %aacomm. 

A9

The barcode notification. This should contain:

  • Icon: %ShopIcons(%ShopPicture)
  • Picture: %ShoppingPaths(%ShopPicture)

Feel free to modify the rest to your liking. As you can see barcodes and QR codes are set based on the index value set previously and the information is pulled directly from the arrays.

Conclusion

If you previously dismissed the shopping and places notification from Google, it will impact this project. Consider resetting your preferences to default in Google Now app.  Reward Cards Tasker Project beats other apps like Stocard or Fidme available from the Google Play Store – it’s smarter, easier to use and more responsive. As I mentioned before the project file contains both versions of this project feel free to use either of them.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?