4MK Mobile Dev Blog

Adventures in Mobile Development

WP7 Devs: Stop adding search buttons! [UPDATED]

NoSearchButtonsUPDATE: During some investigation by Shawn Wildermuth, he figured out that in order to show both the white “Enter” button as well as the typing suggestions, we should use the “ApplicationEnd” Input scope and not “Search”.  Hopefully this get’s fixed in a future update.

When Microsoft first showed off its new Metro design style with the Windows Phone 7, most people agreed that it was slick, clean, and perhaps most importantly, distinctive.  With Blend and the stock controls and styles, developers are able to easily create distinct looking apps that match your company’s style, while still keeping it within the Metro guidelines.  If you ever get stuck wondering how something should act or look, a quick trip through the OS and bundled apps should be enough to set you in the right direction.

So why do so many applications get their search boxes wrong?

As I mentioned above, a quick tour through the OS will give you all the inspiration you need, unlock your phone right now and hit the search button.  Do you notice something missing?

image

Search boxes within the Metro design are not supposed to have a button that says “OK”, “Search”, “Go” or anything else of the sort, there should be no button at all.  Instead of the button, you should be using the “Search” “ApplicationEnd” Input Scope on your textboxes instead, like so:

   1:  <TextBox Name="tbSearch" InputScope="ApplicationEnd"/>

What that will do for you is bring up the soft keyboard designed specifically for searching that looks like this:

image

The biggest thing to note about this is the white key on the bottom right.  That key is the only thing that should launch the search action.

Unfortunately, to the best of my knowledge, Microsoft didn’t add in a specific event for search, so you’ll need to add in some code to handle this.

First, wire up the KeyUp event of your TextBox so that it looks like so:

   1:  <TextBox Name="tbSearch" 
   2:           InputScope="ApplicationEnd" 
   3:           KeyUp="tbSearch_KeyUp"/>

Then code your event handler to look for Key.Enter and call whatever functionality you are using to perform your search like so:

   1:  private void tbSearch_KeyUp(object sender, KeyEventArgs e)
   2:  {
   3:      if (e.Key == Key.Enter)
   4:      {
   5:          PerformSearch(tbSearch.Text);
   6:      }
   7:  }

Think I’m off my rocker and people should be able to put buttons where ever they want and it won’t detract at all from the user experience?  Feel free to leave a comment below.

Developer review of the LG Quantum 7Q (aka a great first step)

Through my work with RedBit Development, I’ve been asked to put together a review of the LG Quantum 7Q from a developer’s perspective.  Not being one to shy away from offering (some would say injecting) my opinion, I jumped at the chance.  So read on for my thoughts on the LG Quantum 7Q in general, as well as what it means for developers.

First some history…

Before making the jump to Windows Phone 7, I spent a few years building Windows Mobile applications for the Utility Industry all over North America.  Working with WM full time gave me a good feel for what the Mobile OS had to offer, and while it certainly had its share of warts, I was a huge fan.  Working and living in Canada meant that unless I felt like importing a phone, my options were severely limited.  The phone that I really wanted, the HTC TyTN II, I don’t think ever made it north of the boarder.  With that in mind, when I first looked through the list of launch devices, the Quantum being the only phone available in Canada that had a hardware keyboard certainly caught my eye.

General overview of the phone…

I should say at this point that the phone that I use for day to day use is the Samsung Focus, so be warned that a lot of these comparisons will be to it. Having said that, the first thing that I noticed between the two were the size and brightness of the screen.  The LG in this case really doesn’t stack up, so if you select you phones based solely on the display; keep moving along, this isn’t the phone for you.

Obviously, the other big thing from a hardware standpoint is the keyboard.  While the on-screen keyboard for WP7 is great, it still is an approximation of typing on keys.  Having tactile feedback to button presses, as well as not having to constantly wipe finger prints of the screen really does remind me of how much I missed hardware keyboards on a phone.

On the software side, its Windows Phone in all it’s milky goodness with no noticeable difference in animations or app loading times.  Where things do change however is in the Manufactures marketplace sections.  Not only having quite a few good LG specific apps, but also sponsoring a few 3rd party apps to be free for the phone, LG has quite obviously done what Samsung has not, take this section seriously. 

The LG Marketplace

I’m not going to go through each of the apps one by one because Mark has already done so better than I ever could that you can check out here

What I will say however is that these applications are a bit of a tease.  As a Developer who’s champing at the bit to get my grubby paws on access to both the compass and the camera control, seeing these apps are certainly bittersweet. Why LG hasn’t released an SDK to access the camera on their own (assuming MS would let them) makes me shake my head.

