The website T-shirt!

I still can’t believe how popular and useful the website had become; until yesterday, when one of my friends Pralhad Sapre mentioned about one of his office colleagues who referred some of the Android tutorials over here to complete her work!

So then I gave it a serious thought and decided it’s high time I took a step towards promoting the blog. I decided to design my own website T-shirt and here’s how it looks! 🙂

website_tshirt_2

My website T-shirt

Just in case you want to get one for yourself, feel free to contact me! 🙂

I, Me and the Xperia Z!!

I couldn’t have asked for a better birthday present. My parents gifted me a brand new Xperia Z. It definitely feels awesome to have Sony’s latest flagship device resting in the palm of your hand.

Through this post, I will try and give you a quick review of the Xperia Z including the battery life, camera, processing speed and so on. One of the interesting features of the smartphone is the fact that it is dust and water resistant. So without wasting much time let’s begin exploring the phone.

1) Battery life

The battery life is pretty good. When fully charged the phone can easily last for a day with normal use but I must say that the phone gets heated up quickly especially when you keep playing those high graphic games for an hour or so. The only solution then is to dip the phone in water 😛

2) Processor

The phone is equipped with a Quad Core 1.5 GHz Qualcomm Snapdragon S4 Pro processor and it’s really fast when your multi tasking. Social networking becomes a lot easier on the Xperia Z.

3) Display

The only thing I have no complaints about is the display quality. The Full HD screen and the mobile BRAVIA engine 2 display is something that Sony is well known for and it surely reflects when you start using the device.

4) Camera

The Xperia Z comes with a 13 MP autofocus fast capture camera with LED flash. It also supports a 2.2 MP secondary camera. Few things I found interesting and really liked about the camera was the Superior Auto mode that tells you exactly what to do when you fire up the camera and the Smile detection feature that enables you to choose between big smiles, average smiles or small smiles.

5) Music and video quality

The Sony walkman music app is one of the best around at present. I got a free Sony headset when I bought the device which adds to the music experience. Videos you shoot are of really high quality. It supports video stabilization as well.

So if your planning to buy the Xperia Z then I would suggest you go for it. It’s a great phone if you are one of those heavy users who loves getting the best out from a smartphone! 🙂

Feel free to comment in case you have any questions!

Pics

xperia_z_3

Tutorial #18: Calling a PL/SQL procedure in ODI

Hello friends!

Today, I will be demonstrating a short tutorial that will help you call a PL/SQL procedure using Oracle Data Integrator (ODI).

Pre-requisites: Oracle Data Integrator 11g, Oracle 10g Express Edition with *SQL Plus.

I will be creating a procedure that will insert a new row in my database table in Oracle. Through ODI, I will execute/call the same procedure!

The steps are as follows:

Step 1: Create table Product

Open *SQL Plus and connect to the database using your credentials. Now, let’s create Product table.

create table Product(prod_id number, prod_name varchar2(30), price number);

Step 2: Create PL/SQL procedure

Let’s write a simple procedure that will insert a new row in the Product table.

create or replace procedure insert_proc as
begin
insert into Product values(104,'Nokia',2440);
end;
/

Once the procedure has been created successfully, open Oracle Data Integrator studio and connect to your work repository. Using ODI we will simply call the procedure.

If you haven’t created your work repository in ODI please refer this.

Step 3: Create data server, physical and logical schema

To create a new data server, go to Topology navigator, under Technologies,right click Oracle and select new data server. Enter the correct details (including JDBC URL) as per your database connection and click on Save.

creating new data server

creating new data server

creating new data server

creating new data server

Now create physical schema by right clicking the data server and selecting new physical schema.

create physical schema

create physical schema

In the same way, create your logical schema. Make sure you select a Context. In my case I have selected Global.

create logical schema

create logical schema

Step 4: Create new project followed by new procedure

Create a new project named test_project under the Designer navigator. Go to First Folder–>Procedure and right click to create new procedure.

create new procedure

create new procedure

Run the procedure and check the Operator navigator for the status of the operation.

view operator status

view operator status

Finally, check if the new row is inserted by performing a select operation on your table in Oracle.

check product table

check product table

Learning Kivy: Canvas

Hey everyone!

In my previous Kivy tutorial I talked about the Carousel widget and the AsyncImage class that one can use to display and load images respectively. Today I would be talking about the Graphics module of the Kivy framework!

