Skip to content

RiddleScanner

Isaac Siegel edited this page May 17, 2016 · 12 revisions

Overview

In this lesson we will be using a barcode scanner to get riddles from QR codes. Then, we will use a substitution cipher to decrypt the text containing the riddles.

Note: You will need to install this android barcode scanner app before starting this project. Most of you should already have it on your phones. (https://play.google.com/store/apps/details?id=com.google.zxing.client.android&hl=en)

New Concepts

Barcode Scanner:

Add these block components to your code to use the phone's barcode scanner. Note that you will need a barcode scanner installed for this to work.

BarcodeScanner

Let's Get Started:

User Interface Designer:

We will need the following components

  • TableLayout(5 columns, 2 rows),
  • 10 buttons in the TableLayout (width=20% each)
  • 2 Buttons
  • 4 Labels (For Decrypted_Message, and Encrypted_Message: height=20%)
  • BarcodeScanner

DesignerView

Logic :

Variables Setup

  1. Initialize a variable called message to " ".

ScanButton Setup

  1. Call the BarcodeScanner's DoScan

BarcodeScanner Setup

When the BarcodeScanner's AfterScan occurs:

  1. Set the Encrypted_Message to the result of the scan.
  2. Set the variable message to the result of the scan.

TEST

After scanning a qr code, you should see the Encrypted message from the scan appear.

DecryptButton Setup

When you click the DecryptButton:

  1. Set the variable message to the substituted result of the Before and After textboxes, and the message variable.
  2. Do this 5 times, for every pair of the substitution boxes.
  3. Set the Decrypted_Message text to the variable message.

Substituted Result

TEST

Use this key and QR code to test the app. Test QRCode

====Substitution Cipher Key====
7 = i
4 = o
1 = a
8 = w
3 = m
====Encrypted====
7’3 t1ll 8hen 7’3 y4ung 1nd 7’3 sh4rt 8hen 7’3 4ld. 8h1t 13 7?
====Decrypted====
I’m tall when I’m young and I’m short when I’m old. What am I?

External References:

Stretch Goals

  1. Add another button that will allow you to speak search keywords. After you speak the keywords, the app should put the spoken text into the search bar, and search just like if you were to press the Search by Keyword button.
  2. It is silly that you have to erase the sample text "Enter ISBN or Keywords" when you want to search for an item. Erase the text when the search box gets focused (a user clicked on it).
  3. When a search is complete, have the app speak, and tell you what the best price is. You will have to write code to figure out the lowest price is, then use text-to-speech.

External References:

  1. Barcode Scanner
Clone this wiki locally