Do you remember at the end of our Android customization project last week, when we finished up making a little voice reminder using Tasker, and I said we'd skip Tasker this week? I lied. Join me as we use Tasker's HTTP Get tool, along with Zooper Widget, to put a daily joke on your Homescreen.
As always, this project is designed to help us learn a few new tools in Tasker, I hope your customization education is coming along. From there, we want to keep it light, as today is Thanksgiving day in the U.S. This project might take some time to build, but it's really easy, then you can get back to Black Friday shopping.
Before we begin
Tasker - Google Play StoreTasker and Zooper Widget. For some reason I think I've written these words before. You have got to know the drill by now, you'll need Tasker installed on your modern Android device to follow along today. Tasker is $2.99 and is still and again found in the Google Play Store.
Zooper Widget - Google Play StoreZooper Widget has a free version that might get you through today, but for the full project, or to also enjoy some of our other Zooper Widget tutorials, you're going to want to drop $2.99 on Zooper Widget Pro in the Google Play Store.
Finally, you are going to want to find yourself a site that offers up quotes or jokes in a relatively simple text format. I have an example below, but you'll need to find a site, possibly with an API, to get your source material. Read on to see what I'm talking about, but consider not actually building your project until you find your content.
Daily Joke on your Homescreen
Our project will proceed very similarly to previous Tasker/Zooper Widget projects. We will perform actions in Tasker, then we'll transfer the final data over to Zooper Widget to display on your screen.
The Tasker actions I speak of will be to use the HTTP Get command, much like you may have done in your CMD screen on the PC. We'll collect a joke from the web, we'll have to tweak it through variables to strip away extra info, then we'll save that text into a variable for Zooper Widget.
From there, as before, Zooper Widget will accept the variable from Tasker and simply display the supplied text. You get to choose exactly how you want that info to display. Perhaps you'll add it into an existing Zooper Widget clock, or create a new widget to get the most out of it.
Finally, we'll head back to Tasker to create a little Profile that triggers the actions above at least once per day. You may want to wake up to a new joke or quote each day, or maybe you'd prefer a new one every hour, it's up to you.
Let's get started.
Tasker HTTP Get
Once you have chosen a site that provides the data you are looking for, the process goes pretty quick. I'll be using a site that specialized in Chuck Norris one-liner jokes. Not all of them are family friendly, but they're not too bad. The reason I've chosen this site is not so much for the content as because they offer up an API and a simple way to get just a joke in text format. I'll explain as we go.
Fire up Tasker and head to the Tasks section.
Tap the "+" button to add a new Task. Provide an appropriate name, I'll call mine "HTTPGetJoke".
Tap the "+" button to ad your first action.
Select Net.
Select HTTP Get.
Enter the Server:Port as required by your web source. Our provider of Chuck Norris jokes are available if you enter "http://ift.tt/1jAWgkG".
Scroll down to Output File and enter the name of a new text file. You can head over to manually add the text file if you want, but Tasker can create it for you if it does not yet exist. Just be sure a file by the name you enter does not already exist, or it will be overwritten.
So, Output File, I'll enter "DailyRandomChuckNorrisJoke.txt".
Tap the system Back button to save and exit.
Now, tap that "+" button to add another action. We need to read that file into a variable.
Select File.
Select Read File.
Under File, enter the name of your text file from above, mine was "DailyRandomChuckNorrisJoke.txt."
Under To Var, enter a new global variable, I'll call mine "%HTTPGETJOKE".
Tap the system Back button to save and exit.
The result now stored in your variable from the HTTP Get command is a text string with the joke and some extra info. For our needs, we'll need to strip that extra info.
A sample is as follows:
{ "type": "success", "value": { "id": 448, "joke": "When Chuck Norris throws exceptions, it's across the room.", "categories": ["nerdy"] } }
Any idea what to do next? That's right, we need to use the Variable Split tool to strip away the fluff. Now, you'll have to carefully identify what characters are required to split the text in the right places. Unfortunately, our example has different characters before and after the actual joke, so we'll need to Variable Split twice. Let's do it.
Tap the "+" button to add a new action.
Select Variables.
Select Variable Split.
Under Name, enter your "%HTTPGETJOKE" variable name.
Then, under Splitter, we'll split on "joke": "" Note the "'s within the "'s and the empty space after the colon.
This time, we will turn on Delete Base. This simply deletes the original variable, which saves RAM usage.
Tap the system Back button to save and exit.
That helps us clear away the text leading the joke, now to clear the text after the joke.
Tap the "+" button to add the next split.
Select Variables. then select Variable Split.
Under Name, enter the newly created variable from the previous split. For me, that will be "%HTTPGETJOKE2".
Under Splitter, enter the characters that will split out the joke from the end of the saved text string, that'll be "", "" from this site. (That's quote comma space quote.) Also, that's not supposed to be an emoji of any sort.
Tap the system Back button to save and exit.
Finally, we save that last split variable into a Zooper Widget variable.
Tap the "+" button to start our last action.
Select Plugin.
Select Zooper Widget.
Tap the pencil icon to the right of Configuration.
Enter a Zooper Widget variable name. Mine will be "HTTPGETJOKE".
Then enter the final split variable that contains your joke, mine is "%HTTPGETJOKE21".
Hit that Save button in the top right corner. Then hit the system Back button to save and exit.
Before you exit out of here, be sure to hit that Run Task (Play arrow) button in the bottom left of your screen. It will be much easier in the next stages if you have a joke pre-loaded.
We're done in Tasker for a bit, time to hit Zooper Widget.
Add the joke to Zooper Widget
I will leave you to follow along previous tutorial or otherwise create a Zooper Widget widget to work with today.
I recommend using a new Rich Text element, as the normal Text element is a little less flexible.
Add your new Rich Text element, feel free to size it up and adjust its location and when you're ready we'll add the joke.
Head into Edit text manually.
Enter the value for your Tasker saved variable. Mine will be #THTTPGETJOKE#
Tap OK in the top right to save.
Optionally, you can add another element, or simply use the Module OnTap setting on the text to trigger the Tasker Task again. This way when you tap the text you get a new joke. Pretty slick.
I recommend allowing your Rich Text element to span a maximum of at least 3 rows, depending on your design. I have mine set to 5 rows with font size 12. This adequately covers the width of my screen.
Hit that system Back button as needed to save and exit right out of Zooper Widget.
Look at that, if you've done everything properly, you will see a Chuck Norris joke on your Homescreen. Or a motivational quote, if that's what you chose. I wonder if there are Chuck Norris themed motivational quotes out there?
Optional: Trigger a new joke with a tap of the widget. As you see, I added a Bitmap image as my trigger button.
If you enabled the Module OnTap function, and that is all you want, you are done. Clean up the widget so that it is perfect and go on your merry way. Otherwise, let's make this thing auto-update every day.
Update it daily
Head back into Tasker, into the Profiles tab.
Tap the "+" button to add a new Profile.
Select Time.
Enter the time of the day you'd like to update. This can be while you are sleeping, or whenever you want.
Enter the same time in both the From and To fields. I'll use 73. Sorry, I mean 7:30 am.
Optionally, enter a Repeat value if you want more than one update per day.
Hit the system Back button to save.
Choose your HTTPGetJoke Task from the popup list.
That's it folks. Save and exit and try not to get in trouble with Chuck Norris.
What's next
We simply slapped this joke onto a Zooper Widget widget on the Homescreen. Don't forget that you can put it on your Lock screen if you want. We've handled the basic procedure before.
Honestly, the hardest part of today's project is going to be finding a quality web source of quotes and jokes. Things can get very complicated with the Variable Split commands, especially if you are trying to extract a single line of text from a full web page. You can do it, just find the appropriate character string for your Split and don't be afraid to split several times in a row to whittle down to your content.
Next week
I wish this was a little bit more Thanksgiving themed for you, but I hope this Android customization project to put a Chuck Norris joke on your Homescreen was enough for you. Next week we'll actually be taking a step back from Tasker, we need to dive into a pretty basic user setting on almost all Android devices, Text-to-speech. This will be a beginner's level tutorial, just something to help the new Android users get the most out of their device.
What do you think, will Chuck Norris approve of this project, or will he roundhouse kick it right off the internet?
from Android Authority http://ift.tt/1SnmO6w
via IFTTT
No comments:
Post a Comment