Idiot Driver 3.0


“Why don’t you blog more?” … “You should blog more.” I’ve been hearing that more and more. Who REALLY has the TIME to DO this?? So it’s been WELL over two years since my last blog post. Since two-dot-oh Twitter has changed their interface and with THAT… my app was broken. I don’t know EXACTLY when that happened, but it happened. Needless to say, I was PISSED. But why should I try to fix it? Twitter was just going to change their interface AGAIN and then my application would be broken… again.

The voice control was pretty much a hack. There was PROMISE of an API (Application Programmer Interface), but nothing really showed up from Microsoft. The Windows Phone 8 came out, but I didn’t have one. So what was the point of fixing idiot driver? All roads pointed to a dead end and some SERIOUS LACK of motivation.

I’m not sure where I got this motivation to rev back up and get in gear. Could it be my new found love of the Top Gear show and how they LOVE to make fun of EVERYTHING? That really could have been IT! It’s been hard to find the time. A few hours here. A few hours there. My to-do list was getting WAY out of hand, but then suddenly I was getting it under control.

My FIRST step was go for broke. Windows 8.1 I thought. I thought WRONG. I’ve been using Visual Studio 2013 for quite some time and the NEW way to run the phone emulation was through Hyper-V (Microsoft’s virtual machine code). By default I believe the Windows Phone SDK (Software Developers Toolkit) comes install by default with VS 2013. If it doesn’t, it’s easy enough to download and get up and running. Microsoft even GIVES their “express” version away to entice more developers. So even BEFORE I generated a template project I needed to get Hyper-V going.

So the RIGHT way to do this is to go to the BIOS FIRST. Make sure that your machine supports virtualization. The Hyper-V installation will tell you what options you need. As it turns out, my aging HP HAS these options but they aren’t on be default. You can typically get to the BIOS by rebooting and then frantically pressing F2, F1, F8, F10, F11, F12… Well, it’s ONE of those. I usually hit the right one eventually. Sometimes the boot screen will actually TELL you which key to press for the BIOS. Yeah. Press THAT one. Dig around and find the virtualization options and make sure they’re ON.

Once you reboot you will have to turn on the Hyper-V options ON in the Windows Options section. This is the “Features” section of the “Programs and Features” control panel. Turn on as many of the Hyper-V options on as you can. You might have to reboot. Yes. AGAIN! But quite possibly I didn’t have to this time.

You will NOW be able to run the phone emulators. If you haven’t set things up correctly, and believe me, I HADN’T quite a few times then these things won’t run. If you’re about to give up, then don’t worry. You can run your development code on your phone or better yet, your OLD phone that you couldn’t trade in. You can register these devices when you get your Windows Phone development account. You can only have so many phones registered at a time, but I think the max is three. If you’re named your new device the SAME name, you will have to UNregister the old phone and the REregister the NEW phone.

If you’re running your emulators fine and then you see weirdness that your application doesn’t authenticate with Twitter… Check the time on the emulator. Make sure the phone emulator time matches the REAL time otherwise you won’t be able to logon. You can close down the emulator and restart it or you can go into its settings to fix the time. This probably happened overnight when your computer went to sleep and the emulator went to sleep along with the computer. When the computer wakes back up, the phone emulator DOESN’T resynchronize with the computer. Sad panda. L

Once you’ve got something on which to run your code, you can create a template. I started with Windows 8.1. I called it PhoneApp2. I figured I could change the name later. Oh wait. I didn’t change the previous version, PhoneApp1. The conversion was going slow and I was creating ALL NEW views and using ALL NEW controls. I sure did MISS the old controls though. I used the ListPicker heavily, but I didn’t see it as one of the standard controls. I had converted the MainPage, About, Settings, and Disclaimer. Things were compiling and I was getting things set up the way they were. I needed to bring TweetSharp into the fold, because the API looked very straightforward. My old code just made the REST calls using Hammock. What a pain in the ass THAT was. I knew I needed to change from THAT mess. I tried to install TweetSharp from NuGet. NO support for Windows 8.1 because the Json serializer wouldn’t install because it wasn’t built for 8.1. BUMMER! All that time wasted. Going with 8.1 and then finding out that it wasn’t going to happen.