1. Graphics (kivy.graphics)

From the Kivy documentation, the Graphics package assembles all low level functions to draw an object.The entire package is compatible with OpenGL ES 2.0 and has a lot of rendering optimizations.

There are basically two things that one would require to draw on a screen. They are namely:

1. Canvas
2. Instruction objects

Each widget in Kivy already have their Canvas by default. When you are creating a widget, you can create all the instructions needed for drawing. If self is your current widget, you can do:

from kivy.graphics import *
with self.canvas:
    # Add a red color
    Color(1., 0, 0)

    # Add a rectangle
    Rectangle(pos=(10, 10), size=(500, 500))

The instructions Color and Rectangle are automatically added to the canvas object, and will be used when the window drawing will happen.

2. Canvas (kivy.graphics.instructions)

The Canvas is a root object used for drawing by a Widget. The Canvas supports Python’s with statement and it’s enter and exit semantics.

Use of Canvas without the with statement

self.canvas.add(Color(1., 1., 0))
self.canvas.add(Rectangle(size=(50, 50)))

Usage of Canvas with Python’s with statement

with self.canvas:
    Color(1., 1., 0)
    Rectangle(size=(50, 50))

Now, here’s a small implementation of the Canvas object!

Open Python IDLE and create a new Python script. Give the name as canvas_demo.py


from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.graphics import Color, Rectangle
from functools import partial

class CanvasApp(App):

    #function to add rectangle to screen
    def add_rects(self,wid,*largs):
        with wid.canvas:
                Color(1, 0, 0, .5, mode='rgba')
                wid.rect = Rectangle(pos=(200,200), size=(300,300))
                
    #function to clear rectangle from screen
    def reset_rects(self,wid,*largs):
        wid.canvas.clear()

    def build(self):
        wid = Widget()
         
        #calling function with default arguments
        btn_add = Button(text='Draw rectangle',on_press=partial(self.add_rects,wid,'Adding a rectangle'))
        btn_clear = Button(text='Clear',on_press=partial(self.reset_rects,wid,'Clear the canvas'))

        layout = GridLayout(cols=1,rows=2)
        layout.add_widget(btn_add)
        layout.add_widget(btn_clear)
        root=GridLayout()
        root.add_widget(wid)
        root.add_widget(layout)

        return root

if __name__ == '__main__':
    CanvasApp().run()

On running the above code, you should see a red color rectangle as soon as you click on the Draw Rectangle button. On pressing the Clear button the rectangle will disappear!

Output

Output

Tutorial #17: AnalogClock Widget in Android

Hello!

I have been meaning to write this post for a long time now! Recently, I was working on a project where I needed to add an AnalogClock to my home screen in Android. After having gone through the Android developers guide, I got to know about the AnalogClock widget that could help me accomplish this task.

So let’s not waste any time and start implementing the clock widget!

Requirements: Android SDK, Eclipse Helios/Indigo.

Step 1: Create a new Android project in Eclipse.

Name it as AndroidAnalogClockWidget. Select Android 2.3.3 as the Target SDK.

Step 2: You need to create a layout for your widget. Create XML file called main.xml that would define the widget layout.

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout01"
    android:layout_height="200dp"
    android:layout_width="160dp"
    android:orientation="horizontal">
  
    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    
</LinearLayout>

As seen from the above XML file, we now have added the Analog clock to our layout. However, we need to add an AppWidgetProvider which would help us implement our own AppWidget functionality.

Step 3: Create a folder named xml within the res folder. Create XML file called clock_widget_provider.xml inside the xml folder.

res/xml/clock_widget_provider.xml

<?xml version="1.0" encoding="utf-8" ?>
<appwidget-provider
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="146dp"
    android:initialLayout="@layout/main"
    android:updatePeriodMillis="1000"
    android:minHeight="144dp"/>

Step 4: Create an empty class named AnalogClockWidget under the src folder with package name com.example

src/com.example/AnalogClockWidget.java

package com.example;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;


public class AnalogClockWidget extends AppWidgetProvider
{
    
}

Step 5: Finally you need to make changes to your AndroidManifest.xml and add a receiver for the clock widget.

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        
        <receiver android:name=".AnalogClockWidget" android:label="AnalogClockWidget">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/clock_widget_provider" />
        </receiver>  
    </application>
</manifest>

Make sure you have no errors in your project. Run the project to see the following output!

Select Analog Clock Widget from list

