Thursday, June 30, 2011

Google Calendar's Design Refresh

After Google Search and Google Maps, it's time for Google Calendar to switch to a Google+ interface. The new design is a lot cleaner, even if no important feature was removed. "Quick add" is now available if you click the arrow next to the "Create button" (not very intuitive), "Print" and "Refresh" are now buttons instead of links, the month view below the "Create" button can be collapsed, "Save" and "Discard" buttons are only displayed at the top of the page.



"Right now, the changes are just cosmetic and have not affected the way Calendar works. You can choose to turn off the new look by clicking the gear icon and choosing Use the classic look (you can turn it back on by going to the gear icon and choosing Try the new look)," explains Google. Obviously, at some point, Google Calendar will integrate with Google+ and we'll see even more changes.

{ Thanks, Andrew. }

A New Interface for Google Search Results Pages

The latest design refresh updated not only Google's homepage, but also search results pages. Google uses a new color scheme for the sidebar, adds grayscale icons next to the specialized search engines, replaces the standard search button with a label-less blue button, uses a smaller Google logo and adds a gray background color to the header.


Google says it has "muted the color of the tools and reserved the use of bolder colors to highlight key action buttons, tools and filters". Unfortunately, the change made the sidebar icons less useful and the search box too prominent. The new header could pave the way to a search results page that uses "infinite scrolling" instead of pagination.

Here's the old interface:


Can you find other changes?

{ Thanks, Kimnaii, Chris, Swen, Nikita. }

Wednesday, June 29, 2011

People Widget and Other New Gmail Features

Gmail added a lot of new features lately. The People Widget, announced one month ago, should be available to everyone. The widget shows information about the people you're communicating with: profile photos, occupation, recent Buzz messages, recent email and documents shared with you, calendar availability and more.


If you already use Rapportive, you need to disable the extension to see the People Widget. You can also disable the People Widget from the settings page. Rapportive has more data sources than Gmail's widget: Twitter, Facebook, LinkedIn, FriendFeed, Google Profiles, so you may find it more useful.

The action bar is displayed at the top of the page even when you scroll down, so you can quickly archive a conversation, label it or read the next conversation without scrolling to the bottom of the page or using keyboard shortcuts. A similar feature is available in Gmail's app for Android.


As you can see in the screenshot above, Gmail now shows additional information next to the sender's name to help you protect against email spoofing. When you receive a message from some who isn't in your address book, Gmail will show the email address next to the name. If a website sends an email on behalf of someone, Gmail adds "via domain.com" next to the email address so that you know that the message wasn't sent directly. Gmail uses email authentication to verify the source of the messages you receive, but this data was only used to detect spam and phishing. Now Gmail also shows a warning which informs you that "this message may not have sent" from the email address that appears in the "from" header.


Google Contacts learned a thing or two about structured addresses and it now allows users to separately list the street name, the city, state and postal code. Google tries to split the address automatically, but the results aren't great all the time. Just click "details" next to the address and a new pane lets you edit address fields:


{ Thanks, Steren, Bogdan, Sean, Alex, Vasu and Amit. }

More Free Storage in Picasa Web for Google+ Users

Picasa Web Albums offers more free storage if you are a Google+ user. According to Picasa Web's help center, "photos up to 2048 x 2048 pixels and videos up to 15 minutes won't count towards your free storage". If you upload photos from Google+, they're automatically resized to 2048 pixels on their longest edge, so they don't use the 1 GB of free storage that's available in Picasa Web Albums.


Most people can't use Google+ because it's invitation-only, so the current rules still apply to them: only the photos up to 800 x 800 won't count towards their free storage quota.

Like Google Buzz, Google+ uses Picasa Web Albums to store photos. You can upload photos from the Google+ interface and even automatically upload the photos taken with your Android phone. Google+ lets you add captions and name tags to your photos, rotate them and apply different filters using the built-in image editor. Now your friends can tag your photos and you'll receive a notification when someone tags you in a photo. The downside is that "tagging a person in one of your photos in Picasa Web Albums or Google+ will share the album with the person tagged".

{ Thanks, Калоян. }

Tuesday, June 28, 2011

The Google+ Bar

A page from the Google+ help center explains the purpose of the new Google navigation bar:


The Google+ bar, which appears at the top of Google products, is your connection to Google+. You can share what's on your mind, view your Google+ notifications, access your profile, or jump to a variety of other Google products. For instance, to get to Google+, all you have to do is click +[your first name].

When you're signed in and look at the Google+ bar, you'll see your full name or email address displayed with a photo or avatar next to it. This helps you identify which account you're currently signed in to. You can sign in to multiple accounts at once and switch between them using the Google+ bar.

One of the most interesting feature of the bar is notifications:
When you receive a notification, the notification area in the Google+ bar will turn red and show the number of new notifications. If you click the notification area in the Google+ bar, you’ll see a summary of your recent notifications. When you click a notification, a preview of the event that generated the notification will appear in the drop-down menu. You can take action on each notification right from the notifications menu, like commenting on a post or adding someone to a circle.

The navigation bar has been morphed into the Google+ bar and it should be more useful. Maybe at some point the bar will include notifications for Gmail, Calendar, Google Docs and other Google services.

Google Takeout

Google wants to differentiate from Facebook by offering a lot of ways to export your data. Google Takeout is a feature that's included in Google+, but it's also available as a standalone service. You can use it to export your contacts, Google Buzz messages, Picasa Web photos and Profile data with one click.

"Google Takeout lets you take your data out of multiple Google products in one fell swoop. Moreover, you’ll find that all your data is in portable and open formats‚ so it's easy to import to other services quickly," mentions the Data Liberation blog.



I've downloaded my data in a huge ZIP archive that included all my Buzz posts saved as HTML files, VCF files for my Gmail groups and the first 100 photos from each of my Picasa Web album. What's the point of downloading the first 100 photos?

Google Swiffy Converts Flash to HTML5

Google Labs has a new useful tool for developers: Swiffy. The application allows you to convert Flash SWF files to HTML5, so you can use any supported modern browser to load the content, even if the browser happens to be Mobile Safari. "Swiffy currently supports a subset of SWF 8 and ActionScript 2.0, and the output works in all Webkit browsers such as Chrome and Mobile Safari."

