Creating and adding an icon to an S60 3rd Edition application

July 18, 2008 at 6:44 pm | In Uncategorized | Leave a Comment
Tags: ,

Overview

This code example describes how to create and add an icon to an S60 3rd Edition application.

In order to create SVG icons, you must have a suitable graphics editor, for example, Inkscape.

This snippet can be self-signed.

Steps

1. Create an SVG icon on a 48-x-48-pixel canvas. You can test the icon by building the HelloWorldBasic application (in S60Ex directory under the SDK) with your own icon.

2. Save the icon in the gfx folder of your application according to the standard Symbian directory structure guidelines.

3. Create group\icons_scalable_dc.mk to automatically convert the icon to a Symbian .mif file whenever the application is compiled:

ifeq (WINS,$(findstring WINS, $(PLATFORM)))
ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
else
ZDIR=$(EPOCROOT)epoc32\data\z
endif

TARGETDIR=$(ZDIR)\resource\apps
ICONTARGETFILENAME=$(TARGETDIR)\Application_aif.mif

ICONDIR=..\gfx

do_nothing :
    @rem do_nothing

MAKMAKE : do_nothing

BLD : do_nothing

CLEAN : do_nothing

LIB : do_nothing

CLEANLIB : do_nothing

RESOURCE :
    mifconv $(ICONTARGETFILENAME) \
        /c32 $(ICONDIR)\icon.svg

FREEZE : do_nothing

SAVESPACE : do_nothing

RELEASABLES :
    @echo $(ICONTARGETFILENAME)

FINAL : do_nothing

Note: When editing the makefile, make sure that you use tabulators instead of spaces. (Otherwise you get the error: “ICONS_SCALABLE_DC.MK:25: *** missing separator. Stop.”)

4. Edit group\bld.inf to contain the makefile created above:

#ifdef EKA2 //3rd Edition
gnumakefile icons_scalable_dc.mk
Application_S60_3rd_ed.mmp
#else       //1st and 2nd Edition
Application_S60_2nd_ed.mmp
#endif

Note: Remember to run “bldmake bldfiles” after editing the bld.inf file.

5. Edit the resource file of your application (data\[app].rss) to contain the icon:

#include <appinfo.rh>
#include "Application.rls"

// ----------------------------------------------------------------------------
//
// r_application_localisable_app_info
//
// ----------------------------------------------------------------------------

RESOURCE LOCALISABLE_APP_INFO r_application_localisable_app_info
    {
    short_caption = STRING_r_app_caption_string;
    caption_and_icon = 
    CAPTION_AND_ICON_INFO
        {
        caption = STRING_r_app_caption_string;

        number_of_icons = 1;
        icon_file = "\\resource\\apps\\Application_aif.mif";
        };
    }

Note: The localizable application information presented above is often located in data\[app]_loc.rss file. Experience has shown that an icon may not always show on the device if it is declared in the loc.rss file. If you decide to use .rss instead of loc.rss, make sure that you remove all references to loc.rss (especially the localisable_resource_file declaration in APP_REGISTRATION_INFO resource in data\[app]_reg.rss and RESOURCE section in group\[app].mmp).

Note: Ensure that App_reg.rss file contains a reference to the localizable application information:

localisable_resource_id = R_APPLICATION_LOCALISABLE_APP_INFO;

6. Edit the pkg file (sis\[app].pkg):

;Language - standard language definitions
&EN,FI

{
"\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\resource\apps\Application.rsc"
"\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\resource\apps\Application.R09"
} -"!:\resource\apps\Application.rsc"

;Icon resources
"\Symbian\9.2\S60_3rd_FP1\Epoc32\Data\z\resource\apps\Application_aif.mif"
  -"!:\resource\apps\Application_aif.mif"

Showing a manufacturer disclaimer during the first launch

July 18, 2008 at 6:36 pm | In Uncategorized | Leave a Comment
Tags: ,

Overview

