Posts Tagged: Ui


9
Feb 10

Nexus One – First Impressions

My thoughts on the Nexus One and the Android OS?  I like it.  A lot.

Likes:

  • Speed.  I have the older iPhone 3G hardware and from a user experience perspective it was not that bad.  When compared to the Nexus One, however, it is down right sluggish.  This probably isn’t as big of a factor when comparing a 3GS versus Nexus One, but for someone coming from a 3G iPhone, it is a huge plus.
  • Being able to run apps in the background.  Browsing the web while streaming Pandora and downloading an app in the background works flawlessly and shows no noticeable signs of lag or sluggishness.
  • The OLED screen is really nice.  Higher resolution and OLED screen looks great in low-light situations and is supposed to save precious battery by not drawing less power than normal LCD screens.
  • The Android OS is pretty sweet.  It has a lot of nice features like the status bar, an active “desktop” that you can put interactive widgets on as well as app icons, and an easy way to get music and files on and off the device.  
  • Integration with Google Apps is fantastic as expected.  I love getting mail and talk updates in the status bar and the overall experience with the apps on the Nexus One is better than on the iPhone.

Dislikes:

  • Cut and Paste is clunky.  I can see why Apple needed to spend awhile working out the UX issues before rolling it out.
  • The touch interaction with the device has not been as good as the iPhone in my experience.  I am not sure where the blame lies (hardware or software), but I sometimes find it difficult to select elements in the UI.  This is not something that occurs frequently, but in the short time I’ve owned the device, it has occurred enough to be noticeable.
  • 4GB of storage out of the box is lacking.  It is an easy upgrade but given the amount of money that Google is charging for the device, this seems like they are skimping here.
  • The Android Market place experience is integrated nicely but isn’t as tightly integrated as the iTunes App Store.  This is arguably a good or a bad thing depending on how you look at it.  As a user this is a bad thing since it makes finding and buying apps more difficult than just popping open iTunes.  I’ve found the Android Marketplace, both on the phone and the web, hard to browse.

There are a few negatives that I can’t pin exclusively on the device but are still worth noting.  I have been using my AT&T SIM with the Nexus One and most likely will do so until my contract is up in a few months.  With that caveat out of the way, the talk quality seemed poor and the phone gets really hot when talking for periods greater than 10 minutes.  I hesitate to even mention these issues since I am not using the phone on the network it was intended, but  I know there probably are others considering doing what I did, and this feedback might help if someone is on the fence.

The Nexus One is exactly the kind of phone and competition that was needed to push Apple.  I strongly recommend anyone looking for a smartphone to give it serious consideration before running out and getting an iPhone.


1
Feb 10

iPhone Wireframes

I stumbled across a great collection of iPhone wireframe templates tonight while going through my feeds.  It got me thinking about the process I’ve been using to layout and design the app I am working on.

I’ve been using regular 3 x 5’ notecards to sketch out different screens for the iPhone app I am working on.  On the ruled side I’ll scribble notes and call out must/should/wish components of the screens to help prioritize features.  On the blank side I’ve been sketching out wireframes of the screens to help get a feel for the UI and flow of the app.

cards_laid_out

I’ve played around with Balsamiq and, while the tool is fantastic, I find myself still partial to the notecards.  With the same rough dimensions of the iPhone and the flexibility of being able to quickly rearrange and reorder the screens, the cards suit my preferences as a visual-spatial learner well. 

As with most tools and techniques, personal preference plays a large role in how and when they’re employed.  I always enjoy checking out how other people work and try and steal glean ideas from them.  I’ve found the following blogs pretty useful for design, usability, and UX.  I hope they help inspire you to create something cool.

I ♥ wireframes
information aesthetics
everydayUX
Sender 11


28
Nov 09

Monotouch: UIAlertView + UITextField = Crazy Delicious

If you have ever tried to buy or install anything from the App Store or iTunes on your iPhone, then you certainly have been prompted for your password by a screen that looks like this:

itunes_pw_iphone

The control used by Apple to prompt you for your password isn’t available out-of-the-box in Cocoa Touch, but fortunately it is pretty easy to roll your own.  I’ve put together a sample project that shows a couple different techniques that are available for creating and customizing the control, and I’ll go over a few of them here.

The stock UIAlertView control consists of a title label, message label, and typically one or more buttons.  It is important to note that in Monotouch, a default button setup isn’t configured, and buttons have to be added explicitly.  If a UIAlertView is configured without any buttons, then dismissing the control will have to be done programmatically because the user will have no way to dismiss the control.  In both of my examples I’ve configured the control to have two buttons (Cancel and Ok), but I could have gotten by with just one.  If only one button is used, it is important to also note that the button is considered the Cancel button by the control, and the CancelButtonIndex property will refer to that button.

Basic_UIAlertView

The easiest way to go about composing a UIAlertView with a UITextField is to create an instance of a UITextField and add it as a sub-view.  Since you’re adding a layer on top of UIAlertView’s view, the key will be fitting this new control into the UI.  There are two ways of going about this.  The first and maybe most obvious way to solve this problem is to make some room between the message label and buttons for the text field ala the iTunes password prompt.  Since the UIAlertView control has already been laid out, moving those controls around within the frame is not as straight forward a task as it may seem.  Before we tackle that we will explore a simpler method that overlays the text field directly on top of the message label.  You sacrifice being able to display an additional message to the user, but the end result looks professional and is very easy to implement.  This will also be the basis for getting the control to have the same look and feel as the iTunes password prompt, so it is important to understand this prior to attempting to move the controls around.

