The UI module (implemented in the com.nokia.example.bcexchanger.ui
package) creates the UI of the MIDlet. The UI is implemented as
a state machine, where each screen is a state. The UI module consists
of the following classes:
AddressBookScreen
—This class displays the
content of the phone book and allows the user to select his or her
own business card. The user can either select a contact or exit the
application. The class extends the Screen
class.
AlertMessage
—This class displays an alert
message. The class extends the Screen
class.
MainScreen
—This class implements the main
(idle state) screen of the application. From this screen, the user
can initiate an exchange of business cards, change their own business
card, and exit the application. The class extends the Screen
class.
ProgressScreen
—This class implements the screen
that indicates that some operation is in progress. For example, when
inquiry, service discovery, or business card sending and receiving
is running, this screen is displayed. From this screen, the user can
cancel the process. The class extends the Screen
class.
Screen
—This class is an abstract base class
for all the UI screens in this MIDlet. This class implements the CommandListener
interface.
ServiceListScreen
—This class displays the
list of devices which provide services (in case there is more than
one "Business Card Exchanger Service" in the vicinity) and provides
the means for selecting a service or canceling the process.
The following figure shows the state machine diagram of the UI module. Each state represents a separate screen.
Figure: UI module state diagram
When the MIDlet starts, the initial state is the address book screen (if the MIDlet is started for the first time) or the main screen (if the MIDlet has been started before). While the MIDlet is in the main screen state, it can display the address book screen if the user needs to change his or her own card, and then transfer back to the main screen after the card has been successfully selected. Note that the application can exit only from the main or address book screens.
When the user initiates the exchange of the cards from the main screen, the state machine performs a change through various progress screens. Each progress screen is transferred to the next progress screen (after successful completion) or to the main screen (in case of errors or cancellations). The only exception is the service discovery progress screen: if more than one service is found, the UI is changed to the service list screen, which allows the user to select one single service.
The MIDlet also has the alert message screen, which is used to
display the results of an operation (for example, "Business card is
sent" or "Inquiry is canceled") and is shown for a limited period
of time (using the Alert
class). This screen is not considered
to be a state of the UI machine, and consequently it is not shown
in the state diagram above.
Figure: BCExchanger UI screens
Now that you have implemented the UI module, implement the Comm module.