What the keyboard means

While most peoples initial thoughts on what a hardware keyboard means for a device is a bonus for those who prefer the feel of hardware buttons, there’s something that it brings that is far more important…screen real estate.  Now this may not be as much of a problem for you, but with my fat thumbs, any game that using the screen to display a virtual joystick automatically puts me off.  When an application has both a virtual joystick and buttons on the screen, they are basically killing off a third of the already limited screen just for user input.  While I have yet to be able to find a game that actually uses the keyboard for input, I’m sure they can’t be far away.

The other thing that puts a damper on the keyboard is that many developers (me unfortunately included) have gotten lazy and skimped out on landscape support in their apps (I won’t be making this mistake again).

Summary

I’ll say this again, if the display is your only consideration, this is not the phone for you.  If however you’re looking for a hardware keyboard and a real effort by the Manufacturer on the software front, LG has made a great first step to wining your choice.  As to whether I’ll be dumping my Focus for the Quantum, the jury is still out.  If LG can continue its strong start and take the next step on a couple of features, then I could certainly see Samsung’s device hitting the test bench.  This takes me to …

3 Action Items for LG

Before listing these off, let me state that I’m not even 100% sure that these items are even feasible given the working relationship LG has with Microsoft and the restrictions that it entails.  Also, since any hardware fixes would require me buying a new phone to benefit from, I’ve left them out and stuck to items that could theoretically be pushed via update to existing phones.

1) Get version 2 of the LG specific apps out the door.  While nice, each of them has nagging problems that prevent them from truly being device sellers.

2)  Show peoples the way. Take some of the marketing budget and pay a couple independent game developers to add keyboard input support to their apps.  I think the first person they should talk to is Farseer Games about adding it to Krashlander (since this is one of the games LG has sponsored, I’m pretty sure they have the number)

3) Release a SDK. As I said, I’m not sure this is even possible, but if it is they really need to release a set of controls to support the camera and compass.

Adventures in WP7 Ad Publishers–Part 1

This is the first in a series of blog posts about my adventures in trying to set up advertising within some of our WP7 applications.  While the first few posts may come across as b#$#ing sessions, hopefully my trials can save a few of you some aggravation when it comes time to monetizing your free apps.

This post will deal with the first three Ad Solutions I’ve tried to use, with more to follow, so without further ado…

Microsoft Advertising SDK for Windows Phone 7

In case you can’t tell, I’m a developer of WP7 apps who lives in Canada.  This means that because I’m not in the States, I cannot use Microsoft’s Ad Control for Windows Phone 7.  While they have said that they are looking to expand the service to allow non-US usage, they haven’t said anything about when that might happen.

AdMob

While AdMob doesn’t support WP7 out of the box, they do provide an SDK for use with mobile web applications that could be wrapped in a browser control that could be a solution.  That is the premise behind two different open source projects on Codeplex: admob for Windows Phone 7 and MoAds.  Looking through them I decided to go with MoAds as it purports to support multiple different Ad Publishers.  Getting it up and running was a breeze.  In about 10 minutes I had the control working and displaying the occasional ad (the fill rate of the first 200 or so requests was 4%).  I started searching around for ways to increase the fill rate, and came across this thread in the official Google group.  Basically what’s happening is that AdMob is happy to serve as many ads as they can to your WP7 device however they will also mark any click that you might get as invalid.  What this means is that there is no way to actually get paid for the ads that they serve to your app. 

Dirty pool Google, dirty pool.

The one good peace of info I received from that thread though was that the WP7 developer in question moved on to Smaato

Smaato

At first glance, Smaato looked like it could be a perfect fit, promises of high fill rates, multiple ad networks supported and even a Windows Phone 7 SDK!  I quickly filled my info in and downloaded the SDK.  Here’s where I first realized that there might be a problem, to get the WP7 SDK you download the Windows Mobile SDK.  Using the name of the old mobile OS from MS certainly isn’t a showstopper so I kept going.

Downloading the samples and running them was mostly pain free.  The test app was ugly as sin, but worked exactly as you’d expect. I then moved on to adding it to our application and fired up the emulator.

It worked first time out.

Rerunning it however is when it started going south quickly.  I noticed that when I reran the application, it was asking me to allow the app to use my current location (this is part of the application I was testing with, however it should only ever ask you the first time and caches the result).  Every time I restarted the application, it completely forgot that I had already given permission for GPS access.  It wasn’t long before realizing what was happening:

The Smaato SDK will delete everything you’ve stored in Isolated Storage without warning.

