Friday, August 30, 2013

Ubuntu Touch Calendar prototype for new design

Lately I am working on Ubuntu Touch's Calendar core app. Recently I tried to create a prototype for calendar to show how new design looks for the app.

Here if demo on youtube.

And following are few snaps from prototype.

Monday, August 26, 2013

Using Invocation API with BB10 Cascades

I was working on update of my application Audiobook Reader. Currently my application has custom file browser that allow user to add file but I wanted to add allow user to add book/file directly from native BB10 file browser, like shown in below picture.

BB10 supports this usecase by Invocation API, your application can receive invocation from other application by using it. Your application can also use other application by the same way.

In my app, I just wanted to receive invocation from default File Browser. To do this we need to register our application as invocation target by entering details in to .bar file.

Following is entry for my app.

Here Target-Type mean can be Card or Application, Application will launch app as separate process, Card will launch app in scope of calling app.

Icon is your app's icon, that will be used by other app to display it in menu.

Action Open mean, suggested file can be opened by other app. Other possible value is View.

Mime-Type is type of file your application can support and exts mean, the extension of file that your app can handle.

    <invoke-target id="com.example.AudiobookReader">
      <invoke-target-name>Audiobook Reader</invoke-target-name>
        <property var="exts" value="mp3,..,..,..."/>

Once this is done, Then we need to add handler code that will be called when other application invoke our app. To do that, we need to connect InvokeManager's onInvoke signal to our slot.

like below.

 bb::system::InvokeManager invokeManager;

 QObject::connect(&invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)),
     &helper, SLOT(onInvoke(const bb::system::InvokeRequest&)));

When our slot is called, we can retrieve URL and other information from InvokeRequest and do the further processing.

void Helper::onInvoke(const bb::system::InvokeRequest& request) {

 mInvokationUrl = request.uri().toString(QUrl::RemoveScheme);

 QFile file( mInvokationUrl );
 QFileInfo fileInfo( file );

 if( !QFile::exists(mInvokationUrl) ) {
  showErrorDialog("Error Locating file!!");

 if( !FileModel::isSupportedMedia(mInvokationUrl)) {
  showErrorDialog("Not valid Audio file!!");

This is it, you can learn more about invocation framework from here.

Saturday, August 10, 2013

Using VibrationController API wit BB10 Cascades QML

I tried to add vibration support to my BB10 application Counter. Application is simple, which just increment the count when you press add button and decrements count on minus button. Simple but useful, I use it quite often to count the stuffs.

But you need to see at screen to see if it button is really pressed, so I thought to add vibration support, so I know button is pressed even without looking at screen. This is first time I am adding Vibration support to any of BB10 application. So I thought to share code.

Code is much simple, only trick is that you need to register VibrationController c++ class to QML system.

Here is how it goes.

First we need to link device lib which has VibrationController API. Add following line to your .pro file and you are good to go.

LIBS += -lbbdevice

Now in main.cpp you need to add proper header to locate VibrarionController API and the register it to QML registry.
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>

#include <bb/device/VibrationController>

using namespace bb::cascades;
using namespace bb::device;

int main(int argc, char **argv)
    Application app(argc, argv);

        ("bb.vibrationController", 1, 0, "VibrationController");

    new Counter(&app);

    return Application::exec();

Now we are ready to use VibrarionController with QML code. First you need to import VibraionController QML by import statement. Then we are creating it by defining it in attachedObjects. Once this is done, we can use it's start API to vibrate phone with certain intensity for certain durarion.

import bb.cascades 1.0
import bb.vibrationController 1.0

Page {
    id: page
    Container {
        id: root
        layout: DockLayout {}
        preferredHeight: 1280
        preferredWidth: 768
        touchPropagationMode: TouchPropagationMode.Full;
        attachedObjects: [
            VibrationController {
                id: vib

        function vibrate() {
            //first parameter intensity, second parameter duration for vibration
            vib.start(80, 100);

            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center 
            onClicked: {

Thant's all, hope this will be helpful.