Posts from October 2008

PleaseBrowseMe for Android

Posted

Edit: Please Browse Me is LIVE in the Android Market.

As I blogged recently, I am the happy owner of a T-Mobile G1. One of the first things I do when it comes to a new platform is to try and port an old application to it. Doing so gives you a good comparision of the difficulty of the two platforms while making it easier to learn the new one. That's what I did with PleaseBrowseMe. If you don't know what that is, in a nutshell, it's a desktop browser for the t-shirt search engine pleasedress.me. Check it out here if you are so inclined.

Like the desktop version, you can search by tag but you can also search by color(from a palette of ROYGBIV - IV + Black and White). You can also save shirts to review later. Unlike the desktop version, they will still be there if you stop and restart the app. A "Buy It" button launches the phone's browser and navigates to the shirt's page on pleasedress.me.

Like I said in the video walkthrough, barring any major problems, I plan to release it in the Android Market. It's a beta so there are some things that need tweaking. My apologies for the bluriness on the video, that was the best my Flip could do.To compensate I'm including a couple screenshots from the emulator.

PleaseBrowseMe for Android

PleaseBrowseMe for Android

 

 

24 hours with Android

Posted

Yesterday afternoon, I received my overnighted G1 in the mail. After a couple hiccups with a bogus SIM card and a visit to the local T-Mobile store, I was ready to go. It turns out that online they are on backorder until November 10th and the San Antonio(Mountain View) store was one of the few in this area to get more phones on Oct 23.

Form factor

Because of the keyboard, the G1 is considerably thicker than the iPod touch/iPhone. However, it has a more rugged less dainty feel to it and conforms to your hand more. The screen is a bit smaller but very crisp and responsive. The keyboard/trackball combo IMHO beats the iPod/Phone's on-screen keyboard hands down. Moving the cursor back when you make a mistake is so much easier than using the long-click gesture on the iPod. And there's copy and paste too.

Apps

I've read some chatter where people were complaining that it didn't have this or that app. True, there were about 50 apps for launch in Android Market but they are quality apps. And we must also not forget that for a year, we were told the web is the SDK(for iPhone). Android had their SDK out there way before launch. That in combination with the lower price for their developer program. I expect there to be a deluge of apps very soon. Gmail on the G1 is much better than the touch. The only app I really would like to have is a Skype app that doesn't use cell minutes but I'm sure the Fring guys are working on that. I've had almost as much fun developping apps for it as I have doing Groovy apps. The UI design doesn't work against you and has a very well-thought out group of base components.

For the record, AFAIK Android would require major hacking to run Groovy. Not impossible but not easy due to the work that would needed to make MOP work.

Thanks to a SD slot that unofficially supports up to 16GB(and probably will be expandable with software updates), the G1 is most likely going to replace my touch and eeepc.

Griffon Font Picker

Posted

A couple days ago while looking at random AIR apps, I came across Font Picker, a nice unitasker to show all the available fonts on one's system. To make my port a bit more than an outright clone, I added font size and styling. The full source code is available in the the Griffon svn repo.

Font Picker screenshot

The Making of PleaseBrowseMe

Posted

In the last post, I released PleaseBrowseMe, a browser for pleasedress.me made with Griffon. In this post, I'm going to explain a bit more of the technical details of creating it. If you're looking for the app, go here.

withWorker

This is one area that would have been more difficult using Java. SwingWorker, the Java concept that withWorker is based on, is designed to be executed once. That is not a restriction in Groovy and was very helpful in loading a batch of images in a EDT-safe way.

def doImageLoad = { evt = null ->   
    withWorker(start:true) {
        onInit {
            doLater {
                model.running = true
                app.appFrames[0].getGlassPane().setVisible(true)
                app.appFrames[0].getGlassPane().setBusy(true)
            }
        }
        
        work {
            for(int i = model.startCount; i < model.endCount; i++) {
                def url = model.searchResults[i].imageUrl
                if (model.searchResults[i].image == null || 
model.searchResults[i].image == model.loadingImage) {
                    def image = ImageIO.read(new URL(url))
                    if (image.width > 180 || image.height > 180) {
                        image = GraphicsUtilities.createThumbnailFast(image,180)
                    }
                    publish([id:i, image:image])
                } else {
                    publish([id:i])
                }		
            }
        }
        
        onUpdate { chunks ->
                   chunks.each { imageMap ->
                   if (imageMap.image != null)                       		
                       model.searchResults[imageMap.id].put('image', imageMap.image)
                   view.shirtPanel.add(drawShirtPanel(imageMap.id))
            } 
        }
        
        onDone {
            model.running = false
            if (model.searchResults.size() == 0)
                view.shirtPanel.add(new JLabel("No results"))
            view.shirtPanel.revalidate() 
            app.appFrames[0].getGlassPane().setVisible(false)
        }
    }
}

search

The only thing special that's going on with search is that I used SwingX-WS calls for http requests/responses to avoid using the more verbose Apache varieties. The JXSearchField component from xswingx helps out too.

 

public search(text) {
    def session = new Session()
	def request = new Request(url:"http://pleasedress.me/api/1.0/shirts/search.xml?q="+text)
    def response = session.execute(request)
    def shirts = []
    if (response.getStatusCode() == StatusCode.OK) {
       def result = model.slurper.parseText(response.getBody())
       result.shirt.each {
            shirts+= [title:it.@title.toString(), url:it.@url.toString(), 
               image:model.loadingImage, imageUrl:it.@image.toString(), price:it.@price.toString()]
       }
       model.searchResults = shirts
       model.startCount = 0
       model.endCount = model.searchResults?.size() > 21 ? 21 : model.searchResults?.size()
       clearShirtPanel()
       doImageLoad()
    } else {
       	JOptionPane.showMessageDialog(app.appFrames[0], "Error", "Something went wrong.", JOptionPane.ERROR_MESSAGE)
    }
}

GlassPane

To indicate when the application was retrieving information from pleasedress.me, I used a JXBusyLabel as my GlassPane. The GlassPane is an invisible layer that exists on top of every frame. To not obscure the underlying view as much, I changed the point shape to circles(Ellipse). I also tweaked the colors to match the animation more apparent. Because it is specific to J(X)Frame, when referring to the glasspane, one must call app.appFrames[number] directly. view.getGlassPane() will not work.

 

import java.awt.Dimension
import java.awt.geom.*
import org.jdesktop.swingx.JXBusyLabel
import org.jdesktop.swingx.painter.BusyPainter

def busyLabel = new JXBusyLabel(new Dimension(700,700))
busyLabel.setOpaque(false)
busyLabel.setBusy(true)
busyLabel.getBusyPainter().setHighlightColor(java.awt.Color.DARK_GRAY)
busyLabel.getBusyPainter().setPointShape(new Ellipse2D.Float(1,1,10,10))

app.appFrames[0].setGlassPane(busyLabel)

PleaseBrowseMe

Posted

As its name somewhat indicates, PleaseBrowseMe is a desktop browser for the t-shirt search engine PleaseDressMe. Mostly it's a tech demo for Griffon, an app framework for Java/Groovy I helped create.

It allows you to:

  • Search pleasedress.me in real time
  • Launch a browser window/tab going directly to the retailer
  • Identify shirts you like and save them
  • Create a widget featuring the shirts you like


It also automatically saves all searches. No affliate links were altered in the creation of this app.

As always Java 6 is pretty much REQUIRED. If you like PleaseBrowseMe and are a Twitter user, check out FriendBackup as well.

 

Launch button

 

PleaseBrowseMe screenshot

PleaseBrowseMe screenshot