analog_clock_widget_2

You can find the source code of this tutorial from over here.

Learning Kivy: Carousel and AsyncImage

Hello everyone!

Today I will talk about two interesting Widgets of the Kivy framework. Both these widgets can be used to display/load images in a particular manner.

1. Carousel

As mentioned in the Kivy docs, the Carousel widget provides a mobile-friendly carousel view where one can swipe between slides. One can add any content to the carousel and use it horizontally or vertically. The carousel can display pages in loop. One can also navigate to the next slide or the previous slide using the Carousel properties.

Here’s how we can use the Carousel view!

Step 1: Create a folder named images on your disk and copy a few pictures inside that folder. I have added a few images for my project. Download the source code from the below link to view them.

Step 2: Open the Python IDLE. Create a new Python script and type the following code!


from kivy.app import App
from kivy.uix.carousel import Carousel
from kivy.factory import Factory
from kivy.uix.image import Image

class Example1(App):

    def build(self):
        #define the carousel
        carousel = Carousel(direction='right',loop='true')
        for i in range(1,5):
            #load pictures from images folder
            src = "images/%d.jpg" % i
            image = Image(source=src,pos=(400, 100), size=(400, 400))
            carousel.add_widget(image)
        return carousel

if __name__ == '__main__':
    Example1().run()

Step 3: Save the file as Example1.py. Make sure to save the Python file inside the same directory as that of the images folder.

Step 4: Open command prompt. Navigate to the directory where you have your Python script. Type kivy Example1.py and press enter. You should get a carousel view of various fruit images!

Kivy Carousel View

Kivy Carousel View

Here is the Source code

2. AsyncImage

Now, the AsyncImage class is used to load images asynchronously from an external webserver. All one needs to do is specify the URL of the website that contains the data. One can use AsyncImage in combination with Carousel to load and display images.

Here’s a short implementation of the AsyncImage class along with the Carousel view.

Once again create a new Python script. Add the following code. Run it as explained previously and you should see some images getting loaded asynchronously!

from kivy.app import App
from kivy.uix.carousel import Carousel
from kivy.factory import Factory
from kivy.uix.image import Image

class Example1(App):

    def build(self):
        carousel = Carousel(direction='right',loop='true')
        
        for i in range(1,5):
            src = "http://placehold.it/480x270.png&text=slide-%d&.png" % i
            #load images asynchronously
            image = Factory.AsyncImage(source=src, allow_stretch=True)
            carousel.add_widget(image)
        return carousel

if __name__ == '__main__':
    Example1().run()

So that’s it for this tutorial. I will talk about the Graphics module of the Kivy framework in my further tutorials! Enjoy! 🙂

Happy Birthday Preeyank!

Engineering was fun! The tests, assignments, vivas and all those things that made my life a little too hectic is something that I miss even today. Some moments were just priceless. I often wonder who made those moments. Who are those who still make me feel that I miss them. Of course your friends, my mind quickly answers. Preeyank was one of those friends with whom I spent some memorable moments.

Here is one of those moments with the MasterMind himself!

2nd semester

It was our second ED (Engineering Drawing) lecture. That day the professor had given us a simple assignment on Orthographic projections and Isometric views which we had to submit in the next lecture. I started working on the assignment during the lunch break itself and managed to finish it on the same day. When I was about to leave that day, Preeyank came and asked me to give him the assignment. I was reluctant to hand over my assignment to him as I wasn’t sure whether he would bring it on the submission day. He promised he would not forget and convinced me at the end. Few days later when he brought the assignment, I could see my drawing sheet torn from one of the corners with my diagrams hardly visible. I was furious and decided not to give him any of my assignments henceforth. All my hard work had gone in vain as I had to redraw everything from scratch. Finally when my submission was done and I was about to leave for the day, Preeyank met me and apologized. He had felt bad for what had happened. He said that he was always extra careful but the early morning rush in the train was the reason the sheets got torn. I accepted his apology since I felt he wasn’t lying and from that day I used to give him my assignments even before he would ask for them.

Over the years as our friendship grew, we started to understand each other well. As a project team member his ideas, though majority non technical, were crucial while we were developing our application. Perhaps that’s the same reason they still call him “The MasterMind”. His constant support and motivation helped me overcome tough situations and I would like to thank him for that. Hope he gets all the success in life!

Wishing you a very happy birthday!

Me and Preeyank