⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jimmui.java.svn-base

📁 类似QQ的功能
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************* Jimm - Mobile Messaging - J2ME ICQ clone Copyright (C) 2003-08  Jimm Project This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. ******************************************************************************** File: src/jimm/JimmUI.java Version: ###VERSION###  Date: ###DATE### Author(s): Artyomov Denis, Igor Palkin, Andreas Rossbacher *******************************************************************************/package jimm;import java.io.IOException;import java.io.InputStream;import java.util.*;import javax.microedition.io.Connector;import javax.microedition.io.HttpConnection;import javax.microedition.lcdui.Alert;import javax.microedition.lcdui.AlertType;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.Form;import javax.microedition.lcdui.Image;import javax.microedition.lcdui.List;import javax.microedition.lcdui.TextBox;import javax.microedition.lcdui.TextField;import jimm.comm.*;import jimm.util.ResourceBundle;import DrawControls.ImageList;import DrawControls.TextList;import DrawControls.VirtualList;public class JimmUI implements CommandListener{	static private Vector lastScreens = new Vector();	static private TextList msgBoxList;		public static void setLastScreen(JimmScreen screen, boolean isRoot)	{		synchronized (lastScreens)		{			if (isRoot) lastScreens.removeAllElements();			else lastScreens.removeElement(screen);			lastScreens.addElement(screen);		}	}		public static void removeScreen(JimmScreen screen)	{		synchronized (lastScreens)		{			lastScreens.removeElement(screen);		}	}		public static void backToLastScreen()	{		synchronized (lastScreens)		{			if (lastScreens.size() == 0) MainMenu.activateMenu();			else			{				for (;;)				{					JimmScreen screen = (JimmScreen)lastScreens.lastElement();					lastScreens.removeElement(screen);										if (lastScreens.size() == 0 || !screen.isScreenActive()) 					{						//System.out.println("lastScreens.size()="+lastScreens.size()+", screen.isScreenActive()="+screen.isScreenActive()+", screen="+screen.getClass().getName());						screen.activate();						break;					}				} 			}		}	}		// Commands codes	final public static int CMD_OK = 1;	final public static int CMD_CANCEL = 2;	final public static int CMD_YES = 3;	final public static int CMD_NO = 4;	final public static int CMD_FIND = 5;	final public static int CMD_BACK = 6;	// Commands	public final static Command cmdSave = new Command(ResourceBundle.getString("save"), Command.ITEM, 1);	public final static Command cmdOk = new Command(ResourceBundle.getString("ok"), Command.OK, 1);	public final static Command cmdCancel = new Command(ResourceBundle.getString("cancel"), Jimm.cmdBack, 5);	public final static Command cmdYes = new Command(ResourceBundle.getString("yes"), Command.OK, 1);	public final static Command cmdNo = new Command(ResourceBundle.getString("no"), Command.CANCEL, 2);	public final static Command cmdFind = new Command(ResourceBundle.getString("find"), Command.OK, 1);	public final static Command cmdBack = new Command(ResourceBundle.getString("back"), Jimm.cmdBack, 1);	public final static Command cmdCopyText = new Command(ResourceBundle.getString("copy_text"), Command.ITEM, 3);	public final static Command cmdCopyAll = new Command(ResourceBundle.getString("copy_all_text"), Command.ITEM, 4);	public final static Command cmdEdit = new Command(ResourceBundle.getString("edit"), Command.ITEM, 1);	public final static Command cmdMenu = new Command(ResourceBundle.getString("menu"), Command.ITEM, 1);	public final static Command cmdSelect = new Command(ResourceBundle.getString("select"), Command.OK, 2);	public final static Command cmdSelect2 = new Command(ResourceBundle.getString("select"), Command.ITEM, 2);	public final static Command cmdSend = new Command(ResourceBundle.getString("send"), Command.OK, 1);	public final static Command cmdList = new Command(ResourceBundle.getString("contact_list"), Command.ITEM, 1);	public final static Command cmdInfo = new Command(ResourceBundle.getString("info"), Command.ITEM, 10);		//#sijapp cond.if modules_SMILES_STD="true" | modules_SMILES_ANI="true" #	public final static Command cmdInsertEmo = new Command(ResourceBundle.getString("insert_emotion"), Command.ITEM, 3);	//#sijapp cond.end#		public final static Command cmdInsTemplate = new Command(ResourceBundle.getString("templates"), Command.ITEM, 4);			//#sijapp cond.if target is "MIDP2" | target is "SIEMENS2" | target is "MOTOROLA"#	public final static Command cmdGotoURL = new Command(ResourceBundle.getString("goto_url"), Command.ITEM, 9);	//#sijapp cond.end#		private final static Command cmdClearText = new Command(ResourceBundle.getString("clear"), Command.ITEM, 5);	static private CommandListener listener;	static private Hashtable commands = new Hashtable();	static private JimmUI _this;		// Misc constants	final private static int GROUP_SELECTOR_MOVE_TAG = 4; 	// Associate commands and commands codes 	static	{		commands.put(cmdOk, new Integer(CMD_OK));		commands.put(List.SELECT_COMMAND, new Integer(CMD_OK));		commands.put(cmdCancel, new Integer(CMD_CANCEL));		commands.put(cmdYes, new Integer(CMD_YES));		commands.put(cmdNo, new Integer(CMD_NO));		commands.put(cmdFind, new Integer(CMD_FIND));		commands.put(cmdBack, new Integer(CMD_BACK));	}	JimmUI()	{		_this = this;	}	// Returns commands index of command	public static int getCommandIdx(Command command)	{		Object result = commands.get(command);		return (result == null) ? -1 : ((Integer) result).intValue();	}	// Place "object = null;" code here:	private static void clearAll()	{		msgForm = null;		aboutTextList = null;		System.gc();	}	public void commandAction(Command c, Displayable d)	{		Jimm.aaUserActivity();				if (isControlActive(tlStatusMessage))		{			tlStatusMessage = null;			statusMessCI = null;			backToLastScreen();		}				else if (isControlActive(loadErrorTextList))		{			MainMenu.activateMenu();		}				else if (isControlActive(removeContactMessageBox))		{			if (c == cmdOk) menuRemoveContactSelected();			else backToLastScreen();			removeContactMessageBox = null;		}				else if ((renameTextbox != null) && (d == renameTextbox))		{			if (c == cmdOk) menuRenameSelected();			backToLastScreen();			renameTextbox = null;		}				else if (isControlActive(removeMeMessageBox))		{			if (c == cmdOk) menuRemoveMeSelected();			else backToLastScreen();			removeMeMessageBox = null;		}				else if (isControlActive(tlContactMenu))		{			if (c == cmdSelect) contactMenuSelected(tlContactMenu.getCurrTextIndex());			else			{				backToLastScreen();				tlContactMenu = null;				clciContactMenu = null;			}		}				else if ((authTextbox != null) && (d == authTextbox))		{			if (c == cmdSend)			{				SystemNotice notice = null;				boolean authRequested = false;				/* If or if not a reason was entered				 Though this box is used twice (reason for auth request and auth repley)				 we have to distinguish what we wanna do requReason is used for that */				String textBoxText = authTextbox.getString();				String reasonText = (textBoxText == null || textBoxText.length() < 1) ? "" : textBoxText;								switch (authType)				{				case AUTH_TYPE_DENY:					notice = new SystemNotice(							SystemNotice.SYS_NOTICE_AUTHORISE,							authContactItem.getStringValue(ContactItem.CONTACTITEM_UIN),							false, reasonText);					break;				case AUTH_TYPE_REQ_AUTH:					notice = new SystemNotice(							SystemNotice.SYS_NOTICE_REQUAUTH,							authContactItem.getStringValue(ContactItem.CONTACTITEM_UIN),							false, reasonText);					authRequested = true;					break;				}								/* Assemble the sysNotAction and request it */				SysNoticeAction sysNotAct = new SysNoticeAction(notice);				try				{					Icq.requestAction(sysNotAct);					ChatHistory.rebuildMenu(authContactItem);					if (authRequested) 						authContactItem.setBooleanValue(ContactItem.CONTACTITEM_IS_TEMP, false);										authContactItem.setBooleanValue(ContactItem.CONTACTITEM_B_AUTREQUESTS, false);				} 				catch (JimmException e)				{					JimmException.handleException(e);					if (e.isCritical()) return;				}			}			boolean activated = ChatHistory.activateIfExists(authContactItem);			if (!activated) JimmUI.backToLastScreen(); 			authTextbox = null;			authContactItem = null;						return;		}				//#sijapp cond.if target is "MIDP2" | target is "MOTOROLA" | target is "SIEMENS2"#		else if (JimmUI.isControlActive(URLList))		{			if (c == cmdSelect)			{				try				{					Jimm.jimm.platformRequest(URLList.getCurrText(0, false));				} catch (Exception e) {}			}			URLList = null;						backToLastScreen();			return;		}		//#sijapp cond.end#				else if ((messageTextbox != null) && (d == messageTextbox))		{			sendTypeingNotify(false);			if (c == cmdCancel)			{				backToLastScreen();			}			else if (c == cmdSend)			{				switch (textMessCurMode)				{				case EDITOR_MODE_MESSAGE:					String messText = messageTextbox.getString();					if (messText.length() != 0)					{						sendMessage(messText, textMessReceiver);						if (Jimm.getPhoneVendor() == Jimm.PHONE_SONYERICSSON)						{							messageTextbox = null;						}						else						{							messageTextbox.setString(null);						}					}					boolean activated = ChatHistory.activateIfExists(textMessReceiver);					if (!activated) JimmUI.backToLastScreen();					break;				}			}						//#sijapp cond.if modules_SMILES_STD="true" | modules_SMILES_ANI="true" #			else if (c == cmdInsertEmo)			{				Emotions.selectEmotion(messageTextbox);			}			//#sijapp cond.end#						else if (c == cmdInsTemplate)			{				Templates.selectTemplate(messageTextbox);			}						else if (c == cmdClearText)			{				messageTextbox.setString(new String());			}		}				// "About" -> "Back"		else if (JimmUI.isControlActive(aboutTextList))		{			if (c == cmdBack)			{				MainMenu.activateMenu();				aboutTextList = null;			}//#sijapp cond.if target isnot "DEFAULT"#						else if (c == cmdSelect)			{				if (aboutTextList.getCurrTextIndex() == ABOUT_JIMM_WAP)				{					try					{											Jimm.jimm.platformRequest("http://jimm.org/wap/");					}					catch (Exception e) {}				}			}//#sijapp cond.end#				}		// "User info"		else if (JimmUI.isControlActive(infoTextList))		{			// "User info" -> "Cancel, Back"			if ((c == cmdCancel) || (c == cmdBack))			{

⌨️ 快捷键说明

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