The key to overlaying the text field on top of the message label is setting the bounding rectangle for the UITextField.  The bounding rectangle is where the text field draws the box in which a user enters text.  For our purposes, the rectangle needs to be drawn in between the title label and the buttons.  It is important to make sure that it covers the area where the message label is drawn.  Thanks to the work of others we know that if we start drawing the text field at the x,y offset of 12,45 that the text field will hide the message label.

The code to overlay the text field is as follows:

void PromptForName(HandlerToUse handlerType)
{
    UITextField tf = new UITextField (new System.Drawing.RectangleF (12f, 45f, 260f, 25f));
    tf.BackgroundColor = UIColor.White;
    tf.UserInteractionEnabled = true;
    tf.AutocorrectionType = UITextAutocorrectionType.No;
    tf.AutocapitalizationType = UITextAutocapitalizationType.None;
    tf.ReturnKeyType = UIReturnKeyType.Done;
    tf.SecureTextEntry = false; 

    UIAlertView myAlertView = new UIAlertView
    {
        Title = "Please enter your name",
        Message = "this line is hidden"
    };

    myAlertView.AddButton("Cancel");
    myAlertView.AddButton("Ok");
    myAlertView.AddSubview(tf);
    // More Setup Goes Here
    myAlertView.Show ();
}

The method starts by instantiating a UITextField control with a bounding rectangle passed via its constructor.  The rectangle itself is constructed with four parameters via its constructor: the first two parameters set the x and y offset from the origin point of the control, and the last two parameters set the size of the drawing area.  After the initial construction of the UITextField, a few additional properties are set to customize the display. 

Among the properties set is the SecureTextEntry.  Setting this property to true will make the text field act like a password field and hide all the characters that you’ve entered.  Once the text field has been created and initialized, we move on to creating a UIAlertView.  Via object initialization, the Title and Message properties are set with some text.  Finally, two buttons are created, and the text field is added as a sub-view to the UIAlertView.  Calling the show on the UIAlertView causes the alert to pop up.  Below you can see the rendered control.

TextField_As_Subview_UIAlertView

So now that we have the basic control setup, we can tweak it so that the text field and the message label can both be displayed.

If you recall our custom UIAlertView control is currently composed of two UILabels, two UIButtons and a UITextField that we added.  The UILabels are derived from UIView and is not a subclass of UIControl; whereas, the UIButton and the UITextField are both derived from UIControls.  Since we want to position the UITextField beneath the labels, we can use this knowledge to selectively shift only the UIControls in the view down leaving the title and message labels in place.

To accomplish this task the following steps need to be performed:

1) The control height needs to be increased to make space for the text field and provide additional space to move the UIControls.  This is done by setting the frame to a larger size.  The frame will be increased by the height of the text field plus a buffer, so the control has space between it and the others.

This is what the frame looks like after being enlarged:

FrameEnlarged_CustomUIAlertView 


2) Once the frame has been enlarged, we’ll loop through the sub-views looking for UIControls and adjust only those types down by the same text field plus buffer offset

Here is what the control looks like after each UIControl is found during the iteration through the sub-views.

FirstUIControlShifted_CancelButton

SecondUIControlShifted_OkButton

FinalUIControlShifted_TextField

Here is the code that does the control adjustment:

public class TextFieldAlertView : UIAlertView
{
    private UITextField _tf;

    // ... 

    private void AdjustControlSize()
    {
        float tfExtH = _tf.Frame.Size.Height + 16.0f;

        var frame = new RectangleF(this.Frame.X,
                                    this.Frame.Y - tfExtH/2,
                                    this.Frame.Size.Width,
                                    this.Frame.Size.Height + tfExtH);

        this.Frame = frame;

        foreach(var view in this.Subviews)
        {
            if(view is UIControl)
            {
                view.Frame = new RectangleF(view.Frame.X,
                                            view.Frame.Y + tfExtH,
                                            view.Frame.Size.Width,
                                            view.Frame.Size.Height);
            }
        }
    }
}

So now that the desired look and feel of the control has been established, it is time to wire up the control.  There are a couple options for handling events generated by the control: one is more in line with how Cocoa handles events, and another that is similar to how .Net works. 

The Cocoa way to wire up delegates involves subclassing a special delegate class associated to the control and selectively overriding the methods for the actions you want to customize.  In the case of the UIAlertView control, that delegate class is a UIAlertViewDelegate.  The delegate class includes overridable methods like Clicked where you can define the actions to take when a button on the control is clicked or where you can extend behaviors by overriding methods like Preseneted which is called after the control has been displayed to the user.

The .Net way to wire up events is to provide specific delegates for specific events.  To make interacting with the Cocoa Touch controls easier, Monotouch provides public events for each one of the methods that can be overridden in the UIAlertViewDelegate class.  Having the individual public events makes wiring up controls more intuitive for the .Net developer, but it is good to know about the Cocoa-style approach especially when looking at Objective-C examples and/or ADC docs.  I have examples of wiring up the control via both methods in the example source.

The last topic I’d like to cover briefly is how I encapsulated the customization of control by subclassing UIAlertView.  The key to getting the control to look right is to override the LayoutSubviews method and build out the text field, add it to the UIAlertView and shift the controls around there.

public override void LayoutSubviews ()
{
    // layout the stock UIAlertView
    base.LayoutSubviews ();

    // build out the text field
    _tf = ComposeTextFieldControl(_secureTextEntry);

    // add the text field to the UIAlertView
    this.AddSubview(_tf);

    // shift the UIControls to fit the text field
    AdjustControlSize();
}

I’ve added some more customizations to my subclassed UIAlertView control that allows you to enable the text field security via a constructor parameter and a tweak to the control’s Transform property to shift the control up so it isn’t hidden by the keyboard.  You can see those changes and the entire working example here on github.

Enjoy.

Links to some of the resources used: