Friday, December 4, 2009

Touch screen keypad in Nokia S60 5th Edition

Overview

S60 5th Edition introduced touch screen and also larger screen of 640 x 360 pixels. For making it easier to run older MIDlets in these devices there is so called on-screen keypad available for MIDlets. It offers backwards compatibility for MIDlets, which are using Canvas and are not originally made for touch devices.
On-screen keypad takes part of the screen from Canvas and offers possibility to use keypad and generate key events for the Canvas application. Pointer events still work normally in the Canvas area despite of the on-screen keypad presence.



Usage

On-screen keypad launches automatically for every installed MIDlet, but user is able to change On-screen keypad visibility from the application manager setting. Possible values are "off", "Navigation keys only" and "Game and navigation keys". The setting is application specific and thus can be defined differently for every installed MIDlet suite. The state of on-screen keypad is defined by using a JAD parameter "Nokia-MIDlet-On-Screen-Keypad", its possible values are "no", "gameactions" and "navigationkeys".
Nokia-MIDlet-On-Screen-Keypad: no
Nokia-MIDlet-On-Screen-Keypad: gameactions
Nokia-MIDlet-On-Screen-Keypad: navigationkeys
Three possible on-screen keypad settings:
  • No keypad
  • Navigation keys keypad: game actions UP, DOWN, LEFT, RIGHT and FIRE
  • Game actions keypad: game actions UP, DOWN, LEFT, RIGHT, FIRE, GAME_A, GAME_B GAME_C and GAME_D
A keypad also includes two softkey buttons. Note, that On-screen keypad has no number or letter keys, just the keys listed above. Note also, that if an application has defined the on-screen keypad setting user cannot change it. If the setting is not defined by using the JAD attribute, user can change it. The on-screen keypad setting is valid for entire MIDlet suite. By default if no keypad setting has been defined the game actions keypad is displayed.
The image below shows the three settings on portrait 360 x 640 screen: on-screen keypad with navigation and game keys, on-screen keypad with navigation keys and no on-screen keypad. The screen resolutions for the screens (actual Canvas drawing area) are:
  • full screen without on-screen keypad: 360 x 640
  • full screen with on-screen keypad with navigation keys: 360 x 384
  • full screen with on-screen keypad with navigation and game keys: 360 x 360
  • NOT full screen without on-screen keypad: 360 x 487
  • NOT full screen with on-screen keypad with navigation keys: 360 x 292
  • NOT full screen with on-screen keypad with navigation and game keys: 360 x 240
Image:Tube_minesweeper3.png
The image below shows the three settings on landscape 640 x 360 screen: on-screen keypad with navigation and game keys, on-screen keypad with navigation keys and no on-screen keypad. The screen resolutions for the screens (actual Canvas drawing area) are:
  • full screen without on-screen keypad: 640 x 360
  • on-screen keypad with navigation keys: 372 x 360
  • on-screen keypad with navigation and game keys: 320 x 360
  • NOT full screen without on-screen keypad: 502 x 288
  • NOT full screen with on-screen keypad with navigation keys: 298 x 288
  • NOT full screen with on-screen keypad with navigation and game keys: 251 x 288
Image:Tube_minesweeper4.png
The images above also show, how the "Nokia-MIDlet-Original-Display-Size" JAD attribute works in practice.

On-screen keypad in devices with keyboard

In devices with touch screen and additional keyboard (like Nokia N97) opening the keyboard adds a new mode of on-screen keypad. When the keyboard is opened, arrow and game keys are removed and soft key labels are shown on right edge or on bottom of the screen. The position can be chosen by using "Nokia-MIDlet-On-Screen-Softkeys-Position" system property. If no property is used, the soft keys are on the right side as default. Note, that if "Nokia-MIDlet-On-Screen-Keypad" attribute has "no" value, soft keys are not shown at all.
Nokia-MIDlet-On-Screen-Softkeys-Position: bottom
Nokia-MIDlet-On-Screen-Softkeys-Position: right // default, this is used, if no property exists in the jad file
The Canvas screen size is 580x360 pixels, when the soft keys are on the right and 480x360 pixels, when the soft keys are on the bottom.
Image:N97_open.pngImage:N97_open_bottom.png

Original link: http://wiki.forum.nokia.com/index.php/Using_on-screen_keypad_in_MIDlets_in_S60_5th_Edition_devices

FullScreen Mode

Thanks to this methods : setFullScreenMode(true);

MSA Components


MIDlet Lifecycle


Perform call

We need to use this method plateformRequest(Phone Number); which is provided by the javax.microedition.midlet.

Open Browser

We need to use this method plateformRequest("http://www.sun.com"); which is provided by the javax.microedition.midlet.

Hello World

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener; 
import javax.microedition.lcdui.Display; 
import javax.microedition.lcdui.Displayable; 
import javax.microedition.lcdui.Form; 
import javax.microedition.midlet.MIDlet; 

public class HelloWorld extends MIDlet implements CommandListener { 
    public HelloWorld() { } 
    public void startApp() { 
        Form form = new Form("Hello world!"); 
        form.addCommand(new Command("Exit",Command.EXIT,1)); 
        form.setCommandListener(this);
        Display.getDisplay(this).setCurrent(form); 
    }
    public void pauseApp() { } 
    public void destroyApp(boolean unconditional) { } 
    public void commandAction(Command c,Displayable d) { 
        if(c.getCommandType() == Command.EXIT) { 
            notifyDestroyed(); 
        } 
    } 
}