Google's gallery includes two ads and two simple games that look pretty well when converted to HTML5, especially when you're using Chrome.


Swiffy uses some SVG features that are only available in WebKit browsers, so that's the reason why you can only use it in Chrome and Safari. Android's browser for smartphones doesn't support SVG and it's likely that the Android 3 implementation doesn't support the required features.

"A SWF file is converted in two phases: the Swiffy compiler (which you can use on this website) processes the SWF file and generates a JSON file. A client-side JavaScript runtime loads that JSON file and renders it using HTML, SVG and CSS. Swiffy supports many common SWF features such as vector graphics, embedded fonts, images and timeline animation. Basic ActionScript 2.0 code is also supported, but don't expect to convert your favorite Flash game yet. In general, Swiffy supports most of the features in Flash 5, so exporting your file as a Flash 5 will give the best results," explains Google.

Unfortunately, the code generated by Google is difficult to edit, so you still have to go back to the original Flash file. Adobe has its own tool for converting FLA files to HTML5.

More About Google+ Hangouts

Google's Justin Uberti has more information about Hangouts, the video conferencing app that will be available in Google+.


To support Hangouts, we built an all-new standards-based cloud video conferencing platform. This platform combines high quality, low latency, and strong security with the ease of use of a web application. Through the efficiency of this new platform, we're able to deliver a leading video conferencing experience at Google scale.

A few noteworthy technical points:
* Fully browser-based/cloud-based
* Client-server: leverages the power of Google's infrastructure
* Designed for low latency (< 100 ms) and high performance (multicore + hardware acceleration)
* Standards-based: XMPP, Jingle, RTP, ICE, STUN, SRTP
* Fully encrypted (HTTPS + SRTP)

Hangouts require the same plugin that's currently used for voice and video chat, it's limited to 10 participants and doesn't work on mobile devices yet. Another interesting thing is that "hangouts are created by one person, but everyone in the hangout shares the ability to invite others. Each hangout has a specific URL. That URL can be shared as a link to invite others." You can also use Hangout to watch a YouTube video with your friends.

Hangout looks like a great Google Talk feature and I don't see why it shouldn't be added to Gmail and to Google Apps. Video conferencing could make Google Apps a lot more useful.

Google's New Interfaces

After many weeks of testing, Google finally updated the homepage and search results pages. The changes aren't so radical, but they're still significant: there's a black navigation bar, two updated buttons for "Google Search" and "I'm Feeling Lucky", while the corporate links are moved to the bottom of the page.


Google says that this is just a small step from a redesign that will affect many other services. "The new Google experience that we've begun working toward is founded on three key design principles: focus, elasticity and effortlessness. (...) With the design changes in the coming weeks and months, we're bringing forward the stuff that matters to you and getting all the other clutter out of your way. Even simple changes, like using bolder colors for actionable buttons or hiding navigation buttons until they're actually needed, can help you better focus on only what you need at the moment."

The new navigation bar seems to draw unnecessary attention and some find it distracting, so it's not clear how it helps you "better focus on only what you need at the moment". Google's black bar is used in Google+, so it's likely that it will include other social features in the future.

Google also says that new design is flexible so that it can be used in the desktop interface, the smartphone interface, the tablet interface and even the interface for smart TVs. "The new design will soon allow you to seamlessly transition from one device to another and have a consistent visual experience." At the moment, I'm seeing a new mobile interface that doesn't have too much in common with the desktop interface:




While the interface continues to be simple and utilitarian, Google wants to use HTML5, WebGL and other new technologies to make Google's apps more powerful and better looking. "Our design philosophy is to combine power with simplicity. We want to keep our look simple and clean, but behind the seemingly simple design, use new technologies like HTML5, WebGL and the latest, fastest browsers to make sure you have all the power of the web behind you," explains Google.

Google promises to improve the user interface in Gmail in the coming months, but I think that many other apps will be redesigned and the main goal is to integrate with Google+. If you want a preview of Google's new interfaces, take a look at the Google+ project. Here's, for example, the new Google Maps design:


It's interesting to see that Google Maps added the label-less blue button from Google+, but Google Search still uses the regular button.

{ Thanks, Nikita. }

The Google+ Project

Google revealed some details about the project that will make Google more social. It's called Google+ and it's an extension of the existing Google Profiles and Buzz, with many new features that make sharing more useful. Google's plan to compete with Facebook is to bring "the subtlety and substance of real-world interactions" to the Web.


Google+ means "Google + You", so it's all about your friends, your photos and videos, your interests and your conversations. The service introduces circles, a way to group your friends and share content with the right people. "Today's online services turn friendship into fast food—wrapping everyone in 'friend' paper — and sharing really suffers. From close family to foodies, we found that people already use real-life circles to express themselves, and to share with precisely the right folks. So we did the only thing that made sense: we brought Circles to software. Just make a circle, add your people, and share what's new."



To help you share content with your "circles" of friends, Google added an app called Sparks that shows interesting new Web pages related to your interests. It's like a feed reader that has a list of tags instead of subscriptions, so it's much easier to set up. "The web, of course, is filled with great content — from timely articles to vibrant photos to funny videos. And great content can lead to great conversations. We noticed, however, that it's still too hard to find and share the things we care about— not without lots of work, and lots of noise. So, we built an online sharing engine called Sparks. Thanks to Google's web expertise, Sparks delivers a feed of highly contagious content from across the Internet. On any topic you want, in over 40 languages. Simply add your interests, and you'll always have something to watch, read and share."


Google+ also comes with an online video conferencing tool called Hangouts. It's just like Google Talk, except that you can add multiple people and they can join the "chat room" without being invited. "With Google+ we wanted to make on-screen gatherings fun, fluid and serendipitous, so we created Hangouts. By combining the casual meetup with live multi-person video, Hangouts lets you stop by when you're free, and spend time with your Circles," explains Google.

Google's social networks is also available on your mobile phone using a dedicated Android app and an upcoming iPhone app. The mobile experience is all about location, photos and conversations. You can add your location to all your posts, share the photos from your phone's camera album immediately after they're created and chat with your friends using Huddle.



Google+ requires an invitation, but you can't get one right now. "We're testing with a small number of people, but it won't be long before the Google+ project is ready for everyone," explains Google.

The black navigation bar that's tested right now in Google's search results pages is all about Google+. Here's how the navigation bar will look:


After years of missing the value of social networking, Google tries to catch up with Facebook and show that it can still create amazing products. Google+ will be the first tab from Google's homepage and it will get a lot of exposure, but not many people associate Google with social products. Google will probably have to redesign many of its services and make Google+ a central part of the Google experience, which means that Google will change a lot in the coming months.



{ Thanks, Gorilla. }

Monday, June 27, 2011

FTC's Google Probe

Google confirmed that the U.S. Federal Trade Commission has began a review of Google's business practices after many companies complained that Google used its dominance in the search market unfairly. "Those companies said that Google's anticompetitive practices include using other companies' content without their permission, deceptive display of search results, manipulation of search results to favor Google's products, and buying up competitive threats to its dominance," informs the Wall Street Journal. "The widely trailed investigation is the most significant in Google's 12-year history, on a par with the lengthy Department of Justice probe into Microsoft, which led to tighter regulation and from which the technology giant's image has never fully recovered," writes the Guardian.

Google says that this review is similar to the European Commission review. Last year, the European Commission notified Google that it has received complaints from three companies who claim that Google imposes unfair penalties on competing sites and uses Universal Search as an opportunity to promote its own services. Google argues that it's not a monopoly in search as "the cost of switching to a different search engine is zero". Google also says that its results are "a type of mathematically-derived opinion" and that Google was built for consumers, not websites.

"Search is much different than a utility. With you electricity provider, your telephone provider and your cable provider, there’s generally one cable coming into your home, and you have only one or two choices about which provider to pay for services. With the Internet, web services are only a click away. Google is like a GPS to the Internet – a helpful guide, but not necessary if you know where you're going," explains Google.

The cost of switching to a different search engine is certainly not zero. Google's brand is very powerful and for some people it's synonymous with search. It's also difficult to use another search engine that has a different interface, other features and doesn't know too much about you. Google is the default search engine in all important browsers, except Internet Explorer and Chrome, which doesn't have a default search engine.

Danny Sullivan says that Google's first real antitrust challenge started after announcing the intention to acquire DoubleClick, back in 2007. The likelihood of an antitrust suit made Google change its mind about the Yahoo search deal. Google barely managed to convince the FTC that it's OK to buy AdMob and the ITA acquisition has a lot of strings attached.

Google will continue to have a difficult time acquiring big companies and even startups, while the long list of investigations and lawsuits could slow Google down.

Gmail's New Inbox Styles

Gmail's Priority Inbox is an advanced version of the regular inbox, with customizable sections for power users. For some people, Priority Inbox looked intimidating, so that's probably the reason why Gmail tests a new version of the regular inbox that integrates Priority Inbox and three lightweight versions of the Priority Inbox.

"Try out all the new inbox styles to see what fits you best. You can always switch back if you change your mind," informs a Gmail promotional box. There are five inbox types: classic, important first, unread first, starred first and Priority Inbox. The three new inbox types could easily be obtained by customizing Priority Inbox, but it's much easier to switch between them. It's the first time when Google uses tabs in Gmail interface if you exclude Gmail's settings page.



{ Thanks, Hugh and Evan. }

A New Google Homepage Experiment

Another day, another Google experiment. This time, Google tests a new design for the homepage that combines two experimental features that have already been used (the black navigation bar and the blue search button) with a new way to display the links to Google's corporate pages: at the bottom of the page.


Google has been testing a lot of UI changes for the homepage and the search results pages and it's obvious that some of them will be included in a new interface that will be released soon. Google does away with many traditional features (the "I'm Feeling Lucky" button could be removed from the homepage, the link to the cached version of a search result could be hidden, while snippet URLs could be replaced by the name of the site) and tries to emphasize the navigation bar, which is likely to include new social features.

{ Thanks, Riccardo and Pascal. }

Sunday, June 26, 2011

Find Similar Images from a Site

Google Image Search has a nifty feature that was added a couple of months ago, but it's not so easy to find. If you restrict the results to a site and click "similar" next to one of the images, Google will only show similar images from that site. For example, if you search for [paris site:wikipedia.org] and click "similar" next to a photo of the Eiffel Tour, Google will show pictures of the Eiffel Tour and other similar monuments from Paris, but only if they are included in a Wikipedia page.



It's a great way to explore a site and group related images when it's difficult to type a precise query. The top results provided by the Similar Images feature are much better than the results for [monuments in Paris site:wikipedia.org], where you can find maps, flags, logos.


It's important to note that Google Image Search's site: operator no longer takes into account the URL of the image, so if a blog includes an image from Flickr, you'll still be able to find the image when you restrict the image results to the blog's domain or subdomain. "In the past, the [site:] operator filtered based on the image URL, not based on the URL of web pages linking to the images. Now, the operator will run your search over web sites that include images, no matter where the images themselves are hosted, which removes a lot of noise from your results and gives you more control over what you're searching for."

Saturday, June 25, 2011

Google's Experimental Black Navigation Bar

A while ago, I spotted a black navigation bar in a Google page and wondered if it's a bug or a new Google experiment. It turns out that it's yet another experiment.

At least three readers of this blog saw the black navigation bar on Google's homepage today.



YouTube also tests a black player, so the two experiments could be connected.

Update: A lot of people see the new design, so it's hard to say if it's a test or a gradual roll-out. If you clear Google's cookies, do you still see the black bar?

{ Thanks, David, Francesc and Don. }

Friday, June 24, 2011

Enable Google Toolbar in Firefox 5

If you've installed Firefox 5 and noticed that Google Toolbar wasn't updated to support the new Firefox release, there's a simple way to enable the extension: install the Add-on Compatibility Reporter. "After installing the Add-on Compatibility Reporter, your incompatible extensions will become enabled for you to test whether they still work with the version of Firefox or Thunderbird that you're using." This should only be a temporary solution until Google Toolbar and other extensions update their compatibility list.



Google Toolbar 7 works well in Firefox 5, especially considering that the new Firefox version didn't make too many important extension-related changes.

