aboutscreen.java

来自「moblie syncml mail javame」· Java 代码 · 共 221 行

JAVA
221
字号


/*
 * Funambol is a mobile platform developed by Funambol, Inc. 
 * Copyright (C) 2003 - 2007 Funambol, Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by
 * the Free Software Foundation with the addition of the following permission 
 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
 * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License 
 * along with this program; if not, see http://www.gnu.org/licenses or write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA.
 * 
 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License
 * version 3, these Appropriate Legal Notices must retain the display of the
 * "Powered by Funambol" logo. If the display of the logo is not reasonably 
 * feasible for technical reasons, the Appropriate Legal Notices must display
 * the words "Powered by Funambol".
 *
 *
 */

package com.funambol.mailclient.ui.view;

import com.funambol.mailclient.loc.Localization;
import com.funambol.mailclient.ui.controller.Theme;
import com.funambol.mailclient.ui.controller.UIController;
import com.funambol.mailclient.ui.utils.UiUtils;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

public class AboutScreen extends Canvas implements CommandListener {
    
    
    private int BACKGROUND_COLOR = 0xffffff; //white!
    private String [] message = { UIController.getClientName() + " " + 
    Localization.getMessages().getVERSION(UIController.getVersion()),
    Localization.getMessages().ABOUT_MESSAGE_3,
    UIController.getClientVendor(),
    Localization.getMessages().ABOUT_MESSAGE_5,
    Localization.getMessages().ABOUT_MESSAGE_6
    };
    private Font font = Font.getDefaultFont();
    private int fireCount=0;
    private int FOREGROUND_COLOR = 0x000000;
    private int LICENSE_COLOR = 0xAAAAAA;
    private int iconNumber;
    
    private int offset;
    Font smallFont = UIController.getDrawer().getGraphicalTheme().getSmallFont();
    Font boldFont = UIController.getDrawer().getGraphicalTheme().getBoldFont();
    private String[] license;
    
    /** Creates a new instance of FunSplashScreen */
    public AboutScreen() {
        //  this.setFullScreenMode(true);
        
        // starting from the center of the screen
        offset = (getHeight() +  Theme.getLogoImage().getHeight()+
                message.length * font.getHeight())/2;
        
        this.addCommand(UIController.backCommand);
        setCommandListener(this);
        Timer t = new Timer();
        t.schedule(new Tic(),100,100);
        
    }
    
    
    protected void paint(Graphics graphics) {
        graphics.setColor(BACKGROUND_COLOR);
        graphics.fillRect(0, 0, getWidth(), getHeight());
        
        graphics.drawImage(Theme.getLogoImage(),
                getWidth()/2,
                ( getOffset() ),
                Graphics.HCENTER | Graphics.TOP );
        graphics.setColor(FOREGROUND_COLOR);
        
        // Log.debug("Offset = " + getOffset());
        
        
        graphics.setFont(boldFont);
        
        
        
            graphics.drawString(
                    message[0],
                    getWidth()/2 ,
                    ( getOffset() + Theme.getLogoImage().getHeight()),
                    Graphics.HCENTER | Graphics.TOP
                    );
        
         graphics.setFont(UIController.getDrawer().getGraphicalTheme().getDefaultFont());
       
        for (int i=1; i< message.length; i++) {
            graphics.drawString(
                    message[i],
                    getWidth()/2 ,
                    ( getOffset() + Theme.getLogoImage().getHeight()  + i*font.getHeight()),
                    Graphics.HCENTER | Graphics.TOP
                    );
        }
        graphics.translate(0,getOffset()+Theme.getLogoImage().getHeight()  + message.length*font.getHeight());
        paintLicense(graphics);
        graphics.translate(0, -(getOffset()+Theme.getLogoImage().getHeight()  + message.length*font.getHeight()));
    }
    
    protected void keyPressed(int keyCode) {
        if (getGameAction(keyCode) == Canvas.FIRE ) {
            fireCount++;
        }
        if (fireCount == 10) {
            
            String [] newmessage = { "JME Team:",
            "Edo",
            "Gazza",
            "Alessio",
            "Beppe",
            "Fra",
            "Ivo",
            "Marco"
            };
            
            message = newmessage;
            repaint();
        }
    }
    
    
    
    public void commandAction(Command command, Displayable displayable) {
        if (command==UIController.backCommand) {
            UIController.showBackScreen();
        }
    }
    
    private int getOffset() {
        
        int pos= offset % ( getHeight() + message.length * font.getHeight() +
                Theme.getLogoImage().getHeight() + getLicense().length * smallFont.getHeight());
        
        return (getHeight() - pos);
        
    }
    
    private void paintLicense(Graphics graphics) {
        
        Font oldFont = graphics.getFont();
        
        graphics.setFont(smallFont);
        getLicense();
        graphics.setColor(LICENSE_COLOR);
        for (int i = 0; i< license.length; i++) {
            graphics.drawString(license[i], getWidth()/2,i*smallFont.getHeight(), Graphics.HCENTER | Graphics.TOP );
        }
        
    }
    
    private String[] getLicense() {
        if (license == null ) {
            String licenseText ="\nThis program is provided AS IS, without warranty licensed under AGPLV3. The " +
                    "Program is free software; you can redistribute it and/or modify it under the " +
                    "terms of the GNU Affero General Public License version 3 as published by the Free " +
                    "Software Foundation including the additional permission set forth source code " +
                    "file header.\n\n" +
                    
                    "The interactive user interfaces in modified source and object code versions of " +
                    "this program must display Appropriate Legal Notices, as required under Section 5 " +
                    "of the GNU Affero General Public License version 3.\n\n " +
                    
                    "In accordance with Section 7(b) of the GNU Affero General Public License version 3, " +
                    "these Appropriate Legal Notices must retain the display of the \"Powered by " +
                    "Funambol\" logo. If the display of the logo is not reasonably feasible for " +
                    "technical reasons, the Appropriate Legal Notices must display the words \"Powered " +
                    "by Funambol\". Funambol is a trademark of Funambol, Inc.";
            
            
            license = UiUtils.getStringArray(licenseText, this.getWidth(), smallFont);
        }
        
        return license;
        
    }
    
    
    
    
    private class Tic extends TimerTask {
        public void run() {
            offset ++;
            repaint();
        }
        
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?