This code snippet demonstrates how to display a manufacturer disclaimer when an application is launched for the first time. This behavior is required at least for VoIP applications that are meant to be sent to Symbian for signing.

In practice, the requested behavior is implemented by deleting the disclaimer file after it has been accepted for the first time. Every time the application is run, it is checked whether or not the file exists.

This snippet can be self-signed.

data\disclaimer.txt

Here is an example of the disclaimer text by Symbian for VoIP applications:

You are about to use <APPLICATION NAME>, which is
developed and owned by <YOUR COMPANY NAME>. The
manufacturer of this device shall have no liability for
any aspect of the application whatsoever, including its
performance, call routing, intellectual property rights
or support.

PKG file

Install the disclaimer file to the device by adding the following line to the PKG file:

"..\data\disclaimer.txt" - "!:\private\E9D7CF12\disclaimer.txt"

MMP file

The following libraries are required:

LIBRARY  bafl.lib

RSS file

RESOURCE DIALOG r_disclaimer_dialog
    {
    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    items=
        {
        DLG_LINE
            {
            type = EAknCtPopupHeadingPane;
            id = EAknMessageQueryHeaderId;
            itemflags = EEikDlgItemNonFocusing;
            control = AVKON_HEADING
                {
                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE;
                };
            },
        DLG_LINE
            {
            type = EAknCtMessageQuery;
            id = EAknMessageQueryContentId;
            control = AVKON_MESSAGE_QUERY
                {
                };
            }
        };
    }

Header file

public:  // Constructors and destructor
        /**
         * 2nd phase constructor.
         */
        void ConstructL();

    private:  // New methods
        /**
         * Shows the disclaimer dialog.
         * @return ETrue if the user accepts the disclaimer; EFalse if not.
         */
        TBool ShowDisclaimerL(RFs& aFs, const TDesC& aFilename);
         /** 
         * Deletes the disclaimer file.
         */
        void DeleteDisclaimerL(RFs& aFs, const TDesC& aFilename);

Source file

#include <aknmessagequerydialog.h>  // CAknMessageQueryDialog
#include <BAUTILS.H> // BaflUtils
#include <EIKENV.H>  // CEikonEnv
void CMyAppUi::ConstructL()
    {
    // Initialize the UI. This has to be done before the disclaimer dialog is
    // shown.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    // Connect to the file server session
    RFs fsSession;
    User::LeaveIfError(fsSession.Connect());
    CleanupClosePushL(fsSession);

    // The disclaimer file
    _LIT(KFilename, "C:\\private\\E9D7CF12\\disclaimer.txt");

    // If the disclaimer file exists, the application hasn't been run yet
    if (BaflUtils::FileExists(fsSession, KFilename))
        {
        // Show the disclaimer dialog
        TBool selectedOption;
        TRAPD(showErr, selectedOption = ShowDisclaimerL(fsSession, KFilename));
        if (showErr != KErrNone)
            {
            // TODO: Error handling
            }
        if (!selectedOption)
            {
            // The user canceled the disclaimer dialog. Exit the application.
            CleanupStack::PopAndDestroy();  // fsSession
            Exit();
            }
        else
            {
            // The user continued with the application launch.
            // Delete the disclaimer file so that it won't be around the next time the
            // application is run.    
            TRAPD(deleteErr, DeleteDisclaimerL(fsSession, KFilename));
            if (deleteErr != KErrNone)
                {
                // TODO: Error handling
                }
            }
        }

    CleanupStack::PopAndDestroy();  // fsSession

    // ...
}
TBool CMyAppUi::ShowDisclaimerL(RFs& aFs, const TDesC& aFilename)
    {
    // Open the disclaimer text file
    RFile file;
    TInt openError = file.Open(aFs, aFilename, EFileRead);
    if (openError != KErrNone)
        {
        _LIT(KErrMsg, "Cannot open the disclaimer file for reading.");
        _LIT(KExitingApp, "Exiting app.");
        CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
        User::Leave(openError);
        }
    CleanupClosePushL(file);

    // Read file size
    TInt fileSize = 0;
    TInt sizeError = file.Size(fileSize);
    if (sizeError != KErrNone)
        {
        CleanupStack::PopAndDestroy();  // file
        User::Leave(sizeError);
        }

    // Read file contents
    HBufC8* disclaimerText8 = HBufC8::NewLC(fileSize);
    TPtr8 disclaimerPtr = disclaimerText8->Des();
    TInt ioError = file.Read(disclaimerPtr, fileSize);
    if (ioError != KErrNone)
        {
        CleanupStack::PopAndDestroy(2);  // disclaimerText8, file
        User::Leave(ioError);
        }

    // Done with the file. Close it.
    file.Close();

    // Convert the 8-bit disclaimer text to 16-bit
    HBufC* disclaimerText = HBufC::NewLC(disclaimerText8->Length());
    disclaimerText->Des().Copy(*disclaimerText8);

    // Show the disclaimer dialog
    _LIT(KTitle, "MyApplication");
    CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*disclaimerText);
    CleanupStack::PushL(dlg);
    dlg->PrepareLC(R_DISCLAIMER_DIALOG);
    dlg->SetHeaderTextL(KTitle);
    CleanupStack::Pop(dlg);

    TBool result = dlg->RunLD();

    CleanupStack::PopAndDestroy(3);  // disclaimerText, disclaimerText8, file

    return result;
    }