Firefox's faster release cycle, inspired by Google Chrome, has an important downside: extension developers need to update their extensions more frequently and update the list of Firefox versions that are supported. Mozilla alleviated this problem by automatically marking almost 4,000 extensions as compatible with Firefox 5, but Google Toolbar is not hosted by Mozilla and it's downloaded from Google's servers.

YouTube Tests a Black Player

A few readers spotted a new YouTube player with a redesigned control bar that uses a black background. The current control bar doesn't stand out so that you can focus on the video you are watching.


A YouTube user says that he "would really appreciate a way to go back to the normal player, with its more obvious progress bar and less ugly/hyperactive popup controls". I really like the bigger pause button, but YouTube should also change the action buttons below the player to better integrate in the new design.


{ Thanks, Josh and Jon. }

How to Use Google Music on an iPad or iPhone

I mentioned in a previous post that you can use Google Music Beta on an iPad and even on an iPhone or iPod Touch, but some users complained that it didn't work for them. Google Music loads well, but after clicking the "play" button nothing happens.

Here's a trick to make Google Music work every time: start playing a song, pause and play again. It's unfortunate that you have to use a workaround, but Google Music doesn't officially support Safari for iOS. The system requirements page says that it only supports "Google Chrome, Firefox, Safari, and Internet Explorer 7 and above" and that you need Adobe Flash.


It's interesting that this trick lets you play music on more than one device simultaneously. For example, I was able to play music on my iPad and iPhone at the same time, even if Google says that "music from your library cannot be played simultaneously on more than one device". The unofficial non-Flash interface is an unexpected loophole.

Thursday, June 23, 2011

A Deep Dive Into Location

[This post is by Reto Meier, Tech Lead for Android Developer Relations, who wrote the book on Android App development. — Tim Bray]

I'm a big fan of location-based apps, but not their seemingly-inevitable startup latency.

Whether it's finding a place to eat or searching for the nearest Boris Bike, I find the delay while waiting for the GPS to get a fix, and then for the results list to populate, to be interminable. Once I’m in a venue and ready to get some tips, check-in, or review the food, I’m frequently thwarted by a lack of data connection.

Rather than shaking my fist at the sky, I’ve written an open-source reference app that incorporates all of the tips, tricks, and cheats I know to reduce the time between opening an app and seeing an up-to-date list of nearby venues - as well as providing a reasonable level of offline support — all while keeping the impact on battery life to a minimum.

Show Me the Code

You can check-out the Android Protips for Location open source project from Google Code. Don’t forget to read the Readme.txt for the steps required to make it compile and run successfully.

What Does it Actually Do?

It uses the Google Places API to implement the core functionality of apps that use location to provide a list of nearby points of interest, drill down into their details, and then check-in/rate/review them.

The code implements many of the best-practices I detailed in my Google I/O 2011 session, Android Protips: Advanced Topics for Expert Android Developers (video), including using Intents to receive location updates, using the Passive Location Provider, using and monitoring device state to vary refresh rates, toggling your manifest Receivers at runtime, and using the Cursor Loader.

The app targets Honeycomb but supports Android platforms from 1.6 and up.

Nothing would make me happier than for you to cut/copy/borrow / steal this code to build better location-based apps. If you do, I’d love it if you told me about it!

Now that you’ve got the code, let’s take a closer look at it

My top priority was freshness: Minimize the latency between opening the app and being able to check in to a desired location, while still minimizing the impact of the app on battery life.

Related requirements:

  • The current location has to be found as quickly as possible.


  • The list of venues should update when the location changes.


  • The list of nearby locations and their details must be available when we’re offline.


  • Check-ins must be possible while we’re offline.


  • Location data and other user data must be handled properly (see our prior blog post on best practices).


Freshness means never having to wait

You can significantly reduce the latency for getting your first location fix by retrieving the last known location from the Location Manager each time the app is resumed.

In this snippet taken from the GingerbreadLastLocationFinder, we iterate through each location provider on the device — including those that aren't currently available — to find the most timely and accurate last known location.

List<String> matchingProviders = locationManager.getAllProviders();
for (String provider: matchingProviders) {
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
float accuracy = location.getAccuracy();
long time = location.getTime();

if ((time > minTime && accuracy < bestAccuracy)) {
bestResult = location;
bestAccuracy = accuracy;
bestTime = time;
}
else if (time < minTime &&
bestAccuracy == Float.MAX_VALUE && time > bestTime){
bestResult = location;
bestTime = time;
}
}
}

If there is one or more locations available from within the allowed latency, we return the most accurate one. If not, we simply return the most recent result.

In the latter case (where it’s determined that the last location update isn't recent enough) this newest result is still returned, but we also request a single location update using that fastest location provider available.

if (locationListener != null &&
(bestTime < maxTime || bestAccuracy > maxDistance)) {
IntentFilter locIntentFilter = new IntentFilter(SINGLE_LOCATION_UPDATE_ACTION);
context.registerReceiver(singleUpdateReceiver, locIntentFilter);
locationManager.requestSingleUpdate(criteria, singleUpatePI);
}

Unfortunately we can’t specify “fastest” when using Criteria to choose a location provider, but in practice we know that coarser providers — particularly the network location provider — tend to return results faster than the more accurate options. In this case I’ve requested coarse accuracy and low power in order to select the Network Provider when it’s available.

Note also that this code snippet shows the GingerbreadLastLocationFinder which uses the requestSingleUpdate method to receive a one-shot location update. This wasn’t available prior to Gingerbread - check out the LegacyLastLocationFinder to see how I have implemented the same functionality for devices running earlier platform versions.

The singleUpdateReceiver passes the received update back to the calling class through a registered Location Listener.

protected BroadcastReceiver singleUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
context.unregisterReceiver(singleUpdateReceiver);

String key = LocationManager.KEY_LOCATION_CHANGED;
Location location = (Location)intent.getExtras().get(key);

if (locationListener != null && location != null)
locationListener.onLocationChanged(location);

locationManager.removeUpdates(singleUpatePI);
}
};

Use Intents to receive location updates

Having obtained the most accurate/timely estimate of our current location, we also want to receive location updates.

