- Timestamp:
- 12/14/08 13:39:10 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/LogicMail.java
r308 r354 33 33 34 34 import java.util.Calendar; 35 36 import net.rim.blackberry.api.homescreen.HomeScreen; 37 import net.rim.device.api.notification.NotificationsConstants; 38 import net.rim.device.api.notification.NotificationsManager; 39 import net.rim.device.api.system.ApplicationManager; 35 40 import net.rim.device.api.system.EventLogger; 36 41 import net.rim.device.api.ui.UiApplication; 37 42 import org.logicprobe.LogicMail.ui.MailHomeScreen; 43 import org.logicprobe.LogicMail.ui.NotificationHandler; 38 44 import org.logicprobe.LogicMail.conf.MailSettings; 39 45 … … 49 55 50 56 /** 51 * Main class for the application 57 * Main class for the application. 52 58 */ 53 59 public class LogicMail extends UiApplication { 54 public LogicMail() { 55 // Load the configuration 56 MailSettings.getInstance().loadSettings(); 60 /** 61 * Instantiates a new instance of the application. 62 * 63 * @param autoStart True if this is the autostart instance, false for normal startup 64 */ 65 public LogicMail(boolean autoStart) { 66 if(autoStart) { 67 doAutoStart(); 68 } 69 else { 70 // Load the configuration 71 MailSettings.getInstance().loadSettings(); 72 73 // Log application startup information 74 if(EventLogger.getMinimumLevel() >= EventLogger.INFORMATION) { 75 StringBuffer buf = new StringBuffer(); 76 buf.append("Application startup\r\n"); 77 buf.append("Date: "); 78 buf.append(Calendar.getInstance().getTime().toString()); 79 buf.append("\r\n"); 80 buf.append("Name: "); 81 buf.append(AppInfo.getName()); 82 buf.append("\r\n"); 83 buf.append("Version: "); 84 buf.append(AppInfo.getVersion()); 85 buf.append("\r\n"); 86 EventLogger.logEvent(AppInfo.GUID, buf.toString().getBytes(), EventLogger.INFORMATION); 87 } 57 88 58 // Log application startup information 59 if(EventLogger.getMinimumLevel() >= EventLogger.INFORMATION) { 60 StringBuffer buf = new StringBuffer(); 61 buf.append("Application startup\r\n"); 62 buf.append("Date: "); 63 buf.append(Calendar.getInstance().getTime().toString()); 64 buf.append("\r\n"); 65 buf.append("Name: "); 66 buf.append(AppInfo.getName()); 67 buf.append("\r\n"); 68 buf.append("Version: "); 69 buf.append(AppInfo.getVersion()); 70 buf.append("\r\n"); 71 EventLogger.logEvent(AppInfo.GUID, buf.toString().getBytes(), EventLogger.INFORMATION); 72 } 73 74 pushScreen(new MailHomeScreen()); 89 // Initialize the notification handler 90 NotificationHandler.getInstance().setEnabled(true); 91 92 // Push the mail home screen 93 pushScreen(new MailHomeScreen()); 94 } 75 95 } 76 96 97 /** 98 * Run the application. 99 */ 77 100 public void run() { 78 101 enterEventDispatcher(); 79 102 } 103 104 /** The constant event source object. */ 105 private static final Object eventSource = new Object() { 106 public String toString() { 107 return "LogicMail New Message"; 108 } 109 }; 110 111 /** 112 * Method to execute in autostart mode. 113 */ 114 private void doAutoStart() { 115 invokeLater(new Runnable() 116 { 117 public void run() 118 { 119 ApplicationManager myApp = ApplicationManager.getApplicationManager(); 120 boolean keepGoing = true; 121 122 while (keepGoing) 123 { 124 if (myApp.inStartup()) 125 { 126 try { Thread.sleep(1000); } 127 catch (Exception ex) { } 128 } 129 else 130 { 131 // The BlackBerry has finished its startup process 132 // Configure the rollover icons 133 HomeScreen.updateIcon(AppInfo.getIcon(), 0); 134 HomeScreen.setRolloverIcon(AppInfo.getRolloverIcon(), 0); 135 136 // Configure the notification source 137 NotificationsManager.registerSource(AppInfo.GUID, eventSource, NotificationsConstants.CASUAL); 138 139 keepGoing = false; 140 } 141 } 142 //Exit the application. 143 System.exit(0); 144 } 145 }); 146 } 80 147 }
Note: See TracChangeset
for help on using the changeset viewer.