void CMyAppUi::DeleteDisclaimerL(RFs& aFs, const TDesC& aFilename)
    {
    // Delete the disclaimer file
    TInt deleteError = BaflUtils::DeleteFile(aFs, aFilename);
    if (deleteError != KErrNone)
        {
        User::Leave(deleteError);
        }
    }

Postconditions

A manufacturer disclaimer is displayed when the application is launched for the first time. The user is given the option to continue with the launch or abort it. If the user decides to accept the disclaimer, the disclaimer file is deleted from the device.

       

Showing a manufacturer disclaimer during application installation

July 18, 2008 at 6:28 pm | In Uncategorized | Leave a Comment
Tags: ,

Overview

This code snippet demonstrates how to display a manufacturer disclaimer when an application is being installed. This behavior is required at least for VoIP applications that are meant to be sent to Symbian for signing.

This snippet can be self-signed.

data\disclaimer.txt

This is an example of the disclaimer text by Symbian for VoIP applications:

You are about to use <APPLICATION NAME>, which is
developed and owned by <YOUR COMPANY NAME>. The
manufacturer of this device shall have no liability for
any aspect of the application whatsoever, including its
performance, call routing, intellectual property rights
or support.

PKG file

To display the disclaimer to the user, add the following line to the PKG file of your application:

"..\data\disclaimer.txt" - "", FILETEXT, TEXTEXIT

The FILETEXT install option indicates that a file is to be displayed to the user during the installation procedure. The file itself is not installed on the target device (the target location is empty).

The TEXTEXIT install option displays a dialog box with “positive” and “negative” buttons, such as Ok and Cancel. If the dialog returns true (the user pressed Ok), the software installer continues with the installation. If the dialog returns false (the user pressed Cancel), the software installer is exited and any files that have already been installed are removed.

Postconditions

A manufacturer disclaimer is displayed when the application is installed. The user is given the option to continue with the installation or abort it.

Best BlackBerry Shortcuts

July 1, 2008 at 1:05 pm | In Uncategorized | Leave a Comment
Tags: , ,

Home Screen Shortcuts

Now you’ll need to hit your Phone icon or click the green phone button to dial a number and place a call, but you’ll have access to all of the following shortcuts from your Home Screen via a single click of the corresponding letter key:

  • WAP Browser — W
  • Alarm — R
  • Tasks — T
  • Calculator — U
  • Options — O
  • Address Book — A
  • Search — S
  • Notes — D
  • Profiles — F
  • Help — H
  • Lock keypad — K
  • Calendar — L
  • Messages — M
  • Browser — B
  • BlackBerry Messenger — N
  • Saved messages — V
  • Compose — C

