Why widgets? Because you can. And because they offer such tremendous convenience. For instance, if there’s a particular text message that you regularly send out (like, say, “Honey I’m home!”), you can make a widget for that so that you just have to touch it and out sends the message.
Or if you want a more convenient one-touch access to a phone feature, such as muting it, then widgets are what you’d want.
For example, here’s a string of widgets that I made on my phone:
Sure, there are apps that give you convenient control panels for your Wi-Fi/ Bluetooth/ etc., but I had very particular needs. Seen here are control buttons to mute the phone (“Sound”), a butterfly icon that resets the network connection (useful if you get stuck in a low-signal area and you want to kickstart the phone), airplane mode (“Airplane”), and quick access to activating or deactivating 3G (“3G Toggle”).
These are essentially on-off switches. Here’s what’s neat though: If I press the Sound widget, for instance, see what happens:
Yup, the widgets themselves can even change color or form upon clicking. So now I know that my Mute mode is in effect.
The on-off widget is actually what is known as a “toggle” switch, because you toggle it on or off by pressing it. But that’s not all. Pressing the switches also give you a tactile buzzing feedback.
So now I will teach you a bit of programming basics that will help you make toggle widgets and more for your phone.
Press it and it turns on. Press it again and it turns off. How do you do that?
Well, we need a way to remember the state of the widget: Is it on or off? And to do that, we use a variable. In the Sound widget example above, I created a variable named %MeetingMode (you know, because you’d wanna mute your phone if you’re in a meeting). Of course, you can give your variable any name you want.
The premise behind a toggle is that it is either on (value of 1), or off (value of 0). So what you’d want is that when you press on the widget, the variable becomes a 1 if it was a 0, and becomes a 0 if it was a 1.
Here’s the very simple formula for that:
%MeetingMode = 1 – %MeetingMode
Yes, if you’re a math wiz that formula doesn’t make sense. But in programming, well, it isn’t exactly a formula. It’s an instruction. And it means: make %MeetingMode equal to 1 minus what it’s current value is at the moment.
The nifty thing about this is that if %MeetingMode was 0, then 1-0 equals 1. And if %MeetingMode was 1, then 1-1 equals zero. That’s how you make a toggle switch!
By now, you’d know how to navigate around Tasker. So fire up Tasker (or rather, flip it down from the Notifications area), and create a new task. For our demo purposes, let’s do the sound muting widget above. So add a new Task and call it Sound (or Mute or whatever you want).
So the first thing you’d want to happen is to change your variable’s condition using the formula above. You use the Variable Set command for that.
Set the Name of the variable to %ModeMeeting (or whatever you want to use), then set the To to the formula. Click on the Do Maths checkbox (to tell Tasker to calculate it), and then click on the checkmark below. And that’s that! Congratulations! You’ve made your first Tasker formula!
The next step is to tell Tasker what to do given one of two conditions: if %ModeMeeting was 1, or if it was 0.
If it was 1, then we take it to mean that you you just pressed on the Sound widget to mute the phone. Therefore, proceed with the muting.
If it was 0, then we take it to mean that you’ve pressed on the Sound widget again to unmute the phone.
The way to do this is to frame each condition within If… End If statements. Commands that are within an If…End If are only executed if the condition of the If statement is true.
You will find the If… End If statements under the Action Category labeled Task.
So let’s begin. The first statement we will make will take care of when %ModeMeeting is 1:
If %ModeMeeting = 1
Set Widget Icon
Silent Mode On
And of course, the second statement, after it, will therefore be:
If %ModeMeeting = 0
Set Widget Icon
Silent Mode Off
The Silent Mode can be found under the Audio Settings action category, while Set Widget Icon can be found under the Tasker category.
But wait. Which icon to choose?
We need to set up the icons for your widget. After all, they have to come from somewhere.
Tasker actually comes with stock widget icons, but… uh… let’s just say that they look too cheesy and cartoony:
This is why you’d be better off downloading your own sets of icons. Don’t worry. When you choose the Set Widget Icon command, you can scroll down and see an option to download more icons online. Do that.
You will be brought to the Google Play store, where you will then see a filtered list of all the available icon sets (called ipacks), free or otherwise. My favorites are the HD packs, particularly the Orb series. In the examples above, I used the Ipack/Blue White Pearl HD icon pack.
But wait. You may also want to change the look of your widget while it’s activated. For instance, make it redded out when your phone is on mute, and then back to normal when it isn’t. That means having another icon pack of a different color.
My favorite complement to the Blue White Pearl HD, for instance, is the Ipack/Orange White Pearl HD set.
So download your preferred packs and then have fun choosing your icons.
So now we have the program down pat, with a variable that keeps track of your preferred state for the phone, and icons that change depending on the state.
One more finishing touch. You want your phone to vibrate every time you click the widget. That way, you get the reassuring haptic feedback that you did indeed click on the widget.
To do this, you need the Vibrate action. You can find this under the Alerts action category. You wouldn’t want too long a vibrate because that would be annoying. From my experience, a vibrate setting of 100 (that’s 100 milliseconds, or 0.1 second) feels just right.
Wrap it up now! Just click on the check marks to close and save everything.
But wait, all you have right now is the task. What about the widget?
Get back to your phone’s home screen, and then scroll around to find an empty spot where you’d want your widget to land in. Activate Android’s Add Widgets mode (typically by long pressing on an empty part of the screen) and scroll until you find the Task widget.
Drag the widget to your selected spot. It will then ask you which action you want to dump over there.
You’ll see a summary of your task. But more important, you would want to give it an icon, via the lower right button that looks like color swatches. Click on that and choose your preferred icon.
(Truth is, at this point it doesn’t matter what you choose. Once you click on your task a couple of times, it’s gonna turn into the icon that you programmed it to show.)
And you’re done!
This just serves as an example of how you can create widget controls on your Android phone. The sky’s the limit. Make auto-SMS widgets! Make alarm clock widgets! If you can think it, you can probably build it!
You must be logged in to post a comment.