Friday, December 31, 2010

Happy New Year 2011

Wishing you and your family a very happy and prosperous new year 2011. :)

 Happy new year 2011

-- Varun

Thursday, December 30, 2010

[How to] Change the boot screen animation on Android

Smartphones are getting smarter day-by-day with cool new features. Still the best part of any Smartphone is its support for personalization. Android allows you to personalize almost anything and everything on your device. Boot screen animation is no exception. If you are bored with the default boot screen animation on your Android device, you can change it to the one you like. Here is a short tutorial to create new animations or use your favorite video as a boot screen animation. Android boot animation is stored as a zip file (uncompressed) containing the sequence of images used for the animation and a text file containing the meta-information.

 Boot screen animation Sample desc file - desc.txt

Steps to create boot screen animation

  • Preparing the image sequence. Create the animation using multimedia software like Flash. Turn the animation into a sequence of images and name them as “boot_0001.png”, “boot_0002.png”, etc. Flash has the capability to generate image sequence for the animation. To use a video sequence as animation, extract the image sequence from the scene using tools like FFmpeg for windows.
  • Place the images in two directories – part1, part2. The sequence copied inside part1 will be played only once where the one in part2 will be played on a loop until the booting is complete. (This is the commonly used configuration and can be altered via the meta data file)
  • Preparing the meta data. Create a text file and name it as “desc.txt”. This file contains two or more lines of information.
    • First line contains three numbers - width, height and the frames per second. Ex: 480 800 32
    • All the lines except the first one will start with the letter “p” indicating that it is a part of the animation. The line contains three items – count (number of times this part is repeated), pause (number of ms to pause after the last frame of this part), and the path to the directory. Ex: p 1 0 part1. Sample description file is shown in the screenshot above.
  • Packaging & installing the animation. Now that the images and meta-info file are ready, we need to package them into a zip file named “bootanimation.zip”. Note: There must be no compression. Once the zip file is ready, push the file to /data/local/. “adb push bootanimation.zip /data/local/.”. Reboot your device to see the new animation.

-- Varun

[via @xda-developers]

Wednesday, December 29, 2010

[Tech] Insight into Google Instant Previews

Google has launched Instant Previews few days ago – a feature which adds screenshot preview of the page along with the search results. The feature does not seem to add much of value addition to search results (as they claim). Nevertheless, the implementation of the feature is rich enough to add huge value for a web developer. Google has employed some neat techniques to ensure that the performance of the search remains the same with this new feature. If you are a web developer or a person interested in learning cool things, you can continue reading rest of the post. And, if you are frustrated with the previews, you can use this script to turn off the feature.

Techniques involved in Google Instant Previews

JavaScript Compilation. Like any other Google products, Google search also uses a lot of JavaScript. JavaScript is minified and crunched using Google’s Closure Compiler. The JavaScript on the results page is loaded lazily so that it does not interfere with the page load. Also, JavaScript is cached very aggressively on the client-side.

On-demand JSONP.  The result previews are loaded only on-demand whenever the user activates it. The browser needs to make asynchronous call to Google servers to get the previews and render it on the screen. Modern browsers have a restriction on the number of concurrent requests the page can send to any host. To overcome this, Google uses a separate domain for hosting the result previews. (Ex: client1.google.com, client2.google.com). Data can be loaded in different ways using JavaScript:

  • Simple AJAX call (XmlHttpRequestXHR) to the server. XHR gives you good control and error handling becomes easy with it. However, XHR does not allow cross-domain access. Only same-origin requests are permitted (Modern browsers have started to support cross-domain access using cross-origin resource sharing). In the case of Instant Previews, the previews need to be fetched from a different sub-domain “client1.google.com”.
  • JSONP. JSONP is another technique where in the requested script returns the desired data as a JSON object wrapped in a JavaScript callback function. Error handling with JSONP is a bit harder to do than XHR but it is not subject to same-origin restrictions. Read this Wiki article to know about the implementation details of JSONP. Google uses this technique to get the result previews. Things to consider while using JSONP:
    1. If you are adding the script tag directly to the page, some of the browsers may show the page loading icon. To avoid that, wrap the DOM call to insert the script in window.setTimeout() – This will be executed in a separate context.
    2. After your requests come back and the processing is done, set the source of the script tag to null and remove the tag. This will prevent the browser from slowing down because of too many script tags. 

Data URIs. The previews shown are not just plain images streamed from the Google server. The data received from the JSONP calls is actually the image data being sent as set of data URIs. (I have used the same technique in VComment – Visual Comment Engine). Data URIs are base64 encodings of image data, that modern browsers can use to display images, instead of loading them from a server as usual. If you have noticed the previews closely, a bounding box will be added to the preview. The usage of data URIs over static images has made this highlighting easier. Data URIs are gzip-compressed to make them comparable in size to the original JPEGs. Data URIs are also aggressively cached on the client-side. 