Typing Shortcuts

  • To capitalize a letter with one click, hold down the letter key.
  • To insert a period, click the Space key twice.
  • Turn CAP Lock on by pressing the ALT key followed by the right Shift key. Turn it off by pressing either Shift key.
  • Turn Number Lock on by pressing the ALT key followed by the left Shift key. Turn it off by pressing either Shift key.
  • Type an accented letter or special character by holding the corresponding letter and scrolling left or right with the trackball.
  • Insert the current date into a message or document by pressing the L key followed by the D key and Space key.
  • Insert the current time into a message or document by pressing the L key followed by the T key and Space key.

Messaging (E-mail and SMS)

  • In e-mail inbox, press the S key to search for a sender or a word within a subject line, and any mail folder regardless of message was sent or received.
  • Within inbox, access the complete list of messages sent by hitting the ALT key followed by the O key.
  • Within inbox, access the complete list of messages received by hitting the ALT key followed by the I key.
  • Within inbox, access the complete list of SMS text messages received by hitting the ALT key followed by the S key.
  • Within inbox, access phone log by hitting the ALT key followed by the P key.
  • Within inbox, access voicemail log by hitting the ALT key followed by the V key.
  • To delete all messages sent or received before a specific date, highlight that date with the cursor, hit the BlackBerry Menu key, select Delete Prior and confirm selection.
  • To enable automatic spell checking of e-mail messages, click the Options icon on BlackBerry home screen. Then click Spell Check and select the Spell Check E-Mail Before Sending option.
  • To do a manual spell check, click the BlackBerry Menu key within a composed message and select Check Spelling.
  • When a message is being spell checked, suggested fixes to unrecognized words can be ignored by clicking the escape key.

When in a list of messages, or when reading a message:

T- Top
B- Bottom
Space bar- next page
Num shift + Space bar – previous page

When in a list of messages:
N- go to Next day
P- go to Prev day

Spreadsheet Attachments:

  1. Change the size of a column by pushing the W key.
  2. Go to a specific cell by pressing the G key.
  3. View contents of a cell by pressing the Space key.
  4. Search for text by clicking the F key, and then type the desired word.
  5. Switch to a different worksheet by pressing V and selecting the desired sheet.

Presentation Attachments:

  1. Skip to the next slide by pressing the N key.
  2. Return to the previous slide by clicking the P key.
  3. Start slideshow by pushing the S key.
  4. Stop slideshow by clicking the Escape key.
  5. Switch to a new view of the slideshow by clicking the M key.

Phone Functions

  1. Multitask while on phone calls by hitting the BlackBerry menu key during a call and then selecting Home Screen. You’ll then have access to e-mail and other documents–though most BlackBerrys don’t allow for simultaneous voice and data transfer, so Internet access is unavailable while on calls.
  2. Find specific contacts from your BlackBerry home screen by pressing keys for first and last initials, with a space between them. If more than one contact has the same initials, scroll to the appropriate contact.

BlackBerry Browser

  1. Bring up the Enter Web Address field from any Web page by pressing the G key.
  2. Insert a period in Web address by clicking the Space key.
  3. Insert a back slash in Web address by clicking either the Left Shift or Right Shift keys and then hitting Space.
  4. Add an item to bookmarks list by clicking the A key.
  5. Bring up your bookmark list by clicking the K key.
  6. Refresh a Web page by clicking the R key.
  7. Display a list of the last 20 pages visited by hitting the I key.
  8. Open browser options with the O key.

Back to Basics: Starts and Stops

  1. To put device into Standby Mode so keys cannot be pressed while it’s not in use, hold down the Mute key for a second or two. Undo Standby Mode by holding Mute for another couple of seconds.
  1. If BlackBerry slows down, starts malfunctioning or freezing, always try removing the battery and SIM card–if the device has one–and waiting a few seconds before reinserting it. Ninety-five percent of the issues Aflac BlackBerry users experience are resolved by simply removing the battery, according to Genet.

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.