DecryptScreen.java

/*
 * Copyright © 2013 Nokia Corporation. All rights reserved. Nokia and Nokia
 * Connecting People are registered trademarks of Nokia Corporation. Oracle and
 * Java are trademarks or registered trademarks of Oracle and/or its affiliates.
 * Other product and company names mentioned herein may be trademarks or trade
 * names of their respective owners. See LICENSE.TXT for license information.
 */
package com.nokia.example.satsa;

import javax.microedition.lcdui.*;

class DecryptScreen
        extends Form
        implements CommandListener {

    private final SATSAMIDlet midlet;
    private final Command commandBack = new Command("Back", Command.BACK, 1);
    private int index;
    private String decryptedMessage;

    DecryptScreen(SATSAMIDlet midlet) {
        super(null);

        this.midlet = midlet;
        createForm();
    }

    public void commandAction(Command c, Displayable d) {
        if (c == commandBack) {
            midlet.showEncryptedMessage(index);
        }
    }

    void setIndex(int index) {
        this.index = index;
    }

    void setMessage(String decryptedMessage) {
        this.decryptedMessage = decryptedMessage.trim();
        createForm();
    }

    private void createForm() {
        deleteAll();
        setTitle("Decrypted Message ");
        StringItem messageItem = new StringItem(null, decryptedMessage);
        append(messageItem);
        addCommand(commandBack);
        setCommandListener(this);
    }
}