That was actually a blessing in disguise, because I created a Windows 8.0 project. Of course I called it something original. Yes. The default. PhoneApp3 was born. When I was digging through the files again of PhoneApp1 I found a README.txt file. Why didn’t I see that before? At the top of the file mentioned the use of the Windows Phone Toolkit. Ah-HA! This was readily available through NuGet as well. Of course I NuGot it. Is that a word? Past tense of NuGet is most certainly NuGot. Or is it NuGetted?

I NuGot TweetSharp which grabbed the Newtonsoft Json Serializer and Hammock (the REST easy library). I just started with the MainPage view. A few controls including the browser (for the oAuth 1.0b authentication). A few application buttons. All I wanted to test was to see if I could talk to Twitter. I could grab a few oAuth keys from the Twitter AppDev pages to bypass the logon. I plugged this stuff into the TweetSharp code and in a few minutes I had about 20 of my latest tweets showing up in my app. SUCCESS!! I coded up the oAuth browser response stuff using most of my old code for reference. Then it was mostly a matter of cutting and pasting the controls from my old PhoneApp1 project (Idiot Driver 2.0) and pasting them into newly created files. I was determined to stick with the MVVM (Model-View-ViewModel) pattern that I’ve been using for Silverlight and WPF. I was successful at this in MOST places, except for the application buttons. You can’t {Bind} to a RelayCommand there. Maybe you can do it in 8.1, but certainly NOT in 8.0. So you have to go old-school and hook up the click event. I created a utility class that would help me with the transition from the code behind (an evil place to put your logic) to the ViewModel. I created a routine to translate the DataContext to the ViewModel generically. I also created a class to call the RelayCommand which I needed for the old-school events.

I found two articles done by somebody who helped with the voice recognition libraries and those helped a TON. I scooped some code out and go the license plate and rant prompts working. I was STUNNED that I could dictate letters and numbers and the code would actually spell out license plates (ABC 123). Since the spacing was rather arbitrary I added some translation code which would turn the word “space” into an actual space. I did the same with “hyphen” and “dash”, which in the end they all got turned into underscore “_” characters anyway so they would be recognized as a Twitter #hashtag. I had to add more options because the API isn’t great at recognizing sentences so I added code to turn the word “period” into a period. I’m not sure if I’ll go total “Dragon”, but it would be nice if you could edit your tweet using your voice versus saying the entire thing over and over until the API recognizes EXACTLY what you’ve said. That’s for FUTURE versions I guess.

So a few more hours sprucing the thing up a bit and getting a few more bugs ironed out. You can edit your default tweet list and turn on/off more options. Once piece of code that I was FINALLY able to implement is the #hashtag #everything option. #This #will #turn #ALL #your #words… Well YOU get the picture. It’s annoying. That’s why you can turn the feature on and off. I swear. I’ve SEEN tweets like this though. THEY need this app!! They can type normally and the app will make their tweet annoying FOR them.

The publishing experience was actually easier than before. The Windows Phone Dev Publishing center remembered all my settings from before. The only hard part was adding the screenshots. That wasn’t working because I needed to delete my old ones FIRST, and THEN add my WXGA ones which would scale down automatically. Once I got that figured out, my app was back out in the store within about an hour of submission. Of course as SOON as you publish, you find bugs. So the next night I’m fixing those and then re-publishing. And the next night. Which brings me to version 3.2. It’s pretty stable. And what can you expect for FREE!

So I’ve put down my coding keyboard and picked up the “creative” keyboard to bring this shiny new blog entry. I doubt you’ve made it to the end, but hopefully you don’t feel like I’ve wasted your time, since I certainly feel like I have. But if you laughed just ONCE, then I’ve done my job.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: