/*
* MessageDetailsScreen.java
*
* Author: C. Enrique Ortiz, October 2003
*
* Companion source code to "Advanced Messaging Coding with JSR 120".
*
* Based on original work by C. Enrique Ortiz.
*
* COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.
* The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
* The use of the software is subject to the terms of the end-user license
* agreement which accompanies or is included with the software. The software is
* provided "as is" and Sony Ericsson specifically disclaim any warranty or
* condition whatsoever regarding merchantability or fitness for a specific
* purpose, title or non-infringement. No warranty of any kind is made in
* relation to the condition, suitability, availability, accuracy, reliability,
* merchantability and/or non-infringement of the software provided herein.
*/
package wmafw;
import javax.microedition.lcdui.*;
/**
* MessageDetailsScreen displays the details for a given short text message.
*/
class MessageDetailsScreen
{
/************/
/* Commands */
/************/
/** Reply Command */
protected static Command REPLY= new Command(UIConstants.TXT_REPLY, Command.OK, 1);
/** Back Command */
protected static Command BACK = new Command(UIConstants.TXT_BACK, Command.BACK, 2);
/******/
/* UI */
/******/
/** Current display context */
private Display display;
/** The command listener responsible of application navigation */
private CommandListener commandListener;
/** The menu screen */
private Form screen;
/** From field value*/
private String from;
/**
* Constructor.
*/
protected MessageDetailsScreen(Display d, CommandListener cl) {
display = d;
commandListener = cl;
screen = new Form(UIConstants.TXT_SMS_SUMM);
screen.addCommand(REPLY);
screen.addCommand(BACK);
screen.setCommandListener(commandListener);
}
/**
* Make the main menu visible.
* @param from is the message's sender
* @param message is the text message contents.
*/
protected void showScreen(String from, String message) {
try {
this.from = from;
if (display != null) {
// Clear the screen before adding new entries.
for(int i=screen.size()-1; i>=0; i--) screen.delete(i);
// Append the From and Message.
screen.append(UIConstants.TXT_FROM + from);
screen.append(UIConstants.TXT_MESSAGE + message);
// Display the screen.
display.setCurrent(screen);
}
} catch (Exception e) {
System.out.println("showException Exception: " + e);
}
}
/**
* Returns the from field.
* @return the message from field.
*/
protected String getFrom() {
return from;
}
/**
* Returns the main menu Displayable.
* @return the message details screen.
*/
protected Displayable getScreen() {
return screen;
}
}
|