The PlacesConstants class includes a number of values that determine the frequency of location updates (and the associated server polling). Tweak them to ensure that updates occur exactly as often as required.

// The default search radius when searching for places nearby.
public static int DEFAULT_RADIUS = 150;
// The maximum distance the user should travel between location updates.
public static int MAX_DISTANCE = DEFAULT_RADIUS/2;
// The maximum time that should pass before the user gets a location update.
public static long MAX_TIME = AlarmManager.INTERVAL_FIFTEEN_MINUTES;

The next step is to request the location updates from the Location Manager. In this snippet taken from the GingerbreadLocationUpdateRequester we can pass the Criteria used to determine which Location Provider to request updates from directly into the requestLocationUpdates call.

public void requestLocationUpdates(long minTime, long minDistance, 
Criteria criteria, PendingIntent pendingIntent) {

locationManager.requestLocationUpdates(minTime, minDistance,
criteria, pendingIntent);
}

Note that we're passing in a Pending Intent rather than a Location Listener.

Intent activeIntent = new Intent(this, LocationChangedReceiver.class);
locationListenerPendingIntent =
PendingIntent.getBroadcast(this, 0, activeIntent, PendingIntent.FLAG_UPDATE_CURRENT);

I generally prefer this over using Location Listeners as it offers the flexibility of registering receivers in multiple Activities or Services, or directly in the manifest.

In this app, a new location means an updated list of nearby venues. This happens via a Service that makes a server query and updates the Content Provider that populates the place list.

Because the location change isn’t directly updating the UI, it makes sense to create and register the associated LocationChangedReceiver in the manifest rather than the main Activity.

<receiver android:name=".receivers.LocationChangedReceiver"/>

The Location Changed Receiver extracts the location from each update and starts the PlaceUpdateService to refresh the database of nearby locations.

if (intent.hasExtra(locationKey)) {
Location location = (Location)intent.getExtras().get(locationKey);
Log.d(TAG, "Actively Updating place list");
Intent updateServiceIntent =
new Intent(context, PlacesConstants.SUPPORTS_ECLAIR ? EclairPlacesUpdateService.class : PlacesUpdateService.class);
updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_LOCATION, location);
updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_RADIUS, PlacesConstants.DEFAULT_RADIUS);
updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, true);

context.startService(updateServiceIntent);
}

Monitor inactive providers for a better option

The snippet from PlacesActivity below shows how to monitor two important conditions:

  • The Location Provider we are using being deactivated.


  • A better Location Provider becoming available.


In either case, we simply re-run the process used to determine the best available provider and request location updates.

// Register a receiver that listens for when the provider I'm using has been disabled. 
IntentFilter intentFilter = new IntentFilter(PlacesConstants.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED);
registerReceiver(locProviderDisabledReceiver, intentFilter);

// Listen for a better provider becoming available.
String bestProvider = locationManager.getBestProvider(criteria, false);
String bestAvailableProvider = locationManager.getBestProvider(criteria, true);
if (bestProvider != null && !bestProvider.equals(bestAvailableProvider))
locationManager.requestLocationUpdates(bestProvider, 0, 0,
bestInactiveLocationProviderListener, getMainLooper());

Freshness means always being up to date. What if we could reduce startup latency to zero?

You can start the PlacesUpdateService in the background to refresh the list of nearby locations while your app is in the background. Done correctly, a relevant list of venues can be immediately available when you open the app.

Done poorly, your users will never find this out as you’ll have drained their battery too quickly.

Requesting location updates (particularly using the GPS) while your app isn’t in the foreground is poor practice, as it can significantly impact battery life. Instead, you can use the Passive Location Provider to receive location updates alongside other apps that have already requested them.

This extract from the FroyoLocationUpdateRequester enables passive updates on Froyo+ platforms.

public void requestPassiveLocationUpdates(long minTime, long minDistance, PendingIntent pendingIntent) {
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER,
PlacesConstants.MAX_TIME, PlacesConstants.MAX_DISTANCE, pendingIntent);
}

As a result receiving background location updates is effectively free! Unfortunately the battery cost of your server downloads aren’t, so you’ll still need to carefully balance how often you act on passive location updates with battery life.

You can achieve a similar effect in pre-Froyo devices using inexact repeating non-wake alarms as shown in the LegacyLocationUpdateRequester.

public void requestPassiveLocationUpdates(long minTime, long minDistance, 
PendingIntent pendingIntent) {

alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
System.currentTimeMillis()+PlacesConstants.MAX_TIME,
PlacesConstants.MAX_TIME, pendingIntent);
}

Rather than receiving updates from the Location Manager, this technique manually checks the last known location at a frequency determined by the maximum location update latency.

This legacy technique is significantly less efficient, so you may choose to simply disable background updates on pre-Froyo devices.

We handle updates themselves within the PassiveLocationChangedReceiver which determines the current location and starts the PlaceUpdateService.

if (location != null) {
Intent updateServiceIntent =
new Intent(context, PlacesConstants.SUPPORTS_ECLAIR ? EclairPlacesUpdateService.class : PlacesUpdateService.class);

updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_LOCATION, location);
updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_RADIUS,
PlacesConstants.DEFAULT_RADIUS);
updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, false);
context.startService(updateServiceIntent);
}

Using Intents to passively receive location updates when your app isn't active

You’ll note that we registered the Passive Location Changed Receiver in the application manifest.

<receiver android:name=".receivers.PassiveLocationChangedReceiver"/>

As a result we can continue to receive these background updates even when the application has been killed by the system to free resources.

This offers the significant advantage of allowing the system to reclaim the resources used by your app, while still retaining the advantages of a zero latency startup.

If your app recognizes the concept of “exiting” (typically when the user clicks the back button on your home screen), it’s good form to turn off passive location updates - including disabling your passive manifest Receiver.

Being fresh means working offline

To add offline support we start by caching all our lookup results to the PlacesContentProvider and PlaceDetailsContentProvider.

Under certain circumstances we will also pre-fetch location details. This snippet from the PlacesUpdateService shows how pre-fetching is enabled for a limited number of locations.

Note that pre-fetching is also potentially disabled while on mobile data networks or when the battery is low.

if ((prefetchCount < PlacesConstants.PREFETCH_LIMIT) &&
(!PlacesConstants.PREFETCH_ON_WIFI_ONLY || !mobileData) &&
(!PlacesConstants.DISABLE_PREFETCH_ON_LOW_BATTERY || !lowBattery)) {
prefetchCount++;

// Start the PlaceDetailsUpdateService to prefetch the details for this place.
}

We use a similar technique to provide support for offline checkins. The PlaceCheckinService queues failed checkins, and checkins attempted while offline, to be retried (in order) when the ConnectivityChangedReceiver determines that we’re back online.

Optimizing battery life: Smart Services and using device state to toggle your manifest Receivers

There's no point running update services when we aren’t online, so the PlaceUpdateService checks for connectivity before attempting an update.

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();

If we’re not connected, the Passive and Active Location Changed Receivers are disabled and the the ConnectivityChangedReceiver is turned on.

ComponentName connectivityReceiver = 
new ComponentName(this, ConnectivityChangedReceiver.class);
ComponentName locationReceiver =
new ComponentName(this, LocationChangedReceiver.class);
ComponentName passiveLocationReceiver =
new ComponentName(this, PassiveLocationChangedReceiver.class);

pm.setComponentEnabledSetting(connectivityReceiver,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);

pm.setComponentEnabledSetting(locationReceiver,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);

pm.setComponentEnabledSetting(passiveLocationReceiver,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);

The ConnectivityChangedReceiver listens for connectivity changes. When a new connection is made, it simply disables itself and re-enables the location listeners.

Monitoring battery state to reduce functionality and save power

When your phone is on its last 15%, most apps are firmly in the back seat to conserving what watts you have remaining. We can register manifest Receivers to be alerted when the device enters or leaves the low battery state.

<receiver android:name=".receivers.PowerStateChangedReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_BATTERY_LOW"/>
<action android:name="android.intent.action.ACTION_BATTERY_OKAY"/>
</intent-filter>
</receiver>

This snippet from the PowerStateChangedReceiver disables the PassiveLocationChangedReceiver whenever the device enters a low battery state, and turns it back on once the battery level is okay.

boolean batteryLow = intent.getAction().equals(Intent.ACTION_BATTERY_LOW);

pm.setComponentEnabledSetting(passiveLocationReceiver,
batteryLow ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED :
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);

You can extend this logic to disable all prefetching or reduce the frequency of your updates during low battery conditions.

What’s Next?

This is already a monster post, so I’m going to leave it there. I’ll follow up in the next week with a post on my personal blog, The Radioactive Yak, that will go in to more detail on the psychic and smooth elements of this app like using the Backup Manager and the Cursor Loader.

I also plan to build a similar reference app for news apps, so that I can spend more time reading and less time waiting.

In the mean time, happy coding!

A Chrome Extension for Google Music

While there's no official extension for Google Music and not even an app in the Chrome Web Store, you can install a really cool third-party extension called "Better Music Beta". The extension adds a button that shows information about the currently playing song, lets you pause the song, go to the next song, add a thumbs up or a thumbs down. There's also a notification that shows up every time the song changes.

My favorite feature is the Last.fm integration: if you enable it, Better Music Beta scrobbles your songs and lets you publicly show that you love a song by clicking the "heart" icon.

The downside is that you still have to open Google Music in a tab, since the music stops playing if you close the tab. Converting the extension into a "background app" would solve this problem.


Google Music requires an invitation and it's supposed to be US-only, but it works even if you're not in the US. Google only checks your location when you request an invitation and you can always use a US proxy for this one-time action. Another interesting thing is that, even though Google Music lists Flash as a requirement, the service works pretty well on an iPad.

Wednesday, June 22, 2011

Box.net Integrates with Google Docs

Box.net, a popular online storage service, added an option that allows its users to create and edit documents and spreadsheets using Google Docs, but without leaving Box.net. The files are stored by Box.net, but they can be edited using the regular Google Docs interface.



"Beginning today, Box's 6 million users can easily create and collaborate on Google Docs and Spreadsheets from within Box, as well as edit the existing 50M+ Word and Excel files already stored on our platform. Google Docs enable entirely new forms of collaboration – like concurrent editing – that are impossible within desktop applications, and now these capabilities are easily available to Box users. We believe that the combination of Google Docs' collaborative editing and Box's content management will transform the way people work," suggests Box's blog.

The integration has a lot of quirks: Google Docs still displays the navigational bar and some options that only makes sense for Google's services. When you edit a document from Box.net, the file is temporarily added to the Google Docs list, but it's quickly removed after the editing window is closed. At some point, Google Docs will also add support for third-party apps, so it will be interesting to see if this feature will be better implemented.

{ via Read Write Web }

Chrome 14 Blocks Insecure JavaScript

Chrome 14, only available in the Dev and Canary channels right now, adds a security feature that could affect a lot of sites. If you're visiting an SSL site that loads some scripts using unencrypted connections, Chrome will refuse to load the scripts.


When a website is secured via HTTPS, the web site designer must also ensure that all of the scripts used by the page will be delivered in the same secure manner as the main page itself. The same requirements also apply to the plugins and external CSS stylesheets used by the page, as these have the same considerations as javascript. When this is not the case (sometimes called a 'mixed script' situation), visitors to the site run the risk that attackers can interfere with the website and change the script so as to serve their own purposes.

Traditionally, browsers have run the mixed script, genuine or not, and notified you after-the-fact by a broken lock icon, a dialog box, or a red https:// in the location bar (in the case of Google Chrome). The problem with this approach is that by the time the script has run, it is already too late, because the script has had access to all of the data on the page. Google Chrome now protects you by refusing up-front to run any script on a secure page unless it is also being delivered over HTTPS.

You can bypass this feature by clicking "Load anyway" in the infobar displayed at the top of the page, but Chrome doesn't remember your preference. Unfortunately, you can't whitelist a domain or a subdomain, so you'll have to click "Load anyway" and wait until the page is reloaded. There's a command-line flag that lets you disable this feature: --allow-running-insecure-content, but Google says that it should only be used by "users and admins who have internal applications without immediate fixes for these errors".