More information about these techniques can be found here.

Note: This post was originally written in the last week of November 2010. Just realized that it was sitting on my drafts itself.  Well, better late than never. 

-- Varun

Tuesday, December 28, 2010

Start menu for Google Chrome

Most of you would have been already aware of the fact that Google has launched its Chrome web store recently. If you are using the latest versions of Chrome, you can install apps on your Chrome from the web store. Once the app is installed, you can launch it from the popular “New Tab” page of Chrome. A new section titled “Apps” has been added to the “New Tab” page. This section will show the icons of all the installed apps as Thumbnails. Clicking on the app icon will launch the app. If you have a big list of apps installed on your Chrome, it will become difficult to search for the app and launch it from here. To make it simple, Google has built an extension “App Launcher” which will act as a Windows Start Menu for Chrome.

Apps section of "New Tab" page

App Launcher for Chrome

App Launcher for Chrome is an extension built by Google for launching the apps installed on Chrome. Install the extension from here. The extension will add a browser action icon clicking on the same will show a list of installed apps. From there, you can launch an app by either clicking on it in the list, or using arrow keys to select it and then pressing enter. The search box on top of the list is quite handy. (However, you have to use only lower cases while searching. Looks like a bug). With this extension, you can launch an app from any page without having to open the “New Tab” page.

App Launcher

-- Varun

[via @labnol]

Sunday, December 26, 2010

Know about Windows Phone 7 Internals

Earlier I have posted an article titled “Intro to WebSockets” from the Chennai Geeks Techmeet-3. This is another topic discussed at the meet – Windows Phone 7 Internals. The talk was delivered by Balaji Damodaran from Thoughtworks. He gave an overview about the internals of Windows Phone 7 and some of the interesting facts about WP7. Note: This post is not properly structured. Posting the contents from the talk as it was delivered for the benefit of all.

Windows Phone 7

Windows Phone 7 (WP7) Facts

  • WP7 applications are developed using Microsoft XNA & Silverlight. Microsoft XNA is a set of tools provided by Microsoft for Xbox game development. Silverlight is a framework for building rich internet applications. WP7 supports Silverlight 3.
  • WP7 phones will have three buttons – Back, Home, Search. (Apart from Power, Volume Up / Down)
  • WP7 features a new user interface with its design language named Metro. All applications should follow Metro design and typeface.
  • WP7 phones allow customizing themes to a greater extent. Another interesting feature is its “Live Tiles”.
  • WP7 applications can use Panorama & Pivot controls. With Panorama control, your application can have multiple screens spanned across a single background. If you are an Android user, you can compare this with the home screen of your Android with wallpaper & multiple pages. Pivot control is used for creating tabbed style applications. More about these controls here.
  • WP7 does not have any local data store.(Android users can use SQLLite for storing the user data). All the user data can be stored on local files or on store it on the cloud and stream it via web service. If you want to store settings data, you can store them on the local file system.
    This is a major drawback when compared to Android.
  • Silverlight has good support of Web Services. Few notable things regarding web services are: 1. Web service calls are always asynchronous. 2. Proxy can not be generated on the fly. 3. Custom bindings are not supported. However, Silverlight’s competitor Adobe Flex offers dynamic proxy creation and custom binding.
  • Silverlight supports three modes of data Binding – One Time, One Way, Two Way. More about it here.
  • Application Bar can have a maximum of four buttons and all the buttons should follow Metro UI theme.
  • Application Lifecycle.
    • No multi-tasking. (This is quite weird as the previous versions of Windows mobile used to support multi-tasking).  If you are getting a phone call while you are using an application, your application will not run in the background. The application will be deactivated and the phone call will be activated. This process is called Tombstoning. Its the responsibility of the app developers to save the state of the application whenever the application is tombstoned.
    • Launchers & Choosers can be used to launch other applications from your application. Launcher will not return back anything from the launched app. Ex: Call. If you want to make a call from your application, use launcher. Chooser will return back a handle to the application. Ex: Camera. You can launch the camera app from your application and get back the photo taken.
    • To get a complete understanding the application lifecycle, execution model, etc, refer to this: Part1, Part2, Part3.
  • WP7 provides location services using Bing maps.
  • WP7 has support for Push Notifications.
  • To avoid the popular fragmentation problem, Microsoft has chosen to take complete control over the OS updates and the device requirements.
  • Finally, Windows Phone 7 is considered to be a competitor for Android and not iPhone. iPhone operates on a different model with single hardware. “The WP7 OS isn’t perfect but aside from the lack of apps, it’s competitive today” - AnandTech.

Impressed with the features of Windows Phone 7? What are you waiting for? Download the SDK (its free) and start playing around with it. No support for Mac dev yet.

-- Varun

google-site-verification: googlea4d68ed16ed2eea6.html