Changeset 553
- Timestamp:
- 11/22/09 15:19:25 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 11 edited
-
LogicMail/src/org/logicprobe/LogicMail/AppInfo.java (modified) (4 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/LogicMail.java (modified) (4 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/PlatformInfo.java (modified) (2 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/PlatformInfoBB42.java (modified) (2 diffs)
-
LogicMail/src/org/logicprobe/LogicMail/ui/AboutDialog.java (modified) (1 diff)
-
LogicMail/src/org/logicprobe/LogicMail/ui/BlankSeparatorField.java (added)
-
LogicMail/src/org/logicprobe/LogicMail/ui/LabeledSeparatorField.java (modified) (1 diff)
-
LogicMail/src/org/logicprobe/LogicMail/ui/MailboxSeparatorField.java (deleted)
-
LogicMail_BB46/src/org/logicprobe/LogicMail/PlatformInfoBB46.java (modified) (2 diffs)
-
LogicMail_BB47/src/org/logicprobe/LogicMail/PlatformInfoBB47.java (modified) (2 diffs)
-
LogicMail_BB47T/src/org/logicprobe/LogicMail/PlatformInfoBB47T.java (modified) (1 diff)
-
LogicMail_BB50/src/org/logicprobe/LogicMail/PlatformInfoBB50.java (modified) (2 diffs)
-
LogicMail_BB50T/src/org/logicprobe/LogicMail/PlatformInfoBB50T.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/AppInfo.java
r405 r553 34 34 import net.rim.device.api.system.ApplicationDescriptor; 35 35 import net.rim.device.api.system.Bitmap; 36 import net.rim.device.api.system.CodeModuleManager;37 36 38 37 /** … … 51 50 private static String appName; 52 51 private static String appVersion; 53 private static String platformVersion;52 private static PlatformInfo platformInfo; 54 53 55 54 /** … … 87 86 appVersion = buf.toString(); 88 87 89 // Get the platform version 90 int[] handles = CodeModuleManager.getModuleHandles(); 91 int size = handles.length; 92 //Check for a particular RIM module (Here, the ribbon app) 93 for (int i = size-1; i>=0;--i) { 94 if (CodeModuleManager.getModuleName(handles[i]).equals("net_rim_bb_ribbon_app")) { 95 platformVersion = 96 CodeModuleManager.getModuleVersion(handles[i]); 97 } 98 } 88 platformInfo = PlatformInfo.getInstance(); 99 89 } 100 90 … … 108 98 109 99 public static String getPlatformVersion() { 110 return platform Version;100 return platformInfo.getPlatformVersion(); 111 101 } 112 102 -
trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.java
r531 r553 53 53 54 54 import org.logicprobe.LogicMail.model.MailManager; 55 import org.logicprobe.LogicMail.ui.BlankSeparatorField; 55 56 import org.logicprobe.LogicMail.ui.NavigationController; 56 57 import org.logicprobe.LogicMail.ui.NotificationHandler; … … 73 74 */ 74 75 public class LogicMail extends UiApplication { 75 private NavigationController navigationController;76 private Screen loadingScreen;77 76 private NavigationController navigationController; 77 private Screen loadingScreen; 78 78 79 /** 79 80 * Instantiates a new instance of the application. … … 82 83 */ 83 84 public LogicMail(String[] args) { 84 boolean autoStart = false; 85 for(int i=0; i<args.length; i++) { 86 if(args[i].indexOf("autostartup") != -1) { 87 autoStart = true; 88 } 89 } 90 AppInfo.initialize(args); 91 92 if(autoStart) { 93 doAutoStart(); 94 } 95 else { 96 logStartupAppInfo(); 97 98 createLoadingScreen(); 99 100 Thread loadingThread = new Thread() { 101 public void run() { 102 // Load the configuration 103 MailSettings.getInstance().loadSettings(); 104 // Set the language, if configured 105 String languageCode = 106 MailSettings.getInstance().getGlobalConfig().getLanguageCode(); 107 if(languageCode != null && languageCode.length() > 0) { 108 try { 109 Locale.setDefault(Locale.get(languageCode)); 110 } catch (Exception e) { } 111 } 112 113 // Initialize the data model explicitly 114 MailManager.initialize(); 115 116 // Initialize the notification handler 117 NotificationHandler.getInstance().setEnabled(true); 118 119 // Initialize the navigation controller 120 navigationController = new NavigationController(LogicMail.this); 121 122 invokeLater(new Runnable() { 123 public void run() { 124 // Push the mail home screen and pop 125 // the loading screen 126 navigationController.displayMailHome(); 127 popScreen(loadingScreen); 128 loadingScreen = null; 129 } 130 }); 131 } 132 }; 133 134 pushScreen(loadingScreen); 135 loadingThread.start(); 136 } 137 } 138 139 private void logStartupAppInfo() { 140 // Log application startup information 141 if(EventLogger.getMinimumLevel() >= EventLogger.INFORMATION) { 142 StringBuffer buf = new StringBuffer(); 143 buf.append("Application startup\r\n"); 144 buf.append("Date: "); 145 buf.append(Calendar.getInstance().getTime().toString()); 146 buf.append("\r\n"); 147 buf.append("Name: "); 148 buf.append(AppInfo.getName()); 149 buf.append("\r\n"); 150 buf.append("Version: "); 151 buf.append(AppInfo.getVersion()); 152 buf.append("\r\n"); 153 buf.append("Platform: "); 154 buf.append(AppInfo.getPlatformVersion()); 155 buf.append("\r\n"); 156 EventLogger.logEvent(AppInfo.GUID, buf.toString().getBytes(), EventLogger.INFORMATION); 157 } 158 } 85 boolean autoStart = false; 86 for(int i=0; i<args.length; i++) { 87 if(args[i].indexOf("autostartup") != -1) { 88 autoStart = true; 89 } 90 } 91 AppInfo.initialize(args); 92 93 if(autoStart) { 94 doAutoStart(); 95 } 96 else { 97 logStartupAppInfo(); 98 99 createLoadingScreen(); 100 101 Thread loadingThread = new Thread() { 102 public void run() { 103 // Load the configuration 104 MailSettings.getInstance().loadSettings(); 105 // Set the language, if configured 106 String languageCode = 107 MailSettings.getInstance().getGlobalConfig().getLanguageCode(); 108 if(languageCode != null && languageCode.length() > 0) { 109 try { 110 Locale.setDefault(Locale.get(languageCode)); 111 } catch (Exception e) { } 112 } 113 114 // Initialize the data model explicitly 115 MailManager.initialize(); 116 117 // Initialize the notification handler 118 NotificationHandler.getInstance().setEnabled(true); 119 120 // Initialize the navigation controller 121 navigationController = new NavigationController(LogicMail.this); 122 123 try { 124 sleep(2000); 125 } catch (InterruptedException e) { 126 // TODO Auto-generated catch block 127 e.printStackTrace(); 128 } 129 130 invokeLater(new Runnable() { 131 public void run() { 132 // Push the mail home screen and pop 133 // the loading screen 134 navigationController.displayMailHome(); 135 popScreen(loadingScreen); 136 loadingScreen = null; 137 } 138 }); 139 } 140 }; 141 142 pushScreen(loadingScreen); 143 loadingThread.start(); 144 } 145 } 146 147 private void logStartupAppInfo() { 148 // Log application startup information 149 if(EventLogger.getMinimumLevel() >= EventLogger.INFORMATION) { 150 StringBuffer buf = new StringBuffer(); 151 buf.append("Application startup\r\n"); 152 buf.append("Date: "); 153 buf.append(Calendar.getInstance().getTime().toString()); 154 buf.append("\r\n"); 155 buf.append("Name: "); 156 buf.append(AppInfo.getName()); 157 buf.append("\r\n"); 158 buf.append("Version: "); 159 buf.append(AppInfo.getVersion()); 160 buf.append("\r\n"); 161 buf.append("Platform: "); 162 buf.append(AppInfo.getPlatformVersion()); 163 if(PlatformInfo.getInstance().hasTouchscreen()) { 164 buf.append(' '); 165 buf.append("(touch)"); 166 } 167 buf.append("\r\n"); 168 EventLogger.logEvent(AppInfo.GUID, buf.toString().getBytes(), EventLogger.INFORMATION); 169 } 170 } 159 171 160 172 private void createLoadingScreen() { 161 loadingScreen = new MainScreen();162 int displayWidth = Display.getWidth();163 Bitmap splashLogo = Bitmap.getBitmapResource("splash-logo.png");164 Bitmap fieldSeparator = new Bitmap(displayWidth, 10);165 int throbberSize = displayWidth / 4;166 int fontHeight = Font.getDefault().getHeight();167 int spacerSize = (Display.getHeight() / 2) - ((splashLogo.getHeight() + throbberSize + fontHeight) / 2) - 10;168 if(spacerSize < 0) { spacerSize = 0; } 169 Bitmap topSpacer = new Bitmap(displayWidth, spacerSize); 170 171 loadingScreen.add(new BitmapField(topSpacer));172 loadingScreen.add(new BitmapField(splashLogo, Field.FIELD_HCENTER));173 loadingScreen.add(new BitmapField(fieldSeparator));174 loadingScreen.add(new ThrobberField(throbberSize, Field.FIELD_HCENTER));175 loadingScreen.add(new BitmapField(fieldSeparator));173 loadingScreen = new MainScreen(); 174 int displayWidth = Display.getWidth(); 175 int displayHeight = Display.getHeight(); 176 int fieldSpacerSize = displayHeight / 24; 177 Bitmap splashLogo = Bitmap.getBitmapResource("splash-logo.png"); 178 int throbberSize = displayWidth / 4; 179 int fontHeight = Font.getDefault().getHeight(); 180 int spacerSize = (displayHeight / 2) - ((splashLogo.getHeight() + throbberSize + fontHeight) / 2) - fieldSpacerSize; 181 if(spacerSize < 0) { spacerSize = 0; } 182 183 loadingScreen.add(new BlankSeparatorField(spacerSize)); 184 loadingScreen.add(new BitmapField(splashLogo, Field.FIELD_HCENTER)); 185 loadingScreen.add(new BlankSeparatorField(fieldSpacerSize)); 186 loadingScreen.add(new ThrobberField(throbberSize, Field.FIELD_HCENTER)); 187 loadingScreen.add(new BlankSeparatorField(fieldSpacerSize)); 176 188 loadingScreen.add(new LabelField("Version " + AppInfo.getVersion(), Field.FIELD_HCENTER)); 177 189 } 178 190 179 191 /** 180 192 * Run the application. 181 193 */ 182 194 public void run() { 183 enterEventDispatcher();184 } 185 195 enterEventDispatcher(); 196 } 197 186 198 /** 187 199 * Method to execute in autostart mode. … … 215 227 Hashtable eventSourceMap = new Hashtable(numAccounts); 216 228 for(int i=0; i<numAccounts; i++) { 217 AccountConfig accountConfig = mailSettings.getAccountConfig(i);218 LogicMailEventSource eventSource =219 new LogicMailEventSource(accountConfig.getAcctName(), accountConfig.getUniqueId());220 NotificationsManager.registerSource(221 eventSource.getEventSourceId(),222 eventSource,223 NotificationsConstants.CASUAL);224 eventSourceMap.put(new Long(accountConfig.getUniqueId()), eventSource);229 AccountConfig accountConfig = mailSettings.getAccountConfig(i); 230 LogicMailEventSource eventSource = 231 new LogicMailEventSource(accountConfig.getAcctName(), accountConfig.getUniqueId()); 232 NotificationsManager.registerSource( 233 eventSource.getEventSourceId(), 234 eventSource, 235 NotificationsConstants.CASUAL); 236 eventSourceMap.put(new Long(accountConfig.getUniqueId()), eventSource); 225 237 } 226 238 227 239 // Save the registered event sources in the runtime store 228 240 RuntimeStore.getRuntimeStore().put(AppInfo.GUID, eventSourceMap); 229 241 keepGoing = false; 230 242 } 231 }232 //Exit the application.233 System.exit(0);243 } 244 //Exit the application. 245 System.exit(0); 234 246 } 235 247 }); -
trunk/LogicMail/src/org/logicprobe/LogicMail/PlatformInfo.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 54 54 return instance; 55 55 } 56 57 public abstract String getPlatformVersion(); 58 59 public abstract boolean hasTouchscreen(); 56 60 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/PlatformInfoBB42.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 31 31 package org.logicprobe.LogicMail; 32 32 33 import net.rim.device.api.system.CodeModuleManager; 34 33 35 public class PlatformInfoBB42 extends PlatformInfo { 36 protected String platformVersion; 34 37 38 public PlatformInfoBB42() { 39 } 40 41 public String getPlatformVersion() { 42 if(platformVersion == null) { 43 // Get the platform version 44 int[] handles = CodeModuleManager.getModuleHandles(); 45 int size = handles.length; 46 //Check for a particular RIM module (Here, the ribbon app) 47 for (int i = size-1; i>=0;--i) { 48 if (CodeModuleManager.getModuleName(handles[i]).equals("net_rim_bb_ribbon_app")) { 49 platformVersion = 50 CodeModuleManager.getModuleVersion(handles[i]); 51 } 52 } 53 } 54 return platformVersion; 55 } 56 57 public boolean hasTouchscreen() { 58 return false; 59 } 35 60 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/AboutDialog.java
r251 r553 42 42 43 43 public class AboutDialog extends Dialog { 44 private static ResourceBundle resources = ResourceBundle.getBundle(LogicMailResource.BUNDLE_ID, LogicMailResource.BUNDLE_NAME);45 46 public AboutDialog() {47 super(48 resources.getString(LogicMailResource.ABOUT_TITLE) + " "+ AppInfo.getName(),49 new Object[] { resources.getString(LogicMailResource.MENUITEM_CLOSE) },50 new int[] { Dialog.OK },51 Dialog.OK,52 Bitmap.getBitmapResource("logicmail.png"));53 setEscapeEnabled(true);54 initFields();55 }56 57 private void initFields() {58 LabelField nameLabelField = new LabelField(AppInfo.getName() + " "+ AppInfo.getVersion(), Field.FIELD_HCENTER);59 LabelField urlLabelField = new LabelField("http://logicmail.sf.net/", Field.FIELD_HCENTER);60 61 add(new SeparatorField());62 add(nameLabelField);63 add(urlLabelField);64 add(new LabelField());65 }44 private static ResourceBundle resources = ResourceBundle.getBundle(LogicMailResource.BUNDLE_ID, LogicMailResource.BUNDLE_NAME); 45 46 public AboutDialog() { 47 super( 48 resources.getString(LogicMailResource.ABOUT_TITLE) + ' ' + AppInfo.getName(), 49 new Object[] { resources.getString(LogicMailResource.MENUITEM_CLOSE) }, 50 new int[] { Dialog.OK }, 51 Dialog.OK, 52 Bitmap.getBitmapResource("logicmail.png")); 53 setEscapeEnabled(true); 54 initFields(); 55 } 56 57 private void initFields() { 58 LabelField nameLabelField = new LabelField(AppInfo.getName() + ' ' + AppInfo.getVersion(), Field.FIELD_HCENTER); 59 LabelField urlLabelField = new LabelField("http://logicmail.sf.net/", Field.FIELD_HCENTER); 60 61 add(new SeparatorField()); 62 add(nameLabelField); 63 add(urlLabelField); 64 add(new LabelField()); 65 } 66 66 } -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/LabeledSeparatorField.java
r549 r553 42 42 */ 43 43 public class LabeledSeparatorField extends Field { 44 private String text;45 private boolean topBorder;46 private boolean bottomBorder;44 private String text; 45 private boolean topBorder; 46 private boolean bottomBorder; 47 47 48 public static long TOP_BORDER = 0x0000000000020L;49 public static long BOTTOM_BORDER = 0x0000000000040L;50 51 /**52 * Instantiates a new mailbox separator field.53 *54 * @param text The text to display.55 * @param style Combination of field style bits to specify display attributes.56 */57 public LabeledSeparatorField(String text, long style) {58 super(style);59 this.text = text;48 public static long TOP_BORDER = 0x0000000000020L; 49 public static long BOTTOM_BORDER = 0x0000000000040L; 50 51 /** 52 * Instantiates a new mailbox separator field. 53 * 54 * @param text The text to display. 55 * @param style Combination of field style bits to specify display attributes. 56 */ 57 public LabeledSeparatorField(String text, long style) { 58 super(style); 59 this.text = text; 60 60 topBorder = ((style & TOP_BORDER) == TOP_BORDER); 61 61 bottomBorder = ((style & BOTTOM_BORDER) == BOTTOM_BORDER); 62 }62 } 63 63 64 /**65 * Instantiates a new mailbox separator field.66 *67 * @param style Combination of field style bits to specify display attributes68 */69 public LabeledSeparatorField(long style) {70 this("", style);71 }64 /** 65 * Instantiates a new mailbox separator field. 66 * 67 * @param style Combination of field style bits to specify display attributes 68 */ 69 public LabeledSeparatorField(long style) { 70 this("", style); 71 } 72 72 73 /** 74 * Sets the text to display; 75 * 76 * @param text the new text to display 77 */ 78 public void setText(String text) { 79 this.text = text; 80 this.invalidate(); 81 } 82 83 /** 84 * Gets the text being displayed 85 * 86 * @return the text being displayed 87 */ 88 public String getText() { 89 return this.text; 90 } 91 92 /* (non-Javadoc) 93 * @see net.rim.device.api.ui.Field#getPreferredHeight() 94 */ 95 public int getPreferredHeight() { 96 return Font.getDefault().getHeight(); 97 }; 98 99 /* (non-Javadoc) 100 * @see net.rim.device.api.ui.Field#layout(int, int) 101 */ 102 protected void layout(int width, int height) { 103 setExtent(width, getPreferredHeight()); 104 } 73 /** 74 * Sets the text to display; 75 * 76 * @param text the new text to display 77 */ 78 public void setText(String text) { 79 this.text = text; 80 this.invalidate(); 81 } 105 82 106 /* (non-Javadoc) 107 * @see net.rim.device.api.ui.Field#onUnfocus() 108 */ 109 protected void onUnfocus() { 110 super.invalidate(); 111 super.onUnfocus(); 112 } 83 /** 84 * Gets the text being displayed 85 * 86 * @return the text being displayed 87 */ 88 public String getText() { 89 return this.text; 90 } 113 91 114 /* (non-Javadoc) 115 * @see net.rim.device.api.ui.Field#paint(net.rim.device.api.ui.Graphics) 116 */ 117 protected void paint(Graphics graphics) { 118 boolean isFocus = this.isFocus(); 92 /* (non-Javadoc) 93 * @see net.rim.device.api.ui.Field#getPreferredHeight() 94 */ 95 public int getPreferredHeight() { 96 return Font.getDefault().getHeight(); 97 }; 98 99 /* (non-Javadoc) 100 * @see net.rim.device.api.ui.Field#layout(int, int) 101 */ 102 protected void layout(int width, int height) { 103 setExtent(width, getPreferredHeight()); 104 } 105 106 /* (non-Javadoc) 107 * @see net.rim.device.api.ui.Field#onUnfocus() 108 */ 109 protected void onUnfocus() { 110 super.invalidate(); 111 super.onUnfocus(); 112 } 113 114 /* (non-Javadoc) 115 * @see net.rim.device.api.ui.Field#paint(net.rim.device.api.ui.Graphics) 116 */ 117 protected void paint(Graphics graphics) { 118 boolean isFocus = this.isFocus(); 119 119 int width = this.getWidth(); 120 120 int height = this.getHeight(); 121 121 int originalColor = graphics.getColor(); 122 122 int textWidth = Font.getDefault().getAdvance(text); 123 123 124 124 int textX = width / 2 - textWidth / 2; 125 125 if(textX <= 0) { 126 textX = 0;127 textWidth = width;126 textX = 0; 127 textWidth = width; 128 128 } 129 129 130 130 // Draw the gradient background 131 131 if(!isFocus) { 132 for(int i=0; i<height; i++) {133 int color = 0xFF - i;134 graphics.setColor((color * 0x10000) + (color * 0x100) + color);135 graphics.drawLine(0, i, width, i);136 }132 for(int i=0; i<height; i++) { 133 int color = 0xFF - i; 134 graphics.setColor((color * 0x10000) + (color * 0x100) + color); 135 graphics.drawLine(0, i, width, i); 136 } 137 137 } 138 138 139 139 // Draw the separator lines 140 140 graphics.setColor(Color.DARKGRAY); 141 141 if(topBorder) { 142 graphics.drawLine(0, 0, width, 0);142 graphics.drawLine(0, 0, width, 0); 143 143 } 144 144 if(bottomBorder) { 145 graphics.drawLine(0, height - 1, width, height - 1);145 graphics.drawLine(0, height - 1, width, height - 1); 146 146 } 147 147 graphics.setColor(originalColor); 148 148 149 149 graphics.drawText(text, textX, 0, DrawStyle.ELLIPSIS, textWidth); 150 }150 } 151 151 } -
trunk/LogicMail_BB46/src/org/logicprobe/LogicMail/PlatformInfoBB46.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 31 31 package org.logicprobe.LogicMail; 32 32 33 public class PlatformInfoBB46 extends PlatformInfo { 33 import net.rim.device.api.system.DeviceInfo; 34 34 35 public class PlatformInfoBB46 extends PlatformInfoBB42 { 36 37 public PlatformInfoBB46() { 38 } 39 40 public String getPlatformVersion() { 41 if(platformVersion == null) { 42 platformVersion = DeviceInfo.getSoftwareVersion(); 43 } 44 return platformVersion; 45 } 46 47 public boolean hasTouchscreen() { 48 return false; 49 } 35 50 } -
trunk/LogicMail_BB47/src/org/logicprobe/LogicMail/PlatformInfoBB47.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 31 31 package org.logicprobe.LogicMail; 32 32 33 public class PlatformInfoBB47 extends PlatformInfo { 33 import net.rim.device.api.ui.Touchscreen; 34 34 35 public class PlatformInfoBB47 extends PlatformInfoBB46 { 36 public boolean hasTouchscreen() { 37 return Touchscreen.isSupported(); 38 } 35 39 } -
trunk/LogicMail_BB47T/src/org/logicprobe/LogicMail/PlatformInfoBB47T.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * -
trunk/LogicMail_BB50/src/org/logicprobe/LogicMail/PlatformInfoBB50.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 * … … 31 31 package org.logicprobe.LogicMail; 32 32 33 public class PlatformInfoBB50 extends PlatformInfo {33 public class PlatformInfoBB50 extends PlatformInfoBB47 { 34 34 35 35 } -
trunk/LogicMail_BB50T/src/org/logicprobe/LogicMail/PlatformInfoBB50T.java
r550 r553 1 1 /*- 2 * Copyright (c) 200 6, Derek Konigsberg2 * Copyright (c) 2009, Derek Konigsberg 3 3 * All rights reserved. 4 4 *
Note: See TracChangeset
for help on using the changeset viewer.