That’s right, it doesn’t just clear it’s own cache, it deletes everything!  Checking around to make sure I wasn’t just being stupid, I found others that have come to the same conclusion and fired off a support request to see if there is a fix coming anytime soon.

 

Until next time, if any of you know of any ad providers that actually work on WP7 please let me know.

OGDI, bring joy to developers everywhere.

Recently I had the pleasure of working on the project Emitter.ca that ties two things very important to me together: open government data, and the environment.  It was the way in which we interacted with the data that I truly loved…

As a developer, you know you’ve had this experience:

Some government agency announces that they are finally embracing open data. The wheels upstairs start to turn dreaming up all the cool apps you’re going to build with this new found bounty. But then it happens, you get to the part of the announcement that describes the format, and all the wind comes out of your sales…flat file. Your dreams of building apps that would make you the envy of your peers, would get you written up on TechCrunch, and discussed at length on YCombinator are now being replaced by thoughts of the hours it’s going to take to set up the database and worries about scheduling the update process to ensure your data is even close to up to date. Your fast lane to fame and fortune just became the traffic jam heading to cottage country on the Friday of a long weekend.

OGDI goes a long way to solving this problem.

The fine developers of the Open Government Data Initiative have obviously been through this headache enough times that they decided to do something about it. The open source project (hosted on codeplex) allows any government agency the ability to not just publish their data, but actually provide developers of all types real tools to access it. Exposing a RESTful service, producing many different output formats including XML, KML, Json and Jsonp, the Azure backed framework saves developers countless hours and dollars by, in many cases, providing everything that the client developer needs from the server tier. Not willing to leave good enough alone, the OGDI framework provides an interactive SDK that allows you to set up any of the queries that you need while seeing the results of said queries, while also providing example code for multiple different programming languages. Given all this, I certainly expect OGDI to quickly become the defacto standard for the public sector to engage the development community.

Once the correct decision was made to move most of the data to OGDI (using DataDOTgc’s instance), I was tasked with migrating the data. Most of the hard work had already been done by the rest of the team (especially Matthew Dance) in shaping the data into the normalized format that we required. Armed with a SQL Server database full of data and the many tools that are available for moving data into the cloud, all it took was a couple of hours to successfully upload all of the data. Once it was up, all the features provided by OGDI worked like a charm.

To show you exactly what I mean about how easy OGDI makes app development, in the very near future I’ll be blogging throughout the entire process of porting the emitter.ca project to Windows Phone 7, Stay tuned…

Quick Tip: Changing all links to open using the WebBrowserTask

ExternalLinksBeforeFor a recent Windows Phone 7 application we were building at RedBit Development (I’m going crazy here waiting to start talking about what we’ve been working on), we were faced with presenting HTML on a page that was being fed through an RSS feed. 

One of the challenges we faced with, was preventing any link in the HTML from changing what we had nicely formatted in our WebBrowserControl (see the screen grab on the right), but instead used the WebBrowserTask to open the link in a new IE window.

The key to this Quick Tip is the ScriptNotify event on the WebBrowserContol, but first some setup…

First thing that you’re going to want to do for any of this to work is make sure that the IsScriptEnabled flag is set to true on your WBC.  As the name suggests, this allows javascript to execute within the control.  While it may be simple, forgetting about it can very quickly lead to headaches.

Then, add an Event handler to the ScriptNotify event filled with the following code:

   1: private void webbrowser_ScriptNotify(object sender, NotifyEventArgs e)

   2: {

   3:     WebBrowserTask wbt = new WebBrowserTask() { URL = e.Value };   

   4:     wbt.Show();

   5: }

The ScriptNotify event is triggered whenever code within the WBC makes the following code:

   1: window.external.Notify(“Value from Javascript”);

It places the value of the argument as the Value property in the NotifyEventArgs (in this case “Value from Javascript”).  So given that, to reroute links to open in the WebBrowserTask, add the following Javascript to the end of your HTML snippet:

   1: var links = document.getElementsByTagName('a')

   2:  

   3: for( var i = 0; i < links.length; i++  ) { 

   4:     links[i].attachEvent('onclick', overrideLink); 

   5: }

   6:  

   7: function preventDefaultAction(evt) {

   8:     if (evt) {  

   9:         evt.returnValue = false; 

  10:     } 

  11:     return false; 

  12: }

  13:  

  14: function overrideLink(evt) { 

  15:     window.external.Notify(evt.srcElement.href); 

  16:     return preventDefaultAction(evt); 

  17: }

For an example of this, see the this sample project.

« Newer PostsOlder Posts »