Chrome has recently added many other security features, including a function for generating strong random numbers, a way to force HTTPS for any domain you want, an initial implementation of Content Security Policy that helps protect against Cross Site Scripting and a more secure Gmail that uses HTTPS for all connections, even when you type "gmail.com" in the address bar.

Mobile Gmail Adds "Pull Down to Refresh"

Gmail's mobile Web app for iOS added a feature first available in Tweetie, which is now the official Twitter client for iPhone and iPad. Instead of clicking a button to refresh the list of messages, you simply pull down the list and wait to see the new messages. It's a really intuitive way to update a list and many mobile apps started to use it.


"One thing that's cool about Tweetie 2 is the fresh paradigm to refreshing the contents of a table view. Up until now we had been looking for space to mount a reload button on, sometimes having to resort to adding an extra tool bar for just one view so that you can have enough space. Now if you have a tableview that it sorted reverse chronologically, then you have a natural urge to make new items appear at the top by pulling down the table with extra force," suggested Oliver Drobnik back in 2009, when Tweetie added this feature, which is now available in mobile Gmail.

Google Translate Supports 5 Indic Languages

Google Translate has improved a lot in the past 3 years and it's now the most powerful machine translation service that's available for free. Google Translate is the only machine translation service which supports languages that have less than one million speakers (Maltese, Welsh) and languages that are underrepresented on the Web (Galician).

Google added 5 new languages to Google Translate and they're some of the most popular languages in the world, with more than 600 million speakers: Bengali (300 million speakers), Gujarati (46 million), Kannada (51 million), Tamil (65 million), Telugu (130 million).

"Beginning today, you can explore the linguistic diversity of the Indian sub-continent with Google Translate, which now supports five new experimental alpha languages. (...) You can expect translations for these new alpha languages to be less fluent and include many more untranslated words than some of our more mature languages—like Spanish or Chinese — which have much more of the web content that powers our statistical machine translation approach. (...) Since these languages each have their own unique scripts, we've enabled a transliterated input method for those of you without Indian language keyboards," informs Google.


Google Translate now supports 63 languages and 9 of the 10 languages that have more than 100 million native speakers. The only missing language is Punjabi.

Tuesday, June 21, 2011

Google's New Currency Converter

Google updated the OneBox for currency conversion. Until recently, when you searched for [1 usd in eur] or [200 gbp to peso], Google displayed the result and that was it. The new OneBox includes a graph for historical exchange rates and an interactive tool that lets you select a different currency from a long list or change the value you want to covert and instantly get the result.




A similar tool is available at Google Finance, but it's more convenient to access it from Google Search and you don't need to search for USDEUR to convert US dollars to euros. For some reason, when you search for [currency converter] from the US, Google tries to be helpful and shows that 1 US dollar = 0.6957 euros.

{ Thanks, Aahan. }

Monday, June 20, 2011

Things That Cannot Change

[This post is by Dianne Hackborn, whose fingerprints can be found all over the Android Application Framework — Tim Bray]

Sometimes a developer will make a change to an application that has surprising results when installed as an update to a previous version — shortcuts break, widgets disappear, or it can’t even be installed at all. There are certain parts of an application that are immutable once you publish it, and you can avoid surprises by understanding them.

Your package name and certificate

The most obvious and visible of these is the “manifest package name,” the unique name you give to your application in its AndroidManifest.xml. The name uses a Java-language-style naming convention, with Internet domain ownership helping to avoid name collisions. For example, since Google owns the domain “google.com”, the manifest package names of all of our applications should start with “com.google.” It’s important for developers to follow this convention in order to avoid conflicts with other developers.

Once you publish your application under its manifest package name, this is the unique identity of the application forever more. Switching to a different name results in an entirely new application, one that can’t be installed as an update to the existing application.

Just as important as the manifest package name is the certificate that application is signed with. The signing certificate represents the author of the application. If you change the certificate an application is signed with, it is now a different application because it comes from a different author. This different application can’t be uploaded to Market as an update to the original application, nor can it be installed onto a device as an update.

The exact behavior the user sees when installing an application that has changed in one of these two ways is different:

  • If the manifest package name has changed, the new application will be installed alongside the old application, so they both co-exist on the user’s device at the same time.

  • If the signing certificate changes, trying to install the new application on to the device will fail until the old version is uninstalled.

If you change the signing certificate of your application, you should always change its manifest package name as well to avoid failures when it’s installed. In other words, the application coming from a different author makes it a different application, and its package name should be changed appropriately to reflect that. (Of course it’s fine to use the same package name for the development builds of your app signed with your test keys, because these are not published.)

Your AndroidManifest.xml is a public API

More than just your package name that is immutable. A major function of the AndroidManifest.xml is essentially to declare a public API from your application for use by other applications and the Android system. Every component you declare in the manifest that is not private (that is whose android:exported state is true) should be treated as a public API and never changed in a way that breaks compatibility.

A subtle but important aspect of what constitutes a break in compatibility is the android:name attribute of your activity, service, and receiver components. This can be surprising because we think of android:name as pointing to the private code implementing our application, but it is also (in combination with the manifest package name) the official unique public name for that component, as represented by the ComponentName class.

Changing the component name inside of an application can have negative consequences for your users. Some examples are:

  • If the name of a main activity of your application is changed, any shortcuts the user made to it will no longer work. A shortcut is an Intent that directly specifies the ComponentName it should run.

  • If the name of a service implementing a Live Wallpaper changes, then a user who has enabled your Live Wallpaper will have their wallpaper revert to the system default when getting the new version of your app. The same is true for Input Methods, Accessibility Services, Honeycomb’s new advanced Widgets, and so on.

  • If the name of a receiver implementing a Device Admin changes, then as with the live wallpaper example, the device admin will be disabled when the application is updated. This also applies to other kinds of receivers, such as App Widgets.

These behaviors are an outcome of how the Intent system is used on Android. There are two main kinds of Intents:

  • Implicit Intents only specify “what” they should match, using actions, categories, data, MIME types, and so on. The exact components that they will find are only determined at run-time, by the Package Manager matching it against the current applications.

  • Explicit Intents specify a single explicit “who” they should match, through a ComponentName. Regardless of whatever else is in the Intent, it is only associated with the exact manifest package name and class name as given in its ComponentName.

Both of these types of Intents are important to how Android interacts with your application. A typical example of this is how users browse and select live wallpapers.

To let the user pick a live wallpaper, the first thing Android must do is show them a list of the available live wallpaper services. It does this by building an implicit Intent with the appropriate action for a live wallpaper and asking the Package Manager for all services that support this Intent. The result is then the list of live wallpapers shown to the user.

When the user actually selects a specific live wallpaper they want to use, however, Android now must build an explicit Intent that identifies that particular live wallpaper. This is what is handed to the WallpaperManager to tell it which wallpaper to show.

This is why changing the name of the component in your manifest will cause the wallpaper to disappear: the explicit Intent that was previously saved is now invalid because the ComponentName it references no longer exists. There is no information available to indicate what the new name of the component is. (For example consider if your application had two different live wallpaper services the user could select.) Instead, Android must treat that live wallpaper as uninstalled and revert to its default wallpaper.

This is how input methods, device administrators, account managers, app widgets, and even application shortcuts work. The ComponentName is the public unique name of the components you declare in your manifest, and must not change if they are visible to other applications.

In conclusion: There are some parts of your application that can not change. Please be careful.

Saturday, June 18, 2011

Google's Gay Rainbow

It's not the first June when Google changes the search results interface when you search for [gay] and other related terms. While in 2009 and 2010 Google added a colorful bar below the search box, this year there's a rainbow next to the search box.


June is the "Gay and Lesbian Pride Month" and there are many pride parades all over the world. Last year, Google's blog included an article about gay parades and the Google employees who participated.

"Google supports its LGBT employees in many ways: raising its voice in matters of policy, taking a moment to remember the plight of transgender people around the world and going the extra mile to ensure that its employees are treated fairly."

{ Thanks, multilind. }

Google Docs Tests Offline Support, Powered by HTML5

Google Docs team promised to bring back offline support this summer, but some traces of the new offline interface are already available. "I logged into Docs today and saw this! It's not yet functional, but an exciting sign! The code is being pushed," says Owen, a reader of this blog.


Angelo "saw a black bar flash up on screen quickly when loading the DocList of [his] Google Apps account". After a few refreshes, he managed to see the bar that lets you switch to the offline mode. Unfortunately, Google Docs doesn't work offline, at least not yet.

In a recent Reddit thread, a member of the Google Docs team said that "you're going to see offline start to roll out later this summer. We used to have offline with Google Gears, but it became pretty clear that plugins weren't the right approach. We've been reimplementing offline using HTML5 standards like AppCache, File API, and IndexDB We're some of the first webapps that are really putting those standards to the test, so it's taken a while to iron out the kinks."

{ Thanks, Owen and Angelo. }

Google Could Add Face Recognition to Google Profiles

Florian Rohrweck found a lot of interesting things analyzing Google's code. For example, Google Profiles will add an option that will allow Google to recognize your face in other people's photos. Picasa Web's name tags can become global: a new section from your profile titled "photos of you" will list the photos from other people where you are tagged. Google provides an approval mechanism, so you can reject some of the photos. "When a tag is approved, it is linked to your profile, and the photo is added to the 'Photos of you' section."


Google Profiles will include a new tab for videos, a photo editing feature, you'll be able to group your friends in "circles", chat from Google Profiles and add gadgets. There's also a "camera sync" feature that could automatically upload the photos from the "camera" album of a mobile phone or tablet.


As expected, Google Profiles is the place where Google's social efforts are most visible. Buzz will be a back-end service for activity streams and not a standalone service. Google Profiles could eventually replace iGoogle, since it will add support for gadgets and it will include the most interesting items shared by the people you're following.

{ Thanks, Florian. }

Chromification of the Operating System

Three years ago, when Google launched Chrome many people wondered if it will be successful. Chrome became a very popular browser, with more than 160 million active users, but its most important achievement was accelerating the development of all the other browsers and shifting their priorities from adding UI features to removing clutter, making them faster and better suited for running Web apps. Internet Explorer embraced HTML5, Firefox started to update more often, Opera simplified its interface. Google started from the scratch and created a browser for today's Web apps.


For some, Chrome OS may seem pointless. Why buy a notebook that can only run a single program, when you can install Chrome on your existing computer? But why switch from Firefox to a browser that doesn't support advanced extensions? After all, Firefox is a lot more customizable than Chrome since any extension can dramatically alter the interface and integrate with the browser. It turns out that Firefox extensions can sometimes slow down the browser, some use a lot of resources, they're difficult to update and every new major release can break them. Chrome's extensions are less powerful, but they don't slow down the browser, they're easier to develop and to maintain and major new releases rarely break them.

Just like Chrome influenced all the other important browsers, Chrome OS will change the other operating systems. Sandboxing applications can make the operating system a lot more secure, saving your settings and files online allows you to use them from any other computer, Web applications are powerful enough to replace some of the native apps and they don't live on your computer, so they can be constantly updated. Even Windows intends to switch to "Web-powered apps built using HTML5 and JavaScript that have access to the full power of the PC" in the next major release, while still supporting "legacy" apps. It's obvious that most of the apps will eventually migrate to the Web and Chrome OS is better suited to support them because it doesn't have to worry about legacy apps and because it's designed just like a Google Web app: constantly updated, fast, clutter-free. "The future is already here – it's just not evenly distributed," said William Gibson. Chrome OS is ready... when you are.


{ image from the Chrome Comic Book, licensed by Google as Creative Commons }

Google Tests a New Interface

Another day, another Google experiment. This time, Google tests a new search button inspired by Bing and removes the "I'm Feeling Lucky" button from the homepage, probably because it's no longer useful. Google Instant makes the search button unnecessary most of the time, so Google could remove it altogether. It's interesting that the new design emphasizes the search button instead of making it less prominent.


Google's experiment highlights the header of the search results pages and uses gray/red icons and labels in the vertical navigation menu. Another change is that the "cached" and "similar" links are placed in the Instant Preview box, so they're more difficult to find.



All the icons and images for this experiment are available in a sprite.

{ Thanks, Juuso, François and Websonic. }